فهرست منبع

修改方法+商品添加按分类查询

YY 2 سال پیش
والد
کامیت
8d93f506af

+ 3 - 0
src/components/usual/c-search.vue

@@ -9,6 +9,9 @@
                 <slot :name="i.model"></slot>
               </el-select>
             </template>
+            <template v-else-if="i.custom">
+              <slot :name="i.model" v-bind="{ item: i }"></slot>
+            </template>
             <template v-else>
               <el-input v-model="form[i.model]" :placeholder="`输入${i.label}`"></el-input>
             </template>

+ 4 - 2
src/views/account/account/index.vue

@@ -3,8 +3,10 @@
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight">
         <el-col :span="24" class="one"> <span>修改密码</span> </el-col>
-        <el-col :span="12"> <data-form :span="24" :fields="fields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave"> </data-form> </el-col
-      ></el-col>
+        <el-col :span="12">
+          <data-form :span="24" :fields="fields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave"> </data-form>
+        </el-col>
+      </el-col>
     </el-row>
   </div>
 </template>

+ 2 - 2
src/views/platSettings/config/index.vue

@@ -149,7 +149,7 @@ export default {
           data = {
             ...data,
             logo: data.config.logo,
-            buyPoint: data.config.buyPoint,
+            buyPoint: Number(data.config.buyPoint),
             pointPlan: data.config.pointPlan,
             share: data.config.share,
             autoCloseOrder: data.config.autoCloseOrder,
@@ -196,7 +196,7 @@ export default {
     // 保存
     async toSave({ data }) {
       data.bottom_menu.list = this.list;
-      let config = { logo: data.logo, buyPoint: data.buyPoint, pointPlan: data.pointPlan, share: data.share, autoCloseOrder: data.autoCloseOrder };
+      let config = { logo: data.logo, buyPoint: Number(data.buyPoint), pointPlan: data.pointPlan, share: data.share, autoCloseOrder: data.autoCloseOrder };
       data.config = config;
       const res = await this.update(data);
       this.$checkRes(res, '操作成功', '操作失败');

+ 1 - 1
src/views/platfinance/statistics/parts/card-2.vue

@@ -53,7 +53,7 @@ export default {
   methods: {
     ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
-      let res = await this.query({ skip, limit, type: info.time, start: info.start, end: info.end });
+      let res = await this.query({ skip, limit, status: '1', type: info.time, start: info.start, end: info.end });
       if (this.$checkRes(res)) {
         let list = res.data.sMarkOrder;
         let xAxisList = [];

+ 26 - 44
src/views/platmanag/goods/index.vue

@@ -1,7 +1,16 @@
 <template>
   <div id="goods">
     <template v-if="view === 'list'">
-      <search-1 :form="searchInfo" @onSubmit="search" @querySearch="querySearch" @toReset="toClose" :shopList="shopList"> </search-1>
+      <search-1
+        :form="searchInfo"
+        @onSubmit="search"
+        @querySearch="querySearch"
+        @toReset="toClose"
+        @changeTags="changeTags"
+        :shopList="shopList"
+        :tagsList="tagsList"
+      >
+      </search-1>
       <data-btn :fields="btnList" @add="toAdd"></data-btn>
       <data-table
         ref="dataTable"
@@ -13,7 +22,6 @@
         @query="search"
         @edit="toEdit"
         @puton="toPuton"
-        @lower="toLower"
         @delete="toDelete"
         @spec="toSpec"
         @copy="toCopy"
@@ -23,7 +31,7 @@
       <el-row>
         <el-col :span="24" style="margin: 0 0 10px 0">
           <el-col :span="2"><el-button type="primary" size="mini" @click="toBack()">返回</el-button></el-col>
-          <el-col :span="2"><el-button type="primary" size="mini" @click="onSubmit(form)">保存</el-button></el-col>
+          <el-col :span="2"><el-button type="primary" size="mini" @click="toSave(form)">保存</el-button></el-col>
         </el-col>
         <el-col :span="24">
           <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
@@ -88,7 +96,7 @@ export default {
       opera: [
         { label: '修改', method: 'edit' },
         { label: '上架', method: 'puton', display: (i) => i.status == '0' },
-        { label: '下架', method: 'lower', display: (i) => i.status == '1' },
+        { label: '下架', method: 'puton', display: (i) => i.status == '1' },
         { label: '库存管理', method: 'spec' },
         { label: '复制', method: 'copy' },
         { label: '删除', method: 'delete', confirm: true, type: 'danger' },
@@ -113,7 +121,6 @@ export default {
         { label: '商品图片', model: 'file', type: 'upload', url: '/files/point/goods/upload' },
         { label: '商品介绍', model: 'brief', custom: true },
       ],
-
       rules: {
         shop: [{ required: true, message: '请选择商铺名称', trigger: 'change' }],
       },
@@ -191,6 +198,10 @@ export default {
         this.$set(this, 'shopList', res.data);
       }
     },
+    changeTags(value) {
+      let tags = _.last(value);
+      this.$set(this.searchInfo, `tags`, tags);
+    },
     // 重置
     toClose() {
       this.searchInfo = {};
@@ -261,28 +272,15 @@ export default {
       return arr.join(';');
     },
     // 保存
-    async onSubmit(data) {
-      let res;
-      if (data.id) {
-        data.shop = this.user.shop.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();
-      }
-    },
-    // 保存
     async toSave({ data }) {
       let res;
-      if (data.id) {
-        data.shop = this.user.shop.id;
-        res = await this.update(data);
+      if (data == '' || data == undefined) {
+        let form = this.form;
+        if (form.id) res = await this.update(form);
+        else res = await this.create(form);
       } else {
-        res = await this.create(data);
+        if (data.id) res = await this.update(data);
+        else res = await this.create(data);
       }
       if (this.$checkRes(res)) {
         this.$message({ type: `success`, message: `维护信息成功` });
@@ -297,33 +295,17 @@ export default {
     },
     // 上架
     async toPuton({ data }) {
-      this.$confirm('是否确认上架该商品?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-      }).then(async () => {
-        data.status = '1';
-        let res;
-        if (data.id) res = await this.update(data);
-        if (this.$checkRes(res)) {
-          this.$message({ type: `success`, message: `上架成功` });
-        }
-        this.search();
-      });
-    },
-    // 下架
-    async toLower({ data }) {
-      this.$confirm('是否确认下架该商品?', '提示', {
+      this.$confirm('是否确认上架/下架该商品?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning',
       }).then(async () => {
-        data.status = '0';
+        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)) {
-          console.log(res.data);
-          this.$message({ type: `success`, message: `下架成功` });
+          this.$message({ type: `success`, message: `修改成功` });
         }
         this.search();
       });

+ 18 - 1
src/views/platmanag/goods/parts/search-1.vue

@@ -24,6 +24,19 @@
               </el-select>
             </el-form-item>
           </el-col>
+          <el-col :span="6">
+            <el-form-item label="商品分类" prop="tags">
+              <el-cascader
+                v-model="form.tags"
+                :options="tagsList"
+                :props="propss"
+                clearable
+                filterable
+                :show-all-levels="false"
+                @change="changeTags"
+              ></el-cascader>
+            </el-form-item>
+          </el-col>
           <el-col :span="24" class="btn">
             <el-button type="primary" icon="el-icon-search" size="mini" @click="onSubmit('form')">搜索</el-button>
             <el-button icon="el-icon-refresh" size="mini" @click="toReset('form')">重置</el-button>
@@ -38,11 +51,12 @@
 import { mapState, createNamespacedHelpers } from 'vuex';
 export default {
   name: 'search-1',
-  props: { form: { type: Object }, shopList: { type: Array } },
+  props: { form: { type: Object }, shopList: { type: Array }, tagsList: { type: Array } },
   components: {},
   data: function () {
     return {
       loading: false,
+      propss: { multiple: false, label: 'label', value: 'code' },
     };
   },
   created() {},
@@ -52,6 +66,9 @@ export default {
       this.$emit('querySearch', value);
       this.loading = false;
     },
+    changeTags(value) {
+      this.$emit('changeTags', value);
+    },
     handleSelect(value) {
       this.$set(this.form, `shop`, value);
     },

+ 35 - 42
src/views/selfShop/goods/index.vue

@@ -5,6 +5,17 @@
         <template #status>
           <el-option v-for="i in goodsStatusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
         </template>
+        <template #tags="{ item }">
+          <el-cascader
+            v-model="searchInfo[item.model]"
+            :options="tagsList"
+            :props="propss"
+            clearable
+            filterable
+            :show-all-levels="false"
+            @change="changeTags"
+          ></el-cascader>
+        </template>
       </data-search>
       <data-btn :fields="btnList" @add="toAdd"></data-btn>
       <data-table
@@ -17,7 +28,6 @@
         @query="search"
         @edit="toEdit"
         @puton="toPuton"
-        @lower="toLower"
         @delete="toDelete"
         @spec="toSpec"
         @copy="toCopy"
@@ -27,7 +37,7 @@
       <el-row>
         <el-col :span="24" style="margin: 0 0 10px 0">
           <el-col :span="2"><el-button type="primary" size="mini" @click="toBack()">返回</el-button></el-col>
-          <el-col :span="2"><el-button type="primary" size="mini" @click="onSubmit(form)">保存</el-button></el-col>
+          <el-col :span="2"><el-button type="primary" size="mini" @click="toSave(form)">保存</el-button></el-col>
         </el-col>
         <el-col :span="24">
           <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
@@ -61,7 +71,9 @@ const { mapActions: actTags } = createNamespacedHelpers('actTags');
 export default {
   name: 'index',
   props: {},
-  components: { editor: () => import('@/components/editor.vue') },
+  components: {
+    editor: () => import('@/components/editor.vue'),
+  },
   data: function () {
     return {
       view: 'list',
@@ -76,7 +88,7 @@ export default {
       opera: [
         { label: '修改', method: 'edit' },
         { label: '上架', method: 'puton', display: (i) => i.status == '0' },
-        { label: '下架', method: 'lower', display: (i) => i.status == '1' },
+        { label: '下架', method: 'puton', display: (i) => i.status == '1' },
         { label: '库存管理', method: 'spec' },
         { label: '复制', method: 'copy' },
         { label: '删除', method: 'delete', confirm: true, type: 'danger' },
@@ -85,6 +97,7 @@ export default {
       searchFields: [
         { label: '商品名称', model: 'name' },
         { label: '商品状态', model: 'status', type: 'select' },
+        { label: '商品分类', model: 'tags', custom: true },
       ],
       searchInfo: {},
       list: [],
@@ -104,15 +117,14 @@ export default {
         { label: '商品图片', model: 'file', type: 'upload', url: '/files/point/goods/upload' },
         { label: '商品介绍', model: 'brief', custom: true },
       ],
-
       rules: {},
       form: {},
       // 商品分类
       tagsList: [],
       props: { multiple: true, label: 'label', value: 'code' },
+      propss: { multiple: false, label: 'label', value: 'code' },
       // 活动标签
       act_tagsList: [],
-
       goodsStatusList: [],
     };
   },
@@ -144,6 +156,10 @@ export default {
       };
       this.$set(this, 'form', obj);
     },
+    changeTags(value) {
+      let tags = _.last(value);
+      this.$set(this.searchInfo, `tags`, tags);
+    },
     // 复制
     async toCopy({ data }) {
       this.$confirm('是否确认复制该商品?', '提示', {
@@ -162,10 +178,13 @@ export default {
     },
     // 查询其他信息
     async searchOthers() {
+      // 商品分类
       let res = await this.tree();
       if (this.$checkRes(res)) this.$set(this, `tagsList`, res.data);
+      // 商品状态
       res = await this.getDict({ code: 'goods_status' });
       if (this.$checkRes(res)) this.$set(this, `goodsStatusList`, res.data);
+      // 活动标签
       res = await this.actQuery();
       if (this.$checkRes(res)) this.$set(this, `act_tagsList`, res.data);
     },
@@ -202,26 +221,15 @@ export default {
       return arr.join(';');
     },
     // 保存
-    async onSubmit(data) {
-      let res;
-      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();
-      }
-    },
-    // 保存
     async toSave({ data }) {
       let res;
-      if (data.id) {
-        res = await this.update(data);
+      if (data == '' || data == undefined) {
+        let form = this.form;
+        if (form.id) res = await this.update(form);
+        else res = await this.create(form);
       } else {
-        res = await this.create(data);
+        if (data.id) res = await this.update(data);
+        else res = await this.create(data);
       }
       if (this.$checkRes(res)) {
         this.$message({ type: `success`, message: `维护信息成功` });
@@ -236,32 +244,17 @@ export default {
     },
     // 上架
     async toPuton({ data }) {
-      this.$confirm('是否确认上架该商品?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-      }).then(async () => {
-        data.status = '1';
-        let res;
-        if (data.id) res = await this.update(data);
-        if (this.$checkRes(res)) {
-          this.$message({ type: `success`, message: `上架成功` });
-        }
-        this.search();
-      });
-    },
-    // 下架
-    async toLower({ data }) {
-      this.$confirm('是否确认下架该商品?', '提示', {
+      this.$confirm('是否确认上架/下架该商品?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning',
       }).then(async () => {
-        data.status = '0';
+        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.$message({ type: `success`, message: `修改成功` });
         }
         this.search();
       });

+ 12 - 39
src/views/zr/zrGoods/index.vue

@@ -17,7 +17,6 @@
         @query="search"
         @edit="toEdit"
         @puton="toPuton"
-        @lower="toLower"
         @delete="toDelete"
       ></data-table>
     </template>
@@ -25,7 +24,7 @@
       <el-row>
         <el-col :span="24" style="margin: 0 0 10px 0">
           <el-col :span="2"><el-button type="primary" size="mini" @click="toBack()">返回</el-button></el-col>
-          <el-col :span="2"><el-button type="primary" size="mini" @click="onSubmit(form)">保存</el-button></el-col>
+          <el-col :span="2"><el-button type="primary" size="mini" @click="toSave(form)">保存</el-button></el-col>
         </el-col>
         <el-col :span="24">
           <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
@@ -65,7 +64,7 @@ export default {
       opera: [
         { label: '修改', method: 'edit' },
         { label: '上架', method: 'puton', display: (i) => i.status == '0' },
-        { label: '下架', method: 'lower', display: (i) => i.status == '1' },
+        { label: '下架', method: 'puton', display: (i) => i.status == '1' },
         { label: '删除', method: 'delete', confirm: true, type: 'danger' },
       ],
       btnList: [{ label: '添加', method: 'add' }],
@@ -139,26 +138,15 @@ export default {
       return '';
     },
     // 保存
-    async onSubmit(data) {
-      let res;
-      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();
-      }
-    },
-    // 保存
     async toSave({ data }) {
       let res;
-      if (data.id) {
-        res = await this.update(data);
+      if (data == '' || data == undefined) {
+        let form = this.form;
+        if (form.id) res = await this.update(form);
+        else res = await this.create(form);
       } else {
-        res = await this.create(data);
+        if (data.id) res = await this.update(data);
+        else res = await this.create(data);
       }
       if (this.$checkRes(res)) {
         this.$message({ type: `success`, message: `维护信息成功` });
@@ -173,32 +161,17 @@ export default {
     },
     // 上架
     async toPuton({ data }) {
-      this.$confirm('是否确认上架该商品?', '提示', {
+      this.$confirm('是否确认上架/下架该商品?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'warning',
       }).then(async () => {
-        data.status = '1';
+        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();
-      });
-    },
-    // 下架
-    async toLower({ data }) {
-      this.$confirm('是否确认下架该商品?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-      }).then(async () => {
-        data.status = '0';
-        let res;
-        if (data._id) res = await this.update(data);
-        if (this.$checkRes(res)) {
-          this.$message({ type: `success`, message: `下架成功` });
+          this.$message({ type: `success`, message: `修改成功` });
         }
         this.search();
       });