record.vue 6.0 KB

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