record.vue 7.2 KB

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