修改对消息管理接口返回值的利用

master
toesbieya 6 years ago
parent 782ed1b19c
commit ccc102fcfd
  1. 20
      vue/src/views/message/user/MessageStream.vue
  2. 3
      vue/src/views/message/user/index.vue

@ -50,18 +50,22 @@
<script> <script>
import tablePageMixin from '@/mixins/tablePageMixin' import tablePageMixin from '@/mixins/tablePageMixin'
import Empty from '@/components/Empty'
import AutoHidden from "./AutoHidden" import AutoHidden from "./AutoHidden"
import Empty from '@/components/Empty'
import {search, read, readAll} from "@/api/message/user" import {search, read, readAll} from "@/api/message/user"
import {isEmpty} from "@/utils" import {isEmpty} from "@/utils"
export default { export default {
name: "MessageStream", name: "MessageStream",
mixins: [tablePageMixin], mixins: [tablePageMixin],
components: {Empty, AutoHidden},
components: {AutoHidden, Empty},
props: { props: {
mode: String, mode: String,
}, },
data() { data() {
return { return {
searchForm: { searchForm: {
@ -69,6 +73,7 @@
}, },
} }
}, },
computed: { computed: {
unreadCount() { unreadCount() {
return this.$store.state.message.unreadCount return this.$store.state.message.unreadCount
@ -77,19 +82,24 @@
return this.mode === 'unread' && this.unreadCount > 0 return this.mode === 'unread' && this.unreadCount > 0
} }
}, },
watch: { watch: {
mode() { mode() {
this.search() this.search()
} }
}, },
methods: { methods: {
search() { search() {
if (this.config.loading) return if (this.config.loading) return
const unread = this.mode === 'unread'
const currentMode = this.mode
this.tableData = [] this.tableData = []
this.config.loading = true this.config.loading = true
search({...this.searchForm, unread: this.mode === 'unread'}) search({...this.searchForm, unread})
.then(({list, total, data}) => { .then(({list, total}) => {
!isEmpty(data) && this.$store.commit('message/unreadCount', data) if (this.mode !== currentMode) return
unread && this.$store.commit('message/unreadCount', total)
this.searchForm.total = total this.searchForm.total = total
this.tableData = this.transformList(list) this.tableData = this.transformList(list)
}) })

@ -14,13 +14,16 @@
export default { export default {
name: "userMessage", name: "userMessage",
components: {MessageStream}, components: {MessageStream},
data() { data() {
return { return {
tabs: [{label: '未读消息', name: 'unread'}, {label: '已读消息', name: 'read'}], tabs: [{label: '未读消息', name: 'unread'}, {label: '已读消息', name: 'read'}],
activeTab: 'unread', activeTab: 'unread',
} }
}, },
computed: { computed: {
tabPosition() { tabPosition() {
return this.$store.state.app.device === 'pc' ? 'left' : 'top' return this.$store.state.app.device === 'pc' ? 'left' : 'top'

Loading…
Cancel
Save