index.vue 54 KB

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