赫艾前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
6.7 KiB

  1. <template>
  2. <div>
  3. <el-dialog
  4. :title="'沟通记录 - 回复'"
  5. :close-on-click-modal="false"
  6. width="450px"
  7. @close="closeDialog()"
  8. :visible.sync="visible">
  9. <el-form :model="dataForm" :inline="true" label-position="top" ref="dataForm"
  10. label-width="80px">
  11. <el-row >
  12. <el-col :span="24">
  13. <el-form-item label="内容">
  14. <el-input type="textarea" style="width: 305px" v-model="dataForm.content"></el-input>
  15. </el-form-item>
  16. </el-col>
  17. </el-row>
  18. <el-row style="margin-top: 20px" >
  19. <el-col :span="24">
  20. <el-form-item label="附件" >
  21. <el-input style="width: 305px; color: red" readonly v-model="dataForm.fileName"></el-input>
  22. </el-form-item>
  23. <el-form-item style="margin-top: 24px" >
  24. <ftp-upload @childByValue="childByValue"></ftp-upload>
  25. </el-form-item>
  26. </el-col>
  27. </el-row>
  28. <el-row >
  29. <el-col :span="24">
  30. <span style="font-size: 12px">附件清单</span>
  31. <el-table
  32. :data="fileList"
  33. border
  34. :height="height"
  35. highlight-current-row
  36. style="width: 100%;">
  37. <el-table-column
  38. v-for="(item,index) in columnList" :key="index"
  39. :sortable="item.columnSortable"
  40. :prop="item.columnProp"
  41. :header-align="'center'"
  42. :show-overflow-tooltip="item.showOverflowTooltip"
  43. :align="item.align"
  44. :fixed="item.fixed==''?false:item.fixed"
  45. :width="item.columnWidth"
  46. :label="item.columnLabel">
  47. <template slot-scope="scope">
  48. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  49. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  50. style="width: 100px; height: 80px"/></span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. fixed="right"
  55. header-align="center"
  56. align="center"
  57. width="80"
  58. label="操作">
  59. <template slot-scope="scope">
  60. <el-link type="text" size="small" @click="deleteFile(scope.row)">删除</el-link>
  61. <el-link type="text" size="small" @click="downFtpFile(scope.row)"> | 下载</el-link>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. </el-col>
  66. </el-row>
  67. </el-form>
  68. <span slot="footer" class="dialog-footer">
  69. <el-button type="primary" @click="saveChatting()">发送</el-button>
  70. <el-button type="primary" @click="visible = false">关闭</el-button>
  71. </span>
  72. </el-dialog>
  73. </div>
  74. </template>
  75. <script>
  76. import FtpUpload from '@/views/modules/common/ftp-upload.vue'
  77. import {saveChatHistory} from '@/api/taskmanage/chatHistory.js'
  78. import axios from "axios";
  79. import Vue from "vue";
  80. export default {
  81. data() {
  82. return {
  83. visible: false,
  84. height: 200,
  85. // 展示列集
  86. columnList: [
  87. {
  88. columnProp: "fileName",
  89. columnLabel: "文件名",
  90. columnHidden: false,
  91. columnImage: false,
  92. columnSortable: false,
  93. columnWidth: null,
  94. format: null,
  95. sortLv: 0,
  96. status: true,
  97. fixed: '',
  98. serialNumber: null,
  99. columnType: null,
  100. align: null
  101. },
  102. {
  103. columnProp: "fileType",
  104. columnLabel: "文件类型",
  105. columnHidden: false,
  106. columnImage: false,
  107. columnSortable: false,
  108. columnWidth: null,
  109. format: null,
  110. sortLv: 0,
  111. status: true,
  112. fixed: '',
  113. serialNumber: null,
  114. columnType: null,
  115. align: null
  116. }
  117. ],
  118. userList: [],
  119. dataListSelections: [],
  120. dataForm: {
  121. site: '',
  122. userName: '',
  123. content: '',
  124. createdBy: '',
  125. createDate: '',
  126. ossIds: [],
  127. fileName: '',
  128. taskId: 0,
  129. },
  130. fileList: []
  131. }
  132. },
  133. components:{
  134. FtpUpload
  135. },
  136. methods: {
  137. init(id) {
  138. this.dataForm.taskId = id
  139. this.visible = true
  140. },
  141. childByValue(childValue) {
  142. // childValue就是子组件传过来的值
  143. this.dataForm.fileName = childValue.fileName
  144. this.fileList.push(childValue)
  145. },
  146. // 移除附件
  147. deleteFile(row){
  148. this.fileList = this.fileList.filter(item => item.fileName != row.fileName)
  149. },
  150. // 下载附件
  151. downFtpFile(row){
  152. //'/proxyApi/ftp/file/downFtpFile/'
  153. axios.get( '/api/ftp/file/downFtpFile/' + row.id, {
  154. responseType: 'blob',
  155. headers: {
  156. 'Content-Type': 'application/json',
  157. 'token': Vue.cookie.get('token')
  158. }
  159. }).then(({data}) => {
  160. // 不限制文件下载类型
  161. const blob = new Blob([data], {type: "application/octet-stream"})
  162. // 下载文件名称
  163. const fileName = row.fileName
  164. // a标签下载
  165. const linkNode = document.createElement('a')
  166. linkNode.download = fileName // a标签的download属性规定下载文件的名称
  167. linkNode.style.display = 'none'
  168. linkNode.href = URL.createObjectURL(blob) // 生成一个Blob URL
  169. document.body.appendChild(linkNode)
  170. linkNode.click() // 模拟在按钮上的一次鼠标单击
  171. URL.revokeObjectURL(linkNode.href) // 释放URL 对象
  172. document.body.removeChild(linkNode)
  173. // }
  174. })
  175. },
  176. // 保存记录
  177. saveChatting(){
  178. this.dataForm.site = this.$store.state.user.site
  179. this.dataForm.userName = this.$store.state.user.name
  180. this.dataForm.ossIds = this.fileList.map(item => item.id)
  181. this.dataForm.createdBy = this.$store.state.user.name
  182. this.dataForm.createDate = this.dayjs().format("YYYY-MM-DD HH:mm:ss")
  183. saveChatHistory(this.dataForm).then(({data}) =>{
  184. if (data && data.code == 0){
  185. this.visible = false
  186. this.$message.success(data.msg)
  187. this.$emit('refreshDataList')
  188. }else{
  189. this.$message.error(data.msg)
  190. }
  191. })
  192. },
  193. closeDialog(){
  194. Object.assign(this.$data, this.$options.data())
  195. }
  196. },
  197. created() {
  198. }
  199. }
  200. </script>