chooseALaboratory.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <!-- 选择实验室 -->
  2. <template>
  3. <view id="chooseALaboratory">
  4. <view class="picker-box">
  5. <picker @change="facultyChange" :value="facultyIndex" :range="faculty">
  6. <view class="picker-min-box">
  7. <view class="left-box">请选择院系:</view>
  8. <view>{{faculty[facultyIndex]}}</view>
  9. <img src="@/images/basicsModules/icon_04.png">
  10. </view>
  11. </picker>
  12. </view>
  13. <view class="picker-box">
  14. <picker @change="buildingChange" :value="buildingIndex" :range="building">
  15. <view class="picker-min-box">
  16. <view class="left-box">请选择实验楼:</view>
  17. <view>{{building[buildingIndex]}}</view>
  18. <img src="@/images/basicsModules/icon_04.png">
  19. </view>
  20. </picker>
  21. </view>
  22. <view class="for-max-box">
  23. <view class="for-box" v-for="(item,index) in dataList" :key="index" @click="goAccessApplication(item)">
  24. <view class="left-box">
  25. <view>{{item.name}}</view>
  26. <view>{{item.deptName}}{{item.buildName}}{{item.room}}</view>
  27. </view>
  28. <view class="right-p" :class="{'colorA':!item.isApply}">{{item.isApply?'已申请':'立即申请'}}</view>
  29. <img v-if="!item.isApply" src="@/images/basicsModules/icon_04.png">
  30. </view>
  31. <view class="bottom-null-view">暂无更多数据</view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import { departmentsList,buildingList,mySecuritySubjectList,subjectMaterialList } from '@/api/apiDemo/index.js'
  37. export default {
  38. data() {
  39. return {
  40. //空数据展示
  41. nullType:false,
  42. faculty:['暂无院系数据'],
  43. facultyList:[],
  44. facultyIndex:0,
  45. building:['暂无实验楼数据'],
  46. buildingList:[],
  47. buildingIndex:0,
  48. dataList:[],
  49. }
  50. },
  51. onLoad() {
  52. },
  53. onShow(){
  54. this.getDepartmentsList();
  55. },
  56. methods: {
  57. //查询院系
  58. async getDepartmentsList() {
  59. let self = this;
  60. const {data} = await departmentsList()
  61. if(data.code==200){
  62. if (data.data[0]){
  63. let list = [];
  64. for(let i=0;i<data.data.length;i++){
  65. list.push(data.data[i].deptName);
  66. }
  67. this.faculty = list;
  68. this.facultyIndex = 0;
  69. this.facultyList = data.data;
  70. this.getDuildingList(this.facultyList[0].deptId)
  71. }else{
  72. this.faculty = ['暂无院系数据'];
  73. this.facultyIndex = 0;
  74. this.facultyList = [];
  75. this.building = ['暂无实验楼数据'];
  76. this.buildingIndex = 0;
  77. this.buildingList = [];
  78. this.dataList=[];
  79. }
  80. }
  81. },
  82. //查询楼栋
  83. async getDuildingList(deptId) {
  84. let self = this;
  85. let obj = {deptId:deptId}
  86. const {data} = await buildingList(obj);
  87. if(data.code==200){
  88. if (data.data[0]){
  89. let list = [];
  90. for(let i=0;i<data.data.length;i++){
  91. list.push(data.data[i].deptName);
  92. }
  93. this.building = list;
  94. this.buildingIndex = 0;
  95. this.buildingList = data.data;
  96. this.mySecuritySubjectList(this.buildingList[0].deptId);
  97. }else{
  98. this.building = ['暂无实验楼数据'];
  99. this.buildingIndex = 0;
  100. this.buildingList = [];
  101. this.dataList=[];
  102. }
  103. }
  104. },
  105. //查询列表
  106. async mySecuritySubjectList(deptId) {
  107. let self = this;
  108. let obj = {deptId:deptId}
  109. const {data} = await mySecuritySubjectList(obj);
  110. if(data.code==200){
  111. if(data.data[0]){
  112. this.dataList = data.data;
  113. }else{
  114. this.dataList=[];
  115. }
  116. }
  117. },
  118. facultyChange(e){
  119. this.facultyIndex = e.target.value;
  120. this.getDuildingList(this.facultyList[this.facultyIndex].deptId)
  121. },
  122. buildingChange(e){
  123. this.buildingIndex = e.target.value;
  124. this.mySecuritySubjectList(this.buildingList[this.buildingIndex].deptId)
  125. },
  126. goAccessApplication(item){
  127. if(item.isApply){
  128. //已申请
  129. return
  130. item.infoId = item.appId;
  131. uni.navigateTo({
  132. url:'/pages_student/accessApplication/applicationDetails?item='+encodeURIComponent(JSON.stringify(item))
  133. })
  134. }else{
  135. //未申请
  136. this.subjectMaterialList(item);
  137. }
  138. },
  139. //查询实验室下的安全准入资格材料表
  140. async subjectMaterialList(item){
  141. let obj = {
  142. subjectId:item.id
  143. }
  144. const {data} = await subjectMaterialList(obj)
  145. if(data.code == 200){
  146. if(data.data[0]){
  147. item.buildId = this.buildingList[this.buildingIndex].deptId;
  148. item.deptId = this.facultyList[this.facultyIndex].deptId;
  149. uni.navigateTo({
  150. url:'/pages_student/accessApplication/accessApplication?item='+encodeURIComponent(JSON.stringify(item))+'&list='+encodeURIComponent(JSON.stringify(data.data))
  151. })
  152. }else{
  153. uni.showToast({
  154. title: '该实验室未配置准入资格,无法申请~',
  155. icon:"none",
  156. mask:true,
  157. duration: 2000
  158. });
  159. }
  160. }
  161. },
  162. }
  163. }
  164. </script>
  165. <style lang="stylus" scoped>
  166. #chooseALaboratory{
  167. height:100%;
  168. width:100%;
  169. display flex
  170. flex-direction column
  171. .picker-box:nth-child(1){
  172. border-bottom:1rpx solid #e0e0e0;
  173. }
  174. .picker-box:nth-child(2){
  175. margin-bottom:40rpx;
  176. }
  177. .picker-box{
  178. height:80rpx;
  179. background: #fff
  180. .picker-min-box{
  181. display flex;
  182. view:nth-child(1){
  183. flex:1;
  184. line-height 80rpx
  185. color:#333
  186. margin-left:20rpx;
  187. }
  188. view:nth-child(2){
  189. line-height 80rpx
  190. color:#CCCCCC
  191. }
  192. img{
  193. width:12rpx;
  194. height:24rpx;
  195. margin:28rpx 20rpx 0 28rpx;
  196. }
  197. }
  198. }
  199. .for-max-box{
  200. flex:1;
  201. overflow-y scroll
  202. .bottom-null-view{
  203. font-size:26rpx;
  204. color:#999;
  205. text-align: center
  206. line-height:80rpx;
  207. }
  208. .for-box{
  209. background #fff
  210. display flex
  211. border-bottom:1rpx solid #e0e0e0;
  212. .left-box{
  213. flex:1;
  214. margin-left:20rpx;
  215. view:nth-child(1){
  216. line-height: 28rpx;
  217. font-size: 28rpx;
  218. color: #333333;
  219. margin:20rpx 0 0 0;
  220. }
  221. view:nth-child(2){
  222. line-height: 24rpx;
  223. font-size: 24rpx;
  224. color: #999;
  225. margin:25rpx 0 0 0;
  226. }
  227. }
  228. .right-p{
  229. line-height:120rpx;
  230. font-size:24;
  231. color: #999999;
  232. margin-right:52rpx;
  233. }
  234. img{
  235. width:12rpx;
  236. height:24rpx;
  237. margin:48rpx 20rpx 48rpx 20rpx;
  238. }
  239. .colorA{
  240. color: #0183FA;
  241. margin-right:0;
  242. }
  243. }
  244. }
  245. }
  246. </style>