chooseALaboratory.vue 6.3 KB

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