laboratoryList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <!-- 实验室列表 -->
  2. <template>
  3. <view id="laboratoryList">
  4. <view class='top-search-value-max-box'>
  5. <view class='top-search-value-box'>
  6. <img :src="imagesUrl('commonality/icon_sys_ss@1x.png')" @click="searchValueClick()">
  7. <input class="input-box" v-model="queryParams.searchValue"
  8. maxlength="10" placeholder="搜索实验室/房间号"
  9. type="text" @confirm="searchValueClick()">
  10. <view v-if="queryParams.searchValue" class="button-box" @click="delSearchValue">清除</view>
  11. </view>
  12. </view>
  13. <view class="top-picker-max-box">
  14. <view class="top-picker-box">
  15. <picker @change="facultyChange" :value="facultyIndex" :range="facultyArray">
  16. <view class="picker-view">
  17. <view>{{!facultyIndex&&facultyIndex!=0?'二级单位':facultyArray[facultyIndex]}}</view>
  18. <img class="picker-img" :src="imagesUrl('commonality/icon_06.png')" alt="">
  19. </view>
  20. </picker>
  21. </view>
  22. <view class="top-picker-box">
  23. <picker @change="subjectChange" :value="subjectIndex" :range="subjectArray">
  24. <view class="picker-view">
  25. <view>{{!subjectIndex&&subjectIndex!=0?'分类':subjectArray[subjectIndex]}}</view>
  26. <img class="picker-img" :src="imagesUrl('commonality/icon_06.png')" alt="">
  27. </view>
  28. </picker>
  29. </view>
  30. <view class="top-picker-box">
  31. <picker @change="levelChange" :value="levelIndex" :range="levelArray">
  32. <view class="picker-view">
  33. <view>{{!levelIndex&&levelIndex!=0?'分级':levelArray[levelIndex]}}</view>
  34. <img class="picker-img" :src="imagesUrl('commonality/icon_06.png')" alt="">
  35. </view>
  36. </picker>
  37. </view>
  38. </view>
  39. <scroll-view scroll-y @scrolltolower="scrollGet" class="for-max-box">
  40. <img class="null-img" v-if="!dataList[0]" :src="imagesUrl('commonality/null-data-1.png')">
  41. <view class="for-box" v-for="(item,index) in dataList" :key="index" @click="tableButton('subDetail',item)">
  42. <view class="top-title-box">
  43. <view>
  44. {{item.subName}} {{item.roomName?'('+item.roomName+')':''}}
  45. </view>
  46. </view>
  47. <view class="bottom-text-max-box">
  48. <view class="bottom-text-box">
  49. <view v-if="item.levelName" class="lv-p" :style="'border:1rpx solid '+item.levelColor+';background:#fff;color:'+item.levelColor+';'">{{item.levelName}}</view>
  50. <view v-if="item.typeName" class="type-p">{{item.typeName}}</view>
  51. <view v-if="item.moldName" class="class-p">{{item.moldName}}</view>
  52. <view v-if="item.subArea" class="num-p">{{item.subArea}}m²</view>
  53. </view>
  54. <view class="bottom-address-box">
  55. <img :src="imagesUrl('commonality/icon_sys_dz@1x.png')">
  56. <view>{{item.deptName}}丨{{item.buildName}}-{{item.floorName}}</view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="get-data-null-p" v-if="getDataType">- 没有更多数据 -</view>
  61. </scroll-view>
  62. <tab-bar></tab-bar>
  63. </view>
  64. </template>
  65. <script>
  66. import tabBar from '@/pages/component/tabBar.vue'
  67. import $mqtt from '@/utils/mqtt.min.js';
  68. import {
  69. config
  70. } from '@/api/request/config.js'
  71. import {
  72. systemDeptDropList,
  73. laboratoryClassTypeGetList,
  74. laboratoryClassLevelGetList,
  75. laboratoryAppletSubList,
  76. laboratoryAppletGetSubDetailInfo
  77. } from '@/pages/api/index.js'
  78. export default {
  79. components: {
  80. tabBar,
  81. },
  82. data() {
  83. return {
  84. total: 0,
  85. dataList: [],
  86. getDataType: false,
  87. //院系选择器数据
  88. facultyList: [],
  89. facultyArray: [],
  90. facultyIndex: "",
  91. //分类选择器数据
  92. subjectList: [],
  93. subjectArray: [],
  94. subjectIndex: 0,
  95. //级别选择器数据
  96. levelList: [],
  97. levelArray: [],
  98. levelIndex: 0,
  99. // 查询参数
  100. queryParams: {
  101. page: 1,
  102. pageSize: 10,
  103. searchValue:"",
  104. deptId:"",
  105. typeId:"",
  106. levelId:"",
  107. },
  108. }
  109. },
  110. onLoad() {
  111. Promise.all([
  112. this.laboratoryClassTypeGetList(),
  113. this.laboratoryClassLevelGetList()
  114. ]).then((result) => {
  115. this.systemDeptDropList();
  116. }).catch((error) => {
  117. uni.showToast({
  118. title: '数据异常,请稍候再试!',
  119. icon: "none",
  120. duration: 3000
  121. });
  122. })
  123. },
  124. onShow() {
  125. },
  126. methods: {
  127. //选择学院
  128. facultyChange: function(e) {
  129. if (this.facultyArray[0]) {
  130. this.facultyIndex = parseInt(e.target.value);
  131. this.$set(this.queryParams,'page',1);
  132. this.getList();
  133. }
  134. },
  135. //选择类型
  136. subjectChange: function(e) {
  137. if (this.subjectArray[0]) {
  138. this.subjectIndex = parseInt(e.target.value);
  139. this.$set(this.queryParams,'page',1);
  140. this.getList();
  141. }
  142. },
  143. //选择级别
  144. levelChange: function(e) {
  145. if (this.levelArray[0]) {
  146. this.levelIndex = parseInt(e.target.value);
  147. this.$set(this.queryParams,'page',1);
  148. this.getList();
  149. }
  150. },
  151. //获取院系
  152. async systemDeptDropList() {
  153. const {
  154. data
  155. } = await systemDeptDropList({
  156. deptName: '',
  157. level: 2,
  158. deptType: 1
  159. });
  160. if (data.code == 200) {
  161. let list = [];
  162. for (let i = 0; i < data.data.length; i++) {
  163. list.push(data.data[i].deptName)
  164. }
  165. console.log('uni.getStorageSync',uni.getStorageSync('subAdmin'))
  166. if(uni.getStorageSync('subAdmin')==1){
  167. this.facultyArray.push('我的实验室')
  168. this.facultyList.push({
  169. deptName: "我的实验室",
  170. deptId: "-1"
  171. })
  172. }
  173. if(config.schoolId == uni.getStorageSync('user')){
  174. list.push('全部')
  175. this.facultyList.push({
  176. deptName: "全部",
  177. deptId: ""
  178. })
  179. this.facultyArray = this.facultyArray.concat(list)
  180. this.facultyList = this.facultyArray.concat(data.data)
  181. }else{
  182. this.facultyArray.push(uni.getStorageSync('userDeptName'))
  183. this.facultyList.push({
  184. deptName: uni.getStorageSync('userDeptName'),
  185. deptId: uni.getStorageSync('userDeptId')
  186. })
  187. }
  188. if(this.facultyList[0]){
  189. this.$set(this,'facultyIndex',0);
  190. this.getList()
  191. }
  192. }
  193. },
  194. //分类下拉列表
  195. async laboratoryClassTypeGetList() {
  196. const {
  197. data
  198. } = await laboratoryClassTypeGetList();
  199. if (data.code == 200) {
  200. let list = [];
  201. for (let i = 0; i < data.data.length; i++) {
  202. list.push(data.data[i].subType)
  203. }
  204. this.subjectArray = list;
  205. list.unshift('全部分类');
  206. this.subjectList = data.data;
  207. this.subjectList.unshift({
  208. subType: "全部分类",
  209. typeId: ""
  210. })
  211. }
  212. },
  213. //分级下拉列表
  214. async laboratoryClassLevelGetList() {
  215. const {
  216. data
  217. } = await laboratoryClassLevelGetList();
  218. if (data.code == 200) {
  219. let list = [];
  220. for (let i = 0; i < data.data.length; i++) {
  221. list.push(data.data[i].titleName)
  222. }
  223. this.levelArray = list;
  224. list.unshift('全部分类');
  225. this.levelList = data.data;
  226. this.levelList.unshift({
  227. titleName: "全部分类",
  228. levelId: ""
  229. })
  230. }
  231. },
  232. //滚动加载事件
  233. scrollGet() {
  234. let self = this;
  235. if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
  236. this.$set(this, 'getDataType', true);
  237. } else {
  238. this.queryParams.page += 1;
  239. this.$nextTick(() => {
  240. this.getList();
  241. })
  242. }
  243. },
  244. delSearchValue(){
  245. this.$set(this.queryParams,'searchValue','')
  246. this.$set(this.queryParams,'page',1);
  247. this.$nextTick(() => {
  248. this.getList();
  249. })
  250. },
  251. searchValueClick(){
  252. if(this.facultyList[0]){
  253. this.$set(this.queryParams,'page',1);
  254. this.$nextTick(() => {
  255. this.getList();
  256. })
  257. }
  258. },
  259. //获取实验室列表
  260. async getList() {
  261. if(!this.facultyList[0]||uni.getStorageSync('userType')==2){
  262. return
  263. }
  264. let self = this;
  265. let obj = JSON.parse(JSON.stringify(this.queryParams));
  266. obj.deptId = this.facultyIndex||this.facultyIndex==0 ? this.facultyList[this.facultyIndex].deptId : '';
  267. obj.typeId = this.subjectIndex||this.subjectIndex==0 ? this.subjectList[this.subjectIndex].typeId : '';
  268. obj.levelId = this.levelIndex||this.levelIndex==0 ? this.levelList[this.levelIndex].levelId : '';
  269. const {
  270. data
  271. } = await laboratoryAppletSubList(obj);
  272. if (data.code == 200) {
  273. if(self.queryParams.page == 1){
  274. this.dataList = data.data.records;
  275. this.total = data.data.total;
  276. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  277. this.$set(this, 'getDataType', true);
  278. }
  279. }else{
  280. this.dataList = [...this.dataList, ...data.data.records]
  281. this.total = data.data.total;
  282. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  283. this.$set(this, 'getDataType', true);
  284. }
  285. }
  286. }
  287. },
  288. tableButton(type, row) {
  289. let self = this;
  290. if (type == 'subDetail') {
  291. //实验室详情
  292. this.laboratoryAppletGetSubDetailInfo(row.infoId)
  293. }
  294. },
  295. //获取实验室详情
  296. async laboratoryAppletGetSubDetailInfo(infoId) {
  297. const {
  298. data
  299. } = await laboratoryAppletGetSubDetailInfo({
  300. infoId: infoId
  301. });
  302. if (data.code == 200) {
  303. uni.navigateTo({
  304. url: '/pages_manage/views/laboratory/safetyCardScan?infoData=' + encodeURIComponent(JSON.stringify(data.data))+'&saoCode=true'
  305. // url: '/pages_manage/views/laboratory/infoPage?infoData=' + encodeURIComponent(JSON.stringify(data.data))
  306. });
  307. }
  308. },
  309. },
  310. }
  311. </script>
  312. <style lang="stylus" scoped>
  313. @import '@/api/request/imagesUrl.styl';
  314. #laboratoryList {
  315. height: 100%;
  316. display flex;
  317. flex-direction column;
  318. .top-search-value-max-box{
  319. background-color: #fff;
  320. .top-search-value-box{
  321. display: flex;
  322. border:50rpx;
  323. height:80rpx;
  324. border:1px solid #E0E0E0;
  325. border-radius:40rpx;
  326. margin: 20rpx 30rpx 10rpx;
  327. img{
  328. width:26rpx;
  329. height:26rpx;
  330. margin:27rpx 30rpx;
  331. }
  332. .input-box{
  333. height:78rpx;
  334. line-height:78rpx;
  335. flex:1;
  336. }
  337. .button-box{
  338. width:120rpx;
  339. line-height:78rpx;
  340. height:78rpx;
  341. margin-right:10rpx;
  342. text-align: center;
  343. color:#0183FA;
  344. font-size:24rpx;
  345. }
  346. }
  347. }
  348. .top-picker-max-box {
  349. display: flex;
  350. padding: 0 20rpx;
  351. background #fff;
  352. border-bottom: 1rpx solid #E0E0E0;
  353. .top-picker-box {
  354. line-height: 80rpx;
  355. height: 80rpx;
  356. .picker-view {
  357. display flex;
  358. view {
  359. display: block;
  360. overflow: hidden;
  361. text-overflow: ellipsis;
  362. white-space: nowrap;
  363. font-size: 28rpx;
  364. }
  365. .picker-img {
  366. width: 24rpx;
  367. height: 13rpx;
  368. margin-top: 36rpx;
  369. margin-left: 13rpx;
  370. }
  371. }
  372. }
  373. .top-picker-box:nth-child(1) {
  374. text-align left;
  375. width: 320rpx;
  376. .picker-view {
  377. view {
  378. max-width: 260rpx;
  379. }
  380. }
  381. }
  382. .top-picker-box:nth-child(2) {
  383. text-align left;
  384. width: 215rpx;
  385. .picker-view {
  386. view {
  387. max-width: 156rpx;
  388. }
  389. }
  390. }
  391. .top-picker-box:nth-child(3) {
  392. text-align right;
  393. width: 195rpx;
  394. .picker-view {
  395. view {
  396. flex: 1;
  397. }
  398. }
  399. }
  400. }
  401. .for-max-box {
  402. flex: 1;
  403. overflow-y scroll;
  404. .null-img {
  405. display block;
  406. width: 276rpx;
  407. height: 321rpx;
  408. position absolute;
  409. top: 200rpx;
  410. left: 274rpx;
  411. }
  412. .for-box:nth-child(1) {
  413. border-top: none;
  414. }
  415. .for-box {
  416. width:690rpx;
  417. margin:20rpx 30rpx 0;
  418. .top-title-box{
  419. height:126rpx;
  420. width:690rpx;
  421. background: url($imagesUrl+'commonality/img_sys_bg@1x.png');
  422. background-size 100%;
  423. background-repeat: no-repeat;
  424. view{
  425. height:42rpx;
  426. line-height:42rpx;
  427. font-size:30rpx;
  428. color:#333333;
  429. padding:20rpx 37rpx;
  430. display:block;
  431. overflow:hidden;
  432. text-overflow:ellipsis;
  433. white-space:nowrap;
  434. }
  435. }
  436. .bottom-text-max-box{
  437. overflow: hidden;
  438. border-radius:0 0 20rpx 20rpx;
  439. padding-bottom:26rpx;
  440. width:690rpx;
  441. background #ffffff;
  442. .bottom-text-box{
  443. padding:0 30rpx;
  444. view{
  445. margin-left:10rpx;
  446. margin-bottom:5rpx;
  447. display:inline-block;
  448. overflow: hidden;
  449. padding:0 20rpx;
  450. text-align: center;
  451. border-radius:10rpx;
  452. }
  453. .lv-p{
  454. height:38rpx;
  455. line-height:36rpx;
  456. font-size:28rpx;
  457. color: #FF0000;
  458. }
  459. .type-p,.class-p,.num-p{
  460. height:40rpx;
  461. line-height:38rpx;
  462. font-size:24rpx;
  463. color:#0183FA;
  464. background: rgba(1,131,250,0.2);
  465. }
  466. }
  467. .bottom-address-box{
  468. display: flex;
  469. padding:21rpx 30rpx 0;
  470. img{
  471. display: block;
  472. width:30rpx;
  473. height:30rpx;
  474. margin:0 15rpx 0 12rpx;
  475. }
  476. view{
  477. height:30rpx;
  478. line-height:30rpx;
  479. font-size:28rpx;
  480. display:block;
  481. overflow:hidden;
  482. text-overflow:ellipsis;
  483. white-space:nowrap;
  484. }
  485. }
  486. }
  487. }
  488. .get-data-null-p {
  489. text-align: center;
  490. height: 100rpx;
  491. line-height: 100rpx;
  492. color: #999;
  493. padding-bottom:200rpx;
  494. }
  495. }
  496. }
  497. </style>