craftFilesTable.vue 4.2 KB

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