link-material-dialog.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <ele-modal :visible.sync="visible" :title="`给工序【${row.code}${row.name}】分配物料`" width="90%" @close="cancel">
  3. <el-row :gutter="40">
  4. <el-col :span="12">
  5. <headerTitle>
  6. <template v-slot:title>
  7. 可分配
  8. <el-button
  9. type="primary"
  10. class="ml20"
  11. size="mini"
  12. @click="handleConect"
  13. >分配</el-button
  14. >
  15. </template>
  16. </headerTitle>
  17. <ele-pro-table
  18. ref="table"
  19. :columns="columns"
  20. :datasource="datasourceShow"
  21. :selection.sync="selection"
  22. cache-key="link-material-dialog"
  23. height="45vh"
  24. :initLoad="false"
  25. :need-page="false"
  26. >
  27. </ele-pro-table>
  28. </el-col>
  29. <el-col :span="12">
  30. <headerTitle>
  31. <template v-slot:title>
  32. 已关联
  33. <el-button
  34. type="primary"
  35. class="ml20"
  36. size="mini"
  37. @click="handleCancelConect"
  38. >取消分配</el-button>
  39. </template>
  40. </headerTitle>
  41. <ele-pro-table
  42. ref="tableRight"
  43. :columns="columns"
  44. :datasource="datasourceRightShow"
  45. :selection.sync="selectionRight"
  46. height="45vh"
  47. :initLoad="false"
  48. :need-page="false"
  49. cache-key="link-material-dialog-right"
  50. >
  51. <template v-slot:capacity="{ row }">
  52. <el-row>
  53. <el-col :span="8">
  54. <el-input v-model="row.quantity"></el-input
  55. ></el-col>
  56. <el-col :span="8">
  57. <DictSelection
  58. class="line-select"
  59. dictName="重量单位"
  60. clearable
  61. v-model="row.quantityUnitId"
  62. >
  63. </DictSelection
  64. ></el-col>
  65. <el-col :span="8">
  66. <DictSelection
  67. class="line-select"
  68. dictName="提前期单位"
  69. clearable
  70. v-model="row.timeUnit"
  71. >
  72. </DictSelection
  73. ></el-col>
  74. </el-row>
  75. </template>
  76. <template v-slot:angle="{ row }">
  77. <DictSelection dictName="角度" clearable v-model="row.angle">
  78. </DictSelection>
  79. </template> </ele-pro-table
  80. ></el-col>
  81. </el-row>
  82. <div slot="footer" class="footer">
  83. <el-button type="primary" @click="save">保存</el-button>
  84. <el-button @click="cancel">取消</el-button>
  85. </div>
  86. </ele-modal>
  87. </template>
  88. <script>
  89. import { getBomSubList , saveBomList } from '@/api/technology/version/version.js';
  90. export default {
  91. components: { },
  92. data () {
  93. return {
  94. visible: false,
  95. row: {},
  96. datasourceShow: [],
  97. datasourceRightShow: [],
  98. selectionRight: [],
  99. selection: [],
  100. }
  101. },
  102. created () {
  103. },
  104. computed: {
  105. columns () {
  106. return [
  107. {
  108. type: 'selection',
  109. align: 'center'
  110. },
  111. {
  112. label: '子项编号',
  113. prop: 'subCode'
  114. },
  115. {
  116. label: '子项物料编码',
  117. prop: 'categoryCode'
  118. },
  119. {
  120. label: '子项物料名称',
  121. prop: 'categoryName'
  122. },
  123. {
  124. label: '基本数量',
  125. prop: 'baseNum'
  126. },
  127. {
  128. label: '单位',
  129. prop: 'unit'
  130. }
  131. ];
  132. },
  133. },
  134. methods: {
  135. open (row) {
  136. this.row = row;
  137. this.getDatasource();
  138. this.visible = true;
  139. },
  140. cancel () {
  141. this.visible = false;
  142. },
  143. async save () {
  144. if (!this.datasourceRightShow.length) {
  145. return this.$message.error('请添加关联数据');
  146. }
  147. const arr = []
  148. this.datasourceRightShow.map(item=>{
  149. arr.push(item.bomSubId)
  150. })
  151. const params = {
  152. produceVersionId:this.row.produceVersionId,
  153. taskInstanceId:this.row.id,
  154. bomSubId: arr
  155. };
  156. await saveBomList(params);
  157. this.cancel();
  158. this.$message.success('操作成功!');
  159. this.$emit('success');
  160. },
  161. handleConect () {
  162. if (!this.selection.length) {
  163. return this.$message.error('请选择关联数据');
  164. }
  165. this.datasourceShow = this.datasourceShow.filter((i) =>
  166. !this.selection.find((t) => t.bomSubId == i.bomSubId)
  167. );
  168. this.datasourceRightShow.push(...this.selection);
  169. this.selection = [];
  170. },
  171. handleCancelConect () {
  172. if (!this.selectionRight.length) {
  173. return this.$message.error('请选择取消关联数据');
  174. }
  175. this.datasourceRightShow = this.datasourceRightShow.filter((i) =>
  176. !this.selectionRight.find((t) => t.bomSubId == i.bomSubId)
  177. );
  178. this.datasourceShow.push(...this.selectionRight);
  179. this.selectionRight = [];
  180. },
  181. async getDatasource () {
  182. const params = {
  183. bomId:this.row.bomId,
  184. produceVersionId:this.row.produceVersionId,
  185. routingTaskId:this.row.id,
  186. pageNum:1,
  187. size:-1
  188. }
  189. const data = await getBomSubList(params);
  190. if(typeof data.uncorrelatedList == 'string' ){
  191. this.datasource = []
  192. }else{
  193. this.datasourceShow = data.uncorrelatedList;
  194. }
  195. if(typeof data.correlatedList == 'string' ){
  196. this.datasourceRightShow = []
  197. }else{
  198. this.datasourceRightShow = data.correlatedList;
  199. }
  200. },
  201. }
  202. };
  203. </script>
  204. <style lang="scss" scoped>
  205. .ml20 {
  206. margin-left: 20px;
  207. }
  208. .footer {
  209. text-align: right;
  210. }
  211. </style>