瀏覽代碼

__scanCallback 设置时间,防止两次扫描同一个设备,assetid不改变,watch监听不触发

yunxing 4 年之前
父節點
當前提交
9bf44cece3
共有 4 個文件被更改,包括 137 次插入21 次删除
  1. 5 2
      src/components/Navbar.vue
  2. 1 1
      src/main.ts
  3. 130 17
      src/views/equipmentFacilities/MoreEquipmentList.vue
  4. 1 1
      src/views/equipmentFacilities/index.vue

+ 5 - 2
src/components/Navbar.vue

@@ -32,7 +32,9 @@ window.__scanCallback = function (data) {
         // 扫码的是设备二维码
         case 1:
         case '1':
-            store.commit('SCANASSETID', data.text)
+            // 设置时间,防止两次扫描同一个设备,assetid不改变,watch监听不触发
+            let time = new Date().getTime()
+            store.commit('SCANASSETID', `${data.text}__${time}`)
             break
         // 扫码失败
         case -1:
@@ -59,7 +61,8 @@ export default {
         // 扫到二维码,跳转设备详情页
         scanAssetid(newV, oldV) {
             if (newV) {
-                this.$router.push({ name: 'AssetDetail', query: { assetid: newV } })
+                let assetid = newV.split('__')[0]
+                this.$router.push({ name: 'AssetDetail', query: { assetid } })
             }
         },
     },

+ 1 - 1
src/main.ts

@@ -19,7 +19,7 @@ import VConsole from 'vconsole'
 // 开发环境引入 vConsole调试工具
 if (process.env.NODE_ENV === 'production' && process.env.VUE_APP_RealEnv !== 'production') {
     // TODO: vConsole
-    // new VConsole()
+    new VConsole()
 }
 const ua = navigator.userAgent
 

+ 130 - 17
src/views/equipmentFacilities/MoreEquipmentList.vue

@@ -87,7 +87,7 @@ import { NavBar, Search, List, Cell, Icon, Popup, Button, Empty } from 'vant'
 Vue.use(NavBar).use(Search).use(List).use(Cell).use(Icon).use(Popup).use(Button).use(Empty)
 import { mapGetters } from 'vuex'
 
-import { querySmsLocation } from '@/api/equipmentList'
+import { queryMoreAsset, queryAssetClass } from '@/api/equipmentList'
 import { queryPic } from '@/api/public'
 import ImagePreview from '@/components/ImagePreview'
 import { sleep } from '@/utils/util'
@@ -235,7 +235,10 @@ export default {
     computed: {
         ...mapGetters(['plazaId', 'smsxt', 'categoryId']),
     },
-    created() {},
+    created() {
+        this.system_code = this.smsxt
+        this.onLoad()
+    },
     beforeMount() {},
     mounted() {},
     methods: {
@@ -252,12 +255,71 @@ export default {
             this.loadMore = false
             this.sbssList = [{ text: '全部', code: '', active: 'active' }]
             // 查询筛选条件的 设备设施
-            // this.getSbss()
+            this.getSbss()
+        },
+        /**
+         * 获取设备列表
+         */
+        async getList() {
+            let data = {
+                page: this.page,
+                size: this.size,
+                plazaId: this.plazaId,
+                onlyMainAsset: true,
+            }
+            let postParams = {
+                system_code: this.system_code,
+            }
+            // 筛选后,专业系统选择全部, 删除上传system_code的字段
+            if (!this.system_code || this.system_code === '全部') {
+                delete postParams.system_code
+            }
+            // TODO:  筛选后, 使用classstructureid字段
+            if (this.sbss_code) {
+                data.classstructureid = this.sbss_code
+            }
+            // TODO: keyword
+            if (this.keyword) {
+                data.keyword = `${this.keyword}:sbjc,assetnum;`
+            }
+            let resData = await queryMoreAsset({ data, postParams })
+            if (!resData && !resData?.data) {
+                return false
+            }
+            console.log(resData)
+        },
+        async onLoad() {
+            console.log('onload')
+            if (this.page > 1) {
+                await sleep(1000)
+            }
+            await this.getList()
+            this.page++
+            this.loading = false
+            if (this.list.length >= this.count) {
+                this.finished = true
+            }
+        },
+        /**
+         * 跳转设备详情页
+         */
+        goToDetail(item) {
+            const { assetid } = item
+            assetid && this.$router.push({ name: 'AssetDetail', query: { assetid } })
         },
         onSearch() {
             // 初始化数据,查询列表
         },
         /**
+         *  初始化数据,查询列表
+         */
+        initData() {
+            this.finished = false
+            this.page = 1
+            this.count = 0
+            this.list = []
+        },
+        /**
          * popup 更改系统
          */
         changeSystem(data) {
@@ -271,34 +333,85 @@ export default {
             })
             // 弹窗选中的系统
             this.$set(this.modalDataBak, 'system', data.smsxt)
-            // this.getSbss(data.smsxt)
+            this.getSbss(data.smsxt)
+        },
+        /**
+         * popup 更改设备设施
+         */
+        changeSbss(data) {
+            let sbssList = this.sbssList
+            sbssList.map((item) => {
+                item.active = ''
+                if (item.text === data.text && item.code === data.code) {
+                    item.active = 'active'
+                }
+            })
+            // 弹窗选中的系统
+            // TODO: 111
+            console.log(data)
+            this.$set(this.modalDataBak, 'sbss', data.code)
         },
         /**
+         * 获取设备设施筛选条件
+         * @param smsxt 右弹窗 更改专业系统传递参数
+         */
+        async getSbss(smsxt) {
+            console.log(this.smsxt, this.system_code)
+            let getParams = {
+                system_code: smsxt || this.smsxt,
+            }
+            if (smsxt === '全部') {
+                delete getParams.system_code
+            }
+            let resData = await queryAssetClass({ getParams })
+            console.log(resData)
+            if (!resData && !resData?.data) {
+                this.sbssList = [{ text: '全部', code: '全部', active: 'active' }]
+                return false
+            }
+            let res_data = resData.data || []
+            let sbssList = []
+            res_data.map((item) => {
+                sbssList.push({
+                    text: item.classqc,
+                    active: '',
+                    // code: detail.systemqm,
+                    code: item.classstructureid,
+                })
+            })
+            this.sbssList = [{ text: '全部', code: '全部', active: 'active' }, ...sbssList]
+        },
+
+        /**
          * 重置
          */
         reset() {
-            // this.modalDataBak = {
-            //     system: '',
-            // }
-            // this.modalData = {
-            //     system: '',
-            // }
-            // this.system_code = this.smsxt
+            this.modalDataBak = {
+                system: '',
+                sbss: '全部',
+            }
+            this.modalData = {
+                system: '',
+                sbss: '全部',
+            }
+            this.system_code = this.smsxt
+            this.sbss_code = ''
             this.showPopup = false
             // 初始化数据,查询列表
-            // this.initData()
-            // this.onLoad()
+            this.initData()
+            this.onLoad()
         },
         /**
          * 弹窗确认
          */
         confirm() {
-            // this.modalData = cloneDeep(this.modalDataBak)
+            this.modalData = cloneDeep(this.modalDataBak)
             this.showPopup = false
-            // this.system_code = this.modalData.system
+            this.system_code = this.modalData.system
+            this.sbss_code = this.modalData.sbss
             // 初始化数据,查询列表
-            // this.initData()
-            // this.onLoad()
+            this.initData()
+            this.onLoad()
         },
     },
 }

+ 1 - 1
src/views/equipmentFacilities/index.vue

@@ -535,7 +535,7 @@ export default {
          * 点击更多设备卡片,跳转设备列表页面
          */
         goToMoreEquipment() {
-            this.$router.push({ name: 'MoreEquipmentList', params: {} })
+            // this.$router.push({ name: 'MoreEquipmentList', params: {} })
         },
     },
 }