order-dailog.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <ele-modal
  3. :visible.sync="visible"
  4. title="添加工单-选择设备"
  5. width="65vw"
  6. append-to-body
  7. >
  8. <div class="search-box">
  9. 生产工单号:
  10. <el-input placeholder="请输入" v-model="orderCode" clearable></el-input>
  11. <el-button type="primary" @click="reload">搜索</el-button>
  12. </div>
  13. <!-- 数据表格 -->
  14. <ele-pro-table
  15. ref="table"
  16. :columns="columns"
  17. @done="handleDone"
  18. @update:selection="selectionChange"
  19. row-key="id"
  20. :selection.sync="selectionList"
  21. :datasource="datasource"
  22. height="45vh"
  23. >
  24. </ele-pro-table>
  25. <div class="footer" slot="footer">
  26. <el-button @click="cancel">取消</el-button>
  27. <el-button @click="confirm" type="primary">确定</el-button>
  28. </div>
  29. </ele-modal>
  30. </template>
  31. <script>
  32. import { getPage } from '@/api/produceOrder/index.js';
  33. export default {
  34. data () {
  35. return {
  36. visible: false,
  37. orderCode: '',
  38. selectionList: [],
  39. memoList: [],
  40. callback: null
  41. };
  42. },
  43. computed: {
  44. columns () {
  45. const list = [
  46. {
  47. columnKey: 'index',
  48. label: '序号',
  49. type: 'index',
  50. width: 55,
  51. align: 'center',
  52. fixed: 'left',
  53. showOverflowTooltip: true
  54. },
  55. {
  56. slot: 'code',
  57. label: '生产工单号',
  58. align: 'center'
  59. },
  60. {
  61. prop: 'productionPlanCode',
  62. label: '计划编号',
  63. align: 'center'
  64. },
  65. {
  66. prop: 'planType',
  67. label: '计划类型',
  68. align: 'center'
  69. },
  70. {
  71. prop: 'produceVersionName',
  72. label: '生产版本',
  73. align: 'center'
  74. },
  75. {
  76. prop: 'productCode',
  77. label: '产品编号',
  78. align: 'center'
  79. },
  80. {
  81. prop: 'productName',
  82. label: '产品名称',
  83. align: 'center'
  84. },
  85. {
  86. prop: 'brandNo',
  87. label: '牌号',
  88. align: 'center'
  89. },
  90. {
  91. prop: 'model',
  92. label: '型号',
  93. align: 'center'
  94. },
  95. {
  96. prop: 'formingNum',
  97. label: '要求成型数量',
  98. align: 'center',
  99. showOverflowTooltip: true
  100. },
  101. {
  102. prop: 'formingWeight',
  103. label: '要求成型重量',
  104. align: 'center',
  105. showOverflowTooltip: true
  106. },
  107. {
  108. prop: 'formedNum',
  109. label: '已成型数量',
  110. align: 'center',
  111. showOverflowTooltip: true
  112. },
  113. {
  114. prop: 'formedWeight',
  115. label: '已成型重量',
  116. align: 'center',
  117. showOverflowTooltip: true
  118. },
  119. {
  120. prop: 'planStartTime',
  121. label: '计划开始时间',
  122. align: 'center',
  123. showOverflowTooltip: true,
  124. minWidth: 110
  125. },
  126. {
  127. prop: 'startTime',
  128. label: '实际开始时间',
  129. align: 'center',
  130. showOverflowTooltip: true,
  131. minWidth: 110
  132. },
  133. {
  134. prop: 'createTime',
  135. label: '创建时间',
  136. align: 'center',
  137. showOverflowTooltip: true,
  138. minWidth: 110
  139. },
  140. {
  141. type: 'selection',
  142. width: 55,
  143. align: 'center',
  144. fixed: 'right',
  145. reserveSelection: true
  146. }
  147. ];
  148. return list;
  149. }
  150. },
  151. watch: {
  152. selectionList (newVal, oldVal) {
  153. console.log(newVal, oldVal);
  154. if (newVal.length < oldVal.length) {
  155. const arr = oldVal.filter(
  156. (item) => !newVal.find((p) => p.id === item.id)
  157. );
  158. this.memoList = this.memoList.filter(
  159. (item) => !arr.find((p) => p.id === item.id)
  160. );
  161. }
  162. }
  163. },
  164. methods: {
  165. open (val, list = []) {
  166. this.memoList = list;
  167. this.visible = true;
  168. },
  169. handleDone ({ data }) {
  170. if (this.memoList.length && data.length) {
  171. this.$nextTick(() => {
  172. this.$refs.table.setSelectedRowKeys(this.memoList.map((i) => i.id));
  173. });
  174. }
  175. },
  176. reload () {
  177. this.$refs.table.reload();
  178. },
  179. selectionChange (selection) {
  180. console.log(selection);
  181. },
  182. /* 表格数据源 */
  183. datasource ({ page, limit }) {
  184. return getPage({
  185. pageNum: page,
  186. size: limit,
  187. code: this.orderCode,
  188. statusList: [5, 4, 7]
  189. });
  190. },
  191. confirm () {
  192. if (!this.selectionList?.length)
  193. return this.$message.error('请选择数据');
  194. this.$emit('success', [...this.selectionList, ...this.memoList]);
  195. this.cancel();
  196. },
  197. cancel () {
  198. this.$refs.table.clearSelection();
  199. this.orderCode = '';
  200. this.visible = false;
  201. }
  202. }
  203. };
  204. </script>
  205. <style lang="scss" scoped>
  206. .search-box {
  207. display: flex;
  208. justify-content: flex-start;
  209. align-items: center;
  210. margin-bottom: 20px;
  211. .el-input {
  212. width: 220px;
  213. margin: 0 32px;
  214. }
  215. }
  216. </style>