index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. autoAmendPage
  13. :parse-data="parseData"
  14. :selection.sync="selection"
  15. :height="tableHeight"
  16. :pageSize="20"
  17. @fullscreen-change="fullscreenChange"
  18. >
  19. <template v-slot:toolbar>
  20. <el-button type="primary" size="mini" @click="handleReturn"
  21. >新建</el-button
  22. >
  23. </template>
  24. <template v-slot:scene="{ row }">
  25. {{ sceneListFn(row.scene) }}
  26. </template>
  27. <template v-slot:storageInfo="{ row }">
  28. <span v-if="row.storageInfo">
  29. {{ row.storageInfo.approvalUserName }}
  30. </span>
  31. </template>
  32. <template v-slot:action="{ row }">
  33. <el-button type="text" size="mini" @click="handDetailed(row)"
  34. >详情</el-button
  35. >
  36. <el-button type="text" size="mini" @click="checkProcess(row)"
  37. >流程</el-button
  38. >
  39. </template>
  40. </ele-pro-table>
  41. </el-card>
  42. <returnPop
  43. v-if="returnShow"
  44. :returnDetailsId="returnDetailsId"
  45. @close="close"
  46. :sceneList="sceneList"
  47. ></returnPop>
  48. <flow ref="flowRef"></flow>
  49. </div>
  50. </template>
  51. <script>
  52. import { returnPage } from '@/api/materialReturn/index.js';
  53. import returnSearch from './components/return-search.vue';
  54. import flow from './components/flow.vue';
  55. import returnPop from './components/returnPop.vue';
  56. import { getByCode } from '@/api/system/dictionary-data';
  57. export default {
  58. components: {
  59. returnSearch,
  60. returnPop,
  61. flow
  62. },
  63. data() {
  64. return {
  65. // 加载状态
  66. loading: false,
  67. selection: [],
  68. returnShow: false,
  69. returnDetailsId: null,
  70. sceneList: [],
  71. tableHeight: 'calc(100vh - 300px)'
  72. };
  73. },
  74. computed: {
  75. columns() {
  76. return [
  77. {
  78. prop: 'code',
  79. label: '退料单编号',
  80. align: 'center'
  81. },
  82. {
  83. prop: 'name',
  84. label: '退料单名称',
  85. align: 'center'
  86. },
  87. {
  88. slot: 'scene',
  89. prop: 'scene',
  90. label: '退料场景',
  91. align: 'center'
  92. },
  93. {
  94. prop: 'executorName',
  95. label: '退料人',
  96. align: 'center'
  97. },
  98. {
  99. prop: 'executorTime',
  100. label: '退料时间',
  101. align: 'center'
  102. },
  103. {
  104. prop: 'remark',
  105. label: '退料描述',
  106. align: 'center'
  107. },
  108. {
  109. prop: 'storageInfo',
  110. slot: 'storageInfo',
  111. label: '审核人',
  112. align: 'center'
  113. },
  114. {
  115. prop: '',
  116. label: '操作',
  117. width: 160,
  118. align: 'center',
  119. resizable: false,
  120. fixed: 'right',
  121. slot: 'action'
  122. }
  123. ];
  124. }
  125. },
  126. created() {
  127. this.getByCodeFn();
  128. },
  129. methods: {
  130. /* 表格数据源 */
  131. async datasource({ page, limit, where }) {
  132. let res = await returnPage({
  133. ...where,
  134. pageNum: page,
  135. size: limit
  136. });
  137. return res;
  138. },
  139. // 新增退料
  140. handleReturn() {
  141. this.returnDetailsId = null;
  142. this.returnShow = true;
  143. },
  144. close(val) {
  145. if (val) {
  146. this.reload();
  147. }
  148. this.returnDetailsId = null;
  149. this.returnShow = false;
  150. },
  151. //查看详情
  152. handDetailed(row) {
  153. this.returnDetailsId = row.id;
  154. this.returnShow = true;
  155. },
  156. //查看流程
  157. checkProcess(row) {
  158. if (!row.storageInfo || !row.storageInfo.processInstanceId) {
  159. return this.$message.warning('暂无流程图');
  160. }
  161. this.$refs.flowRef.open(row.storageInfo.processInstanceId);
  162. },
  163. getByCodeFn() {
  164. getByCode('returnScenario').then((res) => {
  165. let _arr = [];
  166. res.data.map((item) => {
  167. const key = Object.keys(item)[0];
  168. const value = item[key];
  169. _arr.push({ label: value, value: key });
  170. });
  171. this.sceneList = _arr;
  172. });
  173. },
  174. sceneListFn(val) {
  175. let _arr = this.sceneList;
  176. for (const item of _arr) {
  177. if (item.value == val) {
  178. return item.label;
  179. }
  180. }
  181. },
  182. /* 刷新表格 */
  183. reload(where = {}) {
  184. this.$refs.table.reload({ page: 1, where });
  185. },
  186. /* 数据转为树形结构 */
  187. parseData(data) {
  188. return {
  189. ...data,
  190. list: this.$util.toTreeData({
  191. data: data.list,
  192. count: data.total,
  193. idField: 'id',
  194. parentIdField: 'parentId'
  195. })
  196. };
  197. },
  198. fullscreenChange(fullscreen) {
  199. if (fullscreen) {
  200. this.tableHeight = 'calc(100vh - 120px)';
  201. } else {
  202. this.tableHeight = 'calc(100vh - 300px)';
  203. }
  204. }
  205. }
  206. };
  207. </script>