فهرست منبع

Merge branch 'master' of http://git.cc-lotus.info/pointToNetwork/web-admin

YY 2 سال پیش
والد
کامیت
30fda4a93a

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

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

+ 2 - 0
src/store/index.js

@@ -18,6 +18,7 @@ import indexModule from './module/system/indexModule';
 import actTags from './module/system/actTags';
 import config from './module/system/config';
 import platformAct from './module/system/platformAct';
+import goodsJoinAct from './module/system/goodsJoinAct';
 
 import shop from './module/shop/shop';
 import selfShop from './module/shop/selfShop';
@@ -60,6 +61,7 @@ export default new Vuex.Store({
     actTags,
     config,
     platformAct,
+    goodsJoinAct,
     goodsRate,
     getBill,
     outBill,

+ 44 - 0
src/store/module/system/goodsJoinAct.js

@@ -0,0 +1,44 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+const _ = require('lodash');
+Vue.use(Vuex);
+const api = {
+  url: '/point/v1/api/goodsJoinAct',
+};
+
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.url}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.url}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.url}/${payload}`);
+    return res;
+  },
+  async update({ commit }, payload) {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await this.$axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.url}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 8 - 37
src/views/system/act/detail.vue

@@ -9,7 +9,7 @@
           <data-form :span="24" :fields="fields" v-model="form" :rules="rules" @save="onSubmit">
             <template #act_time>
               <el-form ref="act_time" :model="act_time" label-width="80px">
-                <el-form-item label="活动时间">
+                <el-form-item>
                   <el-input v-model="act_time.value"></el-input>
                 </el-form-item>
                 <el-form-item label="是否显示">
@@ -17,26 +17,18 @@
                     <el-option v-for="i in isuseList" :key="i.model" :label="i.label" :value="i.value"></el-option>
                   </el-select>
                 </el-form-item>
-                <el-form-item>
-                  <el-button type="primary" @click="timesubmitForm('act_time')" size="mini">提交</el-button>
-                  <el-button @click="resetForm('act_time')" size="mini">重置</el-button>
-                </el-form-item>
               </el-form>
             </template>
             <template #content>
               <el-form ref="content" :model="content" label-width="80px">
-                <el-form-item label="活动说明">
-                  <el-input type="textarea" v-model="content.value"></el-input>
+                <el-form-item>
+                  <editor v-model="content.value" url="/files/point/act/upload" />
                 </el-form-item>
                 <el-form-item label="是否显示">
                   <el-select v-model="content.is_use" placeholder="请选择">
                     <el-option v-for="i in isuseList" :key="i.model" :label="i.label" :value="i.value"></el-option>
                   </el-select>
                 </el-form-item>
-                <el-form-item>
-                  <el-button type="primary" @click="contentonSubmit('content')" size="mini">提交</el-button>
-                  <el-button @click="resetForm('content')" size="mini">重置</el-button>
-                </el-form-item>
               </el-form>
             </template>
             <template #is_use>
@@ -62,7 +54,9 @@ const { mapActions: dictData } = createNamespacedHelpers('dictData');
 export default {
   name: 'form-1',
   props: {},
-  components: {},
+  components: {
+    editor: () => import('@/components/editor.vue'),
+  },
   data: function () {
     return {
       form: {},
@@ -107,34 +101,11 @@ export default {
         this.$set(this.content, `is_use`, '0');
       }
     },
-    // 活动时间提交
-    timesubmitForm(formName) {
-      this.$refs[formName].validate((valid) => {
-        if (valid) {
-          this.$set(this.form, `act_time`, this.act_time);
-        } else {
-          console.log('error submit!!');
-          return false;
-        }
-      });
-    },
-    resetForm(type) {
-      this.$set(this, type, {});
-    },
-    // 说明提交
-    contentonSubmit(formName) {
-      this.$refs[formName].validate((valid) => {
-        if (valid) {
-          this.$set(this.form, `content`, this.content);
-        } else {
-          console.log('error submit!!');
-          return false;
-        }
-      });
-    },
     // 提交
     async onSubmit({ data }) {
       let res;
+      data.act_time = this.act_time;
+      data.content = this.content;
       if (data.id) res = await this.update(data);
       else res = await this.create(data);
       if (this.$checkRes(res)) {

+ 156 - 0
src/views/system/act/goods.vue

@@ -0,0 +1,156 @@
+<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="toAdd()">新增</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: 'title' },
+        { 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: [],
+      total: 0,
+      // 商品搜索
+      goods: '',
+      goodsList: [],
+      // 是否开启
+      isuseList: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...dictData({ dictQuery: 'query' }),
+    ...goods({ gQuery: 'query' }),
+    ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
+    // 查询
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const condition = _.cloneDeep(this.searchForm);
+      let res = await this.gQuery({ skip, limit, ...condition, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, 'goodsList', 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);
+    },
+    // 重置
+    toClose() {
+      this.goods = '';
+      this.search();
+    },
+    // 查询其他信息
+    async searchOther() {
+      let res;
+      // 是否使用
+      res = await this.dictQuery({ code: 'use' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `isuseList`, 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;
+  }
+}
+</style>

+ 6 - 1
src/views/system/act/index.vue

@@ -11,7 +11,7 @@
         </el-col>
         <el-col :span="24" class="four">
           <data-table :select="true" :selected="selected" @handleSelect="handleSelect" :fields="fields" :opera="opera"
-                      @query="search" :data="list" :total="total" @edit="toEdit" @del="toDel">
+                      @query="search" :data="list" :total="total" @edit="toEdit" @del="toDel" @manage="toManage">
           </data-table>
         </el-col>
       </el-col>
@@ -36,6 +36,7 @@ export default {
       // 列表
       opera: [
         { label: '修改', method: 'edit' },
+        { label: '商品管理', method: 'manage' },
         { label: '删除', method: 'del', confirm: true, type: 'danger' },
       ],
       fields: [
@@ -94,6 +95,10 @@ export default {
     async toEdit({ data }) {
       this.$router.push({ path: '/system/act/detail', query: { id: data.id } });
     },
+    // 平台管理
+    async toManage({ data }) {
+      this.$router.push({ path: '/system/act/goods', query: { id: data.id } });
+    },
     // 删除
     async toDel({ data }) {
       let res = await this.delete(data._id);