index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <byProductSearch @search="reload" ref="searchRef"> </byProductSearch>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. row-key="id"
  11. cache-key="pickKey"
  12. :selection.sync="selection"
  13. autoAmendPage
  14. :parse-data="parseData"
  15. @update:selection="handleSelectionChange"
  16. >
  17. <template v-slot:toolbar>
  18. <el-button type="primary" size="mini" @click="handByProd">新建回收单</el-button>
  19. </template>
  20. <template v-slot:formedNum="{ row }">
  21. {{ row.notFormedNum || 0 }} / {{ row.formedNum || 0 }}
  22. </template>
  23. <template v-slot:weight="{ row }">
  24. {{ row.weight || 0 }} / {{ row.weightUnit }}
  25. </template>
  26. <template v-slot:action="{ row }">
  27. <el-button type="text" size="mini">详情</el-button>
  28. </template>
  29. </ele-pro-table>
  30. </el-card>
  31. <addByProduct v-if="addByProductShow" @close="close"></addByProduct>
  32. </div>
  33. </template>
  34. <script>
  35. import { getPage } from '@/api/byProduct/index';
  36. import byProductSearch from './components/byProduct-search.vue';
  37. import addByProduct from './components/addByProduct.vue';
  38. export default {
  39. components: {
  40. byProductSearch,
  41. addByProduct
  42. },
  43. data() {
  44. return {
  45. // 加载状态
  46. loading: false,
  47. selection: [],
  48. addByProductShow: false
  49. };
  50. },
  51. computed: {
  52. columns() {
  53. return [
  54. {
  55. columnKey: 'index',
  56. label: '序号',
  57. type: 'index',
  58. width: 55,
  59. align: 'center',
  60. showOverflowTooltip: true,
  61. fixed: 'left'
  62. },
  63. {
  64. prop: 'code',
  65. label: '回收单号',
  66. align: 'left',
  67. width: '300'
  68. },
  69. {
  70. prop: 'workOrderCode',
  71. label: '工单编码',
  72. align: 'center'
  73. },
  74. {
  75. prop: 'taskName',
  76. label: '工序',
  77. align: 'center'
  78. },
  79. {
  80. prop: 'categoryCode',
  81. label: '物品编码',
  82. align: 'center'
  83. },
  84. {
  85. prop: 'categoryName',
  86. label: '物品名称',
  87. align: 'center'
  88. },
  89. {
  90. prop: 'formedNum',
  91. slot: 'formedNum',
  92. label: '不合格品/合格品数量',
  93. align: 'center',
  94. width: 140
  95. },
  96. {
  97. prop: 'weight',
  98. slot: 'weight',
  99. label: '重量',
  100. align: 'center',
  101. width: 140
  102. },
  103. {
  104. prop: 'executorName',
  105. label: '回收人',
  106. align: 'center',
  107. width: 95
  108. },
  109. {
  110. prop: 'createTime',
  111. label: '创建时间',
  112. align: 'center',
  113. width: 95
  114. },
  115. {
  116. prop: '',
  117. label: '操作',
  118. width: 80,
  119. align: 'center',
  120. resizable: false,
  121. fixed: 'right',
  122. slot: 'action'
  123. }
  124. ];
  125. }
  126. },
  127. created() {},
  128. methods: {
  129. /* 表格数据源 */
  130. async datasource({ page, limit, where }) {
  131. let parma = {
  132. ...where,
  133. pageNum: page,
  134. size: limit
  135. };
  136. let res = await getPage(parma);
  137. return res;
  138. },
  139. /* 数据转为树形结构 */
  140. parseData(data) {
  141. return {
  142. ...data,
  143. list: this.$util.toTreeData({
  144. data: data.list,
  145. count: data.total,
  146. idField: 'id',
  147. parentIdField: 'parentId'
  148. })
  149. };
  150. },
  151. handleSelectionChange(data) {
  152. console.log(data);
  153. },
  154. /* 刷新表格 */
  155. reload(where = {}) {
  156. this.$refs.table.reload({ page: 1, where });
  157. },
  158. handByProd() {
  159. this.addByProductShow = true;
  160. },
  161. close(val) {
  162. if(val) {
  163. this.reload();
  164. }
  165. this.addByProductShow = false;
  166. },
  167. }
  168. };
  169. </script>