record.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. this.getMsgList()
  90. }
  91. },
  92. data() {
  93. return {
  94. msgList: [],
  95. replyId:'',
  96. msgData: {
  97. business_id: '',
  98. msg: '',
  99. reply_id: 0,
  100. msg_img: [],
  101. file_list: [],
  102. },
  103. isAjax:false
  104. }
  105. },
  106. methods: {
  107. setMsg() {
  108. console.log('------butClick--------------')
  109. if (this.isAjax) {
  110. return;
  111. }
  112. // this.isAjax=true;
  113. this.msgData.business_id = this.businessId
  114. if (this.replyId) {
  115. this.msgData.reply_id = this.replyId;
  116. }
  117. setMsg(this.msgData).then((res) => {
  118. if (res.code === 1) {
  119. tools.success(res.msg)
  120. this.msgData.reply_id=''
  121. this.msgData.msg=''
  122. this.msgData.msg_img=[]
  123. this.getMsgList()
  124. this.$refs.popup.close()
  125. } else {
  126. tools.error(res.msg)
  127. this.isAjax = false;
  128. }
  129. })
  130. },
  131. openFile(file) {
  132. if (!file.url) {
  133. tools.error('下载地址不存在')
  134. return
  135. }
  136. tools.showLoading()
  137. uni.downloadFile({
  138. url: file.url, //仅为示例,并非真实的资源
  139. success: (dRes) => {
  140. tools.hideLoading()
  141. if (dRes.statusCode === 200) {
  142. tools.success('下载成功')
  143. uni.saveFile({
  144. tempFilePath: dRes.tempFilePath,
  145. success: (res) => {
  146. uni.openDocument({
  147. filePath: res.savedFilePath,
  148. showMenu: true,
  149. success: function (res) {
  150. }
  151. });
  152. }
  153. });
  154. }
  155. }
  156. });
  157. },
  158. getMsgList() {
  159. if(this.businessId<=0){
  160. return
  161. }
  162. getMsgList({
  163. 'business_id': this.businessId
  164. }).then((res) => {
  165. if (res.code === 1) {
  166. this.msgList = res.data;
  167. // this.setImgList()
  168. }
  169. })
  170. },
  171. moveHandle() {
  172. return false
  173. },
  174. onSendChat(replyId) {
  175. this.replyId=replyId
  176. this.$refs.popup.open('bottom')
  177. },
  178. onClose() {
  179. this.$refs.popup.close('bottom')
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .record-box {
  186. .reply-box {
  187. position: relative;
  188. }
  189. .reply-top {
  190. width: 98rpx;
  191. height: 45rpx;
  192. background: #0FB160;
  193. border-radius: 6rpx;
  194. opacity: 0.1;
  195. }
  196. .reply-buttom {
  197. width: 98rpx;
  198. height: 45rpx;
  199. line-height: 45rpx;
  200. text-align: center;
  201. position: absolute;
  202. top: 0;
  203. color: #0FB160;
  204. }
  205. }
  206. .empty-box {
  207. width: 80rpx;
  208. }
  209. .image-box {
  210. display: flex;
  211. flex-wrap: wrap;
  212. .reply-img {
  213. width: 130rpx;
  214. height: 130rpx;
  215. display: block;
  216. }
  217. }
  218. .file-item:last-child {
  219. margin-bottom: 0;
  220. }
  221. </style>