فهرست منبع

feat: 加入三级联动数据变更

Damon 11 ماه پیش
والد
کامیت
da6c56bbac
2فایلهای تغییر یافته به همراه85 افزوده شده و 45 حذف شده
  1. 81 41
      src/views/operation/activity/detail.vue
  2. 4 4
      src/views/operation/activity/index.vue

+ 81 - 41
src/views/operation/activity/detail.vue

@@ -84,13 +84,32 @@
             </template>
           </el-table-column>
 
-          {{ this.form }}
-          <el-table-column label="活动权益" align="center">
+          <el-table-column
+            v-if="form.platformName === platformNames[1]"
+            label="活动权益"
+            align="center"
+          >
             <template slot-scope="scope">
-              <el-form-item
-                :prop="`deviceRespList.${scope.$index}.goodId`"
-                :rules="{ required: true, trigger: 'change' }"
-              >
+              <el-form-item>
+                <el-select
+                  v-model="scope.row.goodId"
+                  placeholder="请选择活动权益"
+                  :disabled="scope.row.deviceId == null || disabledActivity"
+                >
+                  <el-option
+                    v-for="item in aaaa[scope.row.deviceId]"
+                    :key="item.goodId"
+                    :value="item.goodId"
+                    :label="item.goodName"
+                  />
+                </el-select>
+              </el-form-item>
+            </template>
+          </el-table-column>
+
+          <el-table-column v-else label="活动权益" align="center">
+            <template slot-scope="scope">
+              <el-form-item>
                 <el-select
                   v-model="scope.row.goodId"
                   placeholder="请选择活动权益"
@@ -98,14 +117,15 @@
                 >
                   <el-option
                     v-for="item in serviceTimeOptions"
-                    :key="item.value"
-                    :value="item.value"
-                    :label="item.label"
+                    :key="item.goodId"
+                    :value="item.goodId"
+                    :label="item.goodName"
                   />
                 </el-select>
               </el-form-item>
             </template>
           </el-table-column>
+
           <el-table-column label="领取数量" align="center">
             <template slot-scope="scope">
               <el-form-item
@@ -159,14 +179,16 @@ import { detail, goodList, submit } from "@/api/operation/activity";
 import { devMixin, serviceTimeMixin } from "@/mixin/index";
 export default {
   mixins: [serviceTimeMixin, devMixin],
+
   data() {
     return {
-      ///赠送流量权益列表
-      deviceEquities: [],
+      aaaa: {},
       // 表单
+      deviceRespListTemp: [],
       form: {
         deviceRespList: [],
       },
+
       platformNames: ["会员赠送", "流量赠送"],
       // 除蓝牙设备
       types: [2, 4],
@@ -203,45 +225,59 @@ export default {
       },
     };
   },
+
   watch: {
     "form.deviceRespList": {
       handler(val) {
-        for (let i in this.devOptions) {
-          this.devOptions[i].disabled = false;
-        }
-        // 禁用已关联设备
-        val.map((i, index) => {
-          if (i.deviceId) {
-            let index = this.devOptions.findIndex(
-              (j) => j.value === i.deviceId
-            );
-            this.devOptions[index].disabled = true;
+        if (this.form.platformName == this.platformNames[1]) {
+          if (this.deviceRespListTemp.length == val.length) {
+            for (var i = 0; i < val.length; i++) {
+              var deviceId = val[i].deviceId;
+              if (this.deviceRespListTemp[i].deviceId != val[i].deviceId) {
+                let a = this.aaaa[`${deviceId}`];
+                if (a == null || a.length == 0) {
+                  this.getGoodList(deviceId);
+                }
+                break;
+              }
+            }
           }
-        });
-      },
-      deep: true,
-    },
+        }
+        this.deviceRespListTemp = JSON.parse(JSON.stringify(val));
 
-    "form.platformName": {
-      handler(val) {
-        console.log("gasdfasdfasdfaf==00==" + this.form.platformName);
+        // for (let i in this.devOptions) {
+        //   this.devOptions[i].disabled = false;
+        // }
+        // // 禁用已关联设备
+        // val.map((i, index) => {
+        //   if (i.deviceId) {
+        //     let index = this.devOptions.findIndex(
+        //       (j) => j.value === i.deviceId
+        //     );
+        //     this.devOptions[index].disabled = true;
+        //   }
+        // });
       },
       deep: true,
     },
 
     "form.platformName": {
       handler(val) {
-        console.log("gasdfasdfasdfaf==00==" + this.form.platformName);
+        for (let i in this.form.deviceRespList) {
+          if (this.form.deviceRespList[i].goodId != null) {
+            this.form.deviceRespList[i].goodId = null;
+          }
+        }
       },
       deep: true,
     },
 
-    "form.platformName": {
-      handler(val) {
-        console.log("gasdfasdfasdfaf==00==" + this.form.platformName);
-      },
-      deep: true,
-    },
+    // "form.platformName": {
+    //   handler(val) {
+    //     console.log("gasdfasdfasdfaf==22==" + this.form.platformName);
+    //   },
+    //   deep: true,
+    // },
   },
   mounted() {
     this.getDevList();
@@ -252,15 +288,19 @@ export default {
 
   methods: {
     // 超级详情
-    getGoodList() {
-      this.deviceEquities = [];
-      var param = {
-        deviceId: this.$route.query.id,
-        platformId: 1,
+    getGoodList(deviceId) {
+      let platformId = 1;
+      let param = {
+        deviceId: deviceId,
+        platformId: platformId,
       };
+
       goodList(param).then((res) => {
         if (res.code === 0) {
-          this.deviceEquities = res.data;
+          this.aaaa[`${deviceId}`] = res.data;
+          console.log(
+            "gasdfasdfasdfaf==啊啊啊啊=11=" + JSON.stringify(this.aaaa)
+          );
           ///goodId  goodName
         }
       });

+ 4 - 4
src/views/operation/activity/index.vue

@@ -208,10 +208,10 @@
 
 <script>
 import {
-  allNoDeleteList,
-  change,
-  doExchange,
-  list,
+allNoDeleteList,
+change,
+doExchange,
+list,
 } from "@/api/operation/activity";
 import { currentMixin, devMixin, disabledMixin } from "@/mixin/index";
 export default {