From 0e08a1fef80e15bd434a2b17e603711e782878d5 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Mon, 31 May 2021 19:34:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes .../mapper/custom/SysServicesTopicMapper.xml | 22 +- stdiet-ui/src/api/custom/message.js | 4 +- stdiet-ui/src/store/getters.js | 6 +- stdiet-ui/src/store/modules/message.js | 60 +++- stdiet-ui/src/views/custom/message/index.vue | 2 +- .../views/custom/message/messageBrowser.vue | 45 --- .../custom/message/messageBrowser/Comment.vue | 94 ++++++ .../custom/message/messageBrowser/index.vue | 276 ++++++++++++++++++ 9 files changed, 439 insertions(+), 70 deletions(-) delete mode 100644 stdiet-ui/src/views/custom/message/messageBrowser.vue create mode 100644 stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue create mode 100644 stdiet-ui/src/views/custom/message/messageBrowser/index.vue diff --git a/.DS_Store b/.DS_Store index 20c255b4c0208f1c6c70c5b04b3dd52fbaef6a68..d343bcd39fd6f5467ffeb3453751438201595a32 100644 GIT binary patch delta 61 zcmZoMXfc@J&&aVcU^gQp$7UX;WsLHi48;s33@Hqm45>g`m!Xs)vn;qMFDE}Qoq>UY Paq~uIGnUQl9Dn%%?J^Ju delta 32 ocmZoMXfc@J&&a+pU^gQp`(_@dWsIAzFdMT>Y*5 - + + + @@ -21,21 +23,9 @@ @@ -92,10 +82,12 @@ diff --git a/stdiet-ui/src/api/custom/message.js b/stdiet-ui/src/api/custom/message.js index f453c905f..7b81d2223 100644 --- a/stdiet-ui/src/api/custom/message.js +++ b/stdiet-ui/src/api/custom/message.js @@ -20,7 +20,7 @@ export function postTopicReply(data) { return request({ url: "/services/topic/reply", method: "post", - body: data + data }); } @@ -28,6 +28,6 @@ export function postTopicComment(data) { return request({ url: "/services/topic/comment", method: "post", - body: data + data }); } diff --git a/stdiet-ui/src/store/getters.js b/stdiet-ui/src/store/getters.js index 8550c09d2..c74df90cb 100644 --- a/stdiet-ui/src/store/getters.js +++ b/stdiet-ui/src/store/getters.js @@ -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, // diff --git a/stdiet-ui/src/store/modules/message.js b/stdiet-ui/src/store/modules/message.js index b65fc812f..bd01aa685 100644 --- a/stdiet-ui/src/store/modules/message.js +++ b/stdiet-ui/src/store/modules/message.js @@ -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; } }; diff --git a/stdiet-ui/src/views/custom/message/index.vue b/stdiet-ui/src/views/custom/message/index.vue index 0df449440..a2239526f 100644 --- a/stdiet-ui/src/views/custom/message/index.vue +++ b/stdiet-ui/src/views/custom/message/index.vue @@ -5,7 +5,7 @@ - diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue new file mode 100644 index 000000000..db43c3cd8 --- /dev/null +++ b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue @@ -0,0 +1,94 @@ + + + diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue new file mode 100644 index 000000000..3e0ba46ea --- /dev/null +++ b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue @@ -0,0 +1,276 @@ + + + From d86bdedf790b61e9ec8c8fb2788dd30ce9225d47 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Mon, 31 May 2021 19:39:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdiet-ui/src/store/getters.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdiet-ui/src/store/getters.js b/stdiet-ui/src/store/getters.js index c74df90cb..ccedcde6d 100644 --- a/stdiet-ui/src/store/getters.js +++ b/stdiet-ui/src/store/getters.js @@ -8,11 +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 => ["dietician"], + roles: state => state.user.roles, + // roles: state => ["dietician"], permissions: state => state.user.permissions, - // userId: state => state.user.userId, - userId: state => 131, + userId: state => state.user.userId, + // userId: state => 131, userRemark: state => state.user.remark, permission_routes: state => state.permission.routes, //