record.vue 6.3 KB

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