瀏覽代碼

feat(device): replace support product

Casper Dai 2 年之前
父節點
當前提交
37efecb953
共有 1 個文件被更改,包括 26 次插入7 次删除
  1. 26 7
      src/views/external/box/components/Device.vue

+ 26 - 7
src/views/external/box/components/Device.vue

@@ -42,7 +42,7 @@
           <span class="c-grid-form__label u-required">MAC</span>
           <el-input
             v-model.trim="currObj.mac"
-            class="u-width--sm"
+            class="u-width"
             placeholder="ff:ff:ff:ff:ff:ff"
             maxlength="17"
             clearable
@@ -97,11 +97,18 @@
           <span class="c-grid-form__label u-required">MAC</span>
           <el-input
             v-model.trim="currObj.mac"
-            class="u-width--sm"
+            class="u-width"
             placeholder="ff:ff:ff:ff:ff:ff"
             maxlength="17"
             clearable
           />
+          <span class="c-grid-form__label">配置</span>
+          <schema-select
+            ref="productSelect"
+            v-model="currObj.productId"
+            class="u-width"
+            :schema="replaceProductSelectSchema"
+          />
         </div>
       </template>
     </confirm-dialog>
@@ -151,8 +158,11 @@ export default {
     return {
       currObj: {},
       isSub: false,
-      ratio: null,
       productSelectSchema,
+      replaceProductSelectSchema: {
+        ...productSelectSchema,
+        placeholder: '不选择时使用原配置'
+      },
       schema: {
         keepalive: true,
         props: {
@@ -525,12 +535,13 @@ export default {
       this.$device = device
       this.currObj = {
         serialNumber: '',
-        mac: ''
+        mac: '',
+        productId: ''
       }
       this.$refs.replaceDialog.show()
     },
     onConfirmReplace (done) {
-      const { serialNumber, mac } = this.currObj
+      const { serialNumber, mac, productId } = this.currObj
       if (!serialNumber) {
         this.$message({
           type: 'warning',
@@ -554,12 +565,20 @@ export default {
       }
       const realMac = mac.toLowerCase()
       if (serialNumber === this.$device.serialNumber && realMac === this.$device.mac) {
-        done()
+        this.$message({
+          type: 'warning',
+          message: '序列号与MAC不能均与原数据一致'
+        })
         return
       }
-      replaceDevice(this.$device.id, { serialNumber, mac: realMac }).then(() => {
+      const productName = productId ? this.$refs.productSelect.getOptions().find(({ value }) => value === productId).label : ''
+      replaceDevice(this.$device.id, { serialNumber, mac: realMac, productId }).then(() => {
         this.$device.serialNumber = serialNumber
         this.$device.mac = realMac
+        if (productId) {
+          this.$device.productId = productId
+          this.$device.productName = productName
+        }
         this.$device = null
         done()
       })