Kaynağa Gözat

添加活动标签

YY 2 yıl önce
ebeveyn
işleme
595fc8e4b1
1 değiştirilmiş dosya ile 38 ekleme ve 4 silme
  1. 38 4
      src/views/selfShop/goods/index.vue

+ 38 - 4
src/views/selfShop/goods/index.vue

@@ -30,6 +30,16 @@
             <template #tags="{ item }">
               <el-cascader v-model="form[item.model]" :options="tagsList" :props="props" clearable filterable :show-all-levels="false"></el-cascader>
             </template>
+            <template #act_tags="{ item }">
+              <el-cascader
+                v-model="form[item.model]"
+                :options="act_tagsList"
+                :props="act_tagsProps"
+                clearable
+                filterable
+                :show-all-levels="false"
+              ></el-cascader>
+            </template>
             <template #status>
               <el-option v-for="i in goodsStatusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
             </template>
@@ -58,7 +68,8 @@ export default {
       fields: [
         { label: '商品名称', model: 'name' },
         { label: '店铺名称', model: 'shop.name' },
-        { label: '商品标签', model: 'tags', format: (i) => this.getTags(i) },
+        { label: '商品分类', model: 'tags', format: (i) => this.getTags(i) },
+        { label: '活动标签', model: 'act_tags', format: (i) => this.getAct_tags(i) },
         { label: '商品状态', model: 'status', format: (i) => this.getStatus(i) },
       ],
       opera: [
@@ -78,7 +89,8 @@ export default {
       // info部分
       infoFields: [
         { label: '商品名称', model: 'name' },
-        { label: '商品标签', model: 'tags', custom: true },
+        { label: '商品分类', model: 'tags', custom: true },
+        { label: '活动标签', model: 'act_tags', custom: true },
         { label: '简短简介', model: 'shot_brief', maxLength: 50 },
         { label: '预计发货时间', model: 'send_time' },
         { label: '商品图片', model: 'file', type: 'upload', url: '/files/point/goods/upload' },
@@ -87,10 +99,14 @@ export default {
       ],
       rules: {},
       form: {},
-
+      // 商品分类
       tagsList: [],
-      goodsStatusList: [],
       props: { multiple: true, label: 'label', value: 'code' },
+      // 活动标签
+      act_tagsList: [],
+      act_tagsProps: { multiple: true, label: 'label', value: 'value' },
+
+      goodsStatusList: [],
 
       shop: {},
     };
@@ -128,6 +144,8 @@ export default {
       if (this.$checkRes(res)) this.$set(this, `goodsStatusList`, res.data);
       res = await this.getInfo();
       if (this.$checkRes(res)) this.$set(this, `shop`, res.data);
+      res = await this.getDict({ code: 'act_tags' });
+      if (this.$checkRes(res)) this.$set(this, `act_tagsList`, res.data);
     },
     getStatus(data) {
       const res = this.goodsStatusList.find((f) => f.value === data);
@@ -150,6 +168,22 @@ export default {
       }
       return arr.join(';');
     },
+    getAct_tags(data) {
+      let list = this.act_tagsList;
+      const getChildren = (list) =>
+        list.map((i) => {
+          if (i.children) return getChildren(i.children);
+          return i;
+        });
+      list = _.flattenDeep(getChildren(list));
+      const arr = [];
+      for (const ts of data) {
+        const last = _.last(ts);
+        const r = list.find((f) => f.value === last);
+        if (r) arr.push(r.label);
+      }
+      return arr.join(';');
+    },
     toSpec({ data }) {
       this.$router.push({ path: `/selfShop/spec/${data._id}` });
     },