diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesTopic.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesTopic.java index 3ce77b0bd..ca31d6095 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesTopic.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysServicesTopic.java @@ -85,6 +85,11 @@ public class SysServicesTopic { String toName; String name; + String avatar; + String fromAvatar; + String toAvatar; + + List<SysServicesTopic> comments; List<SysServicesTopic> replys; diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysServicesTopicMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysServicesTopicMapper.xml index a1dc84685..bfbd1d630 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysServicesTopicMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysServicesTopicMapper.xml @@ -25,7 +25,7 @@ SELECT * FROM ( SELECT topic_id, id, `read`, create_time, update_time, 'customer' AS role FROM sys_services_topic_status WHERE role = #{role} AND uid = #{uid} ) AS status - LEFT JOIN sys_services_topic USING(topic_id) + LEFT JOIN sys_services_topic USING(topic_id) WHERE del_flag = 0 ORDER BY `read` ASC, update_time DESC </select> @@ -39,6 +39,7 @@ <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/> <result column="create_time" property="createTime"/> <association property="name" column="{uid=uid,role=role}" select="selectUserInfo"/> + <association property="avatar" column="{uid=uid,role=role}" select="selectUserAvatar"/> <association property="comments" column="topic_id" select="selectServicesTopicCommentByTopicId"/> </resultMap> @@ -53,7 +54,9 @@ <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/> <result column="create_time" property="createTime"/> <association property="fromName" column="{uid=from_uid,role=from_role}" select="selectUserInfo"/> + <association property="fromAvatar" column="{uid=from_uid,role=from_role}" select="selectUserAvatar"/> <association property="toName" column="{uid=to_uid,role=to_role}" select="selectUserInfo"/> +<!-- <association property="toAvatar" column="{uid=to_uid,role=to_role}" select="selectUserAvatar"/>--> <association property="replys" column="id" select="selectServicesTopicCommentReplyByCommentId"/> </resultMap> @@ -71,7 +74,9 @@ <result column="img" property="img" typeHandler="com.stdiet.custom.typehandler.ArrayJsonHandler"/> <result column="create_time" property="createTime"/> <association property="fromName" column="{uid=from_uid,role=from_role}" select="selectUserInfo"/> + <association property="fromAvatar" column="{uid=from_uid,role=from_role}" select="selectUserAvatar"/> <association property="toName" column="{uid=to_uid,role=to_role}" select="selectUserInfo"/> +<!-- <association property="toAvatar" column="{uid=to_uid,role=to_role}" select="selectUserAvatar"/>--> </resultMap> @@ -103,6 +108,18 @@ </choose> </select> + <!-- 查询头像--> + <select id="selectUserAvatar" parameterType="java.util.Map" resultType="String"> + <choose> + <when test="_parameter.get('role') == 'customer'"> + select avatar_url from sys_wx_user_info where cus_id = #{uid} + </when> + <otherwise> + select IF(avatar != '', CONCAT("https://api.stdiet.top/prod-api", avatar), '') as avatar from sys_user where user_id = #{uid} + </otherwise> + </choose> + </select> + <!-- 插入问题--> <insert id="insertSysServicesTopic" parameterType="SysServicesTopic" useGeneratedKeys="true" keyProperty="id" keyColumn="id"> diff --git a/stdiet-ui/src/store/modules/message.js b/stdiet-ui/src/store/modules/message.js index e4f2bcb64..e3643e1c5 100644 --- a/stdiet-ui/src/store/modules/message.js +++ b/stdiet-ui/src/store/modules/message.js @@ -75,7 +75,7 @@ const actions = { commit("save", { selTopicId: topicId }); // 客户信息 if (healthyData.customerId !== parseInt(uid)) { - dispatch("getHealthyData", { cusId: uid }); + dispatch("getHealthyData", { cusId: uid, callback: payload.callback }); } // const result = await fetchTopicDetail({ topicId, id }); @@ -116,22 +116,26 @@ const actions = { const healthyDataResult = await getCustomerPhysicalSignsByCusId( payload.cusId ); - let healthyData = undefined, - healthyDataType = 0; + const newState = {}; if (healthyDataResult.code === 200) { if (!healthyDataResult.data.customerHealthy) { - throw new Error("客户还没填写健康评估表"); + // throw new Error("客户还没填写健康评估表"); + payload.callback && payload.callback("客户还没填写健康评估表"); + } else { + newState.healthyDataType = healthyDataResult.data.type; + newState.healthyData = dealHealthy( + healthyDataResult.data.customerHealthy + ); + newState.avoidFoodIds = (newState.healthyData.avoidFood || []).map( + obj => obj.id + ); } - healthyDataType = healthyDataResult.data.type; - healthyData = dealHealthy(healthyDataResult.data.customerHealthy); } else { throw new Error(healthyDataResult.msg); } commit("save", { healthDataLoading: false, - healthyDataType, - healthyData, - avoidFoodIds: (healthyData.avoidFood || []).map(obj => obj.id) + ...newState }); } }; diff --git a/stdiet-ui/src/views/custom/customer/index.vue b/stdiet-ui/src/views/custom/customer/index.vue index 48f628f07..217efab90 100644 --- a/stdiet-ui/src/views/custom/customer/index.vue +++ b/stdiet-ui/src/views/custom/customer/index.vue @@ -27,7 +27,12 @@ </el-select> </el-form-item> --> <el-form-item label="进粉渠道" prop="channelId"> - <el-select v-model="queryParams.channelId" filterable clearable placeholder="请选择"> + <el-select + v-model="queryParams.channelId" + filterable + clearable + placeholder="请选择" + > <el-option v-for="dict in accountIdOptions" :key="dict.dictValue" @@ -84,24 +89,24 @@ </el-select> </el-form-item> - <el-form-item label="病史体征" prop="physicalSignsId"> - <el-select - v-model="queryParams.physicalSignsId" - filterable - clearable - allow-create - default-first-option - placeholder="请选择病史体征" + <el-form-item label="病史体征" prop="physicalSignsId"> + <el-select + v-model="queryParams.physicalSignsId" + filterable + clearable + allow-create + default-first-option + placeholder="请选择病史体征" + > + <el-option + v-for="physicalSign in physicalSignsList" + :key="physicalSign.id" + :label="physicalSign.name" + :value="physicalSign.id" > - <el-option - v-for="physicalSign in physicalSignsList" - :key="physicalSign.id" - :label="physicalSign.name" - :value="physicalSign.id" - > - </el-option> - </el-select> - </el-form-item> + </el-option> + </el-select> + </el-form-item> <el-form-item> <el-button type="cyan" icon="el-icon-search" @click="handleQuery" @@ -330,8 +335,18 @@ <el-row :gutter="15"> <el-form ref="form" :model="form" :rules="rules" label-width="100px"> <el-col :span="12"> - <el-form-item label="进粉渠道" prop="channelId" style="width:400px"> - <el-select v-model="form.channelId" placeholder="请选择" filterable clearable @change="channelAutoSelectNutritionist"> + <el-form-item + label="进粉渠道" + prop="channelId" + style="width: 400px" + > + <el-select + v-model="form.channelId" + placeholder="请选择" + filterable + clearable + @change="channelAutoSelectNutritionist" + > <el-option v-for="dict in accountIdOptions" :key="dict.dictValue" @@ -356,12 +371,12 @@ </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="客户名字" prop="name" style="width:300px"> + <el-form-item label="客户名字" prop="name" style="width: 300px"> <el-input v-model.trim="form.name" placeholder="请输入名字" /> </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="手机号" prop="phone" style="width:300px"> + <el-form-item label="手机号" prop="phone" style="width: 300px"> <el-input v-model.trim="form.phone" placeholder="请输入手机号" /> </el-form-item> </el-col> @@ -413,8 +428,6 @@ </el-select> </el-form-item> </el-col> - - </el-form> </el-row> <div slot="footer" class="dialog-footer"> @@ -508,7 +521,7 @@ export default { assistantDietitian: null, afterDietitian: null, salesman: null, - physicalSignsId: null + physicalSignsId: null, }, // 表单参数 form: {}, @@ -551,7 +564,7 @@ export default { }, }, //病史体征 - physicalSignsList:[] + physicalSignsList: [], }; }, created() { @@ -573,8 +586,8 @@ export default { } }); this.getList(); - listPhysicalSigns().then(response => { - this.physicalSignsList = response.rows; + listPhysicalSigns().then((response) => { + this.physicalSignsList = response.rows; }); }, computed: { @@ -789,52 +802,68 @@ export default { }) .catch(function () {}); }, - channelAutoSelectNutritionist(channelValue){ - this.form.fansChannel = channelValue == "" ? null : channelValue; - if(channelValue == undefined || channelValue == null || channelValue == ""){ - this.form.mainDietitian = null; - return; - } - if(this.form.fansTime == undefined || this.form.fansTime == null){ - this.form.mainDietitian = null; - return; - } - this.autoSelectNutritionist(); + channelAutoSelectNutritionist(channelValue) { + this.form.fansChannel = channelValue == "" ? null : channelValue; + if ( + channelValue == undefined || + channelValue == null || + channelValue == "" + ) { + this.form.mainDietitian = null; + return; + } + if (this.form.fansTime == undefined || this.form.fansTime == null) { + this.form.mainDietitian = null; + return; + } + this.autoSelectNutritionist(); }, - fanTimeAutoSelectNutritionist(fansTime){ - this.form.fansTime = fansTime; - if(fansTime == undefined || fansTime == null){ - this.form.mainDietitian = null; - return; - } - if(this.form.fansChannel == undefined || this.form.fansChannel == null || this.form.fansChannel == ""){ - this.form.mainDietitian = null; - return; - } - this.autoSelectNutritionist(); + fanTimeAutoSelectNutritionist(fansTime) { + this.form.fansTime = fansTime; + if (fansTime == undefined || fansTime == null) { + this.form.mainDietitian = null; + return; + } + if ( + this.form.fansChannel == undefined || + this.form.fansChannel == null || + this.form.fansChannel == "" + ) { + this.form.mainDietitian = null; + return; + } + this.autoSelectNutritionist(); }, - autoSelectNutritionist(){ - getLiveSchedulByTime({'fanChannel':this.form.fansChannel,'liveStartTimeString':encodeURIComponent(this.form.fansTime)}).then((response) => { - if (response.code === 200) { - let live = response.data; - if(live != undefined && live != null && live.liveNutritionistId != null && this.nutritionistIdOptions != null){ - let mainDietitian = null; - this.nutritionistIdOptions.forEach((item,index) => { - if(live.liveNutritionistId == item.dictValue){ - mainDietitian = live.liveNutritionistId; - } - if(index == this.nutritionistIdOptions.length - 1){ - this.form.mainDietitian = mainDietitian; - } - }); - }else{ - this.form.mainDietitian = null; - } - }else{ - this.form.mainDietitian = null; + autoSelectNutritionist() { + getLiveSchedulByTime({ + fanChannel: this.form.fansChannel, + liveStartTimeString: encodeURIComponent(this.form.fansTime), + }).then((response) => { + if (response.code === 200) { + let live = response.data; + if ( + live != undefined && + live != null && + live.liveNutritionistId != null && + this.nutritionistIdOptions != null + ) { + let mainDietitian = null; + this.nutritionistIdOptions.forEach((item, index) => { + if (live.liveNutritionistId == item.dictValue) { + mainDietitian = live.liveNutritionistId; } - }); - } + if (index == this.nutritionistIdOptions.length - 1) { + this.form.mainDietitian = mainDietitian; + } + }); + } else { + this.form.mainDietitian = null; + } + } else { + this.form.mainDietitian = null; + } + }); + }, }, }; </script> diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue index 04f56f3e1..94a390e71 100644 --- a/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue +++ b/stdiet-ui/src/views/custom/message/messageBrowser/Comment.vue @@ -1,7 +1,9 @@ <template> - <div class="topic_comment_item"> + <div class="topic_comment_item" @click="handOnClick(data)"> <div class="comment_avatar"> - <el-avatar size="medium">{{ data.fromName.substr(-1) }}</el-avatar> + <el-avatar size="medium" :src="data.fromAvatar || ''">{{ + data.fromName.substr(-1) + }}</el-avatar> </div> <div class="comment_content"> <div class="content_title"> @@ -10,11 +12,7 @@ <div class="content_type">{{ data.content }}</div> <div class="content_time"> {{ formatDate(data.createTime) }} - <div - v-if="data.fromUid !== userId.toString()" - class="reply_btn" - @click="handOnClick(data)" - > + <div v-if="data.fromUid !== userId.toString()" class="reply_btn"> 回复 </div> </div> @@ -30,7 +28,7 @@ export default { return { roleDict: { customer: "客户", - dietician: "主营养师", + dietician: "主任营养师", after_sale: "售后营养师", dietician_assistant: "营养师助理", }, @@ -61,6 +59,7 @@ export default { .topic_comment_item { margin: 12px; display: flex; + cursor: pointer; .comment_avatar { flex: 0 0 36px; @@ -87,7 +86,7 @@ export default { .reply_btn { margin-left: 16px; color: #1890ff; - cursor: pointer; + // cursor: pointer; } } } diff --git a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue index 2e90a4659..dac7a0d1b 100644 --- a/stdiet-ui/src/views/custom/message/messageBrowser/index.vue +++ b/stdiet-ui/src/views/custom/message/messageBrowser/index.vue @@ -31,12 +31,19 @@ </div> <div class="topic_detail"> <div class="topic_detail_list"> - <div class="topic_detail_title" v-if="!!detailData.content"> - <div>{{ detailData.content }}</div> - <div class="content_time" :style="{ marginTop: '4px' }"> - {{ formatDate(detailData.createTime) }} - <div class="reply_btn" @click="handleOnReplyTopic(detailData)"> - 回复 + <div + class="topic_detail_title" + v-if="!!detailData.content" + @click="handleOnReplyTopic(detailData)" + > + <el-avatar :src="detailData.avatar">{{ + detailData.name.substr(-1) + }}</el-avatar> + <div :style="{ marginLeft: '8px' }"> + <div>{{ detailData.content }}</div> + <div class="content_time" :style="{ marginTop: '4px' }"> + {{ formatDate(detailData.createTime) }} + <div class="reply_btn">回复</div> </div> </div> </div> @@ -83,12 +90,8 @@ import { createNamespacedHelpers, mapActions as globalMapActions } from "vuex"; import Comment from "./Comment"; import dayjs from "dayjs"; import { keys } from "@/utils/websocket"; -const { - mapActions, - mapState, - mapMutations, - mapGetters, -} = createNamespacedHelpers("message"); +const { mapActions, mapState, mapMutations, mapGetters } = + createNamespacedHelpers("message"); export default { data() { return { @@ -179,14 +182,17 @@ export default { return dayjs(date).format("MM-DD HH:mm"); }, handleOnTopicClick(data) { - this.replyTarget = ""; - this.replyContent = ""; - this.replyObj = {}; - this.fetchTopicDetailActions({ - topicId: data.topicId, - id: data.id, - uid: data.uid, - }); + if (data.topicId !== this.selTopicId) { + this.replyTarget = ""; + this.replyContent = ""; + this.replyObj = {}; + this.fetchTopicDetailActions({ + topicId: data.topicId, + id: data.id, + uid: data.uid, + callback: (err) => this.$message.error(err), + }); + } }, handleOnReplyTopic(data) { this.replyTarget = "主题"; @@ -340,11 +346,13 @@ export default { .reply_btn { margin-left: 16px; color: #1890ff; - cursor: pointer; + // cursor: pointer; } } .topic_detail_title { + display: flex; + cursor: pointer; } .comment_reply_item {