index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <return-search @search="reload" ref="searchRef"> </return-search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. row-key="id"
  11. cache-key="returnKey"
  12. :selection.sync="selection"
  13. >
  14. <template v-slot:toolbar>
  15. <el-button type="primary" size="mini" @click="handleReturn"
  16. >新建</el-button
  17. >
  18. </template>
  19. <template v-slot:scene="{ row }">
  20. {{ sceneListFn(row.scene) }}
  21. </template>
  22. <template v-slot:action="{ row }">
  23. <el-button type="text" size="mini" @click="handDetailed(row)"
  24. >详情</el-button
  25. >
  26. </template>
  27. </ele-pro-table>
  28. </el-card>
  29. <returnPop
  30. v-if="returnShow"
  31. :returnDetailsId="returnDetailsId"
  32. @close="close"
  33. :sceneList="sceneList"
  34. ></returnPop>
  35. </div>
  36. </template>
  37. <script>
  38. import { returnPage } from '@/api/materialReturn/index.js';
  39. import returnSearch from './components/return-search.vue';
  40. import returnPop from './components/returnPop.vue';
  41. import { getByCode } from '@/api/system/dictionary-data';
  42. export default {
  43. components: {
  44. returnSearch,
  45. returnPop
  46. },
  47. data() {
  48. return {
  49. // 加载状态
  50. loading: false,
  51. selection: [],
  52. returnShow: false,
  53. returnDetailsId: null ,
  54. sceneList: []
  55. };
  56. },
  57. computed: {
  58. columns() {
  59. return [
  60. {
  61. prop: 'code',
  62. label: '退料单编号',
  63. align: 'center'
  64. },
  65. {
  66. prop: 'name',
  67. label: '退料单名称',
  68. align: 'center'
  69. },
  70. {
  71. slot: 'scene',
  72. prop: 'scene',
  73. label: '退料场景',
  74. align: 'center'
  75. },
  76. {
  77. prop: 'executorName',
  78. label: '退料人',
  79. align: 'center'
  80. },
  81. {
  82. prop: 'executorTime',
  83. label: '退料时间',
  84. align: 'center'
  85. },
  86. {
  87. prop: 'remark',
  88. label: '退料描述',
  89. align: 'center'
  90. },
  91. {
  92. prop: '',
  93. label: '操作',
  94. width: 80,
  95. align: 'center',
  96. resizable: false,
  97. fixed: 'right',
  98. slot: 'action'
  99. }
  100. ];
  101. }
  102. },
  103. created() {
  104. this.getByCodeFn();
  105. },
  106. methods: {
  107. /* 表格数据源 */
  108. async datasource({ page, limit, where }) {
  109. let res = await returnPage({
  110. ...where,
  111. pageNum: page,
  112. size: limit
  113. });
  114. return res;
  115. },
  116. handleReturn() {
  117. this.returnDetailsId = null
  118. this.returnShow = true;
  119. },
  120. close(val) {
  121. if (val) {
  122. this.reload();
  123. }
  124. this.returnDetailsId = null;
  125. this.returnShow = false;
  126. },
  127. handDetailed(row) {
  128. this.returnDetailsId = row.id
  129. this.returnShow = true
  130. },
  131. getByCodeFn() {
  132. getByCode('returnScenario').then((res) => {
  133. let _arr = [];
  134. res.data.map((item) => {
  135. const key = Object.keys(item)[0];
  136. const value = item[key];
  137. _arr.push({ label: value, value: key });
  138. });
  139. this.sceneList = _arr;
  140. });
  141. },
  142. sceneListFn(val) {
  143. let _arr = this.sceneList;
  144. for (const item of _arr) {
  145. if (item.value == val) {
  146. return item.label;
  147. }
  148. }
  149. },
  150. /* 刷新表格 */
  151. reload(where = {}) {
  152. this.$refs.table.reload({ page: 1, where });
  153. }
  154. }
  155. };
  156. </script>