create-order.vue 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567
  1. <template>
  2. <div>
  3. <ele-modal
  4. :visible.sync="visible"
  5. :title="title"
  6. width="80vw"
  7. append-to-body
  8. :maxable="true"
  9. >
  10. <el-form
  11. ref="form"
  12. :model="form"
  13. :rules="rules"
  14. label-width="90px"
  15. class="create-form"
  16. >
  17. <el-row :gutter="24">
  18. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  19. <el-form-item label="销售订单号:">
  20. <el-input
  21. clearable
  22. :maxlength="20"
  23. v-model="form.code"
  24. disabled
  25. />
  26. </el-form-item>
  27. </el-col>
  28. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  29. <el-form-item label="订单类型:" prop="orderType">
  30. <el-select v-model="form.orderType" style="width: 100%">
  31. <el-option
  32. v-for="item of orderTypeList"
  33. :key="item.id"
  34. :label="item.label"
  35. :value="item.id"
  36. ></el-option>
  37. </el-select>
  38. </el-form-item>
  39. </el-col>
  40. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  41. <el-form-item label="销售类型:">
  42. <DictSelection
  43. dictName="订单类型"
  44. clearable
  45. v-model="form.saleType"
  46. >
  47. </DictSelection>
  48. </el-form-item>
  49. </el-col>
  50. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  51. <el-form-item label="按单按库:">
  52. <DictSelection
  53. dictName="按单按库"
  54. clearable
  55. v-model="form.orderLibraryType"
  56. >
  57. </DictSelection>
  58. </el-form-item>
  59. </el-col>
  60. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  61. <el-form-item label="客户名称:">
  62. <el-input
  63. clearable
  64. v-model="form.customerName"
  65. :disabled="form.saleType == 3"
  66. style="width: calc(100% - 70px)"
  67. />
  68. <!-- <el-button style="margin-left: 3px;" size="small" type="primary" @click.native="$refs.contactDialogRef.open()"
  69. >选择
  70. </el-button> -->
  71. <contactDialog
  72. style="margin-left: 3px"
  73. @changeParent="contactDialogSuccess"
  74. ></contactDialog>
  75. </el-form-item>
  76. </el-col>
  77. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  78. <el-form-item label="客户简称:">
  79. <el-input
  80. clearable
  81. v-model="form.simpleName"
  82. :disabled="form.saleType == 3"
  83. />
  84. </el-form-item>
  85. </el-col>
  86. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  87. <el-form-item label="客户代号:">
  88. <el-input
  89. clearable
  90. v-model="form.serialNo"
  91. :disabled="form.saleType == 3"
  92. />
  93. </el-form-item>
  94. </el-col>
  95. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  96. <el-form-item label="业务员:">
  97. <el-input
  98. clearable
  99. v-model="form.salesman"
  100. style="width: calc(100% - 70px)"
  101. />
  102. <el-button
  103. style="margin-left: 3px"
  104. type="primary"
  105. size="small"
  106. @click="selectPersonnel"
  107. >选择</el-button
  108. >
  109. </el-form-item>
  110. </el-col>
  111. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  112. <el-form-item label="交付日期:" prop="deliveryTime">
  113. <el-date-picker
  114. :picker-options="pickerOptions"
  115. style="width: 100%"
  116. v-model="form.deliveryTime"
  117. type="date"
  118. placeholder="选择日期"
  119. value-format="yyyy-MM-dd"
  120. >
  121. </el-date-picker>
  122. </el-form-item>
  123. </el-col>
  124. <!-- <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  125. <el-form-item label="齐套状态:" prop="completeState">
  126. <el-select v-model="form.completeState" style="width: 100%">
  127. <el-option v-for="item of completeList" :key="item.code" :label="item.name"
  128. :value="item.code"></el-option>
  129. </el-select>
  130. </el-form-item>
  131. </el-col> -->
  132. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  133. <el-form-item label="备注:">
  134. <el-input clearable v-model="form.notes" />
  135. </el-form-item>
  136. </el-col>
  137. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  138. <el-form-item label="交付要求:">
  139. <DictSelection
  140. dictName="紧急程度"
  141. clearable
  142. v-model="form.deliveryRequirements"
  143. >
  144. </DictSelection>
  145. </el-form-item>
  146. </el-col>
  147. <!-- <el-col v-bind="styleResponsive ? { lg: 5, md: 10 } : { span: 5 }">
  148. <el-form-item label="生产要求:" required>
  149. <el-input
  150. v-model="form.productionRequirements"
  151. style="width: 100%"
  152. placeholder=""
  153. type="textarea"
  154. disabled
  155. ></el-input>
  156. </el-form-item>
  157. </el-col> -->
  158. </el-row>
  159. <el-table :data="form.productInfoList" border height="40vh" key="id">
  160. <el-table-column label="序号" align="center" width="60">
  161. <template slot-scope="scope">
  162. <span>{{ scope.$index + 1 }}</span>
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="行号" align="center" prop="lineNumber">
  166. </el-table-column>
  167. <el-table-column
  168. label="名称"
  169. align="center"
  170. prop="productName"
  171. width="150"
  172. show-overflow-tooltip
  173. >
  174. </el-table-column>
  175. <el-table-column
  176. label="编码"
  177. align="center"
  178. prop="productCode"
  179. width="150"
  180. show-overflow-tooltip
  181. >
  182. </el-table-column>
  183. <el-table-column label="牌号" align="center" prop="brandNo">
  184. </el-table-column>
  185. <el-table-column label="型号" align="center" prop="model">
  186. </el-table-column>
  187. <el-table-column
  188. label="规格"
  189. align="center"
  190. prop="specification"
  191. width="150"
  192. show-overflow-tooltip
  193. >
  194. </el-table-column>
  195. <el-table-column label="单重" align="center" prop="productUnitWeight">
  196. </el-table-column>
  197. <el-table-column label="重量单位" align="center" prop="weightUnit">
  198. </el-table-column>
  199. <el-table-column
  200. label="机型"
  201. align="center"
  202. prop="modelKey"
  203. width="240"
  204. >
  205. <template slot-scope="scope">
  206. <el-form-item
  207. label-width="0px"
  208. :prop="'productInfoList.' + scope.$index + '.modelKey'"
  209. >
  210. <el-select
  211. clearable
  212. v-model="scope.row.modelKey"
  213. multiple
  214. filterable
  215. allow-create
  216. default-first-option
  217. >
  218. <el-option
  219. v-for="item in modelList"
  220. :key="item.label"
  221. :value="item.label"
  222. :label="item.label"
  223. >
  224. </el-option>
  225. </el-select>
  226. </el-form-item>
  227. </template>
  228. </el-table-column>
  229. <el-table-column
  230. label="颜色"
  231. align="center"
  232. prop="colorKey"
  233. width="240"
  234. >
  235. <template slot-scope="scope">
  236. <el-form-item
  237. label-width="0px"
  238. :prop="'productInfoList.' + scope.$index + '.colorKey'"
  239. >
  240. <el-select
  241. clearable
  242. v-model="scope.row.colorKey"
  243. multiple
  244. filterable
  245. allow-create
  246. default-first-option
  247. >
  248. <el-option
  249. v-for="item in colorList"
  250. :key="item.label"
  251. :value="item.label"
  252. :label="item.label"
  253. >
  254. </el-option>
  255. </el-select>
  256. </el-form-item>
  257. </template>
  258. </el-table-column>
  259. <el-table-column
  260. label="生产编号"
  261. align="center"
  262. prop="productionCodes"
  263. width="140"
  264. >
  265. <template slot-scope="scope">
  266. <el-form-item
  267. label-width="0px"
  268. :prop="'productInfoList.' + scope.$index + '.productionCodes'"
  269. >
  270. <el-input
  271. style="width: 100%"
  272. size="small"
  273. v-model="scope.row.productionCodes"
  274. placeholder="请输入"
  275. >
  276. </el-input>
  277. </el-form-item>
  278. </template>
  279. </el-table-column>
  280. <el-table-column
  281. label="生产要求"
  282. align="center"
  283. prop="productionRequirements"
  284. width="200"
  285. v-if="title == '修改订单'"
  286. >
  287. <template slot-scope="scope">
  288. <el-form-item
  289. label-width="0px"
  290. :prop="
  291. 'productInfoList.' + scope.$index + '.productionRequirements'
  292. "
  293. >
  294. <el-input
  295. style="width: 100%"
  296. size="small"
  297. v-model="scope.row.productionRequirements"
  298. placeholder="请输入"
  299. type="textarea"
  300. disabled
  301. >
  302. </el-input>
  303. </el-form-item>
  304. </template>
  305. </el-table-column>
  306. <el-table-column
  307. label="批次号"
  308. align="center"
  309. prop="batchNo"
  310. width="140"
  311. >
  312. <template slot-scope="scope">
  313. <el-form-item
  314. label-width="0px"
  315. :prop="'productInfoList.' + scope.$index + '.batchNo'"
  316. >
  317. <el-input
  318. style="width: 100%"
  319. size="small"
  320. v-model="scope.row.batchNo"
  321. placeholder="请输入"
  322. @input="
  323. (value) =>
  324. (scope.row.batchNo = value.replace(/[^a-zA-Z0-9_-]/g, ''))
  325. "
  326. >
  327. </el-input>
  328. </el-form-item>
  329. </template>
  330. </el-table-column>
  331. <el-table-column
  332. label="订单数量"
  333. width="140"
  334. align="center"
  335. prop="contractNum"
  336. >
  337. <template slot="header" slot-scope="scope">
  338. <div class="header_required"
  339. ><span class="is-required">订单数量</span></div
  340. >
  341. </template>
  342. <template slot-scope="scope">
  343. <el-form-item
  344. label-width="0px"
  345. :prop="'productInfoList.' + scope.$index + '.contractNum'"
  346. :rules="{
  347. required: true,
  348. message: '请输入订单数量',
  349. trigger: 'blur'
  350. }"
  351. >
  352. <el-input
  353. v-model.number="scope.row.contractNum"
  354. size="small"
  355. type="number"
  356. style="width: 100%"
  357. placeholder="输入数量"
  358. @input="inputNumber(scope.row, scope.$index)"
  359. ></el-input>
  360. </el-form-item>
  361. </template>
  362. </el-table-column>
  363. <el-table-column
  364. label="BOM类型"
  365. width="140"
  366. align="center"
  367. prop="productType"
  368. >
  369. <template slot="header" slot-scope="scope">
  370. <div :class="isRequired ? 'header_required' : ''"
  371. ><span class="is-required">BOM类型</span></div
  372. >
  373. </template>
  374. <template slot-scope="scope">
  375. <el-form-item
  376. label-width="0px"
  377. :prop="'productInfoList.' + scope.$index + '.productType'"
  378. >
  379. <el-select
  380. v-model="scope.row.productType"
  381. @change="changeProductType(scope.row, scope.$index)"
  382. :key="scope.$index"
  383. :disabled="!isAdd"
  384. >
  385. <el-option
  386. v-for="item of scope.row.producedList"
  387. :key="scope.$index + item.code"
  388. :label="item.name"
  389. :value="item.code"
  390. ></el-option>
  391. </el-select>
  392. </el-form-item>
  393. </template>
  394. </el-table-column>
  395. <el-table-column
  396. :label-class-name="isRequired ? 'header_required' : ''"
  397. label="BOM版本"
  398. width="140"
  399. align="center"
  400. prop="bomCategoryId"
  401. v-if="clientEnvironmentId != 4"
  402. >
  403. <template slot="header" slot-scope="scope">
  404. <div :class="isRequired ? 'header_required' : ''"
  405. ><span class="is-required">BOM版本</span></div
  406. >
  407. </template>
  408. <template slot-scope="scope">
  409. <el-form-item
  410. label-width="0px"
  411. :prop="'productInfoList.' + scope.$index + '.bomCategoryId'"
  412. :key="scope.$index"
  413. >
  414. <el-select
  415. v-model="scope.row.bomCategoryId"
  416. @change="changeBomId(scope.row, scope.$index)"
  417. :disabled="!isAdd"
  418. >
  419. <el-option
  420. v-for="item of scope.row.bomVersionList"
  421. :key="item.id"
  422. :label="item.name + '(V' + item.versions + '.0)'"
  423. :value="item.id"
  424. ></el-option>
  425. </el-select>
  426. </el-form-item>
  427. </template>
  428. </el-table-column>
  429. <el-table-column
  430. label="工艺路线"
  431. width="240"
  432. align="center"
  433. prop="produceRoutingId"
  434. v-if="clientEnvironmentId != 4"
  435. >
  436. <template slot="header" slot-scope="scope">
  437. <div class="header_required"
  438. ><span class="is-required">工艺路线</span></div
  439. >
  440. </template>
  441. <template slot-scope="scope">
  442. <el-form-item
  443. label-width="0px"
  444. :prop="'productInfoList.' + scope.$index + '.produceRoutingId'"
  445. >
  446. <div style="display: flex">
  447. <el-select
  448. v-model="scope.row.produceRoutingId"
  449. @change="changeRoutingList(scope.row, scope.$index)"
  450. v-show="isRouteSelect(scope.row)"
  451. >
  452. <el-option
  453. v-for="item of scope.row.routingList"
  454. :key="item.id"
  455. :label="item.name"
  456. :value="item.id"
  457. ></el-option>
  458. </el-select>
  459. <div style="display: flex">
  460. <el-input
  461. v-show="!isRouteSelect(scope.row)"
  462. disabled
  463. v-model="scope.row.produceRoutingName"
  464. ></el-input>
  465. <el-button
  466. v-show="isSelectShow"
  467. type="primary"
  468. size="mini"
  469. @click="openDialog(scope.$index)"
  470. >选择</el-button
  471. >
  472. </div>
  473. </div>
  474. </el-form-item>
  475. </template>
  476. </el-table-column>
  477. <el-table-column
  478. label="工艺路线"
  479. align="center"
  480. prop="produceRoutingName"
  481. v-if="clientEnvironmentId == 4"
  482. >
  483. <template slot-scope="scope">
  484. <el-form-item
  485. label-width="0px"
  486. :prop="
  487. 'productInfoList.' + scope.$index + '.produceRoutingName'
  488. "
  489. >
  490. <el-input
  491. v-model="form.produceRoutingName"
  492. style="width: 100%"
  493. readonly
  494. ></el-input>
  495. </el-form-item>
  496. </template>
  497. </el-table-column>
  498. <el-table-column
  499. label="所属工厂"
  500. width="140"
  501. align="center"
  502. prop="factoriesId"
  503. >
  504. <template slot="header" slot-scope="scope">
  505. <div class="header_required"
  506. ><span class="is-required">所属工厂</span></div
  507. >
  508. </template>
  509. <template slot-scope="scope">
  510. <el-form-item label-width="0px">
  511. <el-select
  512. v-model="scope.row.factoriesId"
  513. :key="scope.row.factoriesId"
  514. @change="(e) => factorChange(e, scope.row)"
  515. >
  516. <el-option
  517. v-for="item of factoryList"
  518. :key="item.id"
  519. :label="item.name"
  520. :value="item.id"
  521. ></el-option>
  522. </el-select>
  523. </el-form-item>
  524. </template>
  525. </el-table-column>
  526. <el-table-column label="计量单位" align="center" prop="measuringUnit">
  527. </el-table-column>
  528. <el-table-column
  529. label="模数"
  530. align="center"
  531. width="100"
  532. v-if="clientEnvironmentId == '4'"
  533. >
  534. <template slot-scope="scope">
  535. <div>
  536. <el-input
  537. style="width: 100%"
  538. size="small"
  539. v-model="scope.row.moCount"
  540. oninput="value=value.replace(/[^0-9.]/g,'')"
  541. @input="
  542. tableHandleKeyUp(scope.row, scope.$index, $event, 'moCount')
  543. "
  544. placeholder="请输入"
  545. >
  546. </el-input>
  547. </div>
  548. </template>
  549. </el-table-column>
  550. <el-table-column
  551. align="center"
  552. width="100"
  553. label="块数"
  554. v-if="clientEnvironmentId == '4'"
  555. >
  556. <template slot-scope="scope">
  557. <div>
  558. <el-input
  559. size="small"
  560. style="width: 100%"
  561. @input="
  562. tableHandleKeyUp(
  563. scope.row,
  564. scope.$index,
  565. $event,
  566. 'blockCount'
  567. )
  568. "
  569. v-model="scope.row.blockCount"
  570. placeholder="请输入"
  571. ></el-input>
  572. </div>
  573. </template>
  574. </el-table-column>
  575. <el-table-column label="订单重量" align="center" prop="productWeight">
  576. <template slot-scope="{ row }">
  577. <span>{{ row.productWeight ? row.productWeight : '-' }}</span>
  578. </template>
  579. </el-table-column>
  580. <el-table-column label="操作" align="center" width="160">
  581. <template slot-scope="scope">
  582. <!-- <el-link
  583. type="primary"
  584. :underline="false"
  585. @click="homogeneityInspect(scope.row)"
  586. >
  587. 齐套性检查
  588. </el-link> -->
  589. <el-button
  590. type="text"
  591. @click="handleDeleteItem(scope.$index)"
  592. v-if="!scope.row.id"
  593. >删除</el-button
  594. >
  595. </template>
  596. </el-table-column>
  597. </el-table>
  598. <div class="add-product" @click="addEquipment" v-if="isAdd">
  599. <i class="el-icon-circle-plus-outline"></i>
  600. </div>
  601. </el-form>
  602. <template v-slot:footer>
  603. <el-button @click="cancel">取消</el-button>
  604. <el-button type="primary" @click="save" :loading="loading">
  605. 确定
  606. </el-button>
  607. </template>
  608. <!-- 选择工艺路线 -->
  609. <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
  610. <!-- 选择产品 -->
  611. <EquipmentDialog
  612. ref="equipmentRefs"
  613. @choose="confirmChoose"
  614. :selectList="
  615. form.productInfoList.filter(
  616. (i) => !disabledList.find((p) => p.productCode === i.productCode)
  617. )
  618. "
  619. >
  620. </EquipmentDialog>
  621. </ele-modal>
  622. <orderHomogeneityInspectDialog
  623. ref="orderHomogeneityInspectDialog"
  624. ></orderHomogeneityInspectDialog>
  625. <orderHomogeneityInspectInstallDialog
  626. ref="orderHomogeneityInspectInstallDialog"
  627. >
  628. </orderHomogeneityInspectInstallDialog>
  629. <personnelDialog ref="personnelRef" @changePersonnel="changePersonnel" />
  630. </div>
  631. </template>
  632. <script>
  633. import { getCode } from '@/api/codeManagement';
  634. import EquipmentDialog from '../components/EquipmentDialog.vue';
  635. import orderHomogeneityInspectDialog from './orderHomogeneityInspectDialog';
  636. import orderHomogeneityInspectInstallDialog from './orderHomogeneityInspectInstallDialog';
  637. import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
  638. import personnelDialog from './personnelDialog.vue';
  639. import {
  640. createOrUpdate,
  641. getOrderDetail,
  642. bomListByPlan,
  643. bomRoutingList,
  644. getFactoryList,
  645. findBomCategoryByCategoryIds
  646. } from '@/api/saleOrder';
  647. import { listBomType } from '@/api/productionPlan/index';
  648. import { parameterGetByCode } from '@/api/mainData/index';
  649. import dayjs from 'dayjs';
  650. import { multiply } from '@/utils/math';
  651. import contactDialog from '@/components/contactDialog/openContactDialog.vue';
  652. import { getByCode } from '@/api/system/dictionary-data';
  653. export default {
  654. name: 'CreateOrder',
  655. components: {
  656. EquipmentDialog,
  657. orderHomogeneityInspectDialog,
  658. orderHomogeneityInspectInstallDialog,
  659. ProcessRoute,
  660. contactDialog,
  661. personnelDialog
  662. },
  663. props: {
  664. isAdd: {
  665. type: Boolean,
  666. default: true
  667. }
  668. },
  669. data() {
  670. return {
  671. visible: false,
  672. loading: false,
  673. disabledList: [], //已保存数据不做删除
  674. form: {
  675. salesman: '',
  676. salesmanId: '',
  677. productInfoList: [],
  678. deliveryRequirements: 1,
  679. saleType: 1,
  680. orderLibraryType: 2,
  681. productType: 2,
  682. bomCategoryId: '',
  683. produceRoutingId: '',
  684. factoriesId: '',
  685. deliveryTime: dayjs(
  686. new Date().getTime() + 3600 * 1000 * 24 * 10
  687. ).format('YYYY-MM-DD'),
  688. orderType: 0
  689. },
  690. // 表单验证规则
  691. rules: {
  692. deliveryTime: [
  693. { required: true, message: '请选择交付日期', trigger: 'change' }
  694. ],
  695. orderType: [
  696. { required: true, message: '请选择订单类型', trigger: 'blur' }
  697. ]
  698. },
  699. typeList: [
  700. { id: 1, label: '内销订单' },
  701. { id: 2, label: '外销订单' },
  702. { id: 3, label: '预制订单' }
  703. ],
  704. producedList: [
  705. { code: 2, name: '加工(MBOM)' },
  706. { code: 3, name: '装配(ABOM)' }
  707. ],
  708. completeList: [
  709. { code: 1, name: '齐套' },
  710. { code: 2, name: '缺料' }
  711. ],
  712. routingList: [],
  713. factoryList: [],
  714. title: '创建订单',
  715. pickerOptions: {
  716. disabledDate: (time) => {
  717. // 禁用日期
  718. let nowData = new Date();
  719. nowData = new Date(nowData.setDate(nowData.getDate() - 1));
  720. return time < nowData;
  721. }
  722. },
  723. // 订单类型
  724. orderTypeList: [
  725. {
  726. id: 0,
  727. label: '库存性订单'
  728. },
  729. {
  730. id: 1,
  731. label: '生产性订单'
  732. },
  733. {
  734. id: 2,
  735. label: '无客户生产性订单'
  736. },
  737. {
  738. id: 4,
  739. label: '不定向订单'
  740. }
  741. ],
  742. selectIndex: 0, // 选择工艺路线的当前数据下标
  743. processingRequired: 0, // 生产类型跟BOM 版本是否必填 1:是 0:否
  744. sourceSalesOrderId: '', // 源销售订单ID
  745. modelList: [], // 机型数据
  746. colorList: [] // 颜色数据
  747. };
  748. },
  749. watch: {
  750. // disabledList() {
  751. // console.log(this.disabledList, 'disabledList');
  752. // }
  753. },
  754. computed: {
  755. // 是否开启响应式布局
  756. styleResponsive() {
  757. return this.$store.state.theme.styleResponsive;
  758. },
  759. clientEnvironmentId() {
  760. return this.$store.state.user.info.clientEnvironmentId;
  761. },
  762. // 是否必填字段
  763. isRequired() {
  764. // if (this.form.planType == 5) {
  765. // return false;
  766. // }
  767. return this.processingRequired == 1;
  768. },
  769. // 工艺路线 输入框展示跟选择框判断
  770. isRouteSelect() {
  771. return (row) => {
  772. if (this.isRequired) {
  773. return true;
  774. }
  775. if (!row.selectionRowShow) {
  776. return true;
  777. }
  778. return false;
  779. };
  780. },
  781. // 选择按钮的显示
  782. isSelectShow() {
  783. // if (this.form.planType == 5) {
  784. // return true;
  785. // }
  786. return this.processingRequired == 0;
  787. }
  788. },
  789. created() {},
  790. mounted() {
  791. this.mandatoryField();
  792. this.getFactoryList();
  793. this.getCodeData();
  794. },
  795. methods: {
  796. selectPersonnel() {
  797. this.$refs.personnelRef.open(this.form.salesmanId);
  798. },
  799. changePersonnel(row) {
  800. this.form.salesman = row.name;
  801. this.form.salesmanId = row.id;
  802. },
  803. // 获取
  804. async getCodeData() {
  805. let arr1 = await this.getLevelCode('product_model_key');
  806. let arr2 = await this.getLevelCode('product_color_key');
  807. this.modelList = arr1;
  808. this.colorList = arr2;
  809. },
  810. async getLevelCode(code) {
  811. try {
  812. const res = await getByCode(code);
  813. if (res.code == 0) {
  814. let list = Object.values(res.data).map((el) => {
  815. let k = Object.keys(el)[0];
  816. let v = Object.values(el)[0];
  817. return {
  818. label: v,
  819. value: k
  820. };
  821. });
  822. return list;
  823. }
  824. } catch (err) {
  825. this.$message.error(err.message);
  826. }
  827. },
  828. // 是否必填
  829. mandatoryField() {
  830. parameterGetByCode({
  831. code: 'production_plan_code'
  832. }).then((res) => {
  833. if (res) {
  834. this.processingRequired = res.value;
  835. }
  836. });
  837. },
  838. factorChange(e, row) {
  839. let obj = this.factoryList.find((el) => el.id === e);
  840. if (obj) {
  841. row.factoriesIdName = obj.name;
  842. }
  843. // factoriesIdName
  844. },
  845. // filterInput(value) {
  846. // let aaa = value.replace(/[^a-zA-Z0-9]/g, '');
  847. // console.log('cccaaaaaaaccc', aaa);
  848. // },
  849. changeRoutingList(row, index) {
  850. const obj = row.routingList?.find(
  851. (item) => item.id === row.produceRoutingId
  852. );
  853. if (obj) {
  854. row.produceRoutingName = obj.name;
  855. }
  856. },
  857. async getFactoryList() {
  858. this.factoryList = await getFactoryList();
  859. },
  860. open(row) {
  861. this.visible = true;
  862. if (row) {
  863. this.title = '修改订单';
  864. this.getDetail(row.code);
  865. } else {
  866. this.title = '创建订单';
  867. this.getSaleCode();
  868. }
  869. },
  870. getDetail(code) {
  871. getOrderDetail(code).then(async (res) => {
  872. console.log(res, 'res');
  873. if (res.productInfoList) {
  874. for (let item of res.productInfoList) {
  875. if (!item.bomCategoryId) {
  876. item.productType = '';
  877. item.selectionRowShow = true;
  878. } else {
  879. item.selectionRowShow = false;
  880. }
  881. if (item.productType) {
  882. item.productType = parseInt(item.productType);
  883. }
  884. }
  885. }
  886. if (res.productInfoList && res.productInfoList.length != 0) {
  887. res.productInfoList.forEach((item, index) => {
  888. if (item.colorKey && typeof item.colorKey == 'string') {
  889. this.$set(
  890. res.productInfoList[index],
  891. 'colorKey',
  892. item.colorKey.split(',')
  893. );
  894. }
  895. if (item.modelKey && typeof item.modelKey == 'string') {
  896. this.$set(
  897. res.productInfoList[index],
  898. 'modelKey',
  899. item.modelKey.split(',')
  900. );
  901. }
  902. item.lackNum = null;
  903. if (item.bomVersionList?.length && item.productType) {
  904. item.bomVersionList = item.bomVersionList.filter(
  905. (el) => el.bomType == item.productType
  906. );
  907. }
  908. });
  909. }
  910. // this.disabledList = res.productInfoList;
  911. if (res.productInfoList.length > 0) {
  912. const promiselist = [];
  913. res.productInfoList.forEach(async (el, index) => {
  914. promiselist.push(this.getBomInfo(el));
  915. });
  916. await Promise.all(promiselist);
  917. }
  918. this.disabledList = res.productInfoList;
  919. this.form = res;
  920. const promiseProduct = [];
  921. this.form.productInfoList.forEach(async (el, index) => {
  922. let lis = el.producedList;
  923. if (lis && lis.length > 0) {
  924. el.productType = el.productType || el.producedList[0].code;
  925. promiseProduct.push(this.changeProductType(el, index, 'init'));
  926. }
  927. });
  928. await Promise.all(promiseProduct);
  929. // // 如果没有bom版本的选择的话
  930. });
  931. },
  932. // 获取bom信息
  933. async getBomInfo(data) {
  934. let params = { categoryId: data.categoryId };
  935. const res = await listBomType(params);
  936. if (!res || res.length == 0) return;
  937. let bomMap = {
  938. 1: { code: 1, name: 'PBOM' },
  939. 2: { code: 2, name: 'MBOM' },
  940. 3: { code: 3, name: 'ABOM' }
  941. };
  942. let arr = [];
  943. res.map((item) => {
  944. if (bomMap[item.bomType]) {
  945. arr.push(bomMap[item.bomType]);
  946. delete bomMap[item.bomType];
  947. }
  948. });
  949. console.log('什么时候进来');
  950. // this.$set(data, 'producedList', arr);
  951. data.producedList = arr;
  952. console.log(arr, 'arr');
  953. },
  954. cancel() {
  955. this.form = {
  956. salesmanId: '',
  957. salesman: '',
  958. productInfoList: [],
  959. deliveryRequirements: 1,
  960. saleType: 1,
  961. orderLibraryType: 2,
  962. deliveryTime: dayjs(
  963. new Date().getTime() + 3600 * 1000 * 24 * 10
  964. ).format('YYYY-MM-DD')
  965. };
  966. this.$refs.form.clearValidate();
  967. this.visible = false;
  968. },
  969. contactDialogSuccess(data) {
  970. this.$set(this.form, 'customerName', data.name);
  971. this.$set(this.form, 'simpleName', data.simpleName);
  972. this.$set(this.form, 'serialNo', data.serialNo);
  973. this.$set(this.form, 'simpleName', data.simpleName);
  974. },
  975. // 表格:模数、数量(方)、块数输入框 输入事件
  976. tableHandleKeyUp(row, index, e, name) {
  977. let modelArr = row.specification.split('*');
  978. let modelLong = modelArr[0]; // model规格长度
  979. let modeWide = modelArr[1]; // model规格宽度
  980. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  981. modeHight = Number(modeHight);
  982. if (name === 'moCount') {
  983. // 模数
  984. row.moCount = e;
  985. // 计算块数的公式:
  986. // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
  987. // 每一模的块数*模数moCount = 总块数
  988. if (row.productName.includes('板材')) {
  989. row.blockCount =
  990. Math.floor(600 / modelLong) *
  991. Math.floor(120 / modeHight) *
  992. Math.floor(60 / modeWide) *
  993. row.moCount;
  994. } else if (row.productName.includes('砌块')) {
  995. let modelLongFixed = (600 / modelLong).toFixed(2);
  996. modelLongFixed = modelLongFixed.substring(
  997. 0,
  998. modelLongFixed.length - 1
  999. );
  1000. let modeWideFixed = (120 / modeWide).toFixed(2);
  1001. modeWideFixed = modeWideFixed.substring(
  1002. 0,
  1003. modeWideFixed.length - 1
  1004. );
  1005. let modeHightFixed = (60 / modeHight).toFixed(2);
  1006. modeHightFixed = modeHightFixed.substring(
  1007. 0,
  1008. modeHightFixed.length - 1
  1009. );
  1010. row.blockCount =
  1011. Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
  1012. row.moCount;
  1013. }
  1014. row.contractNum =
  1015. ((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
  1016. row.blockCount;
  1017. } else if (name === 'sum') {
  1018. //方数
  1019. row.contractNum = e;
  1020. row.blockCount = Math.floor(
  1021. e / ((modelLong * modeWide * modeHight) / 1000000)
  1022. );
  1023. if (row.productName.includes('板材')) {
  1024. row.moCount = Math.ceil(
  1025. row.blockCount /
  1026. (Math.floor(600 / modelLong) *
  1027. Math.floor(120 / modeHight) *
  1028. Math.floor(60 / modeWide))
  1029. );
  1030. } else if (row.productName.includes('砌块')) {
  1031. row.moCount = Math.ceil(
  1032. row.blockCount /
  1033. Math.floor(
  1034. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1035. )
  1036. );
  1037. }
  1038. } else if (name === 'blockCount') {
  1039. //块数
  1040. row.blockCount = e;
  1041. if (row.productName.includes('板材')) {
  1042. row.moCount = Math.ceil(
  1043. row.blockCount /
  1044. (Math.floor(600 / modelLong) *
  1045. Math.floor(120 / modeHight) *
  1046. Math.floor(60 / modeWide))
  1047. );
  1048. } else if (row.productName.includes('砌块')) {
  1049. row.moCount = Math.ceil(
  1050. row.blockCount /
  1051. Math.floor(
  1052. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1053. )
  1054. );
  1055. }
  1056. row.contractNum =
  1057. (Number(e) * modelLong * modeWide * modeHight) / 1000000;
  1058. }
  1059. row.contractNum = Number(row.contractNum.toFixed(5));
  1060. },
  1061. // 删除产品
  1062. handleDeleteItem(index) {
  1063. this.form.productInfoList.splice(index, 1);
  1064. this.changeLineNumber();
  1065. },
  1066. addEquipment() {
  1067. this.$refs.equipmentRefs.open();
  1068. },
  1069. /* 保存编辑 */
  1070. save() {
  1071. this.$refs.form.validate((valid) => {
  1072. if (!valid) {
  1073. return false;
  1074. }
  1075. if (!this.form.productInfoList.length) {
  1076. return this.$message.warning('产品列表不能为空!');
  1077. }
  1078. let flag = this.parameterVerification();
  1079. // 必填参数校验
  1080. if (!flag) return;
  1081. console.log(this.form, '33333333333');
  1082. this.loading = true;
  1083. let params = {
  1084. ...this.form,
  1085. sourceType: this.isAdd ? 1 : 2
  1086. };
  1087. if (!this.isAdd) {
  1088. params.sourceSalesOrderId = this.sourceSalesOrderId;
  1089. params.productInfoList.forEach((el) => delete el.id);
  1090. }
  1091. params.productInfoList.forEach((item) => {
  1092. item.colorKey = item.colorKey.toString();
  1093. item.modelKey = item.modelKey.toString();
  1094. });
  1095. createOrUpdate(params)
  1096. .then((res) => {
  1097. this.loading = false;
  1098. this.$message.success('成功');
  1099. this.cancel();
  1100. this.$emit('refresh');
  1101. })
  1102. .catch((e) => {
  1103. this.loading = false;
  1104. });
  1105. });
  1106. },
  1107. // 参数校验
  1108. parameterVerification() {
  1109. let flag = true;
  1110. for (let i = 0; i < this.form.productInfoList.length; i++) {
  1111. let v = this.form.productInfoList[i];
  1112. if (this.isRequired) {
  1113. if (!v.productType) {
  1114. flag = false;
  1115. this.$message.warning('请选择生产类型');
  1116. break;
  1117. }
  1118. if (!v.productType) {
  1119. flag = false;
  1120. this.$message.warning('请选择BOM版本');
  1121. break;
  1122. }
  1123. }
  1124. if (!v.contractNum) {
  1125. flag = false;
  1126. this.$message.warning('请输入订单数量且订单数量不能为0');
  1127. break;
  1128. }
  1129. //contractNum
  1130. if (!v.produceRoutingId) {
  1131. flag = false;
  1132. this.$message.warning('请选择工艺路线');
  1133. break;
  1134. }
  1135. if (!v.factoriesId) {
  1136. flag = false;
  1137. this.$message.warning('请选择所属工厂');
  1138. break;
  1139. }
  1140. }
  1141. // this.form.productInfoList.forEach((v) => {
  1142. // if (this.isRequired) {
  1143. // if (!v.productType) {
  1144. // flag = false;
  1145. // this.$message.warning('请选择生产类型');
  1146. // return;
  1147. // }
  1148. // if (!v.productType) {
  1149. // flag = false;
  1150. // this.$message.warning('请选择BOM版本');
  1151. // return;
  1152. // }
  1153. // }
  1154. // if (!v.produceRoutingId) {
  1155. // flag = false;
  1156. // this.$message.warning('请选择工艺路线');
  1157. // return;
  1158. // }
  1159. // });
  1160. return flag;
  1161. },
  1162. // 选择订单类型
  1163. chooseType(val) {
  1164. if (val == 2) {
  1165. this.$set(this.form, 'orderLibraryType', 1);
  1166. } else {
  1167. this.$set(this.form, 'orderLibraryType', 2);
  1168. }
  1169. this.$set(this.form, 'customerName', '');
  1170. },
  1171. async getSaleCode() {
  1172. const res = await getCode('order_sale_code');
  1173. if (res) {
  1174. this.$set(this.form, 'code', res);
  1175. }
  1176. },
  1177. // 确定选择
  1178. async confirmChoose(list) {
  1179. list.map((el) => (el.selectionRowShow = false));
  1180. list = list
  1181. .filter(
  1182. (i) =>
  1183. !this.disabledList.find(
  1184. (p) => p.productCode == i.code || p.productCode == i.productCode
  1185. )
  1186. )
  1187. .map((item, index) => {
  1188. if (item.productCode) {
  1189. return item;
  1190. } else {
  1191. return {
  1192. categoryId: item.id,
  1193. productCode: item.code,
  1194. productName: item.name,
  1195. productUnitWeight: item.netWeight,
  1196. weightUnit: item.weightUnit,
  1197. model: item.modelType,
  1198. specification: item.specification,
  1199. brandNo: item.brandNum,
  1200. measuringUnit: item.measuringUnit
  1201. };
  1202. }
  1203. })
  1204. .concat(this.disabledList);
  1205. // 取出在弹窗中选中并且不在表格中的数据
  1206. const result = list.filter(
  1207. (i) =>
  1208. this.form.productInfoList.findIndex(
  1209. (p) => p.productCode === i.productCode
  1210. ) === -1
  1211. );
  1212. // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
  1213. const del = this.form.productInfoList.filter(
  1214. (i) => list.findIndex((p) => p.productCode === i.productCode) === -1
  1215. );
  1216. for (let i = this.form.productInfoList.length - 1; i >= 0; i--) {
  1217. for (let j in del) {
  1218. if (
  1219. this.form.productInfoList[i].productCode === del[j].productCode
  1220. ) {
  1221. this.form.productInfoList.splice(i, 1);
  1222. break;
  1223. }
  1224. }
  1225. }
  1226. if (result.length > 0) {
  1227. // let ids = result.map((item) => item.categoryId);
  1228. // const res = await findBomCategoryByCategoryIds(ids);
  1229. // let datas = JSON.parse(JSON.stringify(result));
  1230. // console.log(datas, 'datas 00000');
  1231. // datas = await this.handleResult(datas, res);
  1232. let datas = JSON.parse(JSON.stringify(result));
  1233. const promiselist = [];
  1234. datas.forEach(async (el) => {
  1235. promiselist.push(this.getBomInfo(el));
  1236. this.getBomInfo(el);
  1237. });
  1238. await Promise.all(promiselist);
  1239. this.form.productInfoList = this.form.productInfoList.concat(datas);
  1240. const promiseProduct = [];
  1241. this.form.productInfoList.forEach(async (el, index) => {
  1242. let lis = el.producedList;
  1243. if (!el.bomCategoryId && lis && lis.length > 0) {
  1244. el.productType = el.producedList[0].code;
  1245. promiseProduct.push(this.changeProductType(el, index));
  1246. }
  1247. });
  1248. await Promise.all(promiseProduct);
  1249. } else {
  1250. this.form.productInfoList = this.form.productInfoList.concat(result);
  1251. }
  1252. this.changeLineNumber();
  1253. },
  1254. // 计算生产类型数据
  1255. calculationType(data) {
  1256. console.log(data, 'data 99955');
  1257. let list = [];
  1258. let listMap = {
  1259. 1: { code: 1, name: 'PBOM' },
  1260. 2: { code: 2, name: 'MBOM' },
  1261. 3: { code: 3, name: 'ABOM' }
  1262. };
  1263. data.forEach((el) => {
  1264. if (listMap[el.bomType]) {
  1265. list.push(listMap[el.bomType]);
  1266. delete listMap[el.bomType];
  1267. }
  1268. });
  1269. return list;
  1270. },
  1271. //
  1272. async handleResult(result, res, type) {
  1273. result.forEach((item) => {
  1274. if (!res[item.categoryId]) {
  1275. return;
  1276. }
  1277. let val = res[item.categoryId];
  1278. if (!val || val.length == 0) {
  1279. return;
  1280. }
  1281. let arr = [];
  1282. let first = val[0];
  1283. arr = val.filter((item) => item.bomType == first.bomType);
  1284. if (!item.productType) {
  1285. item.productType = first.bomType - 0;
  1286. }
  1287. console.log(arr, 'arr');
  1288. let list = this.calculationType(val);
  1289. item.producedList = list;
  1290. if (!type) {
  1291. item.bomVersionList = arr;
  1292. // arr.map((el) => (el.bomCategoryId = el.id));
  1293. item.bomCategoryId = arr[0].id;
  1294. }
  1295. // if (type) {
  1296. // let obj = item.bomVersionList.find(
  1297. // (el) => el.id == item.bomCategoryId
  1298. // );
  1299. // if (obj) return;
  1300. // this.changeBomId(item.bomVersionList[0],0)
  1301. // console.log(obj,'obj 11')
  1302. // }
  1303. });
  1304. result.forEach(async (ele) => {
  1305. ele = await this.getFindRoutingListByBomId(ele);
  1306. console.log(ele, 'ele');
  1307. });
  1308. return result;
  1309. },
  1310. // 获取工艺路线
  1311. async getFindRoutingListByBomId(ele) {
  1312. let proArr = ele.bomVersionList;
  1313. if (!proArr || proArr.length == 0) {
  1314. return ele;
  1315. }
  1316. console.log(proArr, 'proArr');
  1317. const res = await bomRoutingList(proArr[0].id);
  1318. let arr = res || [];
  1319. if (arr.length > 0) {
  1320. this.$set(ele, 'routingList', arr);
  1321. ele.produceRoutingName = arr[0].name;
  1322. this.$set(ele, 'produceRoutingId', arr[0].id);
  1323. }
  1324. return ele;
  1325. },
  1326. // // await this.changeBomId(arr[0], 0);
  1327. changeLineNumber() {
  1328. this.form.productInfoList.map((item, index) => {
  1329. item.lineNumber = 10 * (index + 1);
  1330. });
  1331. },
  1332. inputNumber(row, index) {
  1333. const pos = this.form.productInfoList;
  1334. if (pos[index].productUnitWeight) {
  1335. const number = multiply(row.contractNum, row.productUnitWeight);
  1336. this.$set(pos[index], 'productWeight', number);
  1337. }
  1338. if (this.clientEnvironmentId == 4) {
  1339. this.tableHandleKeyUp(row, '', row.contractNum, 'sum');
  1340. }
  1341. },
  1342. getProcessRouteData(list, sourceSalesOrderId) {
  1343. this.sourceSalesOrderId = sourceSalesOrderId;
  1344. list.map(async (row, index) => {
  1345. await this.changeBomId(row, index);
  1346. });
  1347. this.changeLineNumber();
  1348. },
  1349. // 清空BOM 跟工艺路线
  1350. wipeData(index) {
  1351. let row = this.form.productInfoList[index];
  1352. row.bomCategoryId = '';
  1353. row.routingList = [];
  1354. row.bomVersionList = [];
  1355. row.produceRoutingId = '';
  1356. row.produceRoutingName = '';
  1357. // row.produceVersionName = '';
  1358. row.selectionRowShow = false;
  1359. // this.selectionRowShow = false;
  1360. },
  1361. // 选择生产类型
  1362. async changeProductType(row, index, type) {
  1363. let param = {
  1364. bomType: row.productType,
  1365. categoryId: row.categoryId
  1366. };
  1367. if (type != 'init') {
  1368. this.wipeData(index);
  1369. }
  1370. const res = await bomListByPlan(param);
  1371. console.log(res, 'res 3333');
  1372. let arr = res || [];
  1373. // let data = this.form.productInfoList[index];
  1374. if (arr.length) {
  1375. this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
  1376. if (type == 'init') {
  1377. this.$set(
  1378. this.form.productInfoList[index],
  1379. 'bomCategoryId',
  1380. row.bomCategoryId || arr[0].id
  1381. );
  1382. } else {
  1383. this.$set(
  1384. this.form.productInfoList[index],
  1385. 'bomCategoryId',
  1386. arr[0].id
  1387. );
  1388. }
  1389. await this.changeBomId(row, index, type);
  1390. let arrAll = JSON.parse(JSON.stringify(this.form));
  1391. this.$set(this, 'form', arrAll);
  1392. }
  1393. this.$forceUpdate();
  1394. // let arr = res || [];
  1395. // if (arr.length == 0) {
  1396. // row.bomCategoryId = '';
  1397. // }
  1398. // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
  1399. // this.$forceUpdate();
  1400. // console.log(this.form,'this.formthis.form')
  1401. },
  1402. // 选择BOM
  1403. async changeBomId(row, index, type) {
  1404. const res = await bomRoutingList(row.bomCategoryId);
  1405. let arr = res || [];
  1406. // if (arr.length == 0) {
  1407. // row.produceRoutingId = '';
  1408. // }
  1409. this.$set(this.form.productInfoList[index], 'routingList', arr);
  1410. if (arr.length > 0) {
  1411. if (type == 'init') {
  1412. this.$set(
  1413. this.form.productInfoList[index],
  1414. 'produceRoutingName',
  1415. row.produceRoutingName || arr[0].name
  1416. );
  1417. this.$set(
  1418. this.form.productInfoList[index],
  1419. 'produceRoutingId',
  1420. row.produceRoutingId || arr[0].id
  1421. );
  1422. } else {
  1423. this.$set(
  1424. this.form.productInfoList[index],
  1425. 'produceRoutingName',
  1426. arr[0].name
  1427. );
  1428. this.$set(
  1429. this.form.productInfoList[index],
  1430. 'produceRoutingId',
  1431. arr[0].id
  1432. );
  1433. }
  1434. }
  1435. this.$forceUpdate();
  1436. },
  1437. homogeneityInspect(row) {
  1438. if (!row.productType) {
  1439. this.$message.warning('请选择生产类型');
  1440. return;
  1441. }
  1442. if (!row.bomCategoryId) {
  1443. this.$message.warning('请选择BOM版本');
  1444. return;
  1445. }
  1446. if (!row.contractNum) {
  1447. this.$message.warning('请输入订单数量且订单数量不能为0');
  1448. return;
  1449. }
  1450. console.log(row, 'row');
  1451. console.log(this.form, 'form +++');
  1452. this.$refs.orderHomogeneityInspectDialog.open([row], this.form, 'new');
  1453. // if (row.productType == 2) {
  1454. // let data = [];
  1455. // data.push(row);
  1456. // this.$refs.orderHomogeneityInspectDialog.open(data, this.form, 'new');
  1457. // } else if (row.productType == 3) {
  1458. // this.$refs.orderHomogeneityInspectInstallDialog.open([row.id]);
  1459. // } else {
  1460. // this.$message.warning('请确认生产类型!');
  1461. // }
  1462. },
  1463. // 打开工艺路线
  1464. openDialog(index) {
  1465. this.selectIndex = index;
  1466. this.$refs.processRouteRef.open();
  1467. },
  1468. // 选择工艺路线
  1469. changeParent(item) {
  1470. let data = this.form.productInfoList[this.selectIndex];
  1471. this.$set(data, 'bomVersionList', []);
  1472. this.$set(data, 'bomCategoryId', '');
  1473. this.$set(data, 'model', '');
  1474. this.$set(data, 'routingList', []);
  1475. this.$set(data, 'productType', '');
  1476. this.$set(data, 'produceRoutingName', item.name);
  1477. this.$set(data, 'produceRoutingId', item.id);
  1478. this.$set(data, 'selectionRowShow', true);
  1479. // this.selectionRowShow = true;
  1480. }
  1481. }
  1482. };
  1483. </script>
  1484. <style lang="scss" scoped>
  1485. .basic-details-title {
  1486. margin: 10px 0;
  1487. }
  1488. .add-product {
  1489. width: 100%;
  1490. display: flex;
  1491. align-items: center;
  1492. justify-content: flex-end;
  1493. font-size: 30px;
  1494. color: #1890ff;
  1495. margin: 10px 0;
  1496. cursor: pointer;
  1497. }
  1498. .create-form .el-form-item {
  1499. margin-bottom: 15px !important;
  1500. }
  1501. .header_required {
  1502. .is-required:before {
  1503. content: '*';
  1504. color: #f56c6c;
  1505. margin-right: 4px;
  1506. }
  1507. }
  1508. </style>