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.

203 lines
5.6 KiB

11 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <template>
  2. <div class="customer-css">
  3. <el-table
  4. :height="searchData.height"
  5. :data="fileList"
  6. border
  7. v-loading="dataListLoading"
  8. style="width: 100%;">
  9. <el-table-column
  10. fixed="right"
  11. header-align="center"
  12. align="center"
  13. width="120"
  14. :label="'Actions'">
  15. <template slot-scope="scope">
  16. <a class="customer-a" @click="handleDownload(scope.row)">View </a>
  17. <!-- <a class="customer-a" @click="deleteFile(scope.row)"> Delete</a>-->
  18. </template>
  19. </el-table-column>
  20. <el-table-column
  21. v-for="(item,index) in attachmentColumnArray" :key="index"
  22. :sortable="item.columnSortable"
  23. :prop="item.columnProp"
  24. :header-align="item.headerAlign"
  25. :show-overflow-tooltip="item.showOverflowTooltip"
  26. :align="item.align"
  27. :fixed="item.fixed==''?false:item.fixed"
  28. :min-width="item.columnWidth"
  29. :label="item.columnLabel">
  30. <template slot-scope="scope">
  31. <span v-if="item.columnProp === 'createDate'">{{ formatDateTime(scope.row.createDate) }}</span>
  32. <span v-else-if="item.columnProp === 'orderRef3'">
  33. <span v-if="scope.row.orderRef3 === '0'">Task</span>
  34. <span v-else>{{ scope.row.orderRef3 }}</span>
  35. </span>
  36. <span v-else-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. </div>
  41. </template>
  42. <script>
  43. import { queryTaskFiles, previewOssFileById, removeOss } from '@/api/oss/oss.js'
  44. export default {
  45. data() {
  46. return {
  47. searchData: {
  48. site: '',
  49. buNo: '',
  50. taskNo: '',
  51. height: 200
  52. },
  53. fileList: [],
  54. dataListLoading: false,
  55. attachmentColumnArray: [
  56. {
  57. columnProp: "orderRef3",
  58. headerAlign: "center",
  59. align: "center",
  60. columnLabel: "ItemNo",
  61. columnWidth: '80',
  62. columnHidden: false,
  63. columnSortable: false,
  64. fixed: false,
  65. showOverflowTooltip: false
  66. },
  67. {
  68. columnProp: "fileName",
  69. headerAlign: "center",
  70. align: "left",
  71. columnLabel: "Filename",
  72. columnWidth: '200',
  73. columnHidden: false,
  74. columnSortable: false,
  75. fixed: false,
  76. showOverflowTooltip: true
  77. },
  78. {
  79. columnProp: "createdBy",
  80. headerAlign: "center",
  81. align: "center",
  82. columnLabel: "CreatedBy",
  83. columnWidth: '100',
  84. columnHidden: false,
  85. columnSortable: false,
  86. fixed: false,
  87. showOverflowTooltip: false
  88. },
  89. {
  90. columnProp: "createDate",
  91. headerAlign: "center",
  92. align: "center",
  93. columnLabel: "CreateDate",
  94. columnWidth: '160',
  95. columnHidden: false,
  96. columnSortable: false,
  97. fixed: false,
  98. showOverflowTooltip: false
  99. }
  100. ]
  101. }
  102. },
  103. methods: {
  104. init(data) {
  105. this.searchData = Object.assign({}, this.searchData, data);
  106. this.getFileList();
  107. },
  108. getFileList() {
  109. if (!this.searchData.taskNo) return;
  110. this.dataListLoading = true;
  111. // 查询任务相关的所有文件
  112. const queryData = {
  113. orderRef1: this.searchData.site,
  114. orderRef2: this.searchData.taskNo
  115. };
  116. queryTaskFiles(queryData).then(({data}) => {
  117. if (data && data.code === 0) {
  118. this.fileList = data.data || [];
  119. } else {
  120. this.$message.error('查询失败:' + (data ? data.msg : '网络错误'));
  121. this.fileList = [];
  122. }
  123. this.dataListLoading = false;
  124. }).catch((error) => {
  125. this.$message.error('查询失败:' + error.message);
  126. this.fileList = [];
  127. this.dataListLoading = false;
  128. });
  129. },
  130. handleDownload(row) {
  131. let selectList = [];
  132. selectList.push(row);
  133. for (let i = 0; i < selectList.length; i++) {
  134. let params = {
  135. id: selectList[i].id,
  136. }
  137. previewOssFileById(params).then((response) => {
  138. const blob = new Blob([response.data], { type: response.headers['content-type'] });
  139. const link = document.createElement('a');
  140. link.href = URL.createObjectURL(blob);
  141. link.setAttribute('download', selectList[i].fileName);
  142. link.target = '_blank';
  143. link.click();
  144. URL.revokeObjectURL(link.href);
  145. });
  146. }
  147. },
  148. deleteFile(row) {
  149. this.$confirm('确定要删除该文件吗?', '提示', {
  150. confirmButtonText: '确定',
  151. cancelButtonText: '取消',
  152. type: 'warning'
  153. }).then(() => {
  154. removeOss([row.id]).then(({data}) => {
  155. if (data && data.code === 0) {
  156. this.$message.success('删除成功');
  157. this.getFileList(); // 重新加载文件列表
  158. } else {
  159. this.$message.warning(data.msg);
  160. }
  161. }).catch((error) => {
  162. this.$message.error('删除失败:' + error.message);
  163. });
  164. });
  165. },
  166. formatDateTime(dateTime) {
  167. if (!dateTime) return '';
  168. // 处理日期时间格式化
  169. if (typeof dateTime === 'string') {
  170. return dateTime.replace('T', ' ').substring(0, 19);
  171. }
  172. return dateTime;
  173. }
  174. }
  175. }
  176. </script>
  177. <style scoped lang="scss">
  178. .customer-bun-min {
  179. min-width: 80px;
  180. }
  181. .customer-a {
  182. color: #409EFF;
  183. cursor: pointer;
  184. text-decoration: none;
  185. }
  186. .customer-a:hover {
  187. color: #66b1ff;
  188. }
  189. .rq .auto /deep/ .el-form-item__content {
  190. height: auto;
  191. line-height: 1.5;
  192. }
  193. </style>