craftFilesTable.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div>
  3. <seek-page :seekList="seekList" @search="search"></seek-page>
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="datasource"
  8. :cache-key="cacheKeyUrl"
  9. :needPage="false"
  10. height="calc(86vh - 230px)"
  11. >
  12. <template v-slot:action="{ row }">
  13. <el-link type="primary" :underline="false" @click="goToDetail(row)">
  14. 详情
  15. </el-link>
  16. </template>
  17. </ele-pro-table>
  18. <fileBrowse ref="fileBrowseRef"></fileBrowse>
  19. </div>
  20. </template>
  21. <script>
  22. import dictMixins from '@/mixins/dictMixins';
  23. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  24. import { batchRecordPage, filePageAPI } from '@/api/produce/workOrder.js';
  25. import fileBrowse from '@/views/produce/components/picking/fileBrowse.vue';
  26. export default {
  27. mixins: [dictMixins, tableColumnsMixin],
  28. components: { fileBrowse },
  29. props: {
  30. tableQuery: {
  31. type: Object,
  32. default: () => {
  33. return {};
  34. }
  35. }
  36. },
  37. data() {
  38. return {
  39. columns: [
  40. {
  41. width: 50,
  42. type: 'index',
  43. columnKey: 'index',
  44. align: 'center',
  45. label: '序号'
  46. },
  47. {
  48. label: '编码',
  49. prop: 'code',
  50. width: 180,
  51. align: 'center',
  52. showOverflowTooltip: true
  53. },
  54. {
  55. prop: 'name',
  56. label: '文档名称',
  57. align: 'center',
  58. slot: 'name',
  59. showOverflowTooltip: true,
  60. minWidth: 200
  61. },
  62. {
  63. prop: 'storagePath',
  64. label: '文件名称',
  65. align: 'center',
  66. showOverflowTooltip: true,
  67. minWidth: 200,
  68. formatter: (_row, _column, cellValue) => {
  69. return cellValue && cellValue[0]?.name;
  70. }
  71. },
  72. {
  73. prop: 'version',
  74. label: '版本',
  75. align: 'center',
  76. showOverflowTooltip: true,
  77. minWidth: 100
  78. },
  79. {
  80. prop: 'createTime',
  81. label: '创建时间',
  82. showOverflowTooltip: true,
  83. align: 'center',
  84. minWidth: 110
  85. },
  86. {
  87. label: '操作',
  88. columnKey: 'action',
  89. slot: 'action',
  90. showOverflowTooltip: true,
  91. minWidth: 110,
  92. align: 'center',
  93. fixed: 'right'
  94. }
  95. ],
  96. cacheKeyUrl: 'mes-259231537-craft-files-table'
  97. };
  98. },
  99. computed: {
  100. seekList() {
  101. return [
  102. {
  103. label: '工单编码:',
  104. value: 'workOrderCode',
  105. type: 'input',
  106. placeholder: '请输入'
  107. }
  108. ];
  109. }
  110. },
  111. methods: {
  112. // 刷新表格
  113. reload(where = {}) {
  114. this.$refs.table.reload({
  115. where,
  116. ...this.tableQuery
  117. });
  118. },
  119. /* 表格数据源 */
  120. datasource({ page, limit, where, order }) {
  121. // 参数
  122. const body = {
  123. ...where,
  124. ...order,
  125. pageNum: page,
  126. size: limit,
  127. ...this.tableQuery
  128. };
  129. return this.getDataList(body);
  130. },
  131. // 查询数据
  132. async getDataList(body) {
  133. let data = await batchRecordPage(body);
  134. const fileIds = data.map((i) => i.fileId);
  135. if (data.length === 0 || fileIds.length === 0) {
  136. return data;
  137. }
  138. const files = await filePageAPI({ ids: fileIds.join(',') });
  139. data = data
  140. .map((item) => {
  141. const file = files.find((f) => f.id === item.fileId);
  142. return {
  143. ...file,
  144. ...item
  145. };
  146. })
  147. .filter((i) => i.id);
  148. console.log('data', data);
  149. return data;
  150. },
  151. search(where) {
  152. this.reload(where);
  153. },
  154. goToDetail(row) {
  155. // 查询文件信息
  156. this.$refs.fileBrowseRef.setFileUrl(row);
  157. }
  158. }
  159. };
  160. </script>
  161. <style></style>