EmrChatBox.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <el-dialog v-model="dialog" title="病历人数" width="70%"
  3. @closed="emits('closed')">
  4. <div class="chat_room_dialog">
  5. <div class="left">
  6. <el-table :data="props.userList" :height="getWindowSize.h / 1.5">
  7. <el-table-column prop="name" label="姓名">
  8. <template #default="{row}">
  9. <span v-if="row.code === userData.code">本人</span>
  10. </template>
  11. </el-table-column>
  12. <el-table-column prop="deptName" label="科室"/>
  13. </el-table>
  14. </div>
  15. <div class="right">
  16. <el-scrollbar :height="getWindowSize.h / 1.8 " ref="scrollbarRef">
  17. <div ref="innerRef">
  18. <div v-for="item in chatHistory" class="list">
  19. <div class="chat_right"
  20. v-if="whetherInPerson(item.code)">
  21. <div style="display: flex; ">
  22. <div style="font-size: 12px;margin-right: 10px">
  23. <div style="text-align: right">
  24. {{ item.date }} {{ item.deptName }} {{ item.name }}
  25. </div>
  26. <div class="message_str" style="float: right;">
  27. {{ item.message }}
  28. </div>
  29. </div>
  30. <div>
  31. <el-avatar shape="square" :src="item.avatar" :size="30"/>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="chat_left" v-else>
  36. <div style="display: flex;">
  37. <div>
  38. <el-avatar shape="square" :src="item.avatar" :size="30"/>
  39. </div>
  40. <div style="font-size: 12px;margin-left: 10px">
  41. <div>{{ item.name }} {{ item.deptName }} {{ item.date }}</div>
  42. <div class="message_str" :class="judgmentQMy(item.message) ? 'specify_me' : '' ">
  43. {{ item.message }}
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </el-scrollbar>
  51. <div>
  52. <el-input type="textarea"
  53. :rows="3"
  54. v-model="messageStr"
  55. @keydown.enter.stop="clickSend"/>
  56. <div style="float: right">
  57. <el-button @click="modifyTheCurrentMedicalRecord">修改当前病历</el-button>
  58. <el-button @click="clickSend">发送</el-button>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </el-dialog>
  64. </template>
  65. <script setup name='EmrChatBox'>
  66. import {getWindowSize} from "@/utils/window-size";
  67. import store from "@/store";
  68. import {getChatHistoryBySid, sendAMessage} from "@/api/zhu-yuan-yi-sheng/emr-socket";
  69. import {stringIsBlank} from "@/utils/blank-utils";
  70. import {xcMessage} from "@/utils/xiaochan-element-plus";
  71. let userData = store.state.user.info
  72. const chatHistory = ref([])
  73. const props = defineProps({
  74. userList: {
  75. type: Array
  76. },
  77. sid: {
  78. type: String
  79. },
  80. currentEditorUser: {
  81. type: Object,
  82. default: null
  83. }
  84. })
  85. const emits = defineEmits(['closed'])
  86. const dialog = ref(true)
  87. const messageStr = ref('')
  88. const scrollbarRef = ref('')
  89. const innerRef = ref('')
  90. const clickSend = async () => {
  91. if (stringIsBlank(messageStr.value)) {
  92. return xcMessage.error('不能发送空白消息。')
  93. }
  94. await sendAMessage(props.sid, messageStr.value)
  95. messageStr.value = ''
  96. await queryJump()
  97. }
  98. const modifyTheCurrentMedicalRecord = async () => {
  99. if (props.currentEditorUser === null) {
  100. return xcMessage.error('当前没有人正在编辑');
  101. }
  102. if (stringIsBlank(props.currentEditorUser.name)) {
  103. return xcMessage.error('当前没有人正在编辑');
  104. }
  105. await sendAMessage(props.sid, '@' + props.currentEditorUser.name + ' 申请修改病历,请尽快保存,后离开当前病历【系统自动发送】');
  106. messageStr.value = ''
  107. await queryJump()
  108. }
  109. const queryJump = async () => {
  110. chatHistory.value = await getChatHistoryBySid(props.sid)
  111. await nextTick()
  112. scrollbarRef.value.setScrollTop(innerRef.value.scrollHeight)
  113. }
  114. const whetherInPerson = (code) => {
  115. return userData.code === code
  116. }
  117. const judgmentQMy = (val) => {
  118. return val.startsWith('@' + userData.name)
  119. }
  120. onMounted(async () => {
  121. await nextTick()
  122. await queryJump()
  123. })
  124. defineExpose({
  125. queryJump
  126. })
  127. </script>
  128. <style scoped lang="scss">
  129. .chat_room_dialog {
  130. display: flex;
  131. width: 100%;
  132. .left {
  133. width: 200px;
  134. }
  135. .right {
  136. flex: 1;
  137. height: max-content;
  138. }
  139. }
  140. .list {
  141. width: 100%;
  142. .specify_me {
  143. background-color: red;
  144. color: white;
  145. }
  146. .chat_right {
  147. display: flex;
  148. justify-content: flex-end;
  149. padding: 5px 10px;
  150. }
  151. .chat_left {
  152. display: flex;
  153. padding: 5px 10px;
  154. }
  155. .message_str {
  156. border: 1px solid #000;
  157. padding: 5px;
  158. width: max-content;
  159. border-radius: 5px;
  160. }
  161. }
  162. .chat_history_div {
  163. height: max-content;
  164. display: flex;
  165. .user_info {
  166. padding: 0 10px;
  167. }
  168. .message {
  169. border: 1px solid #000;
  170. padding: 5px;
  171. width: max-content;
  172. border-radius: 10px;
  173. }
  174. }
  175. </style>