chenrui 4 年之前
父節點
當前提交
7a6798e844

+ 7 - 0
src/api/device.js

@@ -40,3 +40,10 @@ export const deviceFindDevice = (params) => {
     method: 'get'
   })
 }
+// 设备更换箱体类型
+export const deviceUpdateDeviceType = (params) => {
+  return axios.request({
+    url: `/device/updateDeviceType/${params.id}/${params.deviceTypeNo}`,
+    method: 'get'
+  })
+}

+ 10 - 10
src/views/equipmentManage/equipment/equipment.vue

@@ -33,11 +33,11 @@
       :data="loadData"
       bordered>
       <!-- 箱体投放比例 -->
-      <template slot="boxOnePersent" slot-scope="text, record">{{ record.boxOnePersent ? record.boxOnePersent * 100 + '%' : '--' }}</template>
-      <template slot="boxTwoPersent" slot-scope="text, record">{{ record.boxTwoPersent ? record.boxTwoPersent * 100 + '%' : '--' }}</template>
-      <template slot="boxThreePersent" slot-scope="text, record">{{ record.boxThreePersent ? record.boxThreePersent * 100 + '%' : '--' }}</template>
-      <template slot="boxFourPersent" slot-scope="text, record">{{ record.boxFourPersent ? record.boxFourPersent * 100 + '%' : '--' }}</template>
-      <template slot="boxFivePersent" slot-scope="text, record">{{ record.boxFivePersent ? record.boxFivePersent * 100 + '%' : '--' }}</template>
+      <template slot="boxOnePercent" slot-scope="text, record">{{ record.boxOnePercent ? record.boxOnePercent + '%' : '--' }}</template>
+      <template slot="boxTwoPercent" slot-scope="text, record">{{ record.boxTwoPercent ? record.boxTwoPercent + '%' : '--' }}</template>
+      <template slot="boxThreePercent" slot-scope="text, record">{{ record.boxThreePercent ? record.boxThreePercent + '%' : '--' }}</template>
+      <template slot="boxFourPercent" slot-scope="text, record">{{ record.boxFourPercent ? record.boxFourPercent + '%' : '--' }}</template>
+      <template slot="boxFivePercent" slot-scope="text, record">{{ record.boxFivePercent ? record.boxFivePercent + '%' : '--' }}</template>
       <!-- 状态 -->
       <template slot="state" slot-scope="text, record">
         <span :class="record.state==0 ? 'red' : record.state==1 ? 'green' : ''">{{ record.state == 0 ? '已禁用' : record.state == 1 ? '已启用' : '--' }}</span>
@@ -84,11 +84,11 @@ export default {
         { title: '内置箱体数', dataIndex: 'boxNum', width: 200, align: 'center' },
         { title: '内置各箱体已投放比例(%)',
           children: [
-            { title: '1号箱', scopedSlots: { customRender: 'boxOnePersent' }, width: 100, align: 'center' },
-            { title: '2号箱', scopedSlots: { customRender: 'boxTwoPersent' }, width: 100, align: 'center' },
-            { title: '3号箱', scopedSlots: { customRender: 'boxThreePersent' }, width: 100, align: 'center' },
-            { title: '4号箱', scopedSlots: { customRender: 'boxFourPersent' }, width: 100, align: 'center' },
-            { title: '5号箱', scopedSlots: { customRender: 'boxFivePersent' }, width: 100, align: 'center' }
+            { title: '1号箱', scopedSlots: { customRender: 'boxOnePercent' }, width: 100, align: 'center' },
+            { title: '2号箱', scopedSlots: { customRender: 'boxTwoPercent' }, width: 100, align: 'center' },
+            { title: '3号箱', scopedSlots: { customRender: 'boxThreePercent' }, width: 100, align: 'center' },
+            { title: '4号箱', scopedSlots: { customRender: 'boxFourPercent' }, width: 100, align: 'center' },
+            { title: '5号箱', scopedSlots: { customRender: 'boxFivePercent' }, width: 100, align: 'center' }
           ]
         },
         { title: '版本', dataIndex: 'boxVersion', width: 200, align: 'center' },

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

@@ -59,11 +59,11 @@
         </template>
         <!-- 投放情况 -->
         <template slot="situation" slot-scope="text, record">
-          [{{ record.boxOnePersent ? record.boxOnePersent * 100 + '%' : '--' }}] --
-          [{{ record.boxTwoPersent ? record.boxTwoPersent * 100 + '%' : '--' }}] -
-          [{{ record.boxThreePersent ? record.boxThreePersent * 100 + '%' : '--' }}] -
-          [{{ record.boxFourPersent ? record.boxFourPersent * 100 + '%' : '--' }}] -
-          [{{ record.boxFivePersent ? record.boxFivePersent * 100 + '%' : '--' }}]
+          [{{ record.boxOnePercent ? record.boxOnePercent + '%' : '--' }}] --
+          [{{ record.boxTwoPercent ? record.boxTwoPercent + '%' : '--' }}] -
+          [{{ record.boxThreePercent ? record.boxThreePercent + '%' : '--' }}] -
+          [{{ record.boxFourPercent ? record.boxFourPercent + '%' : '--' }}] -
+          [{{ record.boxFivePercent ? record.boxFivePercent + '%' : '--' }}]
         </template>
         <!-- 工作状态 -->
         <template slot="state" slot-scope="text, record">

+ 48 - 16
src/views/equipmentManage/network/equipmentModal.vue

@@ -47,16 +47,29 @@
       :columns="columns"
       :data-source="equipmentData"
       :pagination="false">
+      <!-- 设备状态 -->
+      <template slot="onlineFlag" slot-scope="text, record">
+        <span :class="record.onlineFlag==0 ? 'red' : record.onlineFlag==1 ? 'green' : ''">{{ record.onlineFlag == 0 ? '离线' : record.onlineFlag == 1 ? '在线' : '--' }}</span>
+      </template>
+      <!-- 投放情况 -->
+      <template slot="situation" slot-scope="text, record">
+        [{{ record.boxOnePercent ? record.boxOnePercent + '%' : '--' }}] --
+        [{{ record.boxTwoPercent ? record.boxTwoPercent + '%' : '--' }}] -
+        [{{ record.boxThreePercent ? record.boxThreePercent + '%' : '--' }}] -
+        [{{ record.boxFourPercent ? record.boxFourPercent + '%' : '--' }}] -
+        [{{ record.boxFivePercent ? record.boxFivePercent + '%' : '--' }}]
+      </template>
       <!-- 箱体类型 -->
       <template slot="type" slot-scope="record">
         <a-select
           id="equipment-type"
-          allowClear
           placeholder="请选择箱体类型"
           style="width: 100%;"
-          @change="typeChange">
-          <a-select-option v-for="(item,index) in typeList" :key="index" :value="item.value">
-            {{ item.value }}
+          v-model="record.deviceTypeNo"
+          :disabled="record.state == 1"
+          @change="typeChange($event, record)">
+          <a-select-option v-for="(item,index) in record.deviceTypeList" :key="index" :value="item.deviceTypeNo">
+            {{ item.name }}
           </a-select-option>
         </a-select>
       </template>
@@ -66,7 +79,7 @@
           checkedChildren="启用"
           unCheckedChildren="禁用"
           id="equipment-changeFlagHandle"
-          v-model="record.workStatus == 1 ? true : false"
+          v-model="record.state == 1 ? true : false"
           @change="changeFlagHandle(record)"
         />
       </template>
@@ -84,7 +97,7 @@
 </template>
 
 <script>
-import { deviceEnable, deviceListQuery, deviceFindDevice } from '@/api/device'
+import { deviceEnable, deviceListQuery, deviceFindDevice, deviceUpdateDeviceType } from '@/api/device'
 import { stationBind, stationUnBind } from '@/api/station'
 import { deviceTypeListQuery } from '@/api/boxSetting'
 
@@ -112,9 +125,9 @@ export default {
       isFocus: false, //  搜索框是否获取焦点
       columns: [
         { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
-        { title: '设备编号', dataIndex: 'equipmentNo', width: 100, align: 'center' },
-        { title: '设备状态', dataIndex: 'equipmentStatus', width: 150, align: 'center' },
-        { title: '投放情况', dataIndex: 'putIn', width: 150, align: 'center' },
+        { title: '设备编号', dataIndex: 'srcDeviceCode', width: 100, align: 'center' },
+        { title: '设备状态', scopedSlots: { customRender: 'onlineFlag' }, width: 150, align: 'center' },
+        { title: '投放情况', scopedSlots: { customRender: 'situation' }, width: 150, align: 'center' },
         { title: '箱体类型', scopedSlots: { customRender: 'type' }, width: 150, align: 'center' },
         { title: '工作状态', scopedSlots: { customRender: 'workStatus' }, width: 150, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center' }
@@ -127,12 +140,14 @@ export default {
     //  已绑设备
     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
+          this.equipmentData.map((item, index) => {
+            item.deviceTypeList = this.setDeviceType(item.boxNum)
+          })
         } else {
           this.equipmentData = []
         }
@@ -141,12 +156,24 @@ export default {
     //  箱体类型下拉数据
     getDeviceType () {
       deviceTypeListQuery({}).then(res => {
-        console.log(res)
         if (res.status == 200) {
-
+          this.typeList = res.data
+        } else {
+          this.typeList = []
         }
       })
     },
+    //  处理每个设备所对应的箱体类型
+    setDeviceType (boxNum) {
+      const arr = []
+      let j = 0
+      for (const i in this.typeList) {
+        if (this.typeList[i].boxNum == boxNum) {
+          arr[j++] = this.typeList[i]
+        }
+      }
+      return arr
+    },
     //  搜索设备
     onSearch (value) {
       if (value) {
@@ -204,8 +231,13 @@ export default {
       })
     },
     //  箱体类型 change
-    typeChange (val) {
-      console.log(val)
+    typeChange (deviceTypeNo, record) {
+      deviceUpdateDeviceType({ id: record.id, deviceTypeNo: deviceTypeNo }).then(res => {
+        console.log(res)
+        if (res.status == 200) {
+          this.$message.success(res.message)
+        }
+      })
     },
     // 更改启用禁用状态
     changeFlagHandle (record) {
@@ -216,7 +248,7 @@ export default {
       deviceEnable(_data).then(res => {
         if (res.status == 200) {
           this.$message.success(res.message)
-          this.$refs.table.refresh()
+          this.getDevice()
         }
       })
     }
@@ -234,8 +266,8 @@ export default {
     },
     networkId (newValue, oldValue) {
       if (this.isShow && newValue) {
-        this.getDevice()
         this.getDeviceType()
+        this.getDevice()
       }
     }
   }

+ 6 - 10
src/views/equipmentManage/network/network.vue

@@ -23,11 +23,7 @@
             <a-form-item label="区域" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
               <a-cascader
                 id="network-areas"
-                v-decorator="[
-                  'options',
-                  {initialValue: areas,
-                   rules: []}
-                ]"
+                v-model="areas"
                 :options="options"
                 placeholder="请选择省市区"
                 @change="addrChange"/>
@@ -60,7 +56,7 @@
       <template slot="action" slot-scope="text, record">
         <a-icon type="eye" id="network-handleView" title="详情" class="actionBtn icon-green" @click="handleView(record)" />
         <a-icon type="edit" id="network-handleEdit" title="编辑" class="actionBtn icon-blues" @click="handleEdit(record)" />
-        <a-badge count="5">
+        <a-badge :count="record.devCount">
           <a-icon type="link" id="network-handleLink" title="绑定箱体设备" class="actionBtn icon-orange" @click="handleBind(record)" />
         </a-badge>
       </template>
@@ -76,8 +72,7 @@
 
 <script>
 import { STable, VSelect } from '@/components'
-import addrData, { province, city, area } from '@/api/address'
-import getDate from '@/libs/getDate.js'
+import addrData from '@/api/address'
 import moment from 'moment'
 import editNetworkModal from './editModal.vue'
 import detailsNetworkModal from './detailsModal.vue'
@@ -156,11 +151,12 @@ export default {
     },
     //  省市区  change
     addrChange (val) {
-      console.log(this.areas, '省市区-', val)
+      this.queryParam.provinceCode = val[0]
+      this.queryParam.cityCode = val[1]
+      this.queryParam.districtCode = val[2]
     },
     // 重置
     handleReset () {
-      console.log('重置', this.queryParam)
       this.queryParam.beginDate = null
       this.queryParam.endDate = null
       this.queryParam.name = ''