record.vue 6.0 KB

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