Преглед изворни кода

设备正在使用中,点击网点管理的编辑和删除,提示“设备正在使用中,暂不能操作”

chenrui пре 4 година
родитељ
комит
a6b39ee288
2 измењених фајлова са 33 додато и 11 уклоњено
  1. 8 0
      src/api/car-wash.js
  2. 25 11
      src/views/CarWashManagement/CarWashManagement.vue

+ 8 - 0
src/api/car-wash.js

@@ -90,3 +90,11 @@ export const storeUpdateStatus = params => {
     method: 'get'
   })
 }
+// 检测设备状态
+export const deviceValidStatus = params => {
+  const url = `device/validStatus/${params.deviceNo}`
+  return axios.request({
+    url: url,
+    method: 'get'
+  })
+}

+ 25 - 11
src/views/CarWashManagement/CarWashManagement.vue

@@ -56,7 +56,7 @@
       </template>
       <!-- 设备状态 -->
       <template slot="deviceStatus" slot-scope="text, record">
-        {{ record.deviceStatus ? $refs.deviceStatus.getNameByCode(record.deviceStatus) : '-' }}
+        {{ record.deviceStatus ? $refs.deviceStatus.getNameByCode(record.deviceStatus.split(',')[0]) : '-' }}
       </template>
       <!-- 营业状态 -->
       <template slot="businessStatus" slot-scope="text, record">
@@ -67,7 +67,7 @@
         <a-tooltip placement="left" overlayClassName="btn-cont">
           <template slot="title">
             <div class="btn-set-cont">
-              <p class="set-sub-btn normal" @click="setStoreUpdateStatus(record, 'OPEN')" v-if="record.deviceStatus != 'PAUSE' && record.businessStatus != 'OPEN'">
+              <p class="set-sub-btn normal" @click="setStoreUpdateStatus(record, 'OPEN')" v-if="record.deviceStatus.split(',')[0] != 'PAUSE' && record.businessStatus != 'OPEN'">
                 <a-icon type="check-circle" class="icon" />
                 正常营业
               </p>
@@ -78,19 +78,19 @@
               <p
                 class="set-sub-btn soon"
                 @click="setStoreUpdateStatus(record, 'TO_BE_OPENED')"
-                v-if="record.deviceStatus != 'PAUSE' && record.businessStatus != 'TO_BE_OPENED'"
+                v-if="record.deviceStatus.split(',')[0] != 'PAUSE' && record.businessStatus != 'TO_BE_OPENED'"
               >
                 <a-icon type="play-circle" class="icon" />
                 即将开业
               </p>
             </div>
           </template>
-          <a-icon type="setting" title="设置" v-if="record.deviceStatus != 'PAUSE'" :style="{ fontSize: '20px', color: '#19be6b', padding: '0 10px' }" />
+          <a-icon type="setting" title="设置" v-if="record.deviceStatus.split(',')[0] != 'PAUSE'" :style="{ fontSize: '20px', color: '#19be6b', padding: '0 10px' }" />
         </a-tooltip>
-        <a-icon type="setting" title="设置" v-if="record.deviceStatus == 'PAUSE'" @click="tooltipSet" :style="{ fontSize: '20px', color: '#19be6b', padding: '0 10px' }" />
+        <a-icon type="setting" title="设置" v-if="record.deviceStatus.split(',')[0] == 'PAUSE'" @click="tooltipSet" :style="{ fontSize: '20px', color: '#19be6b', padding: '0 10px' }" />
         <a-icon type="edit" title="编辑" @click="modalHandle('edit', record)" :style="{ fontSize: '20px', color: '#1890FF', padding: '0 10px' }" />
         <a-icon type="eye" title="查看详情" @click="modalHandle('details', record)" :style="{ fontSize: '20px', color: '#e29e14', padding: '0 10px' }" />
-        <a-icon type="delete" title="删除" @click="del(record)" :style="{ fontSize: '20px', color: 'red', padding: '0 10px' }" />
+        <a-icon type="delete" title="删除" @click="deviceValidStatus('del', record)" :style="{ fontSize: '20px', color: 'red', padding: '0 10px' }" />
         <a-icon type="qrcode" title="查看小程序码" @click="getQrCode(record)" :style="{ fontSize: '20px', color: '#e29e14', padding: '0 10px' }" />
       </template>
     </s-table>
@@ -119,7 +119,7 @@ import { STable, VSelect } from '@/components'
 import AddCarWashModal from './AddCarWashModal.vue'
 import DetailsCarWashModal from './DetailsCarWashModal.vue'
 import { getProvince, getCityByPro } from '@/api/lookup'
-import { storeQuery, storeDel, storeQrCode, storeUpdateStatus } from '@/api/car-wash'
+import { storeQuery, storeDel, storeQrCode, storeUpdateStatus, deviceValidStatus } from '@/api/car-wash'
 export default {
   name: 'CarWashManagement',
   components: { STable, VSelect, AddCarWashModal, DetailsCarWashModal },
@@ -174,15 +174,29 @@ export default {
         this.openModal = true
         this.openDetailsModal = false
       } else if (type === 'edit') {
-        this.carWashId = String(item.id)
-        this.openModal = true
-        this.openDetailsModal = false
+        this.deviceValidStatus('edit', item)
       } else if (type === 'details') {
         this.carWashId = String(item.id)
         this.openDetailsModal = true
         this.openModal = false
       }
     },
+    // 检测设备状态
+    deviceValidStatus (type, item) {
+      deviceValidStatus({ deviceNo: item.deviceNos.split(',')[0] }).then(res => {
+        if (res.status == 200) {
+          if (type === 'edit') {
+            this.carWashId = String(item.id)
+            this.openModal = true
+            this.openDetailsModal = false
+          } else if (type === 'del') {
+            this.del(item)
+          }
+        } else {
+          this.$message.error(res.message)
+        }
+      })
+    },
     // 新增编辑  提交成功
     carWashSubmit () {
       this.$refs.table.refresh(true)
@@ -220,7 +234,7 @@ export default {
     },
     // 查看小程序码
     getQrCode (item) {
-      storeQrCode({ id: item.id, deviceNo: item.deviceNos }).then(res => {
+      storeQrCode({ id: item.id, deviceNo: item.deviceNos.split(',')[0] }).then(res => {
         if (res.status == 200) {
           this.qrCode = 'data:image/png;base64,' + res.data
           this.isQrCodeModal = true