Browse Source

评价+添加商品返现设置

YY 2 years ago
parent
commit
52c3d13239
3 changed files with 114 additions and 43 deletions
  1. 1 0
      src/views/index.vue
  2. 93 43
      src/views/selfShop/goods/index.vue
  3. 20 0
      src/views/selfShop/goodsRate/detail.vue

+ 1 - 0
src/views/index.vue

@@ -108,6 +108,7 @@ export default {
   methods: {
     ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
+      // info.shop = this.user.shop.id;
       let res = await this.query({ skip, limit, ...info });
       if (this.$checkRes(res)) {
         this.$set(this, 'data', res.data);

+ 93 - 43
src/views/selfShop/goods/index.vue

@@ -50,6 +50,30 @@
             <template #status>
               <el-option v-for="i in goodsStatusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
             </template>
+            <template #is_cashBack>
+              <el-option v-for="i in statusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #cb_config>
+              <el-form :model="cb_config" ref="cb_config" label-width="180px" @save="toSave">
+                <el-col :span="24">
+                  <el-form-item label="返现金额类型" prop="back_type">
+                    <el-select v-model="cb_config.back_type" clearable filterable placeholder="请选择返现金额类型" size="small" style="width: 100%">
+                      <el-option v-for="i in typeList" :key="i.label" :label="i.label" :value="i.label"> </el-option>
+                    </el-select>
+                  </el-form-item>
+                </el-col>
+                <el-col :span="24" v-if="cb_config.back_type == '固定金额'">
+                  <el-form-item label="具体返现金额设置" prop="money">
+                    <el-input v-model="cb_config.money" placeholder="请输入金额" type="number" size="small"></el-input>
+                  </el-form-item>
+                </el-col>
+                <el-col :span="24" v-if="cb_config.back_type == '百分比'">
+                  <el-form-item label="具体返现金额设置" prop="money">
+                    <el-input v-model="cb_config.money" placeholder="请输入百分比" type="number" size="small"></el-input>
+                  </el-form-item>
+                </el-col>
+              </el-form>
+            </template>
             <template #brief>
               <editor v-model="form.brief" url="/files/point/goods/upload" />
             </template>
@@ -114,11 +138,15 @@ export default {
         { label: '商品来源', model: 'source' },
         { label: '网址', model: 'url' },
         { label: '排序', model: 'sort', type: 'number' },
+        { label: '是否返现', model: 'is_cashBack', type: 'select' },
+        { label: '返现设置', model: 'cb_config', custom: true },
         { label: '商品图片', model: 'file', type: 'upload', url: '/files/point/goods/upload' },
         { label: '商品介绍', model: 'brief', custom: true },
       ],
       rules: {},
       form: {},
+      // 返现设置
+      cb_config: {},
       // 商品分类
       tagsList: [],
       props: { multiple: true, label: 'label', value: 'code' },
@@ -126,6 +154,10 @@ export default {
       // 活动标签
       act_tagsList: [],
       goodsStatusList: [],
+      // 是否返现
+      statusList: [],
+      // 返现金额类型
+      typeList: [{ label: '固定金额' }, { label: '百分比' }],
     };
   },
   created() {
@@ -148,6 +180,17 @@ export default {
         this.$set(this, `total`, res.total);
       }
     },
+    // 去编辑
+    async toEdit({ data }) {
+      const res = await this.fetch(data._id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `form`, res.data);
+        this.cb_config = res.data.cb_config;
+        this.view = 'info';
+      } else {
+        this.$message.error('未找到指定数据');
+      }
+    },
     // 添加自定义
     initAddData() {
       const obj = {
@@ -177,6 +220,53 @@ export default {
         }
       });
     },
+    // 保存
+    async toSave({ data }) {
+      let res;
+      if (data == '' || data == undefined) {
+        let form = this.form;
+        form.cb_config = this.cb_config;
+        form.cb_config.money = Number(form.cb_config.money);
+        if (form.id) res = await this.update(form);
+        else res = await this.create(form);
+      } else {
+        data.cb_config = this.cb_config;
+        data.cb_config.money = Number(data.cb_config.money);
+        if (data.id) res = await this.update(data);
+        else res = await this.create(data);
+      }
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `维护信息成功` });
+        this.toBack();
+        this.search();
+      }
+    },
+    // 执行返回
+    toBack() {
+      this.form = {};
+      this.view = 'list';
+    },
+    // 上架
+    async toPuton({ data }) {
+      this.$confirm('是否确认上架/下架该商品?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      }).then(async () => {
+        if (data.status == '1') data.status = '0';
+        else data.status = '1';
+        let res;
+        if (data._id) res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({ type: `success`, message: `修改成功` });
+        }
+        this.search();
+      });
+    },
+    // 库存管理
+    toSpec({ data }) {
+      this.$router.push({ path: `/selfShop/spec/${data._id}` });
+    },
     // 查询其他信息
     async searchOthers() {
       // 商品分类
@@ -188,6 +278,9 @@ export default {
       // 活动标签
       res = await this.actQuery();
       if (this.$checkRes(res)) this.$set(this, `act_tagsList`, res.data);
+      // 商品状态
+      res = await this.getDict({ code: 'use' });
+      if (this.$checkRes(res)) this.$set(this, `statusList`, res.data);
     },
     // 商品状态
     getStatus(data) {
@@ -221,49 +314,6 @@ export default {
       }
       return arr.join(';');
     },
-    // 保存
-    async toSave({ data }) {
-      let res;
-      if (data == '' || data == undefined) {
-        let form = this.form;
-        if (form.id) res = await this.update(form);
-        else res = await this.create(form);
-      } else {
-        if (data.id) res = await this.update(data);
-        else res = await this.create(data);
-      }
-      if (this.$checkRes(res)) {
-        this.$message({ type: `success`, message: `维护信息成功` });
-        this.toBack();
-        this.search();
-      }
-    },
-    // 执行返回
-    toBack() {
-      this.form = {};
-      this.view = 'list';
-    },
-    // 上架
-    async toPuton({ data }) {
-      this.$confirm('是否确认上架/下架该商品?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-      }).then(async () => {
-        if (data.status == '1') data.status = '0';
-        else data.status = '1';
-        let res;
-        if (data._id) res = await this.update(data);
-        if (this.$checkRes(res)) {
-          this.$message({ type: `success`, message: `修改成功` });
-        }
-        this.search();
-      });
-    },
-    // 库存管理
-    toSpec({ data }) {
-      this.$router.push({ path: `/selfShop/spec/${data._id}` });
-    },
   },
   computed: {
     ...mapState(['user']),

+ 20 - 0
src/views/selfShop/goodsRate/detail.vue

@@ -38,6 +38,7 @@
                   <el-col v-for="(file, index) in replys.file" :key="index" :span="3">
                     <el-image :src="file.url" class="image" :preview-src-list="replys.url"></el-image>
                   </el-col>
+                  <el-button class="btn" type="primary" size="mini" @click="toDel(replys, item, index)">删除</el-button>
                   <el-col :span="22" class="rates" style="word-break: break-all">商家回复:{{ replys.reply }}</el-col>
                   <el-col style="color: #999">{{ replys.time }}</el-col>
                   <el-col :span="12">
@@ -128,6 +129,25 @@ export default {
       }
       this.search();
     },
+    async toDel(item, data, index) {
+      this.$confirm('是否确认删除该条评价?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      }).then(async () => {
+        let list = data.reply;
+        if (index == '0') {
+          list = [];
+        } else {
+          list.splice(index, 1);
+        }
+        if (data.id) res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({ type: `success`, message: `删除成功` });
+        }
+        this.search();
+      });
+    },
     // 返回
     toBack() {
       window.history.go('-1');