disassemblePlanPop.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <ele-modal
  3. width="80vw"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :close-on-click-modal="false"
  7. row-key="code"
  8. custom-class="ele-dialog-form"
  9. :title="'计划分解'"
  10. >
  11. <div class="form-wrapper">
  12. <el-form :model="requestData" label-width="0" :show-message="false">
  13. <el-descriptions title="" :column="2" border>
  14. <el-descriptions-item label="计划编号">
  15. {{ formData.code }}</el-descriptions-item
  16. >
  17. <el-descriptions-item label="产品编码">{{
  18. formData.productCode
  19. }}</el-descriptions-item>
  20. <el-descriptions-item label="产品名称">{{
  21. formData.productName
  22. }}</el-descriptions-item>
  23. <el-descriptions-item label="牌号|型号">
  24. {{ formData.brandNo }}|{{ formData.model }}</el-descriptions-item
  25. >
  26. <el-descriptions-item label="批次号">{{
  27. formData.batchNo
  28. }}</el-descriptions-item>
  29. <el-descriptions-item label="工艺路线">{{
  30. formData.produceRoutingName
  31. }}</el-descriptions-item>
  32. <el-descriptions-item label="要求生产数量">{{
  33. formData.requiredFormingNum
  34. }}</el-descriptions-item>
  35. <el-descriptions-item label="要求完成日期">{{
  36. formData.reqMoldTime
  37. }}</el-descriptions-item>
  38. <el-descriptions-item label="生产方式">
  39. <el-select v-model="formData.produceType" @change="getBomList">
  40. <el-option
  41. v-for="item of producedList"
  42. :key="item.code"
  43. :label="item.name"
  44. :value="item.code"
  45. ></el-option>
  46. </el-select>
  47. </el-descriptions-item>
  48. </el-descriptions>
  49. <headerTitle title="BOM信息" class="mt20"> </headerTitle>
  50. <ele-pro-table
  51. ref="table"
  52. :needPage="false"
  53. :columns="columns"
  54. :datasource="bomList"
  55. :selection.sync="selection"
  56. @update:selection="handleSelectionChange"
  57. tool-class="ele-toolbar-actions"
  58. max-height="360px"
  59. >
  60. <template v-slot:toolbar>
  61. <div class="toolbar_box">
  62. <div
  63. ><span>基本数量</span>
  64. <el-input
  65. placeholder="请输入"
  66. v-model.number="baseCount"
  67. disabled
  68. >
  69. </el-input>
  70. <DictSelection dictName="计量单位" v-model="unit" disabled
  71. /></div>
  72. <el-button type="primary" size="mini" @click="handleAdd"
  73. >新增</el-button
  74. >
  75. </div>
  76. </template>
  77. </ele-pro-table>
  78. <headerTitle title="计划列表" class="mt20"> </headerTitle>
  79. <ele-pro-table
  80. ref="table2"
  81. :needPage="false"
  82. :columns="jsColumns"
  83. :datasource="jhList"
  84. tool-class="ele-toolbar-actions"
  85. max-height="360px"
  86. >
  87. <template v-slot:requiredFormingNum="{ row }">
  88. <el-input
  89. v-if="row.isManual"
  90. v-model.number="row.requiredFormingNum"
  91. ></el-input>
  92. <span v-else>{{ row.requiredFormingNum }}</span>
  93. </template>
  94. </ele-pro-table>
  95. </el-form>
  96. </div>
  97. <div slot="footer">
  98. <el-button plain @click="cancel">取消</el-button>
  99. <el-button type="primary" @click="confirm">确定</el-button>
  100. </div>
  101. <EquipmentDialog ref="equipmentRefs" @choose="choose"></EquipmentDialog>
  102. </ele-modal>
  103. </template>
  104. <script>
  105. import { deepClone } from '@/utils';
  106. import { getBom } from '@/api/productionPlan/index.js';
  107. import EquipmentDialog from './EquipmentDialog.vue';
  108. export default {
  109. components: {
  110. EquipmentDialog
  111. },
  112. data() {
  113. return {
  114. visible: false,
  115. formData: {},
  116. requestData: {},
  117. bomList: [],
  118. baseCount: '',
  119. unit: '',
  120. selection: [],
  121. jhList: [],
  122. rules: {},
  123. producedList: [
  124. { code: 2, name: '加工' },
  125. { code: 3, name: '装配' }
  126. ],
  127. columns: [
  128. {
  129. columnKey: 'selection',
  130. type: 'selection',
  131. width: 45,
  132. align: 'center'
  133. },
  134. {
  135. prop: 'code',
  136. label: '编码',
  137. showOverflowTooltip: true
  138. },
  139. {
  140. prop: 'name',
  141. label: '名称',
  142. showOverflowTooltip: true
  143. },
  144. {
  145. prop: 'dosage',
  146. label: '用量',
  147. showOverflowTooltip: true
  148. },
  149. {
  150. prop: 'unit',
  151. label: '计量单位',
  152. showOverflowTooltip: true
  153. },
  154. {
  155. prop: 'brandNo',
  156. label: '牌号',
  157. align: 'center',
  158. showOverflowTooltip: true
  159. },
  160. {
  161. prop: 'specification',
  162. label: '规格',
  163. align: 'center',
  164. minWidth: 150,
  165. showOverflowTooltip: true
  166. },
  167. {
  168. prop: 'model',
  169. label: '型号',
  170. align: 'center',
  171. showOverflowTooltip: true
  172. },
  173. {
  174. prop: 'versions',
  175. label: '版本'
  176. },
  177. {
  178. prop: 'status ',
  179. label: '状态',
  180. formatter: (row) => {
  181. return this.statusOpt[+row.status];
  182. }
  183. },
  184. {
  185. prop: 'createName',
  186. label: '创建人',
  187. showOverflowTooltip: true
  188. },
  189. {
  190. prop: 'createTime',
  191. label: '创建日期',
  192. showOverflowTooltip: true
  193. }
  194. ],
  195. statusOpt: {
  196. '': '全部',
  197. 0: '已停用',
  198. 1: '已发布'
  199. },
  200. jsColumns: [
  201. {
  202. prop: 'productCode',
  203. label: '编码',
  204. align: 'center',
  205. minWidth: 140
  206. },
  207. {
  208. prop: 'productName',
  209. label: '名称',
  210. align: 'center',
  211. minWidth: 140
  212. },
  213. {
  214. prop: 'brandNo',
  215. label: '牌号',
  216. align: 'center',
  217. showOverflowTooltip: true
  218. },
  219. {
  220. prop: 'specification',
  221. label: '规格',
  222. align: 'center',
  223. minWidth: 150,
  224. showOverflowTooltip: true
  225. },
  226. {
  227. prop: 'model',
  228. label: '型号',
  229. align: 'center',
  230. showOverflowTooltip: true
  231. },
  232. {
  233. prop: 'produceRoutingName',
  234. label: '工艺路线',
  235. align: 'center',
  236. minWidth: 120
  237. },
  238. {
  239. prop: 'requiredFormingNum',
  240. label: '要求生产数量',
  241. align: 'center',
  242. slot: 'requiredFormingNum'
  243. },
  244. {
  245. prop: 'unit',
  246. label: '计量单位',
  247. showOverflowTooltip: true
  248. }
  249. ]
  250. };
  251. },
  252. methods: {
  253. open(row) {
  254. this.formData = deepClone(row);
  255. this.getBomList();
  256. },
  257. getBomList() {
  258. let params = {
  259. categoryId: this.formData.categoryId,
  260. bomType: this.formData.produceType,
  261. pageNum: 1,
  262. size: -1
  263. };
  264. getBom(params).then((res) => {
  265. this.bomList = res?.bomList || [];
  266. (this.baseCount = res.baseCount),
  267. (this.unit = res.unit),
  268. (this.visible = true);
  269. });
  270. },
  271. handleSelectionChange() {
  272. let _arr = [];
  273. _arr = this.selection.map((m) => {
  274. let _num =
  275. ((this.formData.requiredFormingNum || 0) / (this.baseCount || 0)) *
  276. m.dosage;
  277. _num = _num.toFixed(3);
  278. return {
  279. id: m.id,
  280. productCode: m.code,
  281. productName: m.name,
  282. brandNo: m.brandNo,
  283. specification: m.specification,
  284. model: m.model,
  285. produceRoutingId: '',
  286. produceRoutingName: '',
  287. requiredFormingNum: _num,
  288. unit: this.unit,
  289. isManual: false
  290. };
  291. });
  292. this.jhList = _arr;
  293. },
  294. handleAdd() {
  295. let ids = [];
  296. ids = this.jhList.map((m) => m.id);
  297. // 打开设备选择弹窗
  298. this.$refs.equipmentRefs.open(ids);
  299. },
  300. choose(list) {
  301. let _list = [];
  302. _list = list.map((m) => {
  303. return {
  304. id: m.id,
  305. productCode: m.code,
  306. productName: m.name,
  307. brandNo: m.brandNo,
  308. specification: m.specification,
  309. model: m.model,
  310. produceRoutingId: '',
  311. produceRoutingName: '',
  312. requiredFormingNum: '',
  313. unit: this.unit,
  314. isManual: true
  315. };
  316. });
  317. this.jhList.push(..._list);
  318. },
  319. cancel() {
  320. this.formData = {};
  321. this.visible = false;
  322. },
  323. confirm() {}
  324. }
  325. };
  326. </script>
  327. <style lang="scss" scoped>
  328. .mt20 {
  329. margin-top: 20px;
  330. }
  331. .el-form-item {
  332. margin-bottom: 0 !important;
  333. }
  334. .toolbar_box {
  335. display: flex;
  336. justify-content: space-between;
  337. margin-right: 10px;
  338. > div {
  339. display: flex;
  340. align-items: center;
  341. justify-content: center;
  342. > span {
  343. width: 150px;
  344. }
  345. > div {
  346. margin-left: 10px;
  347. }
  348. }
  349. }
  350. </style>