lrf402788946 3 gadi atpakaļ
vecāks
revīzija
706946a78b

+ 5 - 0
src/router/index.js

@@ -67,6 +67,11 @@ const web = [
         meta: { title: '预评估' },
         component: () => import('../views/adminCenter/disclosure/evaluate.vue'),
       },
+      {
+        path: '/adminCenter/message/index',
+        meta: { title: '消息管理' },
+        component: () => import('../views/adminCenter/message/index.vue'),
+      },
     ],
   },
   {

+ 2 - 1
src/store/index.js

@@ -4,6 +4,7 @@ import * as ustate from '@common/src/store/user/state';
 import * as umutations from '@common/src/store/user/mutations';
 import disclosure from '@common/src/store/patent/disclosure';
 import report from '@common/src/store/patent/report';
+import notice from '@common/src/store/patent/notice';
 // 管理员
 import adminLogin from '@common/src/store/adminLogin';
 // 个人
@@ -20,5 +21,5 @@ export default new Vuex.Store({
   state: { ...ustate },
   mutations: { ...umutations },
   actions: {},
-  modules: { disclosure, adminLogin, personal, inviteCode, organization, expert, report },
+  modules: { disclosure, adminLogin, personal, inviteCode, organization, expert, report, notice },
 });

+ 26 - 10
src/views/adminCenter/message/index.vue

@@ -1,31 +1,47 @@
 <template>
   <div id="index">
-    <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @check="toCheck"> </data-table>
+    <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @off="toOff"> </data-table>
   </div>
 </template>
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: notice } = createNamespacedHelpers('notice');
 export default {
   name: 'index',
   props: {},
   components: {},
   data: function () {
     return {
-      list: [
-        { contact: '消息1', time: '2021-07-01 10:00:21', status: '0' },
-        { contact: '消息2', time: '2021-07-02 12:00:30', status: '1' },
-      ],
-      total: 2,
+      list: [],
+      total: 0,
       fields: [
-        { label: '消息内容', model: 'contact' },
-        { label: '时间', model: 'time' },
+        { label: '消息内容', model: 'content' },
+        { label: '是否已读', model: 'is_read', format: (i) => (i ? '已读' : '未读') },
       ],
       opera: [{ label: '取消提醒', method: 'off', display: (i) => i.status === '0' }],
     };
   },
-  created() {},
-  methods: {},
+  created() {
+    this.search();
+  },
+  methods: {
+    ...notice(['query', 'update']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info, to: this.user._id });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    async toOff({ data }) {
+      data.is_read = true;
+      const res = await this.update(data);
+      if (this.$checkRes(res, '消息已读', res.errmsg || '操作失败')) {
+        this.search();
+      }
+    },
+  },
   computed: {
     ...mapState(['user']),
     pageTitle() {

+ 23 - 9
src/views/jg/message/index.vue

@@ -1,31 +1,45 @@
 <template>
   <div id="index">
-    <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @check="toCheck"> </data-table>
+    <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @off="toOff"> </data-table>
   </div>
 </template>
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: notice } = createNamespacedHelpers('notice');
 export default {
   name: 'index',
   props: {},
   components: {},
   data: function () {
     return {
-      list: [
-        { contact: '消息1', time: '2021-07-01 10:00:21', status: '0' },
-        { contact: '消息2', time: '2021-07-02 12:00:30', status: '1' },
-      ],
-      total: 2,
+      list: [],
+      total: 0,
       fields: [
-        { label: '消息内容', model: 'contact' },
-        { label: '时间', model: 'time' },
+        { label: '消息内容', model: 'content' },
+        { label: '是否已读', model: 'is_read', format: (i) => (i ? '已读' : '未读') },
       ],
       opera: [{ label: '取消提醒', method: 'off', display: (i) => i.status === '0' }],
     };
   },
   created() {},
-  methods: {},
+  methods: {
+    ...notice(['query', 'update']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info, to: this.user._id });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    async toOff({ data }) {
+      data.is_read = true;
+      const res = await this.update(data);
+      if (this.$checkRes(res, '消息已读', res.errmsg || '操作失败')) {
+        this.search();
+      }
+    },
+  },
   computed: {
     ...mapState(['user']),
     pageTitle() {