index.vue 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387
  1. <template>
  2. <!-- :close-on-click-modal="false" -->
  3. <ele-modal
  4. width="80vw"
  5. :visible.sync="visible"
  6. custom-class="ele-dialog-form"
  7. :before-close="cancel"
  8. :title="title"
  9. :maxable="true"
  10. >
  11. <div class="form-wrapper">
  12. <el-form
  13. ref="form"
  14. :model="form"
  15. :rules="rules"
  16. label-width="110px"
  17. class="formbox"
  18. >
  19. <headerTitle title="基本信息"> </headerTitle>
  20. <el-row :gutter="10">
  21. <el-col :span="6">
  22. <el-form-item label="计划编号:" prop="code">
  23. <el-input
  24. placeholder="计划编号"
  25. size="mini"
  26. disabled
  27. v-model="form.code"
  28. ></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="6">
  32. <el-form-item label="计划类型:" prop="planType">
  33. <el-select
  34. v-model="form.planType"
  35. style="width: 100%"
  36. @change="changeProduceType"
  37. size="mini"
  38. >
  39. <el-option
  40. v-for="item of planTypeList"
  41. :key="item.value"
  42. :label="item.label"
  43. :value="item.value"
  44. ></el-option>
  45. </el-select>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="6">
  49. <el-form-item label="批次号:" prop="batchNo">
  50. <el-input
  51. placeholder="输入批次号"
  52. size="mini"
  53. v-model="form.batchNo"
  54. ></el-input>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="6">
  58. <el-form-item
  59. label="计划开始日期:"
  60. label-width="110px"
  61. prop="startTime"
  62. >
  63. <el-date-picker
  64. style="width: 100%"
  65. size="mini"
  66. v-model="form.startTime"
  67. :pickerOptions="{
  68. disabledDate: (time) =>
  69. time.getTime() <
  70. new Date(new Date().setHours(0, 0, 0, 0)).getTime()
  71. }"
  72. type="date"
  73. placeholder="选择日期"
  74. value-format="yyyy-MM-dd"
  75. >
  76. </el-date-picker>
  77. </el-form-item>
  78. </el-col>
  79. </el-row>
  80. <el-row :gutter="24">
  81. <el-col :span="6">
  82. <el-form-item
  83. label="计划结束日期:"
  84. label-width="110px"
  85. prop="endTime"
  86. >
  87. <el-date-picker
  88. style="width: 100%"
  89. size="mini"
  90. v-model="form.endTime"
  91. :pickerOptions="{
  92. disabledDate: (time) =>
  93. time.getTime() <
  94. new Date(new Date().setHours(0, 0, 0, 0)).getTime()
  95. }"
  96. type="date"
  97. placeholder="选择日期"
  98. value-format="yyyy-MM-dd"
  99. >
  100. </el-date-picker>
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="6">
  104. <el-form-item
  105. label="要求完成日期:"
  106. label-width="110px"
  107. prop="reqMoldTime"
  108. >
  109. <el-date-picker
  110. style="width: 100%"
  111. size="mini"
  112. v-model="form.reqMoldTime"
  113. :pickerOptions="{
  114. disabledDate: (time) =>
  115. time.getTime() <
  116. new Date(new Date().setHours(0, 0, 0, 0)).getTime()
  117. }"
  118. type="date"
  119. placeholder="选择日期"
  120. value-format="yyyy-MM-dd"
  121. >
  122. </el-date-picker>
  123. </el-form-item>
  124. </el-col>
  125. </el-row>
  126. <headerTitle title="产品信息"> </headerTitle>
  127. <el-row :gutter="24">
  128. <ele-pro-table
  129. ref="tableRef"
  130. :columns="columns"
  131. row-key="code"
  132. :cache-key="`ProductionPlanTable`"
  133. :datasource="form.productInfoList"
  134. border
  135. height="40vh"
  136. key="id"
  137. >
  138. <template v-slot:requiredFormingNum="{ row, $index }">
  139. <el-input
  140. v-model.number="row.requiredFormingNum"
  141. size="small"
  142. type="number"
  143. style="width: 100%"
  144. placeholder="输入要求生产数量"
  145. @input="tableHandleKeyUp(row, 'procut')"
  146. ></el-input>
  147. <!-- placeholder="输入要求生产数量" @input="tableHandleKeyUp(row, 'sum')"></el-input> -->
  148. </template>
  149. <template v-slot:blockCount="{ row, $index }">
  150. <el-input
  151. v-model.number="row.blockCount"
  152. size="small"
  153. type="number"
  154. style="width: 100%"
  155. placeholder="输入数量"
  156. @input="inputNumber(row, $index)"
  157. ></el-input>
  158. </template>
  159. <template v-slot:productType="{ row, $index }">
  160. <el-select
  161. v-model="row.productType"
  162. @change="changeProductType(row, $index)"
  163. :key="$index"
  164. >
  165. <el-option
  166. v-for="item of producedList"
  167. :key="$index + item.code"
  168. :label="item.name"
  169. :value="item.code"
  170. ></el-option>
  171. </el-select>
  172. </template>
  173. <template v-slot:bomCategoryId="{ row, $index }">
  174. <el-select
  175. v-model="row.bomCategoryId"
  176. @change="changeBomId(row, $index)"
  177. >
  178. <el-option
  179. v-for="item of row.bomVersionList"
  180. :key="item.id"
  181. :label="item.name + '(V' + item.versions + '.0)'"
  182. :value="item.id"
  183. ></el-option>
  184. </el-select>
  185. </template>
  186. <!-- //权重等级 -->
  187. <template
  188. v-slot:weight="{ row, $index }"
  189. v-if="clientEnvironmentId == 4"
  190. >
  191. <el-select
  192. v-model="row.weight"
  193. style="width: 100%"
  194. @change="changeProduceType"
  195. size="mini"
  196. >
  197. <el-option
  198. v-for="item of weightList"
  199. :key="item.code"
  200. :label="item.name"
  201. :value="item.code"
  202. ></el-option>
  203. </el-select>
  204. </template>
  205. <!-- 是否开槽 -->
  206. <template
  207. v-slot:isSlotting="{ row, $index }"
  208. v-if="clientEnvironmentId == 4"
  209. >
  210. <el-select
  211. v-model="row.isSlotting"
  212. style="width: 100%"
  213. @change="changeProduceType"
  214. size="mini"
  215. >
  216. <el-option
  217. v-for="item of isSlotting"
  218. :key="item.code"
  219. :label="item.name"
  220. :value="item.code"
  221. ></el-option>
  222. </el-select>
  223. </template>
  224. <!-- 开槽类型 -->
  225. <template
  226. v-slot:slottingType="{ row, $index }"
  227. v-if="clientEnvironmentId == 4"
  228. >
  229. <DictSelection
  230. dictName="开槽类型"
  231. v-model="row.slottingType"
  232. size="mini"
  233. >
  234. </DictSelection>
  235. </template>
  236. <!-- 工艺路线 -->
  237. <template
  238. v-slot:produceRoutingId="{ row, $index }"
  239. v-if="clientEnvironmentId != 4"
  240. >
  241. <!-- <el-form-item required> -->
  242. <div style="display: flex">
  243. <el-select
  244. v-model="row.produceRoutingId"
  245. v-show="isRouteSelect(row)"
  246. >
  247. <el-option
  248. v-for="item of row.routingList"
  249. :key="item.id"
  250. :label="item.name"
  251. :value="item.id"
  252. ></el-option>
  253. </el-select>
  254. <div style="display: flex">
  255. <el-input
  256. v-show="!isRouteSelect(row)"
  257. disabled
  258. v-model="row.produceRoutingName"
  259. ></el-input>
  260. <el-button
  261. v-show="isSelectShow"
  262. type="primary"
  263. size="mini"
  264. @click="openDialog($index)"
  265. >选择</el-button
  266. >
  267. </div>
  268. </div>
  269. <!-- </el-form-item> -->
  270. </template>
  271. <template v-slot:produceRoutingId="{ row, $index }" v-else>
  272. <el-input
  273. v-model="row.produceRoutingName"
  274. style="width: 100%"
  275. readonly
  276. ></el-input>
  277. </template>
  278. <template v-slot:factoriesId="{ row, $index }">
  279. <el-select
  280. v-model="row.factoriesId"
  281. :key="row.factoriesId"
  282. @change="(e) => selectFactory(e, row)"
  283. >
  284. <el-option
  285. v-for="item of factoryList"
  286. :key="item.id"
  287. :label="item.name"
  288. :value="item.id"
  289. ></el-option>
  290. </el-select>
  291. </template>
  292. <!-- <el-table-column label="所属工厂" width="140" align="center" prop="factoriesId">
  293. <template slot-scope="scope">
  294. <el-form-item label-width="0px">
  295. <el-select v-model="scope.row.factoriesId" :key="scope.row.factoriesId">
  296. <el-option v-for="item of factoryList" :key="item.id" :label="item.name"
  297. :value="item.id"></el-option>
  298. </el-select>
  299. </el-form-item>
  300. </template>
  301. </el-table-column> -->
  302. <!-- 模具数量 -->
  303. <template
  304. v-slot:moCount="{ row, $index }"
  305. v-if="clientEnvironmentId == '4'"
  306. >
  307. <div>
  308. <el-input
  309. style="width: 100%"
  310. size="small"
  311. v-model="row.moCount"
  312. oninput="value=value.replace(/[^0-9.]/g,'')"
  313. @input="tableHandleKeyUp(row, 'moCount')"
  314. placeholder="请输入"
  315. >
  316. </el-input>
  317. </div>
  318. </template>
  319. <!-- 块数 -->
  320. <template
  321. v-slot:blockCount="{ row, $index }"
  322. v-if="clientEnvironmentId == '4'"
  323. >
  324. <div>
  325. <el-input
  326. size="small"
  327. style="width: 100%"
  328. @input="tableHandleKeyUp(row, 'blockCount')"
  329. v-model="row.blockCount"
  330. placeholder="请输入"
  331. ></el-input>
  332. </div>
  333. </template>
  334. <template v-slot:productWeight="{ row, $index }">
  335. <span>{{ row.productWeight ? row.productWeight : '-' }}</span>
  336. </template>
  337. <template v-slot:set="{ row, $index }">
  338. <el-button
  339. type="text"
  340. @click="handleDeleteItem($index)"
  341. v-if="!row.id"
  342. >删除</el-button
  343. >
  344. </template>
  345. <template v-slot:headerProduceRoutingId="{ column }">
  346. <div class="header_required"
  347. ><span class="is-required">{{ column.label }}</span></div
  348. >
  349. </template>
  350. <template v-slot:headeRequiredFormingNum="{ column }">
  351. <div class="header_required"
  352. ><span class="is-required">{{ column.label }}</span></div
  353. >
  354. </template>
  355. <template v-slot:headerProcessingBOM="{ column }">
  356. <div :class="isRequired ? 'header_required' : ''"
  357. ><span class="is-required">{{ column.label }}</span></div
  358. >
  359. </template>
  360. </ele-pro-table>
  361. <div class="add-product" @click="addEquipment">
  362. <i class="el-icon-circle-plus-outline"></i>
  363. </div>
  364. </el-row>
  365. </el-form>
  366. <!-- 选择产品 -->
  367. <EquipmentDialog
  368. @choose="confirmChoose"
  369. :selectList="[]"
  370. ref="equipmentRefs"
  371. isMultiple="0"
  372. >
  373. </EquipmentDialog>
  374. </div>
  375. <template v-slot:footer>
  376. <el-button @click="cancel">取消</el-button>
  377. <el-button type="primary" @click="save" :loading="loading">
  378. 确定
  379. </el-button>
  380. </template>
  381. <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
  382. </ele-modal>
  383. </template>
  384. <script>
  385. import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
  386. import { getCode } from '@/api/codeManagement';
  387. import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
  388. import { parameterGetByCode } from '@/api/mainData/index';
  389. import {
  390. bomRoutingList,
  391. bomListByPlan,
  392. saveSaleToPlan,
  393. getFactoryList,
  394. temporarilyUpdate,
  395. temporaryPlanSave
  396. } from '@/api/saleOrder';
  397. export default {
  398. components: {
  399. EquipmentDialog,
  400. ProcessRoute
  401. },
  402. props: {
  403. factoryType: {
  404. type: Number,
  405. default: 3
  406. },
  407. factoryObj: {
  408. type: Object,
  409. default: () => {}
  410. }
  411. },
  412. watch: {
  413. // factoryObj: {
  414. // immediate: true,
  415. // deep: true,
  416. // handler(val) {
  417. // // 修改
  418. // // this.$nextTick(() => {
  419. // // if (val.id) {
  420. // // this.bomListVersion();
  421. // // if (val.bomCategoryId) {
  422. // // this.getPlanRouting();
  423. // // }
  424. // // }
  425. // // });
  426. // }
  427. // }
  428. },
  429. computed: {
  430. // 是否必填 字段 ( 首先看计划类型 如果是返工返修)
  431. // 就不是必填 否则就看配置参数
  432. // 必填的时候 不显示选择按钮 跟 展示输入框 只能有下拉选择框 ( 选择了加工方式 带出 BOM 版本 带出 工艺路线 工艺路线不能选择)
  433. // 不必填的时候 显示 选择按钮跟 展示输入框 并且可以存在选择框 一开始默认展示选择框
  434. // 选择按钮选择数据后 隐藏选择框 显示展示框(input) 情况 加工方式 跟 BOM版本
  435. // 选择了加工方式 清空 选择框选择的工艺路线
  436. // 是否必填字段
  437. isRequired() {
  438. if (this.form.planType == 5) {
  439. return false;
  440. }
  441. return this.processingRequired == 1;
  442. },
  443. // 工艺路线 输入框展示跟选择框判断
  444. isRouteSelect() {
  445. return (row) => {
  446. if (this.isRequired) {
  447. return true;
  448. }
  449. if (!row.selectionRowShow) {
  450. return true;
  451. }
  452. return false;
  453. };
  454. },
  455. // 选择按钮的显示
  456. isSelectShow() {
  457. if (this.form.planType == 5) {
  458. return true;
  459. }
  460. return this.processingRequired == 0;
  461. },
  462. clientEnvironmentId() {
  463. return this.$store.state.user.info.clientEnvironmentId;
  464. },
  465. columns() {
  466. return [
  467. {
  468. columnKey: 'index',
  469. label: '序号',
  470. type: 'index',
  471. width: 55,
  472. align: 'center',
  473. showOverflowTooltip: true
  474. },
  475. {
  476. slot: 'lineNumber',
  477. prop: 'lineNumber',
  478. label: '行号',
  479. align: 'center',
  480. minWidth: 140
  481. },
  482. {
  483. slot: 'productName',
  484. prop: 'productName',
  485. label: '产品名称',
  486. align: 'center',
  487. minWidth: 140
  488. },
  489. {
  490. slot: 'productCode',
  491. prop: 'productCode',
  492. label: '物料编码',
  493. align: 'center',
  494. minWidth: 140
  495. },
  496. {
  497. slot: 'brandNo',
  498. prop: 'brandNo',
  499. label: '牌号',
  500. align: 'center',
  501. minWidth: 140
  502. },
  503. {
  504. slot: 'model',
  505. prop: 'model',
  506. label: '型号',
  507. align: 'center',
  508. minWidth: 140
  509. },
  510. {
  511. slot: 'specification',
  512. prop: 'specification',
  513. label: '规格',
  514. align: 'center',
  515. minWidth: 140
  516. },
  517. {
  518. slot: 'productUnitWeight',
  519. prop: 'productUnitWeight',
  520. label: '单重',
  521. align: 'center',
  522. minWidth: 140
  523. },
  524. {
  525. slot: 'weightUnit',
  526. prop: 'weightUnit',
  527. label: '重量单位',
  528. align: 'center',
  529. minWidth: 140
  530. },
  531. {
  532. slot: 'requiredFormingNum',
  533. prop: 'requiredFormingNum',
  534. headerSlot: 'headeRequiredFormingNum',
  535. label: '要求生产数量',
  536. align: 'center',
  537. minWidth: 140
  538. },
  539. {
  540. slot: 'productType',
  541. prop: 'productType',
  542. label: '加工方式',
  543. headerSlot: 'headerProcessingBOM',
  544. align: 'center',
  545. minWidth: 180
  546. },
  547. {
  548. slot: 'bomCategoryId',
  549. prop: 'bomCategoryId',
  550. label: 'BOM版本',
  551. headerSlot: 'headerProcessingBOM',
  552. align: 'center',
  553. minWidth: 180,
  554. show: this.clientEnvironmentId !== 4
  555. },
  556. {
  557. slot: 'produceRoutingId',
  558. prop: 'produceRoutingId',
  559. headerSlot: 'headerProduceRoutingId',
  560. label: '工艺路线',
  561. align: 'center',
  562. minWidth: 240
  563. },
  564. {
  565. slot: 'measuringUnit',
  566. prop: 'measuringUnit',
  567. label: '计量单位',
  568. align: 'center',
  569. minWidth: 140
  570. },
  571. {
  572. slot: 'moCount',
  573. prop: 'moCount',
  574. label: '模数',
  575. align: 'center',
  576. minWidth: 140,
  577. show: this.clientEnvironmentId == 4
  578. },
  579. {
  580. slot: 'blockCount',
  581. prop: 'blockCount',
  582. label: '块数',
  583. align: 'center',
  584. minWidth: 140,
  585. show: this.clientEnvironmentId == 4
  586. },
  587. {
  588. slot: 'factoriesId',
  589. prop: 'factoriesId',
  590. label: '所属工厂',
  591. align: 'center',
  592. minWidth: 140
  593. },
  594. {
  595. slot: 'weight',
  596. prop: 'weight',
  597. label: '权重等级',
  598. align: 'center',
  599. minWidth: 140,
  600. show: this.clientEnvironmentId == 4
  601. },
  602. {
  603. slot: 'isSlotting',
  604. prop: 'isSlotting',
  605. label: '是否开槽',
  606. align: 'center',
  607. minWidth: 140,
  608. show: this.clientEnvironmentId == 4
  609. },
  610. {
  611. slot: 'slottingType',
  612. prop: 'slottingType',
  613. label: '开槽类型',
  614. align: 'center',
  615. minWidth: 140,
  616. show: this.clientEnvironmentId == 4
  617. },
  618. {
  619. slot: 'productWeight',
  620. prop: 'productWeight',
  621. label: '订单重量',
  622. align: 'center',
  623. minWidth: 140
  624. },
  625. {
  626. slot: 'set',
  627. prop: 'set',
  628. label: '操作',
  629. align: 'center',
  630. minWidth: 140,
  631. fixed: 'right'
  632. }
  633. ];
  634. }
  635. },
  636. data() {
  637. return {
  638. visible: false,
  639. title: '',
  640. type: 3,
  641. weightList: [
  642. { code: 1, name: 'A' },
  643. { code: 2, name: 'B' },
  644. { code: 3, name: 'C' }
  645. ],
  646. factoryList: [],
  647. isSlotting: [
  648. { code: 1, name: '是' },
  649. { code: 2, name: '否' }
  650. ], //是否开槽
  651. planTypeList: [
  652. { label: '内销计划', value: '1' },
  653. { label: '外销计划', value: '2' },
  654. { label: '预制计划', value: '3' },
  655. { label: '改型计划', value: '4' },
  656. { label: '返工返修计划', value: '5' }
  657. ],
  658. loading: false,
  659. form: {
  660. timeDimensionPlanType: 3,
  661. categoryId: '',
  662. productName: '',
  663. planType: '',
  664. moCount: '', // 模具数量
  665. blockCount: 0, // 块数
  666. noWordCount: '', // 无字数量
  667. weight: '',
  668. startTime: '',
  669. endTime: '',
  670. isSlotting: '', //是否开槽
  671. slottingType: '', //开槽类型
  672. id: '',
  673. produceType: 2,
  674. bomCategoryId: '',
  675. produceRoutingId: '',
  676. requiredFormingNum: '',
  677. productInfoList: []
  678. },
  679. disabledList: [],
  680. bomVersionList: [],
  681. routingList: [],
  682. rules: {
  683. productName: [
  684. { required: true, message: '请选择名称', trigger: 'change' }
  685. ],
  686. bomCategoryId: [
  687. { required: true, message: '请选择BOM版本', trigger: 'blur' }
  688. ],
  689. produceType: [
  690. { required: true, message: '请选择工艺路线', trigger: 'blur' }
  691. ],
  692. produceRoutingId: [
  693. { required: true, message: '请选择工艺路线', trigger: 'blur' }
  694. ],
  695. reqMoldTime: [
  696. { required: true, message: '请选择要求完成日期', trigger: 'blur' }
  697. ],
  698. requiredFormingNum: [
  699. { required: true, message: '请输入生产数量', trigger: 'blur' }
  700. ]
  701. },
  702. producedList: [
  703. { code: 2, name: '加工(MBOM)' },
  704. { code: 3, name: '装配(ABOM)' }
  705. ],
  706. selectIndex: 0, // 选择工艺路线的当前数据下标
  707. processingRequired: 0 // 加工方式跟BOM 版本是否必填 1:是 0:否
  708. // selectionRowShow: false // 工艺路线输入框展示 状态
  709. };
  710. },
  711. // computed: {
  712. // clientEnvironmentId() {
  713. // return this.$store.state.user.info.clientEnvironmentId;
  714. // }
  715. // },
  716. mounted() {
  717. // 加工方式跟BOM版本字段是否必填
  718. parameterGetByCode({
  719. code: 'production_plan_code'
  720. }).then((res) => {
  721. if (res) {
  722. this.processingRequired = res.value;
  723. }
  724. });
  725. },
  726. methods: {
  727. selectFactory(e, row) {
  728. let data = this.factoryList.find((item) => item.id === e);
  729. this.$set(row, 'factoriesName', data.name);
  730. },
  731. // 打开工艺路线
  732. openDialog(index) {
  733. this.selectIndex = index;
  734. this.$refs.processRouteRef.open();
  735. },
  736. // 选择工艺路线
  737. changeParent(item) {
  738. let data = this.form.productInfoList[this.selectIndex];
  739. this.$set(data, 'bomVersionList', []);
  740. this.$set(data, 'bomCategoryId', '');
  741. this.$set(data, 'model', '');
  742. this.$set(data, 'routingList', []);
  743. this.$set(data, 'productType', '');
  744. this.$set(data, 'produceRoutingName', item.name);
  745. this.$set(data, 'produceRoutingId', item.id);
  746. this.$set(data, 'selectionRowShow', true);
  747. // this.selectionRowShow = true;
  748. },
  749. async getFactoryList() {
  750. this.factoryList = await getFactoryList();
  751. },
  752. async open(val) {
  753. await this.getFactoryList();
  754. if (val) {
  755. this.title = !val.id ? '新增临时生产计划' : '编辑临时生产计划';
  756. val.planType = String(val.planType);
  757. this.form = val;
  758. // 修改
  759. if (val.id) {
  760. if (
  761. Array.isArray(val.productInfoList) &&
  762. val.productInfoList.length
  763. ) {
  764. this.form.productInfoList.map(async (v, index) => {
  765. if (!v.bomCategoryId) {
  766. v.productType = '';
  767. v.selectionRowShow = true;
  768. } else {
  769. v.selectionRowShow = false;
  770. }
  771. if (v.productType) {
  772. this.$set(
  773. this.form.productInfoList[index],
  774. 'bomVersionList',
  775. await this.bomListVersionFn(v.productType, v.categoryId)
  776. );
  777. }
  778. if (v.bomCategoryId) {
  779. this.$set(
  780. this.form.productInfoList[index],
  781. 'routingList',
  782. await this.changeBomIdFn(v.bomCategoryId)
  783. );
  784. }
  785. });
  786. }
  787. }
  788. this.$forceUpdate();
  789. }
  790. this.visible = true;
  791. // this.$nextTick(async () => {
  792. // console.log(val.productInfoList);
  793. // this.$set(this.form, 'productInfoList', val.productInfoList);
  794. // this.$set(this.form, 'routingList', val.routingList);
  795. // });
  796. //this.clientEnvironmentId 环境判断 宝悦环境
  797. // if (this.clientEnvironmentId == 4) {
  798. // this.getPlanRoutingNew();
  799. // }
  800. // this.getPlanRoutingNew();
  801. },
  802. addEquipment() {
  803. this.$refs.equipmentRefs.open();
  804. },
  805. confirmChoose(list) {
  806. list.map((el) => (el.selectionRowShow = false));
  807. if (this.clientEnvironmentId == 4) {
  808. list.map((v) => {
  809. if (v.name.includes('板材')) {
  810. v.produceRoutingId = '1856970794952372226';
  811. v.produceRoutingName = '板材';
  812. v.produceVersionName = '板材';
  813. } else {
  814. (v.produceRoutingId = '1857313733642596353'),
  815. (v.produceRoutingName = '砌块'),
  816. (v.produceVersionName = '砌块');
  817. }
  818. });
  819. }
  820. list = list
  821. .filter(
  822. (i) =>
  823. !this.disabledList.find(
  824. (p) => p.productCode == i.code || p.productCode == i.productCode
  825. )
  826. )
  827. .map((item, index) => {
  828. if (item.productCode) {
  829. return item;
  830. } else {
  831. return {
  832. categoryId: item.id,
  833. productCode: item.code,
  834. productName: item.name,
  835. productUnitWeight: item.netWeight,
  836. weightUnit: item.weightUnit,
  837. model: item.modelType,
  838. specification: item.specification,
  839. brandNo: item.brandNum,
  840. measuringUnit: item.measuringUnit,
  841. produceRoutingId: item.produceRoutingId,
  842. produceRoutingName: item.produceRoutingName,
  843. produceVersionName: item.produceVersionName
  844. };
  845. }
  846. })
  847. .concat(this.disabledList);
  848. this.form.productInfoList = [];
  849. // 取出在弹窗中选中并且不在表格中的数据
  850. const result = list.filter(
  851. (i) =>
  852. this.form.productInfoList.findIndex(
  853. (p) => p.productCode === i.productCode
  854. ) === -1
  855. );
  856. // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
  857. const del = this.form.productInfoList.filter(
  858. (i) => list.findIndex((p) => p.productCode === i.productCode) === -1
  859. );
  860. for (let i = this.form.productInfoList.length - 1; i >= 0; i--) {
  861. for (let j in del) {
  862. if (
  863. this.form.productInfoList[i].productCode === del[j].productCode
  864. ) {
  865. this.form.productInfoList.splice(i, 1);
  866. break;
  867. }
  868. }
  869. }
  870. // bomVersionList
  871. this.form.productInfoList = this.form.productInfoList.concat(result);
  872. this.$refs.tableRef.setData(this.form.productInfoList);
  873. this.changeLineNumber();
  874. //重置
  875. this.$set(this.form, 'produceType', '');
  876. this.$set(this.form, 'bomCategoryId', '');
  877. this.$set(this.form, 'produceRoutingId', '');
  878. this.bomListVersion();
  879. },
  880. changeLineNumber() {
  881. this.form.productInfoList.map((item, index) => {
  882. item.lineNumber = 10 * (index + 1);
  883. });
  884. },
  885. handleDeleteItem(index) {
  886. this.$confirm('确定删除当前数据?', '提示')
  887. .then(() => {
  888. const newArray = this.form.productInfoList.filter(
  889. (item, i) => i !== index
  890. );
  891. this.form.productInfoList = newArray;
  892. this.$refs.tableRef.setData(newArray);
  893. })
  894. .catch(() => {});
  895. },
  896. async getPlanCode() {
  897. this.loading = true;
  898. try {
  899. const code = await getCode('product_code');
  900. this.$set(this.form, 'code', code);
  901. } catch (err) {}
  902. },
  903. initForm() {
  904. this.form = {
  905. timeDimensionPlanType: 3,
  906. categoryId: '',
  907. productName: '',
  908. planType: '',
  909. moCount: '', // 模具数量
  910. blockCount: 0, // 块数
  911. noWordCount: '', // 无字数量
  912. weight: '',
  913. isSlotting: '', //是否开槽
  914. slottingType: '', //开槽类型
  915. id: '',
  916. produceType: 2,
  917. status: 2,
  918. bomCategoryId: '',
  919. produceRoutingId: '',
  920. productInfoList: [],
  921. requiredFormingNum: ''
  922. };
  923. // console.log(this.$refs);
  924. // this.$refs.tableRef.setData([]);
  925. },
  926. changeBomIdFn(bomCategoryId) {
  927. return new Promise((resolve, reject) => {
  928. bomRoutingList(bomCategoryId).then((res) => {
  929. let arr = res || [];
  930. if (arr.length == 0) {
  931. row.produceRoutingId = '';
  932. }
  933. resolve(arr);
  934. });
  935. });
  936. },
  937. // 选择BOM
  938. changeBomId(row, index) {
  939. // row.routingList = []
  940. bomRoutingList(row.bomCategoryId).then((res) => {
  941. let arr = res || [];
  942. if (arr.length > 0) {
  943. this.$nextTick(() => {
  944. row.produceRoutingName = arr[0].name;
  945. row.produceVersionName = arr[0].version;
  946. row.routingList = arr;
  947. this.$set(
  948. this.form.productInfoList[index],
  949. 'produceRoutingId',
  950. arr[0].id
  951. );
  952. // this.selectionRowShow = false;
  953. row.selectionRowShow = false;
  954. this.$set(this.form.productInfoList[index], 'routingList', arr);
  955. });
  956. }
  957. this.$forceUpdate();
  958. });
  959. },
  960. // 清空BOM 跟工艺路线
  961. wipeData(index) {
  962. let row = this.form.productInfoList[index];
  963. row.bomCategoryId = '';
  964. row.routingList = [];
  965. row.bomVersionList = [];
  966. row.produceRoutingId = '';
  967. row.produceRoutingName = '';
  968. row.produceVersionName = '';
  969. row.selectionRowShow = false;
  970. // this.selectionRowShow = false;
  971. },
  972. // 选择加工方式
  973. changeProductType(row, index) {
  974. let param = {
  975. bomType: row.productType,
  976. categoryId: row.categoryId
  977. };
  978. this.wipeData(index);
  979. // row.bomCategoryId = '';
  980. // this.form.productInfoList[index].bomVersionList = [];
  981. bomListByPlan(param).then((res) => {
  982. let arr = res || [];
  983. this.$nextTick(() => {
  984. if (arr.length) {
  985. row.bomVersionList = arr;
  986. this.form.productInfoList[index].bomVersionList = arr;
  987. row.bomCategoryId = arr[0].id;
  988. this.changeBomId(row, index);
  989. let arrAll = JSON.parse(JSON.stringify(this.form));
  990. this.$set(this, 'form', arrAll);
  991. }
  992. });
  993. // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
  994. });
  995. },
  996. // 参数校验
  997. parameterVerification() {
  998. let flag = true;
  999. this.form.productInfoList.forEach((v) => {
  1000. if (this.isRequired) {
  1001. if (!v.productType) {
  1002. flag = false;
  1003. this.$message.warning('请选择加工方式');
  1004. return;
  1005. }
  1006. if (!v.bomCategoryId) {
  1007. flag = false;
  1008. this.$message.warning('请选择BOM版本');
  1009. return;
  1010. }
  1011. }
  1012. if (!v.produceRoutingId) {
  1013. flag = false;
  1014. this.$message.warning('请选择工艺路线');
  1015. return;
  1016. }
  1017. if (v.requiredFormingNum == 0) {
  1018. flag = false;
  1019. this.$message.warning('要求生产数量不能为0');
  1020. return;
  1021. }
  1022. if (!v.requiredFormingNum) {
  1023. flag = false;
  1024. this.$message.warning('请输入要求生产数量');
  1025. return;
  1026. }
  1027. });
  1028. return flag;
  1029. },
  1030. save() {
  1031. this.$refs.form.validate(async (valid) => {
  1032. if (!valid) {
  1033. return false;
  1034. }
  1035. let flag = this.parameterVerification();
  1036. // 必填参数校验
  1037. if (!flag) return;
  1038. if (!this.form.id) {
  1039. if (this.form.productInfoList.length) {
  1040. this.form.productInfoList.map((item, index) => {
  1041. delete item.selectionRowShow;
  1042. if (item.bomVersionList && item.bomVersionList.length) {
  1043. item.bomCategoryName = item.bomVersionList[0].name;
  1044. item.bomCategoryVersions = item.bomVersionList[0].versions;
  1045. item.produceRoutingName = item.routingList[0].name;
  1046. }
  1047. });
  1048. }
  1049. this.form.timeDimensionPlanType = this.type;
  1050. await this.getPlanCode();
  1051. this.loading = true;
  1052. // console.log(this.form,'this.form 1+1 ')
  1053. // return
  1054. temporaryPlanSave(this.form)
  1055. .then((res) => {
  1056. this.$message.success('新增成功!');
  1057. this.visible = false;
  1058. this.initForm();
  1059. this.$emit('close', true);
  1060. })
  1061. .finally(() => {
  1062. this.loading = false;
  1063. });
  1064. } else {
  1065. this.loading = true;
  1066. temporaryPlanSave(this.form)
  1067. .then((res) => {
  1068. this.$message.success('修改成功!');
  1069. this.visible = false;
  1070. this.initForm();
  1071. this.$emit('close', true);
  1072. })
  1073. .finally(() => {
  1074. this.loading = false;
  1075. });
  1076. }
  1077. });
  1078. },
  1079. bomListVersionFn(produceType, categoryId) {
  1080. return new Promise((resolve, reject) => {
  1081. let param = {
  1082. bomType: produceType,
  1083. categoryId: categoryId
  1084. };
  1085. bomListByPlan(param).then((res) => {
  1086. this.bomVersionList = res || [];
  1087. resolve(res || []);
  1088. });
  1089. });
  1090. },
  1091. bomListVersion() {
  1092. let param = {
  1093. bomType: this.form.produceType,
  1094. categoryId: this.form.categoryId
  1095. };
  1096. bomListByPlan(param).then((res) => {
  1097. this.$nextTick(() => {
  1098. this.bomVersionList = res || [];
  1099. });
  1100. });
  1101. },
  1102. // 工艺路线
  1103. getPlanRouting() {
  1104. bomRoutingList(this.form.bomCategoryId).then((res) => {
  1105. this.routingList = res || [];
  1106. });
  1107. },
  1108. // 宝悦 工艺路线
  1109. getPlanRoutingNew() {
  1110. // bomRoutingList(this.form.bomCategoryId).then((res) => {
  1111. // this.routingList = res || []
  1112. // })
  1113. },
  1114. tableHandleKeyUp(row, name) {
  1115. // return
  1116. // , index, e, name
  1117. if (name == 'procut') {
  1118. row.return;
  1119. }
  1120. if (row.specification && this.clientEnvironmentId == 4) {
  1121. let modelArr = row.specification.split('*');
  1122. let modelLong = modelArr[0]; // model规格长度
  1123. let modeWide = modelArr[1]; // model规格宽度
  1124. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1125. modeHight = Number(modeHight);
  1126. if (name === 'moCount') {
  1127. // 模数
  1128. this.$set(row, 'moCount', row.moCount);
  1129. // 计算块数的公式:
  1130. // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
  1131. // 每一模的块数*模数moCount = 总块数
  1132. if (row.productName.includes('板材')) {
  1133. // 块数
  1134. let blockCount =
  1135. Math.floor(600 / modelLong) *
  1136. Math.floor(120 / modeHight) *
  1137. Math.floor(60 / modeWide) *
  1138. row.moCount;
  1139. row['blockCount'] = blockCount;
  1140. // this.$set(row, 'blockCount', blockCount);
  1141. } else if (row.productName.includes('砌块')) {
  1142. let modelLongFixed = (600 / modelLong).toFixed(2);
  1143. modelLongFixed = modelLongFixed.substring(
  1144. 0,
  1145. modelLongFixed.length - 1
  1146. );
  1147. let modeWideFixed = (120 / modeWide).toFixed(2);
  1148. modeWideFixed = modeWideFixed.substring(
  1149. 0,
  1150. modeWideFixed.length - 1
  1151. );
  1152. let modeHightFixed = (60 / modeHight).toFixed(2);
  1153. modeHightFixed = modeHightFixed.substring(
  1154. 0,
  1155. modeHightFixed.length - 1
  1156. );
  1157. let num =
  1158. Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
  1159. row.moCount;
  1160. row['blockCount'] = num;
  1161. }
  1162. let numNew = (
  1163. Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
  1164. row.blockCount
  1165. ).toFixed(5);
  1166. row['requiredFormingNum'] = numNew;
  1167. } else if (name === 'sum') {
  1168. let e = row.requiredFormingNum;
  1169. //方数
  1170. row.planProductNum = e;
  1171. row.blockCount = Math.floor(
  1172. e / ((modelLong * modeWide * modeHight) / 1000000)
  1173. );
  1174. if (row.productName.includes('板材')) {
  1175. let num = Math.ceil(
  1176. row.blockCount /
  1177. (Math.floor(600 / modelLong) *
  1178. Math.floor(120 / modeHight) *
  1179. Math.floor(60 / modeWide))
  1180. );
  1181. // 48 480 4807 480
  1182. row.moCount = num;
  1183. } else if (row.productName.includes('砌块')) {
  1184. row.moCount = Math.ceil(
  1185. row.blockCount /
  1186. Math.floor(
  1187. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1188. )
  1189. );
  1190. }
  1191. } else if (name === 'blockCount') {
  1192. //块数
  1193. // row.blockCount = row.moCount;
  1194. row.blockCount = row.blockCount;
  1195. if (row.productName.includes('板材')) {
  1196. let moCount = Math.ceil(
  1197. row.blockCount /
  1198. (Math.floor(600 / modelLong) *
  1199. Math.floor(120 / modeHight) *
  1200. Math.floor(60 / modeWide))
  1201. );
  1202. row.moCount = moCount;
  1203. } else if (row.productName.includes('砌块')) {
  1204. let moCount = Math.ceil(
  1205. row.blockCount /
  1206. Math.floor(
  1207. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1208. )
  1209. );
  1210. this.$set(this.form, 'moCount', moCount);
  1211. row.moCount = moCount;
  1212. }
  1213. let a = (
  1214. (Number(row.blockCount) * modelLong * modeWide * modeHight) /
  1215. 1000000
  1216. ).toFixed(5);
  1217. row.requiredFormingNum = a;
  1218. }
  1219. }
  1220. },
  1221. changeProduceType(e) {
  1222. if (this.clientEnvironmentId !== 4) {
  1223. this.form.bomCategoryId = '';
  1224. this.form['bomCategoryName'] = '';
  1225. this.form['bomCategoryVersions'] = '';
  1226. this.bomVersionList = [];
  1227. this.routingList = [];
  1228. this.form.produceRoutingId = '';
  1229. this.form.produceRoutingName = '';
  1230. this.form.produceVersionName = '';
  1231. this.bomListVersion();
  1232. }
  1233. },
  1234. // changeBomId() {
  1235. // this.routingList = [];
  1236. // this.form.produceRoutingId = '';
  1237. // this.form.produceRoutingName = '';
  1238. // this.form.produceVersionName = '';
  1239. // this.bomVersionList.forEach((f) => {
  1240. // if (f.id == this.form.bomCategoryId) {
  1241. // this.$set(this.form, 'bomCategoryName', f.name);
  1242. // this.$set(this.form, 'bomCategoryVersions', f.versions);
  1243. // }
  1244. // });
  1245. // this.getPlanRouting();
  1246. // },
  1247. changeRoute() {
  1248. this.$forceUpdate();
  1249. this.routingList.forEach((f) => {
  1250. if (f.id == this.form.produceRoutingId) {
  1251. this.$set(this.form, 'produceRoutingId', f.id);
  1252. this.$set(this.form, 'produceRoutingName', f.name);
  1253. this.$set(this.form, 'produceVersionName', f.version);
  1254. }
  1255. });
  1256. },
  1257. cancel() {
  1258. this.visible = false;
  1259. this.initForm();
  1260. this.$emit('close');
  1261. }
  1262. }
  1263. };
  1264. </script>
  1265. <style lang="scss" scoped>
  1266. .el-form-item {
  1267. margin-bottom: 14px !important;
  1268. }
  1269. .add-product {
  1270. width: 100%;
  1271. display: flex;
  1272. align-items: center;
  1273. justify-content: flex-end;
  1274. font-size: 30px;
  1275. color: #1890ff;
  1276. margin: 10px 0;
  1277. cursor: pointer;
  1278. }
  1279. .header_required {
  1280. .is-required:before {
  1281. content: '*';
  1282. color: #f56c6c;
  1283. margin-right: 4px;
  1284. }
  1285. }
  1286. </style>