zs 2 年之前
父节点
当前提交
24db342a52
共有 3 个文件被更改,包括 203 次插入66 次删除
  1. 6 0
      src/router/module/system.js
  2. 40 66
      src/views/system/act/goods.vue
  3. 157 0
      src/views/system/act/goodsDetail.vue

+ 6 - 0
src/router/module/system.js

@@ -119,6 +119,12 @@ export default [
     meta: { title: '平台管理-平台活动商品' },
     meta: { title: '平台管理-平台活动商品' },
     component: () => import(/* webpackChunkName: "system_act_goods" */ '@/views/system/act/goods.vue'),
     component: () => import(/* webpackChunkName: "system_act_goods" */ '@/views/system/act/goods.vue'),
   },
   },
+  {
+    path: '/system/act/goodsDetail',
+    name: 'system_act_goodsDetail',
+    meta: { title: '平台管理-平台活动商品添加' },
+    component: () => import(/* webpackChunkName: "system_act_goodsDetail" */ '@/views/system/act/goodsDetail.vue'),
+  },
   {
   {
     path: '/system/bill',
     path: '/system/bill',
     name: 'system_bill',
     name: 'system_bill',

+ 40 - 66
src/views/system/act/goods.vue

@@ -2,16 +2,25 @@
   <div id="index">
   <div id="index">
     <el-row>
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight">
       <el-col :span="24" class="main animate__animated animate__backInRight">
-        <el-col :span="24" class="one"> <span>平台商品</span> </el-col>
+        <el-col :span="24" class="one"> <span>活动标题</span> </el-col>
         <el-col :span="24" class="two">
         <el-col :span="24" class="two">
-          <el-autocomplete v-model="goods" :fetch-suggestions="querySearchAsync" placeholder="请输入商品名称"
-                           @select="handleSelect"></el-autocomplete>
+          <!-- <search-1 :form="searchForm" @onSubmit="search" @toReset="toClose"></search-1> -->
         </el-col>
         </el-col>
         <el-col :span="24" class="thr">
         <el-col :span="24" class="thr">
           <el-button type="primary" size="mini" @click="toAdd()">新增</el-button>
           <el-button type="primary" size="mini" @click="toAdd()">新增</el-button>
         </el-col>
         </el-col>
         <el-col :span="24" class="four">
         <el-col :span="24" class="four">
-          <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @add="toAdd">
+          <data-table
+            :select="true"
+            :selected="selected"
+            @handleSelect="handleSelect"
+            :fields="fields"
+            :opera="opera"
+            @query="search"
+            :data="list"
+            :total="total"
+            @del="toDel"
+          >
           </data-table>
           </data-table>
         </el-col>
         </el-col>
       </el-col>
       </el-col>
@@ -24,103 +33,68 @@ const _ = require('lodash');
 import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
 import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
 const { mapActions } = createNamespacedHelpers('goodsJoinAct');
 const { mapActions } = createNamespacedHelpers('goodsJoinAct');
 const { mapActions: dictData } = createNamespacedHelpers('dictData');
 const { mapActions: dictData } = createNamespacedHelpers('dictData');
-const { mapActions: goods } = createNamespacedHelpers('goods');
 export default {
 export default {
   name: 'index',
   name: 'index',
   props: {},
   props: {},
-  components: {},
+  components: {
+    // search1: () => import('./parts/search-1.vue'),
+  },
   data: function () {
   data: function () {
     const that = this;
     const that = this;
     return {
     return {
       // 列表
       // 列表
-      opera: [{ label: '添加', method: 'add' }],
+      opera: [{ label: '删除', method: 'del', confirm: true, type: 'danger' }],
       fields: [
       fields: [
         { label: '活动标题', model: 'title' },
         { label: '活动标题', model: 'title' },
         { label: '活动时间', model: 'act_time.value' },
         { label: '活动时间', model: 'act_time.value' },
-        {
-          label: '是否开启',
-          model: 'is_use',
-          format: (i) => {
-            let data = that.isuseList.find((f) => f.value == i);
-            if (data) return data.label;
-            else return '暂无';
-          },
-        },
-        {
-          label: '是否在首页显示',
-          model: 'show_index',
-          format: (i) => {
-            let data = that.isuseList.find((f) => f.value == i);
-            if (data) return data.label;
-            else return '暂无';
-          },
-        },
       ],
       ],
       list: [],
       list: [],
       total: 0,
       total: 0,
-      // 商品搜索
-      goods: '',
-      goodsList: [],
-      // 是否开启
-      isuseList: [],
+      // 查询
+      searchForm: {},
+      // 多选值
+      selected: [],
     };
     };
   },
   },
   async created() {
   async created() {
-    await this.searchOther();
     await this.search();
     await this.search();
   },
   },
   methods: {
   methods: {
     ...dictData({ dictQuery: 'query' }),
     ...dictData({ dictQuery: 'query' }),
-    ...goods({ gQuery: 'query' }),
     ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
     ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
     // 查询
     // 查询
     async search({ skip = 0, limit = 10, ...info } = {}) {
     async search({ skip = 0, limit = 10, ...info } = {}) {
       const condition = _.cloneDeep(this.searchForm);
       const condition = _.cloneDeep(this.searchForm);
-      let res = await this.gQuery({ skip, limit, ...condition, ...info });
+      let res = await this.query({ skip, limit, ...condition, ...info });
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
-        this.$set(this, 'goodsList', res.data);
-        // this.$set(this, 'total', res.total);
+        this.$set(this, 'list', res.data);
+        this.$set(this, 'total', res.total);
       }
       }
     },
     },
-    // 点击选中
-    handleSelect(item) {
-      console.log(item);
-    },
-    querySearchAsync(queryString, cb) {
-      console.log(queryString);
-      console.log(cb);
-      // var restaurants = this.restaurants;
-      // var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
-
-      // clearTimeout(this.timeout);
-      // this.timeout = setTimeout(() => {
-      //   cb(results);
-      // }, 3000 * Math.random());
-    },
     // 新增
     // 新增
-    toAdd({ data }) {
-      console.log(data);
+    toAdd() {
+      this.$router.push({ path: '/system/act/goosDetail' });
     },
     },
-    // 重置
-    toClose() {
-      this.goods = '';
-      this.search();
-    },
-    // 查询其他信息
-    async searchOther() {
-      let res;
-      // 是否使用
-      res = await this.dictQuery({ code: 'use' });
+    // 删除
+    async toDel({ data }) {
+      let res = await this.delete(data._id);
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
-        this.$set(this, `isuseList`, res.data);
+        this.$message({ type: `success`, message: `刪除信息成功` });
+        this.search();
       }
       }
     },
     },
+    // // 重置
+    // toClose() {
+    //   this.searchForm = {};
+    //   this.search();
+    // },
+    // 多选
+    handleSelect(data) {
+      this.$set(this, `selected`, data);
+    },
   },
   },
   computed: {
   computed: {
     ...mapState(['user']),
     ...mapState(['user']),
-    id() {
-      return this.$route.query.id;
-    },
   },
   },
   metaInfo() {
   metaInfo() {
     return { title: this.$route.meta.title };
     return { title: this.$route.meta.title };

+ 157 - 0
src/views/system/act/goodsDetail.vue

@@ -0,0 +1,157 @@
+<template>
+  <div id="index">
+    <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="24" class="two">
+          <el-autocomplete v-model="goods" :fetch-suggestions="querySearchAsync" placeholder="请输入商品名称" @select="handleSelect"></el-autocomplete>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
+        </el-col>
+        <el-col :span="24" class="four">
+          <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @add="toAdd"> </data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('goodsJoinAct');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+const { mapActions: goods } = createNamespacedHelpers('goods');
+export default {
+  name: 'index',
+  props: {},
+  components: {},
+  data: function () {
+    const that = this;
+    return {
+      // 列表
+      opera: [{ label: '添加', method: 'add' }],
+      fields: [
+        { label: '商品名称', model: 'name' },
+        { label: '店铺名称', model: 'shop.name' },
+        { label: '浏览量', model: 'view_num' },
+        {
+          label: '商品状态',
+          model: 'status',
+          format: (i) => {
+            let data = that.statusList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      list: [],
+      total: 0,
+      // 商品搜索
+      goods: '',
+      goodsList: [],
+      timeout: null,
+      // 商品状态
+      statusList: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...dictData({ dictQuery: 'query' }),
+    ...goods({ gQuery: 'query' }),
+    ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
+    // 查询
+    async search() {
+      let res = await this.gQuery();
+      if (this.$checkRes(res)) {
+        for (const val of res.data) {
+          val.value = val.name;
+        }
+        this.$set(this, 'goodsList', res.data);
+      }
+    },
+    // 点击选中
+    handleSelect(item) {
+      this.list.push(item);
+      this.$set(this, 'total', 1);
+    },
+    //获取搜索商品信息
+    querySearchAsync(queryString, cb) {
+      var goodsList = this.goodsList;
+      var results = queryString ? goodsList.filter(this.createStateFilter(queryString)) : goodsList;
+      clearTimeout(this.timeout);
+      this.timeout = setTimeout(() => {
+        cb(results);
+      }, 3000 * Math.random());
+    },
+    createStateFilter(queryString) {
+      return (state) => {
+        return state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
+      };
+    },
+    // 新增
+    async toAdd({ data }) {
+      let form = { platformAct: this.id, shop: data.shop._id, goods: data._id };
+      let res = await this.create(form);
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `添加商品成功` });
+        this.toBack();
+      }
+    },
+    // 返回
+    toBack() {
+      window.history.go('-1');
+    },
+    // 查询其他信息
+    async searchOther() {
+      let res;
+      // 商品状态
+      res = await this.dictQuery({ code: 'goods_status' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `statusList`, res.data);
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) { },
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .one {
+    margin: 0 0 10px 0;
+
+    span:nth-child(1) {
+      font-size: 20px;
+      font-weight: 700;
+      margin-right: 10px;
+    }
+  }
+  .two {
+    margin: 0 0 10px 0;
+  }
+  .thr {
+    margin: 0 0 10px 0;
+    text-align: right;
+  }
+}
+</style>