materialModal.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <el-dialog
  3. v-if="visible"
  4. :title="title"
  5. :visible.sync="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="70%"
  11. :fullscreen="fullscreen"
  12. class="fullscreen"
  13. >
  14. <el-card shadow="never">
  15. <seek-page :seekList="seekList" @search="reload"></seek-page>
  16. <ele-pro-table
  17. style="min-height: 400px"
  18. ref="table"
  19. :columns="columns"
  20. :datasource="datasource"
  21. :selection.sync="selection"
  22. :need-page="false"
  23. row-key="index"
  24. >
  25. </ele-pro-table>
  26. </el-card>
  27. <div class="rx-sc">
  28. <el-button type="primary" size="small" @click="selected">选择</el-button>
  29. <el-button size="small" @click="handleClose">关闭</el-button>
  30. </div>
  31. </el-dialog>
  32. </template>
  33. <script>
  34. import SeekPage from '@/components/common/seekPage.vue';
  35. import {
  36. queryPickAndFeedByWorkOrderId,
  37. queryAllProduceTaskInstanceInPickOrder
  38. } from '@/api/producetaskrulerecord/index.js';
  39. export default {
  40. components: {
  41. SeekPage
  42. },
  43. data() {
  44. return {
  45. fullscreen: false,
  46. visible: false,
  47. title: '选择物品',
  48. type: null,
  49. // 表格列配置
  50. columns: [
  51. {
  52. columnKey: 'selection',
  53. type: 'selection',
  54. width: 45,
  55. align: 'center',
  56. reserveSelection: true,
  57. fixed: 'left',
  58. selectable: (row, index) => {
  59. // 已选物料不可再选
  60. return !this.pickDetails.some(
  61. (item) =>
  62. item.categoryCode === row.categoryCode &&
  63. item.produceTaskInstanceId === row.produceTaskInstanceId
  64. );
  65. }
  66. },
  67. {
  68. width: 45,
  69. type: 'index',
  70. columnKey: 'index',
  71. align: 'center'
  72. },
  73. {
  74. label: '类型',
  75. prop: 'categoryLevelNamePath',
  76. minWidth: 120
  77. },
  78. {
  79. label: '编码',
  80. prop: 'categoryCode',
  81. minWidth: 120
  82. },
  83. {
  84. label: '名称',
  85. prop: 'categoryName',
  86. minWidth: 120
  87. },
  88. {
  89. prop: 'model',
  90. label: '型号',
  91. align: 'center',
  92. showOverflowTooltip: true
  93. },
  94. {
  95. prop: 'specifications',
  96. label: '规格',
  97. align: 'center',
  98. width: 160,
  99. showOverflowTooltip: true
  100. },
  101. {
  102. prop: 'brandNo',
  103. label: '牌号',
  104. align: 'center'
  105. },
  106. {
  107. label: '工序名称',
  108. prop: 'produceTaskName',
  109. minWidth: 120
  110. },
  111. {
  112. label: '数量',
  113. prop: 'feedQuantity',
  114. minWidth: 120,
  115. formatter: (row) => {
  116. return (row.quantity || 0) + (row.unit || '');
  117. }
  118. }
  119. ],
  120. // 表格选中数据
  121. selection: [],
  122. taskPlanList: [],
  123. params: {},
  124. // 已选物料
  125. pickDetails: []
  126. };
  127. },
  128. computed: {
  129. seekList() {
  130. return [
  131. {
  132. label: '关键词:',
  133. value: 'keyword',
  134. type: 'input',
  135. placeholder: '物料编码、物料名称、批次号'
  136. }
  137. ];
  138. }
  139. },
  140. created() {},
  141. methods: {
  142. /* 表格数据源 */
  143. async datasource({ page, limit, where }) {
  144. const res = await queryPickAndFeedByWorkOrderId({
  145. ...where,
  146. ...this.params
  147. // pageNum: page,
  148. // size: limit
  149. });
  150. return res;
  151. },
  152. /* 刷新表格 */
  153. reload(where) {
  154. this.$refs.table.reload({ page: 1, where: where });
  155. },
  156. handleClose() {
  157. this.$refs.table.setSelectedRows([]);
  158. this.selection = [];
  159. this.visible = false;
  160. },
  161. open(params = {}, pickDetails = []) {
  162. this.params = params;
  163. this.visible = true;
  164. },
  165. selected() {
  166. if (this.selection.length === 0) {
  167. this.$message.warning('请至少选择一条数据');
  168. return;
  169. }
  170. this.$emit('confirm', this.selection);
  171. this.handleClose();
  172. }
  173. }
  174. };
  175. </script>
  176. <style lang="scss" scoped>
  177. .rx-sc {
  178. flex: 0 0 50px;
  179. display: flex;
  180. align-items: center;
  181. justify-content: center;
  182. }
  183. .ml60 {
  184. margin-left: 60px;
  185. }
  186. </style>