Ver código fonte

活动标签

YY 2 anos atrás
pai
commit
e64e8c451f

+ 9 - 3
src/layout/data/menu.js

@@ -32,23 +32,29 @@ export const adminMenu = [
         name: '商品标签',
         index: '2-3',
       },
+      {
+        icon: 'icon-rencai',
+        path: '/system/actTags',
+        name: '活动标签',
+        index: '2-4',
+      },
       {
         icon: 'icon-rencai',
         path: '/system/order',
         name: '平台订单管理',
-        index: '2-4',
+        index: '2-5',
       },
       {
         icon: 'icon-rencai',
         path: '/system/coupon',
         name: '优惠券管理',
-        index: '2-5',
+        index: '2-6',
       },
       {
         icon: 'icon-rencai',
         path: '/system/service',
         name: '客服管理',
-        index: '2-6',
+        index: '2-7',
       },
       {
         icon: 'icon-rencai',

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

@@ -71,4 +71,16 @@ export default [
     meta: { title: '平台管理-统计' },
     component: () => import(/* webpackChunkName: "system_statistics" */ '@/views/system/statistics/index.vue'),
   },
+  {
+    path: '/system/actTags',
+    name: 'system_actTags',
+    meta: { title: '平台管理-活动标签' },
+    component: () => import(/* webpackChunkName: "system_actTags" */ '@/views/system/actTags/index.vue'),
+  },
+  {
+    path: '/system/actTags/detail',
+    name: 'system_actTags_detail',
+    meta: { title: '平台管理-活动标签-维护信息' },
+    component: () => import(/* webpackChunkName: "system_actTags_detail" */ '@/views/system/actTags/detail.vue'),
+  },
 ];

+ 2 - 0
src/store/index.js

@@ -13,6 +13,7 @@ import dictData from './module/dev/dictData';
 import goodsTags from './module/system/goodsTags';
 import banner from './module/system/banner';
 import indexModule from './module/system/indexModule';
+import actTags from './module/system/actTags';
 
 import shop from './module/shop/shop';
 import selfShop from './module/shop/selfShop';
@@ -50,5 +51,6 @@ export default new Vuex.Store({
     sot,
     todo,
     sellTotal,
+    actTags,
   },
 });

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

+ 114 - 0
src/views/system/actTags/detail.vue

@@ -0,0 +1,114 @@
+<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 #status>
+              <el-option v-for="i in statusList" :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('actTags');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+
+export default {
+  name: 'form-1',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      form: {},
+      rules: {
+        label: [{ required: true, message: '请输入活动标签', trigger: 'blur' }],
+        value: [{ required: false, message: '请输入编码', trigger: 'blur' }],
+        status: [{ required: true, message: '请选择状态', trigger: 'change' }],
+      },
+      fields: [
+        { label: '活动标签', model: 'label' },
+        { label: '编码', model: 'value' },
+        { label: '排序', model: 'sort', type: 'number' },
+        { label: '状态', model: 'status', type: 'select' },
+      ],
+      // 类型
+      typeList: [],
+      // 是否使用
+      statusList: [],
+    };
+  },
+  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`, { status: '0' });
+      }
+    },
+    // 提交
+    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();
+      }
+    },
+    // 查询其他信息
+    async searchOther() {
+      let res;
+      // 是否使用
+      res = await this.dictQuery({ code: 'status' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `statusList`, 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>

+ 161 - 0
src/views/system/actTags/index.vue

@@ -0,0 +1,161 @@
+<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" :typeList="typeList" @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('actTags');
+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: 'label' },
+        { label: '编码', model: 'value' },
+        {
+          label: '是否正在使用',
+          model: 'status',
+          format: (i) => {
+            let data = that.statusList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      list: [],
+      total: 0,
+      // 查询
+      searchForm: {},
+      // 多选值
+      selected: [],
+      // 类型列表
+      typeList: [],
+      // 是否使用
+      statusList: [],
+    };
+  },
+  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/actTags/detail' });
+    },
+    // 修改
+    async toEdit({ data }) {
+      this.$router.push({ path: '/system/actTags/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: 'status' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `statusList`, 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>

+ 72 - 0
src/views/system/actTags/parts/search-1.vue

@@ -0,0 +1,72 @@
+<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="name">
+              <el-input v-model="form.name" placeholder="请输入名称" size="small"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="类型" prop="type">
+              <el-select v-model="form.type" clearable filterable placeholder="请选择" style="width: 100%" size="small">
+                <el-option v-for="i in typeList" :key="i.label" :label="i.label" :value="i.value"></el-option>
+              </el-select>
+            </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 }, typeList: { type: Array } },
+  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>