lilei 4 лет назад
Родитель
Сommit
7ceb8cbfba
1 измененных файлов с 11 добавлено и 20 удалено
  1. 11 20
      src/views/equipmentManage/network/equipmentModal.vue

+ 11 - 20
src/views/equipmentManage/network/equipmentModal.vue

@@ -51,8 +51,7 @@
         :pagination="false">
         <!-- 设备状态 -->
         <template slot="onlineFlag" slot-scope="text, record">
-			<span :style="{'color':(record.onlineFlag==0 ? 'red' : record.onlineFlag==1 ? 'green' : '')}">{{ record.onlineFlag == 0 ? '离线' : record.onlineFlag == 1 ? '在线' : '--' }}</span>
-          <!-- <span :class="record.onlineFlag==0 ? 'red' : record.onlineFlag==1 ? 'green' : ''">{{ record.onlineFlag == 0 ? '离线' : record.onlineFlag == 1 ? '在线' : '--' }}</span> -->
+          <span :style="{'color':(record.onlineFlag==0 ? 'red' : record.onlineFlag==1 ? 'green' : '')}">{{ record.onlineFlag == 0 ? '离线' : record.onlineFlag == 1 ? '在线' : '--' }}</span>
         </template>
         <!-- 箱体类型 -->
         <template slot="type" slot-scope="record">
@@ -68,17 +67,21 @@
             </a-select-option>
           </a-select>
         </template>
+        <!-- 设备类型 -->
+        <template slot="deviceType" slot-scope="text, record">
+          {{ text == 'BOX' ? '回收箱体' : '电子秤' }}
+        </template>
         <!-- 工作状态 -->
         <template slot="workStatus" slot-scope="record">
           <a-switch
             checkedChildren="启用"
             unCheckedChildren="禁用"
             id="equipment-changeFlagHandle"
-			v-if="record.state"
+            v-if="record.state"
             v-model="record.state == 1 ? true : false"
             @change="changeFlagHandle(record)"
           />
-		  <span v-else>--</span>
+          <span v-else>--</span>
         </template>
         <!-- 操作 -->
         <template slot="action" slot-scope="record">
@@ -126,7 +129,7 @@ export default {
         { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
         { title: '设备编号', dataIndex: 'srcDeviceCode', width: 100, align: 'center' },
         { title: '设备状态', scopedSlots: { customRender: 'onlineFlag' }, width: 150, align: 'center' },
-		{ title: '设备类型', dataIndex:'', width: 150, align: 'center' },
+        { title: '设备类型', dataIndex: 'deviceType', scopedSlots: { customRender: 'deviceType' }, 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' }
@@ -141,12 +144,11 @@ export default {
     getDevice () {
       deviceListQuery({ stationNo: this.networkNo }).then(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)
+            item.no = index + 1
+            //  处理每个设备所对应的箱体类型
+            item.deviceTypeList = this.typeList.filter(tk => !item.boxNum || tk.boxNum == item.boxNum)
           })
         } else {
           this.equipmentData = []
@@ -165,17 +167,6 @@ export default {
         this.getDevice()
       })
     },
-    //  处理每个设备所对应的箱体类型
-    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) {