record.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="text-color-12">
  3. <view class="sys-background-fff m-20 p-20 r-20" v-for="(msg,index) in msgList" :key="index">
  4. <view class="record-box row-justify-sb">
  5. <view class="row-c">
  6. <image class="wh-80 sys-radius-50" :src="msg.head_img" mode="aspectFill"></image>
  7. <view class="column m-l16">
  8. <text class="size-26 sys-weight-600">{{ msg.name }}</text>
  9. <text class="size-24 text-color-999">{{ msg.position_name }}</text>
  10. </view>
  11. </view>
  12. <view class="reply-box size-24">
  13. <view class="reply-top size-24"></view>
  14. <view class="reply-buttom size-24" @click="onSendChat(msg.id)">回复</view>
  15. </view>
  16. </view>
  17. <view class="row m-t20 ">
  18. <view class="empty-box"></view>
  19. <view class="m-l16 size-26 flex">
  20. <!-- 自己发送 -->
  21. <text> {{ msg.msg }}</text>
  22. <view class="image-box" v-if="msg.msg_img.length>0">
  23. <EnImageVideo @onShowImg="onPreviewImage" :img-list="msg.msg_img"></EnImageVideo>
  24. </view>
  25. <!-- 文件类型 -->
  26. <view class="sys-from-background-color p-20 r-20 m-t20" v-if="msg.file_list.length>0">
  27. <view class="file-item row-c m-b20" @click.stop="openFile(file)"
  28. v-for="(file,fileIndex) in msg.file_list" :key="index">
  29. <image class="wh-45 m-r20" src="/page_task/static/img/task-details/icon-pdf.png"
  30. v-if="file.file_type===1" mode="aspectFill"></image>
  31. <image class="wh-45 m-r20" src="page_task//static/img/task-details/icon-word.png"
  32. v-else-if="file.file_type===2" mode="aspectFill"> </image>
  33. <image class="wh-45 m-r20" src="/page_task/static/img/task-details/icon-excel.png" v-else
  34. mode="aspectFill"> </image>
  35. <text class="size-24 color-111827">{{ file.name }}</text>
  36. </view>
  37. </view>
  38. <!-- 1对1回复 -->
  39. <view class="sys-from-background-color p-20 m-t10 r-20" v-if="msg.reply_list.length>0">
  40. <view class="m-t10" v-for="replyItem in msg.reply_list">
  41. <text class="color-00A775">{{ replyItem.name }}</text><text
  42. class="m-lr10 text-color-666">回复</text><text
  43. class="color-00A775">{{ replyItem.ru_name }}:</text>
  44. <view class="">
  45. <view class="m-t16">{{ replyItem.msg }}</view>
  46. <view class="image-box" v-if="replyItem.msg_img.length>0">
  47. <EnImageVideo @onShowImg="onPreviewImage" :img-list="replyItem.msg_img"></EnImageVideo>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="row m-t20 ">
  55. <view class="empty-box"></view>
  56. <view class="size-22 text-color-999 m-l16">{{ msg.created_at }}</view>
  57. </view>
  58. </view>
  59. <en-blank v-if="msgList.length<=0"></en-blank>
  60. <uni-popup ref="popup" type="bottom" @touchmove.stop.prevent="moveHandle">
  61. <view class="page-env-160 sys-background-fff r-20">
  62. <view class="row-justify-sb center p-lr30 p-t30">
  63. <view class="wh-25"></view>
  64. <text class="size-30 sys-weight-600">任务反馈</text>
  65. <image class="wh-25" src="/page_task/static/img/task-details/close.png" mode="" @click="onClose">
  66. </image>
  67. </view>
  68. <SendChat is_button @butClick="setMsg" v-model="msgData"></SendChat>
  69. </view>
  70. </uni-popup>
  71. </view>
  72. </template>
  73. <script>
  74. import SendChat from "./send_chat.vue"
  75. import {
  76. getMsgList,
  77. setMsg
  78. } from "@/api/task";
  79. import EnImageVideo from "@/components/en-utils/en-image-video/en-image-video.vue";
  80. import tools from "@/service/tools";
  81. import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";
  82. export default {
  83. components: {
  84. EnBlank,
  85. EnImageVideo,
  86. SendChat
  87. },
  88. props: {
  89. businessId: {
  90. default: 0
  91. }
  92. },
  93. watch: {
  94. 'businessId': function() {
  95. }
  96. },
  97. data() {
  98. return {
  99. msgList: [],
  100. replyId: '',
  101. msgData: {
  102. business_id: '',
  103. msg: '',
  104. reply_id: 0,
  105. msg_img: [],
  106. file_list: [],
  107. },
  108. isAjax: false
  109. }
  110. },
  111. methods: {
  112. onPreviewImage(url){
  113. this.$emit('onShowImg',url)
  114. },
  115. startData() {
  116. this.getMsgList()
  117. },
  118. setMsg() {
  119. if (this.isAjax) {
  120. return;
  121. }
  122. // this.isAjax=true;
  123. this.msgData.business_id = this.businessId
  124. if (this.replyId) {
  125. this.msgData.reply_id = this.replyId;
  126. }
  127. setMsg(this.msgData).then((res) => {
  128. if (res.code === 1) {
  129. tools.success(res.msg)
  130. this.msgData.reply_id = ''
  131. this.msgData.msg = ''
  132. this.msgData.msg_img = []
  133. this.getMsgList()
  134. this.$refs.popup.close()
  135. } else {
  136. tools.error(res.msg)
  137. this.isAjax = false;
  138. }
  139. })
  140. },
  141. openFile(file) {
  142. if (!file.url) {
  143. tools.error('下载地址不存在')
  144. return
  145. }
  146. tools.showLoading()
  147. uni.downloadFile({
  148. url: file.url, //仅为示例,并非真实的资源
  149. success: (dRes) => {
  150. tools.hideLoading()
  151. if (dRes.statusCode === 200) {
  152. tools.success('下载成功')
  153. uni.saveFile({
  154. tempFilePath: dRes.tempFilePath,
  155. success: (res) => {
  156. uni.openDocument({
  157. filePath: res.savedFilePath,
  158. showMenu: true,
  159. success: function(res) {}
  160. });
  161. }
  162. });
  163. }
  164. }
  165. });
  166. },
  167. getMsgList() {
  168. if (this.businessId <= 0) {
  169. return
  170. }
  171. getMsgList({
  172. 'business_id': this.businessId
  173. }).then((res) => {
  174. if (res.code === 1) {
  175. this.msgList = res.data;
  176. // this.setImgList()
  177. }
  178. })
  179. },
  180. moveHandle() {
  181. return false
  182. },
  183. onSendChat(replyId) {
  184. this.replyId = replyId
  185. this.$refs.popup.open('bottom')
  186. },
  187. onClose() {
  188. this.$refs.popup.close('bottom')
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. .record-box {
  195. .reply-box {
  196. position: relative;
  197. }
  198. .reply-top {
  199. width: 98rpx;
  200. height: 45rpx;
  201. background: #0FB160;
  202. border-radius: 6rpx;
  203. opacity: 0.1;
  204. }
  205. .reply-buttom {
  206. width: 98rpx;
  207. height: 45rpx;
  208. line-height: 45rpx;
  209. text-align: center;
  210. position: absolute;
  211. top: 0;
  212. color: #0FB160;
  213. }
  214. }
  215. .empty-box {
  216. width: 80rpx;
  217. }
  218. .image-box {
  219. display: flex;
  220. flex-wrap: wrap;
  221. .reply-img {
  222. width: 130rpx;
  223. height: 130rpx;
  224. display: block;
  225. }
  226. }
  227. .file-item:last-child {
  228. margin-bottom: 0;
  229. }
  230. </style>