Forráskód Böngészése

修改系统消息

YY 2 éve
szülő
commit
3a340ea006

+ 2 - 0
src/store/index.js

@@ -7,6 +7,7 @@ import admin from './module/user/action';
 import users from './module/user/users';
 // 系统消息
 import notice from './module/user/notice';
+import msgList from './module/user/msgList';
 
 import todo from './module/statistics/todo';
 import sellTotal from './module/statistics/sellTotal';
@@ -113,5 +114,6 @@ export default new Vuex.Store({
     groupTransport,
     salesTransport,
     notice,
+    msgList,
   },
 });

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

+ 4 - 4
src/views/platmanag/notice/detail.vue

@@ -49,8 +49,7 @@ export default {
       // info部分
       infoFields: [
         { label: '用户', model: 'customer', custom: true },
-        { label: '信息来源', model: 'source', type: 'select' },
-        // { label: '来源id', model: 'source_id' },
+        { label: '信息来源', model: 'source', type: 'select', readonly: true },
         { label: '发送时间', model: 'time', type: 'datetime' },
         { label: '内容', model: 'content', type: 'textarea' },
         { label: '状态', model: 'status', type: 'select' },
@@ -89,7 +88,8 @@ export default {
           this.$set(this, `form`, res.data);
         }
       } else {
-        this.$set(this.form, 'status', '0');
+        let obj = { status: '0', source: '0' };
+        this.$set(this, 'form', obj);
       }
       this.loadings = false;
     },
@@ -112,7 +112,7 @@ export default {
     },
     // 返回
     toBack() {
-      this.$emit('toBack');
+      this.$emit('goBack');
     },
     // 查询其他信息
     async searchOthers() {

+ 18 - 47
src/views/platmanag/notice/index.vue

@@ -11,23 +11,17 @@
         <span v-if="view === 'list'">
           <el-col :span="24" class="one"> <span>系统消息管理</span> </el-col>
           <data-search :fields="searchFields" v-model="searchInfo" @query="search">
-            <template #status>
-              <el-option v-for="i in statusList" :key="i.label" :label="i.label" :value="i.value"></el-option>
+            <template #source>
+              <el-option v-for="i in sourceList" :key="i.label" :label="i.label" :value="i.value"></el-option>
             </template>
           </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>
+          <el-col :span="24" class="two">
+            <data-table ref="dataTable" :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @view="toView"></data-table>
+          </el-col>
         </span>
-        <detail v-if="view === 'info'" :id="id" @toBack="toBack"></detail>
+        <notice v-if="view === 'info'" :id="id" @toBack="toBack"></notice>
+        <detail v-if="view === 'infos'" :id="id" @goBack="toBack"></detail>
       </el-col>
     </el-row>
   </div>
@@ -36,6 +30,7 @@
 <script>
 const _ = require('lodash');
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: msgList } = createNamespacedHelpers('msgList');
 const { mapActions: notice } = createNamespacedHelpers('notice');
 const { mapActions: dictData } = createNamespacedHelpers('dictData'); // 字典
 
@@ -43,6 +38,7 @@ export default {
   name: 'index',
   props: {},
   components: {
+    notice: () => import('./notice.vue'),
     detail: () => import('./detail.vue'),
   },
   data: function () {
@@ -51,8 +47,8 @@ export default {
       loading: false,
       view: 'list',
       fields: [
-        { label: '用户', model: 'customer.name', showTip: false },
         { label: '发送时间', model: 'time' },
+        { label: '来源id', model: '_id' },
         {
           label: '信息来源',
           model: 'source',
@@ -62,71 +58,48 @@ export default {
             else return '暂无';
           },
         },
-        {
-          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: 'status', type: 'select' }],
+      opera: [{ label: '查看', method: 'view' }],
+      searchFields: [{ label: '信息来源', model: 'source', type: 'select' }],
       searchInfo: {},
       list: [],
       total: 0,
       id: '',
-      // 状态
-      statusList: [],
       // 信息来源
       sourceList: [],
     };
   },
   created() {
     this.searchOthers();
-
     this.search();
   },
   methods: {
     ...dictData({ dictQuery: 'query' }),
     ...notice(['query', 'delete', 'fetch', 'update', 'create']),
+    ...msgList({ msgQuery: 'query' }),
     // 查询
     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);
+      const res = await this.msgQuery(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');
+      this.$set(this, `view`, 'infos');
     },
-    // 修改
-    async toEdit({ data }) {
+    // 查看
+    async toView({ 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';
@@ -134,8 +107,6 @@ export default {
     // 查询其他信息
     async searchOthers() {
       let res;
-      res = await this.dictQuery({ code: 'notice_status' });
-      if (this.$checkRes(res)) this.$set(this, `statusList`, res.data);
       // 信息来源
       res = await this.dictQuery({ code: 'notice_source' });
       if (this.$checkRes(res)) this.$set(this, `sourceList`, res.data);
@@ -159,7 +130,7 @@ export default {
     }
   }
   .two {
-    margin: 0 0 10px 0;
+    margin: 20px 0 10px 0;
   }
   .thr {
     margin: 0 0 10px 0;

+ 184 - 0
src/views/platmanag/notice/notice.vue

@@ -0,0 +1,184 @@
+<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-row>
+            <el-col :span="2"><el-button type="primary" size="mini" @click="toBack()">返回</el-button></el-col>
+          </el-row>
+          <el-col :span="24" class="one"> <span>系统消息管理</span> </el-col>
+          <data-search :fields="searchFields" v-model="searchInfo" @query="search">
+            <template #status>
+              <el-option v-for="i in statusList" :key="i.label" :label="i.label" :value="i.value"></el-option>
+            </template>
+            <template #source>
+              <el-option v-for="i in sourceList" :key="i.label" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </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="ids" @goBack="goBack"></detail>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: msgList } = createNamespacedHelpers('msgList');
+const { mapActions: notice } = createNamespacedHelpers('notice');
+const { mapActions: dictData } = createNamespacedHelpers('dictData'); // 字典
+
+export default {
+  name: 'index',
+  props: { id: { type: String } },
+  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: '来源id', model: 'source_id' },
+        {
+          label: '信息来源',
+          model: 'source',
+          format: (i) => {
+            let data = this.sourceList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+        {
+          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: 'status', type: 'select' },
+        { label: '信息来源', model: 'source', type: 'select' },
+      ],
+      searchInfo: {},
+      list: [],
+      total: 0,
+      ids: '',
+      // 状态
+      statusList: [],
+      // 信息来源
+      sourceList: [],
+    };
+  },
+  created() {
+    this.searchOthers();
+
+    this.search();
+  },
+  methods: {
+    ...dictData({ dictQuery: 'query' }),
+    ...notice(['query', 'delete', 'fetch', 'update', 'create']),
+    ...msgList({ msgQuery: 'query' }),
+    // 查询
+    async search({ skip = 0, limit = this.$limit, ...others } = {}) {
+      let query = { skip, limit, ...others };
+      if (Object.keys(this.searchInfo).length > 0) query = { ...query, ...this.searchInfo };
+      if (this.id) query.source_id = this.id;
+      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, `ids`, id);
+      this.$set(this, `view`, 'info');
+    },
+    // 修改
+    async toEdit({ data }) {
+      this.$set(this, `ids`, 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(data) {
+      this.$emit('toBack');
+    },
+    goBack() {
+      this.view = 'list';
+    },
+    // 查询其他信息
+    async searchOthers() {
+      let res;
+      res = await this.dictQuery({ code: 'notice_status' });
+      if (this.$checkRes(res)) this.$set(this, `statusList`, res.data);
+      // 信息来源
+      res = await this.dictQuery({ code: 'notice_source' });
+      if (this.$checkRes(res)) this.$set(this, `sourceList`, 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>