管理后台前端搭建

This commit is contained in:
huangdeliang
2021-05-31 19:34:04 +08:00
parent 7e3311ad64
commit 0e08a1fef8
9 changed files with 439 additions and 70 deletions

View File

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

View File

@ -6,11 +6,15 @@ import {
} from "@/api/custom/message";
const oriState = {
topicList: undefined,
detailData: undefined
topicList: [],
detailData: {},
selTopicId: ""
};
const mutations = {
updateSelTopicId(state, payload) {
state.selTopicId = payload.selTopicId;
},
save(state, payload) {
Object.keys(payload).forEach(key => {
state[key] = payload[key];
@ -24,13 +28,59 @@ const mutations = {
};
const actions = {
async init({ rootGetters, commit }, payload) {
async init({ rootGetters, commit, dispatch }, payload) {
const {
roles: [role],
userId
} = rootGetters;
const result = await fetchTopicList({ role: "dietician", uid: 131 });
console.log({ result });
const result = await fetchTopicList({ role, uid: userId });
if (result.code === 200) {
const [defTopic] = result.rows;
dispatch("fetchTopicDetailActions", {
topicId: defTopic.topicId,
id: defTopic.id
});
commit("save", {
topicList: result.rows
});
}
},
async fetchTopicDetailActions({ commit }, payload) {
const { topicId, id } = payload;
commit("save", { selTopicId: topicId });
const result = await fetchTopicDetail({ topicId, id });
if (result.code === 200) {
commit("save", { detailData: result.data[0] });
}
},
async postTopicReplyActions(
{ commit, rootGetters, dispatch, state },
payload
) {
const {
roles: [role],
userId
} = rootGetters;
const { detailData, topicList } = state;
const params = { ...payload, fromRole: role, fromUid: userId };
const result = payload.commentId
? await postTopicReply(params)
: await postTopicComment(params);
if (result.code === 200) {
const tarTopic = topicList.find(
obj => obj.topicId === detailData.topicId
);
if (tarTopic) {
dispatch("fetchTopicDetailActions", {
topicId: tarTopic.topicId,
id: tarTopic.id
});
}
}
return result;
}
};