完善交互

This commit is contained in:
huangdeliang
2021-06-03 10:36:21 +08:00
parent 953d188f50
commit ea8276e6a0
17 changed files with 348 additions and 113 deletions

View File

@ -1,6 +1,9 @@
const actions = {
async init({ dispatch }, payload) {
dispatch("global/init", payload);
},
async updateUnreadCount({ commit }, payload) {
commit("global/save", payload);
}
};

View File

@ -9,12 +9,11 @@ const getters = {
name: state => state.user.name,
introduction: state => state.user.introduction,
roles: state => state.user.roles,
// roles: state => ["dietician"],
permissions: state => state.user.permissions,
userId: state => state.user.userId,
// userId: state => 131,
userRemark: state => state.user.remark,
permission_routes: state => state.permission.routes,
msgUnreadCount: state => state.global.msgUnreadCount,
//
nutritionistIdOptions: state => state.global.nutritionistIdOptions,
nutriAssisIdOptions: state => state.global.nutriAssisIdOptions,

View File

@ -9,7 +9,8 @@ const oriState = {
plannerIdOptions: [],
plannerAssisIdOptions: [],
operatorIdOptions: [],
operatorAssisIdOptions: []
operatorAssisIdOptions: [],
msgUnreadCount: 0,
};
const mutations = {

View File

@ -6,6 +6,7 @@ import {
} from "@/api/custom/message";
const oriState = {
pageNum: 1,
topicList: [],
detailData: {},
selTopicId: ""
@ -28,23 +29,35 @@ const mutations = {
};
const actions = {
async init({ rootGetters, commit, dispatch }, payload) {
async init({ dispatch }, payload) {
dispatch("fetchTopicListApi", {});
},
async fetchTopicListApi({ dispatch, commit, rootGetters, state }, payload) {
const {
roles: [role],
userId
} = rootGetters;
const result = await fetchTopicList({ role, uid: userId });
const { detailData, pageNum, topicList } = state;
const result = await fetchTopicList({
role,
uid: userId,
pageSize: 20,
pageNum
});
if (result.code === 200) {
const [defTopic] = result.rows;
dispatch("fetchTopicDetailActions", {
topicId: defTopic.topicId,
id: defTopic.id
});
commit("save", {
topicList: result.rows
});
if (!detailData.topicId) {
const [defTopic] = result.rows;
dispatch("fetchTopicDetailActions", {
topicId: defTopic.topicId,
id: defTopic.id
});
}
if (result.rows.length) {
commit("save", {
pageNum: pageNum + 1,
topicList: [...topicList, ...result.rows]
});
}
}
},
async fetchTopicDetailActions({ commit }, payload) {