|
@@ -1,31 +1,47 @@
|
|
<template>
|
|
<template>
|
|
<div id="index">
|
|
<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>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions: notice } = createNamespacedHelpers('notice');
|
|
export default {
|
|
export default {
|
|
name: 'index',
|
|
name: 'index',
|
|
props: {},
|
|
props: {},
|
|
components: {},
|
|
components: {},
|
|
data: function () {
|
|
data: function () {
|
|
return {
|
|
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: [
|
|
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' }],
|
|
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: {
|
|
computed: {
|
|
...mapState(['user']),
|
|
...mapState(['user']),
|
|
pageTitle() {
|
|
pageTitle() {
|