index.vue 57 KB

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