create-order.vue 48 KB

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