chenrui 4 سال پیش
والد
کامیت
beda6dc01b

+ 8 - 0
src/api/boxSetting.js

@@ -11,6 +11,14 @@ export const getBoxList = (params) => {
     method: 'post'
   })
 }
+// 查箱体类型列表  不分页
+export const deviceTypeListQuery = (params) => {
+  return axios.request({
+    url: `/deviceType/queryList`,
+    method: 'post',
+    data: params
+  })
+}
 // 确认保存
 export const saveBoxSetting = (params) => {
   const url = `deviceType/save`

+ 7 - 0
src/api/device.js

@@ -33,3 +33,10 @@ export const deviceTypeUpdate = (params) => {
     method: 'get'
   })
 }
+// 根据设备编号查询设备
+export const deviceFindDevice = (params) => {
+  return axios.request({
+    url: `/device/findBySrcDeviceNo/${params.srcDeviceCode}`,
+    method: 'get'
+  })
+}

+ 16 - 0
src/api/station.js

@@ -41,3 +41,19 @@ export const stationDel = (params) => {
     method: 'get'
   })
 }
+// 设备绑定
+export const stationBind = (params) => {
+  return axios.request({
+    url: `/station/binding`,
+    method: 'post',
+    data: params
+  })
+}
+// 设备解绑
+export const stationUnBind = (params) => {
+  return axios.request({
+    url: `/station/remBinding`,
+    method: 'post',
+    data: params
+  })
+}

+ 8 - 5
src/views/equipmentManage/network/detailsModal.vue

@@ -31,13 +31,13 @@
         </a-col>
         <a-col :span="8" class="item-cont">
           <p class="item-label">投递时间段:</p>
-          <p class="item-main">{{ detailsData.timeRuleName }}</p>
+          <p class="item-main">{{ detailsData.timeRuleName ? detailsData.timeRuleName : '--' }}</p>
         </a-col>
       </a-row>
       <a-row :gutter="35">
         <a-col :span="24" class="item-cont">
           <p class="item-label">兑换规则:</p>
-          <p class="item-main">{{ detailsData.exRuleName }}</p>
+          <p class="item-main">{{ detailsData.exRuleName ? detailsData.exRuleName : '--' }}</p>
         </a-col>
       </a-row>
     </div>
@@ -88,6 +88,10 @@ export default {
     networkId: {
       type: [Number, String],
       default: ''
+    },
+    networkNo: {
+      type: String,
+      default: ''
     }
   },
   data () {
@@ -109,7 +113,6 @@ export default {
     //  获取详情
     getDetails () {
       stationFind({ id: this.networkId }).then(res => {
-        console.log(res, '----res')
         if (res.status == 200) {
           this.detailsData = res.data
         }
@@ -117,7 +120,7 @@ export default {
     },
     //  已绑设备
     getDevice () {
-      deviceListQuery({ stationNo: this.detailsData }).then(res => {
+      deviceListQuery({ stationNo: this.networkNo }).then(res => {
         console.log(res)
         if (res.status == 200) {
           res.data.map((item, index) => {
@@ -143,8 +146,8 @@ export default {
     },
     networkId (newValue, oldValue) {
       if (this.isShow && newValue) {
-        this.getDevice()
         this.getDetails()
+        this.getDevice()
       }
     }
   }

+ 62 - 50
src/views/equipmentManage/network/equipmentModal.vue

@@ -24,10 +24,10 @@
       <a-card class="search-sub" :bordered="false">
         <div class="noData" v-if="noData==1" style="text-align: center;">未查询到结果</div>
         <div class="search-sub-item" v-if="resultData && isFocus">
-          <p>{{ resultData.name }}</p>
+          <p>{{ resultData.srcDeviceCode }}</p>
           <a-button
             id="equipment-unbind"
-            v-if="!resultData.params"
+            v-if="resultData.bindingFlag == 0"
             type="primary"
             ghost
             size="small"
@@ -84,7 +84,10 @@
 </template>
 
 <script>
-import { deviceEnable } from '@/api/device'
+import { deviceEnable, deviceListQuery, deviceFindDevice } from '@/api/device'
+import { stationBind, stationUnBind } from '@/api/station'
+import { deviceTypeListQuery } from '@/api/boxSetting'
+
 export default {
   name: 'EquipmentModal',
   props: {
@@ -95,6 +98,10 @@ export default {
     networkId: {
       type: [Number, String],
       default: ''
+    },
+    networkNo: {
+      type: String,
+      default: ''
     }
   },
   data () {
@@ -112,49 +119,54 @@ export default {
         { title: '工作状态', scopedSlots: { customRender: 'workStatus' }, width: 150, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center' }
       ],
-      equipmentData: [
-        { id: 1, no: 1, equipmentNo: 'x13132', equipmentStatus: '1', putIn: '10%-34%-0%-98%', type: '咸阳二代新箱体', workStatus: '1' },
-        { id: 2, no: 2, equipmentNo: 'x23132', equipmentStatus: '1', putIn: '10%-34%-0%-98%', type: '咸阳二代新箱体', workStatus: '1' },
-        { id: 3, no: 3, equipmentNo: 'x33132', equipmentStatus: '1', putIn: '10%-34%-0%-98%', type: '咸阳二代新箱体', workStatus: '2' },
-        { id: 4, no: 4, equipmentNo: 'x43132', equipmentStatus: '1', putIn: '10%-34%-0%-98%', type: '咸阳二代新箱体', workStatus: '1' }
-      ],
+      equipmentData: [],
       typeList: [] //  箱体类型
     }
   },
   methods: {
-    //  获取详情
-    getDetails () {},
+    //  已绑设备
+    getDevice () {
+      deviceListQuery({ stationNo: this.networkNo }).then(res => {
+        console.log(res)
+        if (res.status == 200) {
+          res.data.map((item, index) => {
+            item.no = index + 1
+          })
+          this.equipmentData = res.data
+        } else {
+          this.equipmentData = []
+        }
+      })
+    },
+    //  箱体类型下拉数据
+    getDeviceType () {
+      deviceTypeListQuery({}).then(res => {
+        console.log(res)
+        if (res.status == 200) {
+
+        }
+      })
+    },
     //  搜索设备
     onSearch (value) {
       if (value) {
-        // findVsDevice({ id: value }).then(res => {
-        //   if (res.status == 200) {
-        //     if (res.data) {
-        this.noData = 2
-        // this.resultData = res.data
-        //     } else {
-        //       this.noData = 1
-        //       this.resultData = null
-        //     }
-        //   }
-        // })
+        deviceFindDevice({ srcDeviceCode: value }).then(res => {
+          if (res.status == 200) {
+            if (res.data) {
+              this.noData = 2
+              this.resultData = res.data
+            } else {
+              this.noData = 1
+              this.resultData = null
+            }
+          }
+        })
       } else {
         this.noData = 0
         this.resultData = null
         this.isFocus = false
       }
     },
-    //  门店已绑设备
-    getStoreEquipment (id) {
-      // findStoreVsDevice({ code: id }).then(res => {
-      //   if (res.status == 200) {
-      //     res.data.map((item, ind) => {
-      //       item.no = ind + 1
-      //     })
-      //     this.equipmentData = res.data
-      //   }
-      // })
-    },
     //  解绑
     onUnbundling (item) {
       const _this = this
@@ -163,12 +175,12 @@ export default {
         centered: true,
         content: '确定解绑该设备吗?',
         onOk () {
-          // unbindVsDevice({ id: item.id }).then(res => {
-          //   if (res.status == 200) {
-          //     _this.$message.success(res.message)
-          //     _this.getStoreEquipment(_this.storeCode)
-          //   }
-          // })
+          stationUnBind({ srcDeviceCode: item.srcDeviceCode }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.getDevice()
+            }
+          })
         }
       })
     },
@@ -180,15 +192,14 @@ export default {
         centered: true,
         content: '确定要绑定该设备吗?',
         onOk () {
-          // bindVsDevice({ storeCode: _this.storeCode, vsDeviceId: item.id }).then(res => {
-          //   if (res.status == 200) {
-          //     _this.$message.success(res.message)
-          //     _this.expandedRowKeys = []
-          //     _this.resultData = null
-          //     _this.isFocus = false
-          //     _this.getStoreEquipment(_this.storeCode)
-          //   }
-          // })
+          stationBind({ srcDeviceCode: item.srcDeviceCode, stationNo: _this.networkNo }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.resultData = null
+              _this.isFocus = false
+              _this.getDevice()
+            }
+          })
         }
       })
     },
@@ -200,7 +211,7 @@ export default {
     changeFlagHandle (record) {
       const _data = {
         id: record.id,
-        flag: record.state == 1 ? '0' : '1'
+        state: record.state == 1 ? '0' : '1'
       }
       deviceEnable(_data).then(res => {
         if (res.status == 200) {
@@ -223,7 +234,8 @@ export default {
     },
     networkId (newValue, oldValue) {
       if (this.isShow && newValue) {
-        this.getDetails()
+        this.getDevice()
+        this.getDeviceType()
       }
     }
   }

+ 7 - 2
src/views/equipmentManage/network/network.vue

@@ -68,9 +68,9 @@
     <!-- 新增编辑 -->
     <edit-network-modal :openModal="openNetworkModal" :networkId="networkId" @success="handleReset" @close="openNetworkModal=false" />
     <!-- 详情 -->
-    <details-network-modal :openModal="openDetailModal" :networkId="networkId" @close="openDetailModal=false" />
+    <details-network-modal :openModal="openDetailModal" :networkId="networkId" :networkNo="networkNo" @close="openDetailModal=false" />
     <!-- 绑定箱体设备 -->
-    <equipment-modal :openModal="openBindModal" :networkId="networkId" @close="openBindModal=false" />
+    <equipment-modal :openModal="openBindModal" :networkId="networkId" :networkNo="networkNo" @close="openBindModal=false" />
   </a-card>
 </template>
 
@@ -136,6 +136,7 @@ export default {
       orderTotal: '', // 合计开单数量
       openNetworkModal: false, //  新增编辑网点信息
       networkId: null, //  网点id
+      networkNo: null, //  网点编号
       openDetailModal: false, //  网点信息详情
       openBindModal: false //  绑定箱体设备
     }
@@ -170,20 +171,24 @@ export default {
       this.areas = []
       this.$refs.table.refresh(true)
       this.networkId = null
+      this.networkNo = null
     },
     //  新增、编辑网点
     handleEdit (row) {
       this.networkId = row ? row.id : null
+      this.networkNo = row ? row.stationNo : null
       this.openNetworkModal = true
     },
     //  查看详情
     handleView (row) {
       this.networkId = row ? row.id : null
+      this.networkNo = row ? row.stationNo : null
       this.openDetailModal = true
     },
     //  关联箱体设备
     handleBind (row) {
       this.networkId = row ? row.id : null
+      this.networkNo = row ? row.stationNo : null
       this.openBindModal = true
     }
   }