index.vue 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925
  1. <template>
  2. <!-- :close-on-click-modal="false" -->
  3. <ele-modal
  4. width="80vw"
  5. :visible.sync="visible"
  6. custom-class="ele-dialog-form"
  7. :before-close="cancel"
  8. :title="title"
  9. :maxable="true"
  10. >
  11. <div class="form-wrapper">
  12. <el-form
  13. ref="form"
  14. :model="form"
  15. :rules="rules"
  16. label-width="110px"
  17. class="formbox"
  18. >
  19. <headerTitle title="基本信息"> </headerTitle>
  20. <el-row :gutter="10">
  21. <el-col :span="6">
  22. <el-form-item label="计划编号:" prop="code">
  23. <el-input
  24. placeholder="计划编号"
  25. size="mini"
  26. disabled
  27. v-model="form.code"
  28. ></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="6">
  32. <el-form-item label="计划类型:" prop="planType">
  33. <el-select
  34. v-model="form.planType"
  35. style="width: 100%"
  36. @change="changeProduceType"
  37. size="mini"
  38. >
  39. <el-option
  40. v-for="item of planTypeList"
  41. :key="item.value"
  42. :label="item.label"
  43. :value="item.value"
  44. ></el-option>
  45. </el-select>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="6">
  49. <el-form-item label="批次号:" prop="batchNo">
  50. <el-input
  51. placeholder="输入批次号"
  52. size="mini"
  53. v-model="form.batchNo"
  54. ></el-input>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="6">
  58. <el-form-item label="客户名称:">
  59. <el-input
  60. clearable
  61. v-model="form.customerName"
  62. style="width: calc(100% - 80px)"
  63. />
  64. <contactDialog
  65. style="margin-left: 3px"
  66. @changeParent="contactDialogSuccess"
  67. ></contactDialog>
  68. </el-form-item>
  69. </el-col>
  70. </el-row>
  71. <el-row :gutter="24">
  72. <el-col :span="6" v-if="isSaleOrder">
  73. <el-form-item label="销售订单号:" prop="saleOrder">
  74. <div class="sale-order-select">
  75. <el-input
  76. v-model="form.saleOrder"
  77. size="mini"
  78. type="text"
  79. style="width: calc(100% - 54px)"
  80. placeholder="请选择销售订单号"
  81. readonly
  82. ></el-input>
  83. <el-button
  84. size="mini"
  85. type="primary"
  86. @click="openSaleOrderDialog"
  87. >
  88. 选择
  89. </el-button>
  90. </div>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="6">
  94. <el-form-item
  95. label="生产编号:"
  96. label-width="110px"
  97. prop="productionCodes"
  98. >
  99. <el-input
  100. v-model="form.productionCodes"
  101. size="mini"
  102. type="text"
  103. style="width: 100%"
  104. placeholder=" "
  105. ></el-input>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="6">
  109. <el-form-item
  110. label="计划开始日期:"
  111. label-width="110px"
  112. prop="startTime"
  113. >
  114. <el-date-picker
  115. style="width: 100%"
  116. size="mini"
  117. v-model="form.startTime"
  118. @change="handleStartTimeChange(form)"
  119. type="datetime"
  120. placeholder="选择日期"
  121. value-format="yyyy-MM-dd HH:mm:ss"
  122. >
  123. </el-date-picker>
  124. </el-form-item>
  125. </el-col>
  126. <el-col :span="6">
  127. <el-form-item
  128. label="计划结束日期:"
  129. label-width="110px"
  130. prop="endTime"
  131. >
  132. <el-date-picker
  133. style="width: 100%"
  134. size="mini"
  135. v-model="form.endTime"
  136. @change="handleEndTimeChange(form)"
  137. type="datetime"
  138. placeholder="选择日期"
  139. value-format="yyyy-MM-dd HH:mm:ss"
  140. >
  141. </el-date-picker>
  142. </el-form-item>
  143. </el-col>
  144. <el-col :span="6">
  145. <el-form-item
  146. label="要求完成日期:"
  147. label-width="110px"
  148. prop="reqMoldTime"
  149. >
  150. <el-date-picker
  151. style="width: 100%"
  152. size="mini"
  153. v-model="form.reqMoldTime"
  154. type="datetime"
  155. placeholder="选择日期"
  156. value-format="yyyy-MM-dd HH:mm:ss"
  157. >
  158. </el-date-picker>
  159. </el-form-item>
  160. </el-col>
  161. </el-row>
  162. <!-- <el-row :gutter="24">
  163. <el-col :span="6">
  164. <el-form-item
  165. label="要求完成日期:"
  166. label-width="110px"
  167. prop="reqMoldTime"
  168. >
  169. <el-date-picker
  170. style="width: 100%"
  171. size="mini"
  172. v-model="form.reqMoldTime"
  173. type="datetime"
  174. placeholder="选择日期"
  175. value-format="yyyy-MM-dd HH:mm:ss"
  176. >
  177. </el-date-picker>
  178. </el-form-item>
  179. </el-col>
  180. </el-row> -->
  181. <headerTitle title="产品信息"> </headerTitle>
  182. <el-row :gutter="24">
  183. <ele-pro-table
  184. ref="tableRef"
  185. :columns="columns"
  186. row-key="code"
  187. :cache-key="`ProductionPlanTable`"
  188. :datasource="form.productInfoList"
  189. border
  190. height="40vh"
  191. key="id"
  192. >
  193. <template v-slot:modelKey="{ row, $index }">
  194. <el-select
  195. clearable
  196. v-model="row.modelKey"
  197. filterable
  198. allow-create
  199. default-first-option
  200. >
  201. <el-option
  202. v-for="item in row.modelList"
  203. :key="item"
  204. :value="item"
  205. :label="item"
  206. >
  207. </el-option>
  208. </el-select>
  209. </template>
  210. <template v-slot:colorKey="{ row, $index }">
  211. <el-select
  212. clearable
  213. v-model="row.colorKey"
  214. filterable
  215. allow-create
  216. default-first-option
  217. >
  218. <el-option
  219. v-for="item in row.colorList"
  220. :key="item"
  221. :value="item"
  222. :label="item"
  223. >
  224. </el-option>
  225. </el-select>
  226. </template>
  227. <template v-slot:requiredFormingNum="{ row, $index }">
  228. <el-input
  229. v-model="row.requiredFormingNum"
  230. size="small"
  231. type="text"
  232. style="width: 100%"
  233. placeholder="输入要求生产数量"
  234. @input="(e) => handleQuantityInput(e, row)"
  235. ></el-input>
  236. <!-- placeholder="输入要求生产数量" @input="tableHandleKeyUp(row, 'sum')"></el-input> -->
  237. </template>
  238. <!-- <template v-slot:productionCodes="{ row, $index }">
  239. <el-input
  240. v-model="row.productionCodes"
  241. size="small"
  242. type="text"
  243. style="width: 100%"
  244. placeholder=" "
  245. ></el-input>
  246. </template> -->
  247. <template v-slot:productType="{ row, $index }">
  248. <el-select
  249. v-model="row.productType"
  250. @change="changeProductType(row, $index)"
  251. :key="$index"
  252. >
  253. <el-option
  254. v-for="item of row.producedList"
  255. :key="$index + item.code"
  256. :label="item.name"
  257. :value="item.code"
  258. ></el-option>
  259. </el-select>
  260. </template>
  261. <template v-slot:bomCategoryId="{ row, $index }">
  262. <el-select v-model="row.bomCategoryId">
  263. <el-option
  264. v-for="item of row.bomVersionList"
  265. :key="item.id"
  266. :label="item.name + '(V' + item.versions + '.0)'"
  267. :value="item.id"
  268. @click.native="changeBomId(row, $index, item)"
  269. ></el-option>
  270. </el-select>
  271. </template>
  272. <!-- //权重等级 -->
  273. <template
  274. v-slot:weight="{ row, $index }"
  275. v-if="clientEnvironmentId == 4"
  276. >
  277. <el-select
  278. v-model="row.weight"
  279. style="width: 100%"
  280. @change="changeProduceType"
  281. size="mini"
  282. >
  283. <el-option
  284. v-for="item of weightList"
  285. :key="item.code"
  286. :label="item.name"
  287. :value="item.code"
  288. ></el-option>
  289. </el-select>
  290. </template>
  291. <!-- 是否开槽 -->
  292. <template
  293. v-slot:isSlotting="{ row, $index }"
  294. v-if="clientEnvironmentId == 4"
  295. >
  296. <el-select
  297. v-model="row.isSlotting"
  298. style="width: 100%"
  299. @change="changeProduceType"
  300. size="mini"
  301. >
  302. <el-option
  303. v-for="item of isSlotting"
  304. :key="item.code"
  305. :label="item.name"
  306. :value="item.code"
  307. ></el-option>
  308. </el-select>
  309. </template>
  310. <!-- 开槽类型 -->
  311. <template
  312. v-slot:slottingType="{ row, $index }"
  313. v-if="clientEnvironmentId == 4"
  314. >
  315. <DictSelection
  316. dictName="开槽类型"
  317. v-model="row.slottingType"
  318. size="mini"
  319. >
  320. </DictSelection>
  321. </template>
  322. <!-- 工艺路线 -->
  323. <template
  324. v-slot:produceRoutingId="{ row, $index }"
  325. v-if="clientEnvironmentId != 4"
  326. >
  327. <!-- <el-form-item required> -->
  328. <div style="display: flex">
  329. <el-select
  330. v-model="row.produceRoutingId"
  331. v-show="isRouteSelect(row)"
  332. >
  333. <el-option
  334. v-for="item of row.routingList"
  335. :key="item.id"
  336. :label="item.name"
  337. :value="item.id"
  338. ></el-option>
  339. </el-select>
  340. <div style="display: flex">
  341. <el-input
  342. v-show="!isRouteSelect(row)"
  343. disabled
  344. v-model="row.produceRoutingName"
  345. ></el-input>
  346. <el-button
  347. v-show="isSelectShow"
  348. type="primary"
  349. size="mini"
  350. @click="openDialog($index)"
  351. >选择</el-button
  352. >
  353. </div>
  354. </div>
  355. <!-- </el-form-item> -->
  356. </template>
  357. <template v-slot:produceRoutingId="{ row, $index }" v-else>
  358. <el-input
  359. v-model="row.produceRoutingName"
  360. style="width: 100%"
  361. readonly
  362. ></el-input>
  363. </template>
  364. <template v-slot:factoriesId="{ row, $index }">
  365. <el-select
  366. v-model="row.factoriesId"
  367. :key="row.factoriesId"
  368. @change="(e) => selectFactory(e, row)"
  369. :disabled="!!factoriesId"
  370. >
  371. <el-option
  372. v-for="item of factoryList"
  373. :key="item.id"
  374. :label="item.name"
  375. :value="item.id"
  376. ></el-option>
  377. </el-select>
  378. </template>
  379. <!-- <el-table-column label="所属工厂" width="140" align="center" prop="factoriesId">
  380. <template slot-scope="scope">
  381. <el-form-item label-width="0px">
  382. <el-select v-model="scope.row.factoriesId" :key="scope.row.factoriesId">
  383. <el-option v-for="item of factoryList" :key="item.id" :label="item.name"
  384. :value="item.id"></el-option>
  385. </el-select>
  386. </el-form-item>
  387. </template>
  388. </el-table-column> -->
  389. <!-- 模具数量 -->
  390. <template
  391. v-slot:moCount="{ row, $index }"
  392. v-if="clientEnvironmentId == '4'"
  393. >
  394. <div>
  395. <el-input
  396. style="width: 100%"
  397. size="small"
  398. v-model="row.moCount"
  399. oninput="value=value.replace(/[^0-9.]/g,'')"
  400. @input="tableHandleKeyUp(row, 'moCount')"
  401. placeholder="请输入"
  402. >
  403. </el-input>
  404. </div>
  405. </template>
  406. <!-- 块数 -->
  407. <template
  408. v-slot:blockCount="{ row, $index }"
  409. v-if="clientEnvironmentId == '4'"
  410. >
  411. <div>
  412. <el-input
  413. size="small"
  414. style="width: 100%"
  415. @input="tableHandleKeyUp(row, 'blockCount')"
  416. v-model="row.blockCount"
  417. placeholder="请输入"
  418. ></el-input>
  419. </div>
  420. </template>
  421. <!-- <template v-slot:productWeight="{ row, $index }">
  422. <span>{{ row.productWeight ? row.productWeight : '-' }}</span>
  423. </template> -->
  424. <template v-slot:set="{ row, $index }">
  425. <el-button type="text" @click="handleDeleteItem($index)"
  426. >删除</el-button
  427. >
  428. </template>
  429. <template v-slot:headerProduceRoutingId="{ column }">
  430. <div class="header_required"
  431. ><span class="is-required">{{ column.label }}</span></div
  432. >
  433. </template>
  434. <template v-slot:headeRequiredFormingNum="{ column }">
  435. <div class="header_required"
  436. ><span class="is-required">{{ column.label }}</span></div
  437. >
  438. </template>
  439. <template v-slot:headerProcessingBOM="{ column }">
  440. <div :class="isRequired ? 'header_required' : ''"
  441. ><span class="is-required">{{ column.label }}</span></div
  442. >
  443. </template>
  444. </ele-pro-table>
  445. <div class="add-product" @click="addEquipment" v-if="!form.id">
  446. <i class="el-icon-circle-plus-outline"></i>
  447. </div>
  448. </el-row>
  449. </el-form>
  450. <!-- 选择产品 -->
  451. <EquipmentDialog
  452. @choose="confirmChoose"
  453. :treeType="['9']"
  454. :selectList="[]"
  455. ref="equipmentRefs"
  456. >
  457. </EquipmentDialog>
  458. <saleOrderPop
  459. ref="saleOrderRef"
  460. :isMultiple="false"
  461. @chooseOrder="chooseSaleOrder"
  462. />
  463. </div>
  464. <template v-slot:footer>
  465. <el-button @click="cancel">取消</el-button>
  466. <el-button type="primary" @click="save" :loading="loading">
  467. 确定
  468. </el-button>
  469. <el-button
  470. type="primary"
  471. @click="save('sub')"
  472. :loading="loading"
  473. v-if="!isReview"
  474. >
  475. 发布
  476. </el-button>
  477. </template>
  478. <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
  479. </ele-modal>
  480. </template>
  481. <script>
  482. import { findBomCategoryByCategoryId } from '@/api/productionPlan/index';
  483. import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
  484. import saleOrderPop from './components/saleOrderPop.vue';
  485. import { getCode } from '@/api/codeManagement';
  486. import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
  487. import { parameterGetByCode } from '@/api/mainData/index';
  488. import {
  489. bomRoutingList,
  490. bomListByPlan,
  491. getFactoryList,
  492. saveAndRelease,
  493. temporaryPlanSave,
  494. getUpdateInfoByCode,
  495. getColorModelInfoById
  496. } from '@/api/saleOrder';
  497. import { planIsReview } from '@/api/productionPlan/index';
  498. import contactDialog from '@/components/contactDialog/openContactDialog.vue';
  499. import { deepClone } from '@/utils';
  500. export default {
  501. components: {
  502. EquipmentDialog,
  503. saleOrderPop,
  504. ProcessRoute,
  505. contactDialog
  506. },
  507. props: {
  508. factoryType: {
  509. type: Number,
  510. default: 3
  511. },
  512. factoryObj: {
  513. type: Object,
  514. default: () => {}
  515. },
  516. isAdd: {
  517. type: Boolean,
  518. default: true
  519. }
  520. },
  521. watch: {
  522. // factoryObj: {
  523. // immediate: true,
  524. // deep: true,
  525. // handler(val) {
  526. // // 修改
  527. // // this.$nextTick(() => {
  528. // // if (val.id) {
  529. // // this.bomListVersion();
  530. // // if (val.bomCategoryId) {
  531. // // this.getPlanRouting();
  532. // // }
  533. // // }
  534. // // });
  535. // }
  536. // }
  537. },
  538. computed: {
  539. // 是否必填 字段 ( 首先看计划类型 如果是返工返修)
  540. // 就不是必填 否则就看配置参数
  541. // 必填的时候 不显示选择按钮 跟 展示输入框 只能有下拉选择框 ( 选择了生产类型 带出 BOM 版本 带出 工艺路线 工艺路线不能选择)
  542. // 不必填的时候 显示 选择按钮跟 展示输入框 并且可以存在选择框 一开始默认展示选择框
  543. // 选择按钮选择数据后 隐藏选择框 显示展示框(input) 情况 生产类型 跟 BOM版本
  544. // 选择了生产类型 清空 选择框选择的工艺路线
  545. // 是否必填字段
  546. isRequired() {
  547. if (this.form.planType == 5) {
  548. return false;
  549. }
  550. return this.processingRequired == 1;
  551. },
  552. // 工艺路线 输入框展示跟选择框判断
  553. isRouteSelect() {
  554. return (row) => {
  555. if (this.isRequired) {
  556. return true;
  557. }
  558. if (!row.selectionRowShow) {
  559. return true;
  560. }
  561. return false;
  562. };
  563. },
  564. // 选择按钮的显示
  565. isSelectShow() {
  566. if (this.form.planType == 5) {
  567. return true;
  568. }
  569. return this.processingRequired == 0;
  570. },
  571. // clientEnvironmentId() {
  572. // return this.$store.state.user.info.clientEnvironmentId;
  573. // },
  574. columns() {
  575. return [
  576. {
  577. columnKey: 'index',
  578. label: '序号',
  579. type: 'index',
  580. width: 55,
  581. align: 'center',
  582. showOverflowTooltip: true
  583. },
  584. {
  585. slot: 'lineNumber',
  586. prop: 'lineNumber',
  587. label: '行号',
  588. align: 'center',
  589. minWidth: 140
  590. },
  591. {
  592. slot: 'productName',
  593. prop: 'productName',
  594. label: '名称',
  595. align: 'center',
  596. minWidth: 140
  597. },
  598. {
  599. slot: 'productCode',
  600. prop: 'productCode',
  601. label: '编码',
  602. align: 'center',
  603. minWidth: 140
  604. },
  605. {
  606. slot: 'brandNo',
  607. prop: 'brandNo',
  608. label: '牌号',
  609. align: 'center',
  610. minWidth: 140
  611. },
  612. {
  613. slot: 'model',
  614. prop: 'model',
  615. label: '型号',
  616. align: 'center',
  617. minWidth: 140
  618. },
  619. {
  620. slot: 'specification',
  621. prop: 'specification',
  622. label: '规格',
  623. align: 'center',
  624. minWidth: 140
  625. },
  626. {
  627. slot: 'productUnitWeight',
  628. prop: 'productUnitWeight',
  629. label: '单重',
  630. align: 'center',
  631. minWidth: 140
  632. },
  633. {
  634. slot: 'weightUnit',
  635. prop: 'weightUnit',
  636. label: '重量单位',
  637. align: 'center',
  638. minWidth: 140
  639. },
  640. {
  641. slot: 'modelKey',
  642. prop: 'modelKey',
  643. label: '机型',
  644. align: 'center',
  645. minWidth: 240
  646. },
  647. {
  648. slot: 'colorKey',
  649. prop: 'colorKey',
  650. label: '颜色',
  651. align: 'center',
  652. minWidth: 240
  653. },
  654. {
  655. slot: 'requiredFormingNum',
  656. prop: 'requiredFormingNum',
  657. headerSlot: 'headeRequiredFormingNum',
  658. label: '要求生产数量',
  659. align: 'center',
  660. minWidth: 140
  661. },
  662. {
  663. slot: 'measuringUnit',
  664. prop: 'measuringUnit',
  665. label: '计量单位',
  666. align: 'center',
  667. minWidth: 140
  668. },
  669. // {
  670. // slot: 'productionCodes',
  671. // prop: 'productionCodes',
  672. // label: '生产编号',
  673. // align: 'center',
  674. // minWidth: 140
  675. // },
  676. {
  677. slot: 'moCount',
  678. prop: 'moCount',
  679. label: '模数',
  680. headerSlot: 'headeRequiredFormingNum',
  681. align: 'center',
  682. minWidth: 140,
  683. show: this.clientEnvironmentId == 4
  684. },
  685. {
  686. slot: 'blockCount',
  687. prop: 'blockCount',
  688. label: '块数',
  689. headerSlot: 'headeRequiredFormingNum',
  690. align: 'center',
  691. minWidth: 140,
  692. show: this.clientEnvironmentId == 4
  693. },
  694. {
  695. slot: 'productType',
  696. prop: 'productType',
  697. label: '生产类型',
  698. headerSlot: 'headerProcessingBOM',
  699. align: 'center',
  700. minWidth: 180
  701. },
  702. {
  703. slot: 'bomCategoryId',
  704. prop: 'bomCategoryId',
  705. label: 'BOM版本',
  706. headerSlot: 'headerProcessingBOM',
  707. align: 'center',
  708. minWidth: 180,
  709. show: this.clientEnvironmentId !== 4
  710. },
  711. {
  712. slot: 'produceRoutingId',
  713. prop: 'produceRoutingId',
  714. headerSlot: 'headerProduceRoutingId',
  715. label: '工艺路线',
  716. align: 'center',
  717. minWidth: 240
  718. },
  719. {
  720. slot: 'factoriesId',
  721. prop: 'factoriesId',
  722. headerSlot: 'headerProduceRoutingId',
  723. label: '所属工厂',
  724. align: 'center',
  725. minWidth: 140
  726. },
  727. {
  728. slot: 'weight',
  729. prop: 'weight',
  730. label: '权重等级',
  731. align: 'center',
  732. minWidth: 140,
  733. show: this.clientEnvironmentId == 4
  734. },
  735. {
  736. slot: 'isSlotting',
  737. prop: 'isSlotting',
  738. label: '是否开槽',
  739. align: 'center',
  740. minWidth: 140,
  741. show: this.clientEnvironmentId == 4
  742. },
  743. {
  744. slot: 'slottingType',
  745. prop: 'slottingType',
  746. label: '开槽类型',
  747. align: 'center',
  748. minWidth: 140,
  749. show: this.clientEnvironmentId == 4
  750. },
  751. {
  752. slot: 'newSumOrderWeight',
  753. prop: 'newSumOrderWeight',
  754. label: '计划重量',
  755. align: 'center',
  756. minWidth: 140
  757. },
  758. {
  759. slot: 'set',
  760. prop: 'set',
  761. label: '操作',
  762. align: 'center',
  763. minWidth: 140,
  764. fixed: 'right'
  765. }
  766. ];
  767. }
  768. },
  769. data() {
  770. return {
  771. visible: false,
  772. factoriesId: '',
  773. clientEnvironmentId: '',
  774. title: '新增临时生产计划',
  775. type: 3,
  776. weightList: [
  777. { code: 1, name: 'A' },
  778. { code: 2, name: 'B' },
  779. { code: 3, name: 'C' }
  780. ],
  781. factoryList: [],
  782. isSlotting: [
  783. { code: 1, name: '是' },
  784. { code: 2, name: '否' }
  785. ], //是否开槽
  786. planTypeList: [
  787. { label: '内销计划', value: 1 },
  788. { label: '外销计划', value: 2 },
  789. { label: '预制计划', value: 3 },
  790. { label: '改型计划', value: 4 },
  791. { label: '返工返修计划', value: 5 },
  792. { label: '受托计划', value: 6 }
  793. ],
  794. loading: false,
  795. form: {
  796. timeDimensionPlanType: 3,
  797. categoryId: '',
  798. productName: '',
  799. planType: '',
  800. saleOrder: '',
  801. moCount: '', // 模具数量
  802. blockCount: 0, // 块数
  803. noWordCount: '', // 无字数量
  804. weight: '',
  805. startTime: '',
  806. endTime: '',
  807. isSlotting: '', //是否开槽
  808. slottingType: '', //开槽类型
  809. id: '',
  810. produceType: 2,
  811. bomCategoryId: '',
  812. produceRoutingId: '',
  813. requiredFormingNum: '',
  814. productInfoList: []
  815. },
  816. disabledList: [],
  817. bomVersionList: [],
  818. routingList: [],
  819. rules: {
  820. productName: [
  821. { required: true, message: '请选择名称', trigger: 'change' }
  822. ],
  823. bomCategoryId: [
  824. { required: true, message: '请选择BOM版本', trigger: 'blur' }
  825. ],
  826. planType: [
  827. { required: true, message: '请选择计划类型', trigger: 'blur' }
  828. ],
  829. produceType: [
  830. { required: true, message: '请选择工艺路线', trigger: 'blur' }
  831. ],
  832. produceRoutingId: [
  833. { required: true, message: '请选择工艺路线', trigger: 'blur' }
  834. ],
  835. startTime: [
  836. { required: true, message: '请选择计划开始日期', trigger: 'blur' }
  837. ],
  838. endTime: [
  839. { required: true, message: '请选择计划结束日期', trigger: 'blur' }
  840. ],
  841. // reqMoldTime: [
  842. // { required: true, message: '请选择要求完成日期', trigger: 'blur' }
  843. // ],
  844. requiredFormingNum: [
  845. { required: true, message: '请输入生产数量', trigger: 'blur' }
  846. ],
  847. saleOrder: [
  848. {
  849. validator: (rule, value, callback) => {
  850. if (!this.isSaleOrder) {
  851. callback();
  852. return;
  853. }
  854. if (
  855. value === undefined ||
  856. value === null ||
  857. String(value).trim() === ''
  858. ) {
  859. callback(new Error('请选择销售订单号'));
  860. } else {
  861. callback();
  862. }
  863. },
  864. trigger: ['blur', 'change']
  865. }
  866. ]
  867. },
  868. producedList: [
  869. { code: 2, name: '加工(MBOM)' },
  870. { code: 3, name: '装配(ABOM)' }
  871. ],
  872. selectIndex: 0, // 选择工艺路线的当前数据下标
  873. processingRequired: 0, // 生产类型跟BOM 版本是否必填 1:是 0:否
  874. isReview: false,
  875. isSaleOrder: false
  876. // selectionRowShow: false // 工艺路线输入框展示 状态
  877. };
  878. },
  879. // computed: {
  880. // clientEnvironmentId() {
  881. // return this.$store.state.user.info.clientEnvironmentId;
  882. // }
  883. // },
  884. mounted() {},
  885. methods: {
  886. selectFactory(e, row) {
  887. let data = this.factoryList.find((item) => item.id === e);
  888. this.$set(row, 'factoriesName', data.name);
  889. },
  890. async getPlannedReleaseRequire(code) {
  891. parameterGetByCode({ code }).then((res) => {
  892. if (res) {
  893. this.isReview = res.value == '1' ? true : false;
  894. }
  895. });
  896. },
  897. // 打开工艺路线
  898. openDialog(index) {
  899. this.selectIndex = index;
  900. this.$refs.processRouteRef.open();
  901. },
  902. // 选择工艺路线
  903. changeParent(item) {
  904. let data = this.form.productInfoList[this.selectIndex];
  905. this.$set(data, 'bomVersionList', []);
  906. this.$set(data, 'bomCategoryId', '');
  907. // this.$set(data, 'model', '');
  908. this.$set(data, 'routingList', []);
  909. this.$set(data, 'productType', '');
  910. this.$set(data, 'produceRoutingName', item.name);
  911. this.$set(data, 'produceRoutingId', item.id);
  912. this.$set(data, 'selectionRowShow', true);
  913. // this.selectionRowShow = true;
  914. },
  915. async getFactoryList() {
  916. this.factoryList = await getFactoryList();
  917. },
  918. async open(val) {
  919. const [processingRes, saleOrderRes] = await Promise.all([
  920. parameterGetByCode({ code: 'production_plan_code' }),
  921. parameterGetByCode({ code: 'create_plan_binding_sale_order' }),
  922. this.getFactoryList(),
  923. this.getPlannedReleaseRequire('planned_release_require')
  924. ]);
  925. if (processingRes) {
  926. this.processingRequired = processingRes.value;
  927. }
  928. this.isSaleOrder = saleOrderRes?.value === '1';
  929. this.clientEnvironmentId =
  930. this.$store.state.user.info.clientEnvironmentId;
  931. this.factoriesId = this.$store.state.user.info.factoryId;
  932. if (!val) {
  933. this.title = '新增临时生产计划';
  934. this.visible = true;
  935. return;
  936. }
  937. if (val.planType == null || val.planType === 'null') {
  938. val.planType = '';
  939. }
  940. this.title = val.id ? '编辑临时生产计划' : '新增临时生产计划';
  941. val.planType = String(val.planType);
  942. this.form = await getUpdateInfoByCode(val.code);
  943. if (this.isSaleOrder) {
  944. const salesCode = this.form.salesCode;
  945. this.$set(
  946. this.form,
  947. 'saleOrder',
  948. Array.isArray(salesCode) ? salesCode.join(',') : salesCode || ''
  949. );
  950. }
  951. if (val.id) {
  952. await this.initEditProductList(val);
  953. }
  954. this.$forceUpdate();
  955. this.visible = true;
  956. },
  957. async initEditProductList(val) {
  958. const productList = this.form.productInfoList;
  959. if (Array.isArray(val.productInfoList) && val.productInfoList.length) {
  960. await Promise.all(
  961. productList.map(async (v, index) => {
  962. v.selectionRowShow = !v.bomCategoryId;
  963. if (!v.bomCategoryId) {
  964. v.productType = '';
  965. }
  966. if (v.productType) {
  967. this.$set(
  968. productList[index],
  969. 'bomVersionList',
  970. await this.bomListVersionFn(v.productType, v.categoryId)
  971. );
  972. }
  973. if (v.bomCategoryId) {
  974. this.$set(
  975. productList[index],
  976. 'routingList',
  977. await this.changeBomIdFn(v.bomCategoryId, productList[index])
  978. );
  979. }
  980. })
  981. );
  982. }
  983. const [resAll, infoAll] = await Promise.all([
  984. Promise.all(
  985. productList.map((item) =>
  986. findBomCategoryByCategoryId(item.categoryId)
  987. )
  988. ),
  989. Promise.all(
  990. productList.map(async (item) => {
  991. try {
  992. return (await getColorModelInfoById(item.categoryId)) || {};
  993. } catch (e) {
  994. return {};
  995. }
  996. })
  997. )
  998. ]);
  999. productList.forEach((item, index) => {
  1000. const info = infoAll[index] || {};
  1001. const colorKey = info.colorKey || '';
  1002. const modelKey = info.modelKey || '';
  1003. this.$set(
  1004. productList[index],
  1005. 'colorList',
  1006. colorKey ? colorKey.split(',') : []
  1007. );
  1008. this.$set(
  1009. productList[index],
  1010. 'modelList',
  1011. modelKey ? modelKey.split(',') : []
  1012. );
  1013. this.$set(
  1014. productList[index],
  1015. 'colorKey',
  1016. item.colorKey || (colorKey ? colorKey.split(',')[0] : '')
  1017. );
  1018. this.$set(
  1019. productList[index],
  1020. 'modelKey',
  1021. item.modelKey || (modelKey ? modelKey.split(',')[0] : '')
  1022. );
  1023. if (!resAll[index]) return;
  1024. const listMap = {};
  1025. resAll[index].forEach((el) => {
  1026. if (el.bomType === '2' || el.bomType === '3') {
  1027. if (!listMap[el.bomType]) listMap[el.bomType] = [];
  1028. listMap[el.bomType].push(el);
  1029. }
  1030. });
  1031. const list = [];
  1032. if (listMap[2]) list.push({ code: 2, name: 'MBOM' });
  1033. if (listMap[3]) list.push({ code: 3, name: 'ABOM' });
  1034. if (!item.factoriesId) {
  1035. this.$set(productList[index], 'factoriesId', this.factoriesId);
  1036. this.$set(
  1037. productList[index],
  1038. 'factoriesName',
  1039. this.factoryList?.find((f) => f.id === this.factoriesId)?.name
  1040. );
  1041. }
  1042. this.$set(productList[index], 'producedList', list);
  1043. });
  1044. },
  1045. addEquipment() {
  1046. this.$refs.equipmentRefs.open();
  1047. },
  1048. async confirmChoose(data) {
  1049. let list = deepClone(data);
  1050. list.map((el) => (el.selectionRowShow = false));
  1051. if (this.clientEnvironmentId == 4) {
  1052. list.map((v) => {
  1053. if (v.name.includes('板材')) {
  1054. v.produceRoutingId = '1856970794952372226';
  1055. v.produceRoutingName = '板材';
  1056. v.produceVersionName = '板材';
  1057. } else {
  1058. (v.produceRoutingId = '1857313733642596353'),
  1059. (v.produceRoutingName = '砌块'),
  1060. (v.produceVersionName = '砌块');
  1061. }
  1062. });
  1063. }
  1064. let ids = this.form.productInfoList.map((item) => item.categoryId);
  1065. const filtered = list.filter((i) => !ids.includes(i.id));
  1066. let result = await Promise.all(
  1067. filtered.map(async (item) => {
  1068. let info = {};
  1069. try {
  1070. info = (await getColorModelInfoById(item.id)) || {};
  1071. } catch (e) {
  1072. info = {};
  1073. }
  1074. const colorKey = info.colorKey || '';
  1075. const modelKey = info.modelKey || '';
  1076. return {
  1077. categoryId: item.id,
  1078. productCode: item.code,
  1079. productName: item.name,
  1080. productUnitWeight: item.netWeight,
  1081. weightUnit: item.weightUnit,
  1082. model: item.modelType,
  1083. specification: item.specification,
  1084. brandNo: item.brandNum,
  1085. measuringUnit: item.measuringUnit,
  1086. produceRoutingId: item.produceRoutingId,
  1087. produceRoutingName: item.produceRoutingName,
  1088. produceVersionName: item.produceVersionName,
  1089. factoriesId: this.factoriesId,
  1090. colorList: colorKey ? colorKey.split(',') : [],
  1091. modelList: modelKey ? modelKey.split(',') : [],
  1092. colorKey: colorKey ? colorKey.split(',')[0] : '',
  1093. modelKey: modelKey ? modelKey.split(',')[0] : '',
  1094. factoriesName: this.factoryList?.find(
  1095. (factoryData) => factoryData.id === this.factoriesId
  1096. )?.name
  1097. };
  1098. })
  1099. );
  1100. // this.form.productInfoList = [];
  1101. // 取出在弹窗中选中并且不在表格中的数据
  1102. // const result = list.filter(
  1103. // (i) =>
  1104. // this.form.productInfoList.findIndex(
  1105. // (p) => p.productCode === i.productCode
  1106. // ) === -1
  1107. // );
  1108. // // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
  1109. // const del = this.form.productInfoList.filter(
  1110. // (i) => list.findIndex((p) => p.productCode === i.productCode) === -1
  1111. // );
  1112. // for (let i = this.form.productInfoList.length - 1; i >= 0; i--) {
  1113. // for (let j in del) {
  1114. // if (
  1115. // this.form.productInfoList[i].productCode === del[j].productCode
  1116. // ) {
  1117. // this.form.productInfoList.splice(i, 1);
  1118. // break;
  1119. // }
  1120. // }
  1121. // }
  1122. let promiseAll = [];
  1123. result.forEach(async (item) => {
  1124. let categoryId = item.categoryId;
  1125. promiseAll.push(findBomCategoryByCategoryId(categoryId));
  1126. });
  1127. const resAll = await Promise.all(promiseAll);
  1128. try {
  1129. await result.forEach(async (item, index) => {
  1130. if (resAll[index]) {
  1131. let listMap = {};
  1132. let list = [];
  1133. let arr = [];
  1134. resAll[index].map((el) => {
  1135. if (el.bomType == '2' || el.bomType == '3') {
  1136. console.log(listMap, 'listMap');
  1137. if (listMap[el.bomType]) {
  1138. listMap[el.bomType].push(el);
  1139. } else {
  1140. listMap[el.bomType] = [el];
  1141. }
  1142. }
  1143. });
  1144. if (listMap[2]) {
  1145. list.push({ code: 2, name: 'MBOM' });
  1146. arr = listMap[2];
  1147. item.productType = 2;
  1148. }
  1149. if (listMap[3]) {
  1150. list.push({ code: 3, name: 'ABOM' });
  1151. if (!listMap[2]) {
  1152. arr = listMap[3];
  1153. item.productType = 3;
  1154. }
  1155. }
  1156. if (arr.length > 0) {
  1157. arr.map((el) => (el.bomCategoryId = el.id));
  1158. item.bomCategoryId = arr[0].id;
  1159. await this.changeBomId(arr[0], 0);
  1160. this.$set(item, 'produceRoutingId', arr[0].produceRoutingId);
  1161. this.$set(
  1162. item,
  1163. 'produceVersionName',
  1164. arr[0].produceVersionName
  1165. );
  1166. this.$set(
  1167. item,
  1168. 'produceRoutingName',
  1169. arr[0].produceRoutingName
  1170. );
  1171. console.log(arr[0], 'arr[0]');
  1172. this.$set(item, 'routingList', arr[0].routingList);
  1173. this.$set(item, 'bomCategoryName', arr[0].name);
  1174. this.$set(item, 'bomCategoryVersions', arr[0].versions);
  1175. }
  1176. item.producedList = list;
  1177. item.bomVersionList = arr;
  1178. return item;
  1179. }
  1180. });
  1181. } catch (err) {}
  1182. console.log(result, 'result');
  1183. // return
  1184. this.form.productInfoList.push(...result);
  1185. this.changeLineNumber();
  1186. console.log(this.form.productInfoList, 'this.form.productInfoList');
  1187. this.$refs.tableRef.setData(this.form.productInfoList);
  1188. // console.log(this.form.productInfoList, 'this.form.productInfoList');
  1189. //重置
  1190. this.$set(this.form, 'produceType', '');
  1191. this.$set(this.form, 'bomCategoryId', '');
  1192. this.$set(this.form, 'produceRoutingId', '');
  1193. },
  1194. changeLineNumber() {
  1195. this.form.productInfoList.forEach((item, index) => {
  1196. let data = this.form.productInfoList[index - 1];
  1197. this.$set(
  1198. this.form.productInfoList[index],
  1199. 'lineNumber',
  1200. data ? data.lineNumber + 10 : 10
  1201. );
  1202. });
  1203. },
  1204. handleDeleteItem(index) {
  1205. this.$confirm('确定删除当前数据?', '提示')
  1206. .then(() => {
  1207. const newArray = this.form.productInfoList.filter(
  1208. (item, i) => i !== index
  1209. );
  1210. this.form.productInfoList = newArray;
  1211. this.$refs.tableRef.setData(newArray);
  1212. })
  1213. .catch(() => {});
  1214. },
  1215. async getPlanCode() {
  1216. this.loading = true;
  1217. try {
  1218. const code = await getCode('product_code');
  1219. this.$set(this.form, 'code', code);
  1220. } catch (err) {}
  1221. },
  1222. initForm() {
  1223. this.form = {
  1224. timeDimensionPlanType: 3,
  1225. categoryId: '',
  1226. productName: '',
  1227. planType: '',
  1228. saleOrder: '',
  1229. moCount: '', // 模具数量
  1230. blockCount: 0, // 块数
  1231. noWordCount: '', // 无字数量
  1232. weight: '',
  1233. isSlotting: '', //是否开槽
  1234. slottingType: '', //开槽类型
  1235. id: '',
  1236. produceType: 2,
  1237. status: 2,
  1238. bomCategoryId: '',
  1239. produceRoutingId: '',
  1240. productInfoList: [],
  1241. requiredFormingNum: ''
  1242. };
  1243. // console.log(this.$refs);
  1244. // this.$refs.tableRef.setData([]);
  1245. },
  1246. changeBomIdFn(bomCategoryId, row) {
  1247. return new Promise((resolve, reject) => {
  1248. bomRoutingList(bomCategoryId).then((res) => {
  1249. let arr = res || [];
  1250. if (arr.length == 0) {
  1251. row.produceRoutingId = '';
  1252. }
  1253. resolve(arr);
  1254. });
  1255. });
  1256. },
  1257. // 选择BOM
  1258. async changeBomId(row, index, bomData, typeChange) {
  1259. if (bomData) {
  1260. row.bomCategoryName = bomData.name;
  1261. row.bomCategoryVersions = bomData.versions;
  1262. }
  1263. // row.routingList = []
  1264. return await bomRoutingList(row.bomCategoryId).then((res) => {
  1265. let arr = res || [];
  1266. if (arr.length > 0) {
  1267. // this.$nextTick(() => {
  1268. row.produceRoutingName = arr[0].name;
  1269. row.produceVersionName = arr[0].version;
  1270. row.produceRoutingId = arr[0].id;
  1271. row.routingList = arr;
  1272. if (typeChange) {
  1273. this.$set(this.form.productInfoList[index], 'routingList', arr);
  1274. this.$set(
  1275. this.form.productInfoList[index],
  1276. 'produceRoutingId',
  1277. arr[0].id
  1278. );
  1279. } else {
  1280. this.$set(row, 'produceRoutingId', arr[0].id);
  1281. this.$set(row, 'routingList', arr);
  1282. }
  1283. row.selectionRowShow = false;
  1284. console.log(row.routingList, 'this.form.productInfoList');
  1285. // });
  1286. }
  1287. this.$forceUpdate();
  1288. });
  1289. },
  1290. contactDialogSuccess(data) {
  1291. console.log(data, 'data 11');
  1292. // serialNo
  1293. this.form.serialNo = data.serialNo;
  1294. this.$set(this.form, 'customerName', data.name);
  1295. },
  1296. openSaleOrderDialog() {
  1297. this.$refs.saleOrderRef.open([]);
  1298. },
  1299. chooseSaleOrder(list) {
  1300. const currentRow = list[0] || {};
  1301. this.$set(this.form, 'saleOrder', currentRow.orderNo || '');
  1302. this.$nextTick(() => {
  1303. this.$refs.form && this.$refs.form.validateField('saleOrder');
  1304. });
  1305. },
  1306. // 清空BOM 跟工艺路线
  1307. wipeData(index) {
  1308. this.$set(this.form.productInfoList[index], 'bomCategoryId', '');
  1309. this.$set(this.form.productInfoList[index], 'routingList', []);
  1310. this.$set(this.form.productInfoList[index], 'bomVersionList', []);
  1311. this.$set(this.form.productInfoList[index], 'produceRoutingId', '');
  1312. this.$set(this.form.productInfoList[index], 'produceRoutingName', '');
  1313. this.$set(this.form.productInfoList[index], 'produceVersionName', '');
  1314. this.$set(this.form.productInfoList[index], 'selectionRowShow', false);
  1315. // this.selectionRowShow = false;
  1316. },
  1317. // 选择生产类型
  1318. changeProductType(row, index) {
  1319. let param = {
  1320. bomType: row.productType,
  1321. categoryId: row.categoryId
  1322. };
  1323. this.wipeData(index);
  1324. // row.bomCategoryId = '';
  1325. // this.form.productInfoList[index].bomVersionList = [];
  1326. bomListByPlan(param).then((res) => {
  1327. let arr = res || [];
  1328. this.$nextTick(() => {
  1329. if (arr.length) {
  1330. row.bomVersionList = arr;
  1331. this.form.productInfoList[index].bomVersionList = arr;
  1332. row.bomCategoryId = arr[0].id;
  1333. this.changeBomId(row, index, arr[0], 'typeChange');
  1334. let arrAll = JSON.parse(JSON.stringify(this.form));
  1335. this.$set(this, 'form', arrAll);
  1336. }
  1337. });
  1338. // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
  1339. });
  1340. },
  1341. // 参数校验
  1342. parameterVerification() {
  1343. let flag = true;
  1344. this.form.productInfoList.forEach((v) => {
  1345. if (this.isRequired) {
  1346. if (!v.productType) {
  1347. flag = false;
  1348. this.$message.warning('请选择生产类型');
  1349. return;
  1350. }
  1351. if (!v.bomCategoryId) {
  1352. flag = false;
  1353. this.$message.warning('请选择BOM版本');
  1354. return;
  1355. }
  1356. }
  1357. if (!v.produceRoutingId) {
  1358. flag = false;
  1359. this.$message.warning('请选择工艺路线');
  1360. return;
  1361. }
  1362. if (!v.factoriesId) {
  1363. flag = false;
  1364. this.$message.warning('请选择所属工厂');
  1365. return;
  1366. }
  1367. if (v.requiredFormingNum == 0) {
  1368. flag = false;
  1369. this.$message.warning('要求生产数量不能为0');
  1370. return;
  1371. }
  1372. if (!v.requiredFormingNum) {
  1373. flag = false;
  1374. this.$message.warning('请输入要求生产数量');
  1375. return;
  1376. }
  1377. if (!v.moCount && this.clientEnvironmentId == 4) {
  1378. flag = false;
  1379. this.$message.warning('请输入模数');
  1380. return;
  1381. }
  1382. if (!v.blockCount && this.clientEnvironmentId == 4) {
  1383. flag = false;
  1384. this.$message.warning('请输入块数');
  1385. return;
  1386. }
  1387. });
  1388. return flag;
  1389. },
  1390. save(type) {
  1391. this.$refs.form.validate(async (valid) => {
  1392. if (!valid) return;
  1393. if (!this.parameterVerification()) return;
  1394. const isAdd = !this.form.id;
  1395. this.form.productInfoList.forEach((item) => {
  1396. item.colorKey = item.colorKey == null ? '' : String(item.colorKey);
  1397. item.modelKey = item.modelKey == null ? '' : String(item.modelKey);
  1398. if (isAdd) delete item.selectionRowShow;
  1399. });
  1400. if (isAdd) {
  1401. this.form.timeDimensionPlanType = this.type;
  1402. }
  1403. if (this.isSaleOrder) {
  1404. this.form.salesCode = this.form.saleOrder.split(',');
  1405. }
  1406. this.loading = true;
  1407. const api = type === 'sub' ? saveAndRelease : temporaryPlanSave;
  1408. api(this.form)
  1409. .then(() => {
  1410. this.$message.success(isAdd ? '新增成功!' : '修改成功!');
  1411. this.visible = false;
  1412. this.initForm();
  1413. this.$emit('close', true);
  1414. })
  1415. .finally(() => {
  1416. this.loading = false;
  1417. });
  1418. });
  1419. },
  1420. // save(type) {
  1421. // this.$refs.form.validate(async (valid) => {
  1422. // if (!valid) {
  1423. // return false;
  1424. // }
  1425. // let flag = this.parameterVerification();
  1426. // // 必填参数校验
  1427. // if (!flag) return;
  1428. // this.form.productInfoList.forEach((item, index) => {
  1429. // this.$set(
  1430. // this.form.productInfoList[index],
  1431. // 'colorKey',
  1432. // item.colorKey.toString()
  1433. // );
  1434. // this.$set(
  1435. // this.form.productInfoList[index],
  1436. // 'modelKey',
  1437. // item.modelKey.toString()
  1438. // );
  1439. // });
  1440. // // this.
  1441. // if (!this.form.id) {
  1442. // if (this.form.productInfoList.length) {
  1443. // this.form.productInfoList.map((item, index) => {
  1444. // delete item.selectionRowShow;
  1445. // // if (item.bomVersionList && item.bomVersionList.length) {
  1446. // // item.bomCategoryName = item.bomVersionList[0].name;
  1447. // // item.bomCategoryVersions = item.bomVersionList[0].versions;
  1448. // // item.produceRoutingName = item.routingList[0].name;
  1449. // // }
  1450. // });
  1451. // }
  1452. // this.form.timeDimensionPlanType = this.type;
  1453. // if (this.isSaleOrder) {
  1454. // this.form.saleOrder = this.form.saleOrder.split(',');
  1455. // }
  1456. // this.loading = true;
  1457. // let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
  1458. // api(this.form)
  1459. // .then((res) => {
  1460. // this.$message.success('新增成功!');
  1461. // this.visible = false;
  1462. // this.initForm();
  1463. // this.$emit('close', true);
  1464. // })
  1465. // .finally(() => {
  1466. // this.loading = false;
  1467. // });
  1468. // } else {
  1469. // this.loading = true;
  1470. // let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
  1471. // if (this.isSaleOrder) {
  1472. // this.form.saleOrder = this.form.saleOrder.split(',');
  1473. // }
  1474. // api(this.form)
  1475. // .then((res) => {
  1476. // this.$message.success('修改成功!');
  1477. // this.visible = false;
  1478. // this.initForm();
  1479. // this.$emit('close', true);
  1480. // })
  1481. // .finally(() => {
  1482. // this.loading = false;
  1483. // });
  1484. // }
  1485. // });
  1486. // },
  1487. bomListVersionFn(produceType, categoryId) {
  1488. return new Promise((resolve, reject) => {
  1489. let param = {
  1490. bomType: produceType,
  1491. categoryId: categoryId
  1492. };
  1493. bomListByPlan(param).then((res) => {
  1494. this.bomVersionList = res || [];
  1495. resolve(res || []);
  1496. });
  1497. });
  1498. },
  1499. bomListVersion() {
  1500. let param = {
  1501. bomType: this.form.produceType,
  1502. categoryId: this.form.categoryId
  1503. };
  1504. bomListByPlan(param).then((res) => {
  1505. this.$nextTick(() => {
  1506. this.bomVersionList = res || [];
  1507. console.log(res, 'res 000');
  1508. });
  1509. });
  1510. },
  1511. // 工艺路线
  1512. getPlanRouting() {
  1513. bomRoutingList(this.form.bomCategoryId).then((res) => {
  1514. this.routingList = res || [];
  1515. });
  1516. },
  1517. // 宝悦 工艺路线
  1518. getPlanRoutingNew() {
  1519. // bomRoutingList(this.form.bomCategoryId).then((res) => {
  1520. // this.routingList = res || []
  1521. // })
  1522. },
  1523. tableHandleKeyUp(row, name) {
  1524. // return
  1525. // , index, e, name
  1526. if (name == 'procut') {
  1527. return;
  1528. }
  1529. if (row.specification && this.clientEnvironmentId == 4) {
  1530. let modelArr = row.specification.split('*');
  1531. let modelLong = modelArr[0]; // model规格长度
  1532. let modeWide = modelArr[1]; // model规格宽度
  1533. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1534. modeHight = Number(modeHight);
  1535. if (name === 'moCount') {
  1536. // 模数
  1537. this.$set(row, 'moCount', row.moCount);
  1538. // 计算块数的公式:
  1539. // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
  1540. // 每一模的块数*模数moCount = 总块数
  1541. if (row.productName.includes('板材')) {
  1542. // 块数
  1543. let blockCount =
  1544. Math.floor(600 / modelLong) *
  1545. Math.floor(120 / modeHight) *
  1546. Math.floor(60 / modeWide) *
  1547. row.moCount;
  1548. row['blockCount'] = blockCount;
  1549. // this.$set(row, 'blockCount', blockCount);
  1550. } else if (row.productName.includes('砌块')) {
  1551. let modelLongFixed = (600 / modelLong).toFixed(2);
  1552. modelLongFixed = modelLongFixed.substring(
  1553. 0,
  1554. modelLongFixed.length - 1
  1555. );
  1556. let modeWideFixed = (120 / modeWide).toFixed(2);
  1557. modeWideFixed = modeWideFixed.substring(
  1558. 0,
  1559. modeWideFixed.length - 1
  1560. );
  1561. let modeHightFixed = (60 / modeHight).toFixed(2);
  1562. modeHightFixed = modeHightFixed.substring(
  1563. 0,
  1564. modeHightFixed.length - 1
  1565. );
  1566. let num =
  1567. Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
  1568. row.moCount;
  1569. row['blockCount'] = num;
  1570. }
  1571. let numNew = (
  1572. Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
  1573. row.blockCount
  1574. ).toFixed(5);
  1575. row['requiredFormingNum'] = numNew;
  1576. } else if (name === 'sum') {
  1577. let e = row.requiredFormingNum;
  1578. row.blockCount = Math.floor(
  1579. e / ((modelLong * modeWide * modeHight) / 1000000)
  1580. );
  1581. if (row.productName.includes('板材')) {
  1582. let num = Math.ceil(
  1583. row.blockCount /
  1584. (Math.floor(600 / modelLong) *
  1585. Math.floor(120 / modeHight) *
  1586. Math.floor(60 / modeWide))
  1587. );
  1588. // 48 480 4807 480
  1589. row.moCount = num;
  1590. } else if (row.productName.includes('砌块')) {
  1591. row.moCount = Math.ceil(
  1592. row.blockCount /
  1593. Math.floor(
  1594. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1595. )
  1596. );
  1597. }
  1598. } else if (name === 'blockCount') {
  1599. //块数
  1600. // row.blockCount = row.moCount;
  1601. row.blockCount = row.blockCount;
  1602. if (row.productName.includes('板材')) {
  1603. let moCount = Math.ceil(
  1604. row.blockCount /
  1605. (Math.floor(600 / modelLong) *
  1606. Math.floor(120 / modeHight) *
  1607. Math.floor(60 / modeWide))
  1608. );
  1609. row.moCount = moCount;
  1610. } else if (row.productName.includes('砌块')) {
  1611. let moCount = Math.ceil(
  1612. row.blockCount /
  1613. Math.floor(
  1614. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1615. )
  1616. );
  1617. this.$set(this.form, 'moCount', moCount);
  1618. row.moCount = moCount;
  1619. }
  1620. let a = (
  1621. (Number(row.blockCount) * modelLong * modeWide * modeHight) /
  1622. 1000000
  1623. ).toFixed(5);
  1624. row.requiredFormingNum = a;
  1625. }
  1626. }
  1627. },
  1628. // 数量正则 quantity
  1629. handleQuantityInput(e, row) {
  1630. // 过滤非数字字符(包括负号)
  1631. let value = e.replace(/[^\d.]/g, '');
  1632. // value = value.replace(/-/g, '');
  1633. // 限制不能以 0 开头(除非是 0 本身)
  1634. // if (value.startsWith('0') && value.length > 1) {
  1635. // value = value.slice(1);
  1636. // }
  1637. // 更新绑定值
  1638. row.requiredFormingNum = value;
  1639. // if (
  1640. // item.weightUnit == 'G' ||
  1641. // item.weightUnit == 'g' ||
  1642. // item.weightUnit == '克'
  1643. // ) {
  1644. // let total =
  1645. // ((item.requiredFormingNum - 0) * item.productUnitWeight) /
  1646. // 1000;
  1647. // item.newSumOrderWeight = total.toFixed(2);
  1648. // item.newWeightUnit = 'KG';
  1649. // } else {
  1650. // item.newWeightUnit = item.weightUnit;
  1651. // item.newSumOrderWeight = item.requiredFormingNum;
  1652. // }
  1653. row.newWeightUnit = row.weightUnit;
  1654. if (row.weightUnit == row.measuringUnit) {
  1655. row.newSumOrderWeight = row.requiredFormingNum;
  1656. } else if (row.requiredFormingNum && row.productUnitWeight) {
  1657. row.newSumOrderWeight =
  1658. row.requiredFormingNum * row.productUnitWeight;
  1659. } else {
  1660. row.newSumOrderWeight = 0;
  1661. }
  1662. row.productWeight = row.newSumOrderWeight;
  1663. this.tableHandleKeyUp(row, 'sum');
  1664. },
  1665. changeProduceType(e) {
  1666. if (this.clientEnvironmentId !== 4) {
  1667. this.form.bomCategoryId = '';
  1668. this.form['bomCategoryName'] = '';
  1669. this.form['bomCategoryVersions'] = '';
  1670. this.bomVersionList = [];
  1671. this.routingList = [];
  1672. this.form.produceRoutingId = '';
  1673. this.form.produceRoutingName = '';
  1674. this.form.produceVersionName = '';
  1675. this.bomListVersion();
  1676. }
  1677. },
  1678. // changeBomId() {
  1679. // this.routingList = [];
  1680. // this.form.produceRoutingId = '';
  1681. // this.form.produceRoutingName = '';
  1682. // this.form.produceVersionName = '';
  1683. // this.bomVersionList.forEach((f) => {
  1684. // if (f.id == this.form.bomCategoryId) {
  1685. // this.$set(this.form, 'bomCategoryName', f.name);
  1686. // this.$set(this.form, 'bomCategoryVersions', f.versions);
  1687. // }
  1688. // });
  1689. // this.getPlanRouting();
  1690. // },
  1691. changeRoute() {
  1692. this.$forceUpdate();
  1693. this.routingList.forEach((f) => {
  1694. if (f.id == this.form.produceRoutingId) {
  1695. this.$set(this.form, 'produceRoutingId', f.id);
  1696. this.$set(this.form, 'produceRoutingName', f.name);
  1697. this.$set(this.form, 'produceVersionName', f.version);
  1698. }
  1699. });
  1700. },
  1701. cancel() {
  1702. this.visible = false;
  1703. this.initForm();
  1704. this.$emit('close');
  1705. },
  1706. // 【开始时间变化时】触发
  1707. handleStartTimeChange(row) {
  1708. // 校验 是否 大于结束时间 wda
  1709. this.checkEndTimeValid(row);
  1710. },
  1711. // 【结束时间变化时】触发
  1712. handleEndTimeChange(row) {
  1713. // 校验 是否 大于结束时间 wda
  1714. this.checkEndTimeValid(row);
  1715. },
  1716. handleCompleteChange(row) {
  1717. const { reqMoldTime } = row;
  1718. if (!row.startTime) {
  1719. row.reqMoldTime = '';
  1720. return this.$message.warning('请选择计划开始时间');
  1721. }
  1722. this.handleComplete(reqMoldTime, row);
  1723. },
  1724. handleComplete(reqMoldTime, row) {
  1725. const startTime = new Date(row.startTime).getTime();
  1726. const completeTime = new Date(reqMoldTime).getTime();
  1727. if (completeTime < startTime) {
  1728. row.reqMoldTime = ''; // 修正为开始时间
  1729. return this.$message.warning(
  1730. '要求完成时间不能早于计划开始时间, 请重新选择要求完成时间'
  1731. );
  1732. }
  1733. },
  1734. // 时间校验
  1735. checkEndTimeValid(row) {
  1736. const { startTime: start, endTime: end } = row;
  1737. this.handleChange(start, end, row);
  1738. // // if (!start || !end) return; // 开始/结束时间未填,跳过
  1739. // const startTime = new Date(start); // 开始时间
  1740. // const endTime = new Date(end); // 结束时间
  1741. // if (endTime < startTime) {
  1742. // row.endTime = new Date(startTime); // 修正为开始时间
  1743. // this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
  1744. // }
  1745. },
  1746. handleChange(start, end, row) {
  1747. const startTime = new Date(start).getTime();
  1748. const endTime = new Date(end).getTime();
  1749. if (endTime < startTime) {
  1750. row.endTime = ''; // 修正为开始时间
  1751. return this.$message.warning(
  1752. '计划结束时间不能早于计划开始时间,请重新选择计划结束时间'
  1753. );
  1754. }
  1755. }
  1756. }
  1757. };
  1758. </script>
  1759. <style lang="scss" scoped>
  1760. .el-form-item {
  1761. margin-bottom: 14px !important;
  1762. }
  1763. .sale-order-select {
  1764. display: flex;
  1765. align-items: center;
  1766. gap: 4px;
  1767. }
  1768. .add-product {
  1769. width: 100%;
  1770. display: flex;
  1771. align-items: center;
  1772. justify-content: flex-end;
  1773. font-size: 30px;
  1774. color: #1890ff;
  1775. margin: 10px 0;
  1776. cursor: pointer;
  1777. }
  1778. .header_required {
  1779. .is-required:before {
  1780. content: '*';
  1781. color: #f56c6c;
  1782. margin-right: 4px;
  1783. }
  1784. }
  1785. </style>