Browse Source

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

YY 2 years ago
parent
commit
37f4a1465d

+ 6 - 0
src/layout/data/menu.js

@@ -74,6 +74,12 @@ export const adminMenu = [
         name: '商品评价',
         index: '2-10',
       },
+      {
+        icon: 'icon-rencai',
+        path: '/system/act',
+        name: '平台活动',
+        index: '3-8',
+      },
     ],
   },
   {

+ 14 - 2
src/router/module/system.js

@@ -92,13 +92,25 @@ export default [
   {
     path: '/system/goodsRate',
     name: 'system_goodsRate',
-    meta: { title: '自营店铺-商品评价' },
+    meta: { title: '平台管理-商品评价' },
     component: () => import(/* webpackChunkName: "system_goodsRate" */ '@/views/system/goodsRate/index.vue'),
   },
   {
     path: '/system/goodsRate/detail',
     name: 'system_goodsRate_details',
-    meta: { title: '自营店铺-商品评价' },
+    meta: { title: '平台管理-商品评价' },
     component: () => import(/* webpackChunkName: "system_goodsRate_detail" */ '@/views/system/goodsRate/detail.vue'),
   },
+  {
+    path: '/system/act',
+    name: 'system_act',
+    meta: { title: '平台管理-平台活动' },
+    component: () => import(/* webpackChunkName: "system_act" */ '@/views/system/act/index.vue'),
+  },
+  {
+    path: '/system/act/detail',
+    name: 'system_act_detail',
+    meta: { title: '平台管理-平台活动详情' },
+    component: () => import(/* webpackChunkName: "system_act_detail" */ '@/views/system/act/detail.vue'),
+  },
 ];

+ 2 - 0
src/store/index.js

@@ -17,6 +17,7 @@ import banner from './module/system/banner';
 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 shop from './module/shop/shop';
 import selfShop from './module/shop/selfShop';
@@ -58,6 +59,7 @@ export default new Vuex.Store({
     sellTotal,
     actTags,
     config,
+    platformAct,
     goodsRate,
     getBill,
     outBill,

+ 44 - 0
src/store/module/system/platformAct.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/platformAct',
+};
+
+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,
+};

+ 182 - 0
src/views/system/act/detail.vue

@@ -0,0 +1,182 @@
+<template>
+  <div id="form-1">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight">
+        <el-col class="top-btn">
+          <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
+        </el-col>
+        <el-col :span="24" class="one">
+          <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-input v-model="act_time.value"></el-input>
+                </el-form-item>
+                <el-form-item label="是否显示">
+                  <el-select v-model="act_time.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="timesubmitForm('act_time')" size="mini">提交</el-button>
+                  <el-button @click="timeresetForm('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>
+                <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="contentresetForm('content')" size="mini">重置</el-button>
+                </el-form-item>
+              </el-form>
+            </template>
+            <template #is_use>
+              <el-option v-for="i in isuseList" :key="i.model" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #show_index>
+              <el-option v-for="i in isuseList" :key="i.model" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+const moment = require('moment');
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('platformAct');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+
+export default {
+  name: 'form-1',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      form: {},
+      act_time: {},
+      content: {},
+      rules: {
+        label: [{ required: true, message: '请输入活动标题', trigger: 'blur' }],
+        is_use: [{ required: true, message: '请选择是否开启', trigger: 'change' }],
+      },
+      fields: [
+        { label: '活动标题', model: 'title' },
+        { label: '活动时间', model: 'act_time', custom: true },
+        { label: '活动说明', model: 'content', custom: true },
+        { label: '分享图片(237*190)', model: 'share', type: 'upload', url: '/files/point/act/upload' },
+        { label: '封面图片', model: 'cover', type: 'upload', url: '/files/point/act/upload' },
+        { label: '是否在首页展示', model: 'show_index', type: 'select' },
+        { label: '是否开启', model: 'is_use', type: 'select' },
+      ],
+      // 是否使用
+      isuseList: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...dictData({ dictQuery: 'query' }),
+    ...mapActions(['fetch', 'create', 'update']),
+    // 查询
+    async search() {
+      if (this.id) {
+        let res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+        }
+      } else {
+        this.$set(this, `form`, { is_use: '0', show_index: '0' });
+        this.$set(this.act_time, `is_use`, '0');
+        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;
+        }
+      });
+    },
+    timeresetForm(formName) {
+      this.$refs[formName].resetFields();
+    },
+    // 说明提交
+    contentonSubmit(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          this.$set(this.form, `content`, this.content);
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+    },
+    contentresetForm(formName) {
+      this.$refs[formName].resetFields();
+    },
+    // 提交
+    async onSubmit({ data }) {
+      let res;
+      console.log(data);
+      // 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();
+      // }
+    },
+    // 查询其他信息
+    async searchOther() {
+      let res;
+      // 是否使用
+      res = await this.dictQuery({ code: 'use' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `isuseList`, res.data);
+      }
+    },
+    // 返回
+    toBack() {
+      window.history.go('-1');
+    },
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+    status() {
+      return this.$route.query.status;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) { },
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 159 - 0
src/views/system/act/index.vue

@@ -0,0 +1,159 @@
+<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">
+          <search-1 :form="searchForm" @onSubmit="search" @toReset="toClose"></search-1>
+        </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
+            :select="true"
+            :selected="selected"
+            @handleSelect="handleSelect"
+            :fields="fields"
+            :opera="opera"
+            @query="search"
+            :data="list"
+            :total="total"
+            @edit="toEdit"
+            @del="toDel"
+          >
+          </data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('platformAct');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    search1: () => import('./parts/search-1.vue'),
+  },
+  data: function () {
+    const that = this;
+    return {
+      // 列表
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
+      ],
+      fields: [
+        { label: '活动标题', model: 'title' },
+        { label: '活动时间', model: 'act_time' },
+        {
+          label: '是否开启',
+          model: 'is_use',
+          format: (i) => {
+            let data = that.isuseList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      list: [],
+      total: 0,
+      // 查询
+      searchForm: {},
+      // 多选值
+      selected: [],
+      // 是否开启
+      isuseList: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...dictData({ dictQuery: 'query' }),
+    ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
+    // 查询
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const condition = _.cloneDeep(this.searchForm);
+      let res = await this.query({ skip, limit, ...condition, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, 'list', res.data);
+        this.$set(this, 'total', res.total);
+      }
+    },
+    // 新增
+    toAdd() {
+      this.$router.push({ path: '/system/act/detail' });
+    },
+    // 修改
+    async toEdit({ data }) {
+      this.$router.push({ path: '/system/act/detail', query: { id: data.id } });
+    },
+    // 删除
+    async toDel({ data }) {
+      let res = await this.delete(data._id);
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `刪除信息成功` });
+        this.search();
+      }
+    },
+    // 重置
+    toClose() {
+      this.searchForm = {};
+      this.search();
+    },
+    // 多选
+    handleSelect(data) {
+      this.$set(this, `selected`, data);
+    },
+    // 查询其他信息
+    async searchOther() {
+      let res;
+      // 是否使用
+      res = await this.dictQuery({ code: 'use' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `isuseList`, res.data);
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  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>

+ 70 - 0
src/views/system/act/parts/search-1.vue

@@ -0,0 +1,70 @@
+<template>
+  <div id="search-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-form :model="form" ref="form" label-width="130px">
+          <el-col :span="6">
+            <el-form-item label="活动标题" prop="title">
+              <el-input v-model="form.title" placeholder="请输入活动标题" size="small"></el-input>
+            </el-form-item>
+          </el-col>
+          <!-- <el-col :span="6">
+            <el-form-item label="编码" prop="value">
+              <el-input v-model="form.value" placeholder="请输入编码" size="small"></el-input>
+            </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>
+          </el-col>
+        </el-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'search-1',
+  props: { form: { type: Object } },
+  components: {},
+  data: function () {
+    return {};
+  },
+  created() {},
+  methods: {
+    onSubmit() {
+      this.$emit('onSubmit');
+    },
+    toReset(formName) {
+      this.$refs[formName].resetFields();
+      this.$emit('toReset');
+    },
+  },
+  computed: {},
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .btn {
+    text-align: right;
+  }
+  /deep/.el-form-item {
+    float: left;
+    width: 100%;
+    margin: 0 0 10px 0;
+  }
+}
+</style>