YY 2 lat temu
rodzic
commit
5cc7205d6d

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

@@ -49,6 +49,12 @@ export const adminMenu = [
         name: '售后管理',
         index: '2-6',
       },
+      {
+        icon: 'icon-rencai',
+        path: '/platmanag/notice',
+        name: '系统消息管理',
+        index: '2-7',
+      },
     ],
   },
   {

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

@@ -53,4 +53,10 @@ export default [
     meta: { title: '平台管理-售后管理' },
     component: () => import('@/views/platmanag/sales/index.vue'),
   },
+  {
+    path: '/platmanag/notice',
+    name: 'platmanag_notice',
+    meta: { title: '平台管理-系统消息管理' },
+    component: () => import('@/views/platmanag/notice/index.vue'),
+  },
 ];

+ 3 - 0
src/store/index.js

@@ -5,6 +5,8 @@ import * as umutations from './module/user/mutations';
 import admin from './module/user/action';
 // 用户
 import users from './module/user/users';
+// 系统消息
+import notice from './module/user/notice';
 
 import todo from './module/statistics/todo';
 import sellTotal from './module/statistics/sellTotal';
@@ -110,5 +112,6 @@ export default new Vuex.Store({
     group,
     groupTransport,
     salesTransport,
+    notice,
   },
 });

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

+ 143 - 0
src/views/platmanag/notice/detail.vue

@@ -0,0 +1,143 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="main" v-loading="loadings" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
+        <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>
+        <el-col :span="24">
+          <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
+            <template #customer>
+              <el-select
+                v-model="form.customer"
+                filterable
+                multiple
+                remote
+                placeholder="请选择用户"
+                :remote-method="querySearch"
+                :loading="loading"
+                style="width: 100%"
+              >
+                <el-option v-for="item in customerList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
+              </el-select>
+            </template>
+            <template #status>
+              <el-option v-for="i in statusList" :key="i.label" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </data-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: users } = createNamespacedHelpers('users');
+const { mapActions: dictData } = createNamespacedHelpers('dictData'); // 字典
+const { mapActions: notice } = createNamespacedHelpers('notice'); // 消息
+export default {
+  name: 'detail',
+  props: { id: { type: String } },
+  components: {},
+  data: function () {
+    return {
+      loadings: true,
+      // info部分
+      infoFields: [
+        { label: '用户', model: 'customer', custom: true },
+        { label: '发送时间', model: 'time', type: 'datetime' },
+        { label: '内容', model: 'content', type: 'textarea' },
+        { label: '状态', model: 'status', type: 'select' },
+      ],
+      rules: {
+        goods: [{ required: true, message: '商品名称', trigger: 'change' }],
+        spec: [{ required: true, message: '商品规格', trigger: 'change' }],
+        leader_price: [{ required: true, message: '团长价', trigger: 'blur' }],
+        price: [{ required: true, message: '团购价', trigger: 'blur' }],
+        leader_get: [{ required: true, message: '团长提成金额', trigger: 'blur' }],
+        freight: [{ required: true, message: '运费', trigger: 'blur' }],
+      },
+      form: {},
+      // 加载
+      loading: false,
+      // 远程搜索团长列表
+      customerList: [],
+      // 规格列表
+      statusList: [],
+    };
+  },
+  created() {
+    this.searchOthers();
+    this.search();
+  },
+  methods: {
+    ...users({ usersQuery: 'query', usersFetch: 'fetch' }),
+    ...dictData({ dictQuery: 'query' }),
+    ...notice(['query', 'delete', 'fetch', 'update', 'create']),
+    // 查询
+    async search() {
+      if (this.id) {
+        const res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          let list = [];
+          list.push(res.data.customer);
+          res.data.customer = list;
+          this.$set(this, `form`, res.data);
+        }
+      }
+      this.loadings = false;
+    },
+    // 远程查询
+    async querySearch(value) {
+      this.loading = true;
+      let res = await this.usersQuery({ name: value, is_leader: '0' });
+      if (this.$checkRes(res)) this.$set(this, 'customerList', res.data);
+      this.loading = false;
+    },
+    // 保存
+    async toSave({ 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();
+      }
+    },
+    // 返回
+    toBack() {
+      this.$emit('toBack');
+    },
+    // 查询其他信息
+    async searchOthers() {
+      let res;
+      res = await this.dictQuery({ code: 'notice_status' });
+      if (this.$checkRes(res)) this.$set(this, `statusList`, res.data);
+      // 团长列表
+      res = await this.usersQuery({ is_leader: '0' });
+      if (this.$checkRes(res)) {
+        // for (const p1 of res.data) {
+        //   p1.name = '团长' + '---' + p1.phone + '---' + p1.name;
+        // }
+        this.$set(this, `customerList`, 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></style>

+ 153 - 0
src/views/platmanag/notice/index.vue

@@ -0,0 +1,153 @@
+<template>
+  <div id="goods">
+    <el-row>
+      <el-col
+        :span="24"
+        class="main animate__animated animate__backInRight"
+        v-loading="loadings"
+        element-loading-text="拼命加载中"
+        element-loading-spinner="el-icon-loading"
+      >
+        <span v-if="view === 'list'">
+          <el-col :span="24" class="one"> <span>系统消息管理</span> </el-col>
+          <data-search :fields="searchFields" v-model="searchInfo" @query="search"> </data-search>
+          <data-btn :fields="btnList" @add="toAdd"></data-btn>
+          <data-table
+            ref="dataTable"
+            :fields="fields"
+            :opera="opera"
+            :data="list"
+            :total="total"
+            @query="search"
+            @edit="toEdit"
+            @delete="toDelete"
+          ></data-table>
+        </span>
+        <detail v-if="view === 'info'" :id="id" @toBack="toBack"></detail>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: notice } = createNamespacedHelpers('notice');
+const { mapActions: dictData } = createNamespacedHelpers('dictData'); // 字典
+
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    detail: () => import('./detail.vue'),
+  },
+  data: function () {
+    return {
+      loadings: true,
+      loading: false,
+      view: 'list',
+      fields: [
+        { label: '用户', model: 'customer.name', showTip: false },
+        { label: '发送时间', model: 'time' },
+        {
+          label: '状态',
+          model: 'status',
+          format: (i) => {
+            let data = this.statusList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'delete', confirm: true, type: 'danger' },
+      ],
+      btnList: [{ label: '添加', method: 'add' }],
+      searchFields: [
+        // { label: '商品名称', model: 'goods', custom: true },
+        // { label: '规格名称', model: 'spec', custom: true },
+      ],
+      searchInfo: {},
+      list: [],
+      total: 0,
+      id: '',
+      // 状态
+      statusList: [],
+    };
+  },
+  created() {
+    this.searchOthers();
+
+    this.search();
+  },
+  methods: {
+    ...dictData({ dictQuery: 'query' }),
+    ...notice(['query', 'delete', 'fetch', 'update', 'create']),
+    // 查询
+    async search({ skip = 0, limit = this.$limit, ...others } = {}) {
+      let query = { skip, limit, ...others };
+      if (Object.keys(this.searchInfo).length > 0) query = { ...query, ...this.searchInfo };
+      const res = await this.query(query);
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+      this.loadings = false;
+    },
+
+    // 新增
+    toAdd() {
+      let id = '';
+      this.$set(this, `id`, id);
+      this.$set(this, `view`, 'info');
+    },
+    // 修改
+    async toEdit({ data }) {
+      this.$set(this, `id`, data._id);
+      this.$set(this, `view`, 'info');
+    },
+    // 删除
+    async toDelete({ data }) {
+      let res = await this.delete(data._id);
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `刪除信息成功` });
+        this.search();
+      }
+    },
+    // 执行返回
+    toBack() {
+      this.view = 'list';
+    },
+    // 查询其他信息
+    async searchOthers() {
+      let res;
+      res = await this.dictQuery({ code: 'notice_status' });
+      if (this.$checkRes(res)) this.$set(this, `statusList`, res.data);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+};
+</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>