index.vue 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713
  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. @change="handleCompleteChange(form)"
  119. type="datetime"
  120. placeholder="选择日期"
  121. value-format="yyyy-MM-dd HH:mm:ss"
  122. >
  123. </el-date-picker>
  124. </el-form-item>
  125. </el-col>
  126. </el-row>
  127. <headerTitle title="产品信息"> </headerTitle>
  128. <el-row :gutter="24">
  129. <ele-pro-table
  130. ref="tableRef"
  131. :columns="columns"
  132. row-key="code"
  133. :cache-key="`ProductionPlanTable`"
  134. :datasource="form.productInfoList"
  135. border
  136. height="40vh"
  137. key="id"
  138. >
  139. <template v-slot:modelKey="{ row, $index }">
  140. <el-select
  141. clearable
  142. v-model="row.modelKey"
  143. multiple
  144. filterable
  145. allow-create
  146. default-first-option
  147. >
  148. <el-option
  149. v-for="item in modelList"
  150. :key="item.label"
  151. :value="item.label"
  152. :label="item.label"
  153. >
  154. </el-option>
  155. </el-select>
  156. </template>
  157. <template v-slot:colorKey="{ row, $index }">
  158. <el-select
  159. clearable
  160. v-model="row.colorKey"
  161. multiple
  162. filterable
  163. allow-create
  164. default-first-option
  165. >
  166. <el-option
  167. v-for="item in colorList"
  168. :key="item.label"
  169. :value="item.label"
  170. :label="item.label"
  171. >
  172. </el-option>
  173. </el-select>
  174. </template>
  175. <template v-slot:requiredFormingNum="{ row, $index }">
  176. <el-input
  177. v-model="row.requiredFormingNum"
  178. size="small"
  179. type="text"
  180. style="width: 100%"
  181. placeholder="输入要求生产数量"
  182. @input="(e) => handleQuantityInput(e, row)"
  183. ></el-input>
  184. <!-- placeholder="输入要求生产数量" @input="tableHandleKeyUp(row, 'sum')"></el-input> -->
  185. </template>
  186. <template v-slot:productType="{ row, $index }">
  187. <el-select
  188. v-model="row.productType"
  189. @change="changeProductType(row, $index)"
  190. :key="$index"
  191. >
  192. <el-option
  193. v-for="item of row.producedList"
  194. :key="$index + item.code"
  195. :label="item.name"
  196. :value="item.code"
  197. ></el-option>
  198. </el-select>
  199. </template>
  200. <template v-slot:bomCategoryId="{ row, $index }">
  201. <el-select v-model="row.bomCategoryId">
  202. <el-option
  203. v-for="item of row.bomVersionList"
  204. :key="item.id"
  205. :label="item.name + '(V' + item.versions + '.0)'"
  206. :value="item.id"
  207. @click.native="changeBomId(row, $index, item)"
  208. ></el-option>
  209. </el-select>
  210. </template>
  211. <!-- //权重等级 -->
  212. <template
  213. v-slot:weight="{ row, $index }"
  214. v-if="clientEnvironmentId == 4"
  215. >
  216. <el-select
  217. v-model="row.weight"
  218. style="width: 100%"
  219. @change="changeProduceType"
  220. size="mini"
  221. >
  222. <el-option
  223. v-for="item of weightList"
  224. :key="item.code"
  225. :label="item.name"
  226. :value="item.code"
  227. ></el-option>
  228. </el-select>
  229. </template>
  230. <!-- 是否开槽 -->
  231. <template
  232. v-slot:isSlotting="{ row, $index }"
  233. v-if="clientEnvironmentId == 4"
  234. >
  235. <el-select
  236. v-model="row.isSlotting"
  237. style="width: 100%"
  238. @change="changeProduceType"
  239. size="mini"
  240. >
  241. <el-option
  242. v-for="item of isSlotting"
  243. :key="item.code"
  244. :label="item.name"
  245. :value="item.code"
  246. ></el-option>
  247. </el-select>
  248. </template>
  249. <!-- 开槽类型 -->
  250. <template
  251. v-slot:slottingType="{ row, $index }"
  252. v-if="clientEnvironmentId == 4"
  253. >
  254. <DictSelection
  255. dictName="开槽类型"
  256. v-model="row.slottingType"
  257. size="mini"
  258. >
  259. </DictSelection>
  260. </template>
  261. <!-- 工艺路线 -->
  262. <template
  263. v-slot:produceRoutingId="{ row, $index }"
  264. v-if="clientEnvironmentId != 4"
  265. >
  266. <!-- <el-form-item required> -->
  267. <div style="display: flex">
  268. <el-select
  269. v-model="row.produceRoutingId"
  270. v-show="isRouteSelect(row)"
  271. >
  272. <el-option
  273. v-for="item of row.routingList"
  274. :key="item.id"
  275. :label="item.name"
  276. :value="item.id"
  277. ></el-option>
  278. </el-select>
  279. <div style="display: flex">
  280. <el-input
  281. v-show="!isRouteSelect(row)"
  282. disabled
  283. v-model="row.produceRoutingName"
  284. ></el-input>
  285. <el-button
  286. v-show="isSelectShow"
  287. type="primary"
  288. size="mini"
  289. @click="openDialog($index)"
  290. >选择</el-button
  291. >
  292. </div>
  293. </div>
  294. <!-- </el-form-item> -->
  295. </template>
  296. <template v-slot:produceRoutingId="{ row, $index }" v-else>
  297. <el-input
  298. v-model="row.produceRoutingName"
  299. style="width: 100%"
  300. readonly
  301. ></el-input>
  302. </template>
  303. <template v-slot:factoriesId="{ row, $index }">
  304. <el-select
  305. v-model="row.factoriesId"
  306. :key="row.factoriesId"
  307. @change="(e) => selectFactory(e, row)"
  308. :disabled="factoriesId"
  309. >
  310. <el-option
  311. v-for="item of factoryList"
  312. :key="item.id"
  313. :label="item.name"
  314. :value="item.id"
  315. ></el-option>
  316. </el-select>
  317. </template>
  318. <!-- <el-table-column label="所属工厂" width="140" align="center" prop="factoriesId">
  319. <template slot-scope="scope">
  320. <el-form-item label-width="0px">
  321. <el-select v-model="scope.row.factoriesId" :key="scope.row.factoriesId">
  322. <el-option v-for="item of factoryList" :key="item.id" :label="item.name"
  323. :value="item.id"></el-option>
  324. </el-select>
  325. </el-form-item>
  326. </template>
  327. </el-table-column> -->
  328. <!-- 模具数量 -->
  329. <template
  330. v-slot:moCount="{ row, $index }"
  331. v-if="clientEnvironmentId == '4'"
  332. >
  333. <div>
  334. <el-input
  335. style="width: 100%"
  336. size="small"
  337. v-model="row.moCount"
  338. oninput="value=value.replace(/[^0-9.]/g,'')"
  339. @input="tableHandleKeyUp(row, 'moCount')"
  340. placeholder="请输入"
  341. >
  342. </el-input>
  343. </div>
  344. </template>
  345. <!-- 块数 -->
  346. <template
  347. v-slot:blockCount="{ row, $index }"
  348. v-if="clientEnvironmentId == '4'"
  349. >
  350. <div>
  351. <el-input
  352. size="small"
  353. style="width: 100%"
  354. @input="tableHandleKeyUp(row, 'blockCount')"
  355. v-model="row.blockCount"
  356. placeholder="请输入"
  357. ></el-input>
  358. </div>
  359. </template>
  360. <template v-slot:productWeight="{ row, $index }">
  361. <span>{{ row.productWeight ? row.productWeight : '-' }}</span>
  362. </template>
  363. <template v-slot:set="{ row, $index }">
  364. <el-button type="text" @click="handleDeleteItem($index)"
  365. >删除</el-button
  366. >
  367. </template>
  368. <template v-slot:headerProduceRoutingId="{ column }">
  369. <div class="header_required"
  370. ><span class="is-required">{{ column.label }}</span></div
  371. >
  372. </template>
  373. <template v-slot:headeRequiredFormingNum="{ column }">
  374. <div class="header_required"
  375. ><span class="is-required">{{ column.label }}</span></div
  376. >
  377. </template>
  378. <template v-slot:headerProcessingBOM="{ column }">
  379. <div :class="isRequired ? 'header_required' : ''"
  380. ><span class="is-required">{{ column.label }}</span></div
  381. >
  382. </template>
  383. </ele-pro-table>
  384. <div class="add-product" @click="addEquipment">
  385. <i class="el-icon-circle-plus-outline"></i>
  386. </div>
  387. </el-row>
  388. </el-form>
  389. <!-- 选择产品 -->
  390. <EquipmentDialog
  391. @choose="confirmChoose"
  392. :treeType="['9']"
  393. :selectList="[]"
  394. ref="equipmentRefs"
  395. >
  396. </EquipmentDialog>
  397. </div>
  398. <template v-slot:footer>
  399. <el-button @click="cancel">取消</el-button>
  400. <el-button type="primary" @click="save" :loading="loading">
  401. 确定
  402. </el-button>
  403. <el-button type="primary" @click="save('sub')" :loading="loading">
  404. 发布
  405. </el-button>
  406. </template>
  407. <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
  408. </ele-modal>
  409. </template>
  410. <script>
  411. import { findBomCategoryByCategoryId } from '@/api/productionPlan/index';
  412. import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
  413. import { getCode } from '@/api/codeManagement';
  414. import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
  415. import { parameterGetByCode } from '@/api/mainData/index';
  416. import { getByCode } from '@/api/system/dictionary-data';
  417. import {
  418. bomRoutingList,
  419. bomListByPlan,
  420. getFactoryList,
  421. saveAndRelease,
  422. temporaryPlanSave,
  423. getUpdateInfoByCode
  424. } from '@/api/saleOrder';
  425. import contactDialog from '@/components/contactDialog/openContactDialog.vue';
  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: 'productWeight',
  671. prop: 'productWeight',
  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. produceType: [
  743. { required: true, message: '请选择工艺路线', trigger: 'blur' }
  744. ],
  745. produceRoutingId: [
  746. { required: true, message: '请选择工艺路线', trigger: 'blur' }
  747. ],
  748. startTime: [
  749. { required: true, message: '请选择计划开始日期', trigger: 'blur' }
  750. ],
  751. endTime: [
  752. { required: true, message: '请选择计划结束日期', trigger: 'blur' }
  753. ],
  754. reqMoldTime: [
  755. { required: true, message: '请选择要求完成日期', trigger: 'blur' }
  756. ],
  757. requiredFormingNum: [
  758. { required: true, message: '请输入生产数量', trigger: 'blur' }
  759. ]
  760. },
  761. producedList: [
  762. { code: 2, name: '加工(MBOM)' },
  763. { code: 3, name: '装配(ABOM)' }
  764. ],
  765. selectIndex: 0, // 选择工艺路线的当前数据下标
  766. processingRequired: 0 // 生产类型跟BOM 版本是否必填 1:是 0:否
  767. // selectionRowShow: false // 工艺路线输入框展示 状态
  768. };
  769. },
  770. // computed: {
  771. // clientEnvironmentId() {
  772. // return this.$store.state.user.info.clientEnvironmentId;
  773. // }
  774. // },
  775. mounted() {
  776. this.getCodeData();
  777. // 生产类型跟BOM版本字段是否必填
  778. parameterGetByCode({
  779. code: 'production_plan_code'
  780. }).then((res) => {
  781. console.log(res, 'res 1');
  782. if (res) {
  783. this.processingRequired = res.value;
  784. }
  785. });
  786. },
  787. methods: {
  788. // 获取
  789. async getCodeData() {
  790. let arr1 = await this.getLevelCode('product_model_key');
  791. let arr2 = await this.getLevelCode('product_color_key');
  792. this.modelList = arr1;
  793. this.colorList = arr2;
  794. },
  795. async getLevelCode(code) {
  796. try {
  797. const res = await getByCode(code);
  798. if (res.code == 0) {
  799. let list = Object.values(res.data).map((el) => {
  800. let k = Object.keys(el)[0];
  801. let v = Object.values(el)[0];
  802. return {
  803. label: v,
  804. value: k
  805. };
  806. });
  807. return list;
  808. }
  809. } catch (err) {
  810. this.$message.error(err.message);
  811. }
  812. },
  813. selectFactory(e, row) {
  814. let data = this.factoryList.find((item) => item.id === e);
  815. this.$set(row, 'factoriesName', data.name);
  816. },
  817. // 打开工艺路线
  818. openDialog(index) {
  819. this.selectIndex = index;
  820. this.$refs.processRouteRef.open();
  821. },
  822. // 选择工艺路线
  823. changeParent(item) {
  824. let data = this.form.productInfoList[this.selectIndex];
  825. this.$set(data, 'bomVersionList', []);
  826. this.$set(data, 'bomCategoryId', '');
  827. this.$set(data, 'model', '');
  828. this.$set(data, 'routingList', []);
  829. this.$set(data, 'productType', '');
  830. this.$set(data, 'produceRoutingName', item.name);
  831. this.$set(data, 'produceRoutingId', item.id);
  832. this.$set(data, 'selectionRowShow', true);
  833. // this.selectionRowShow = true;
  834. },
  835. async getFactoryList() {
  836. this.factoryList = await getFactoryList();
  837. },
  838. async open(val) {
  839. await this.getFactoryList();
  840. this.clientEnvironmentId =
  841. this.$store.state.user.info.clientEnvironmentId;
  842. this.factoriesId = this.$store.state.user.info.factoryId;
  843. if (val) {
  844. if (val.planType == null || val.planType == 'null') {
  845. val.planType = '';
  846. }
  847. this.title = !val.id ? '新增临时生产计划' : '编辑临时生产计划';
  848. val.planType = String(val.planType);
  849. this.form = await getUpdateInfoByCode(val.code);
  850. // 修改
  851. if (val.id) {
  852. if (
  853. Array.isArray(val.productInfoList) &&
  854. val.productInfoList.length
  855. ) {
  856. this.form.productInfoList.map(async (v, index) => {
  857. if (!v.bomCategoryId) {
  858. v.productType = '';
  859. v.selectionRowShow = true;
  860. } else {
  861. v.selectionRowShow = false;
  862. }
  863. if (v.productType) {
  864. this.$set(
  865. this.form.productInfoList[index],
  866. 'bomVersionList',
  867. await this.bomListVersionFn(v.productType, v.categoryId)
  868. );
  869. }
  870. if (v.bomCategoryId) {
  871. this.$set(
  872. this.form.productInfoList[index],
  873. 'routingList',
  874. await this.changeBomIdFn(
  875. v.bomCategoryId,
  876. this.form.productInfoList[index]
  877. )
  878. );
  879. }
  880. });
  881. }
  882. // let categoryId = this.form.productInfoList[0].categoryId;
  883. // const res = await findBomCategoryByCategoryId(categoryId);
  884. let promiseAll = [];
  885. this.form.productInfoList.forEach(async (item) => {
  886. let categoryId = item.categoryId;
  887. promiseAll.push(findBomCategoryByCategoryId(categoryId));
  888. });
  889. const resAll = await Promise.all(promiseAll);
  890. console.log(this.form.productInfoList);
  891. this.form.productInfoList.forEach((item, index) => {
  892. if (resAll[index]) {
  893. let list = [];
  894. let listMap = {};
  895. resAll[index].map((el) => {
  896. if (el.bomType == '2' || el.bomType == '3') {
  897. console.log(listMap, 'listMap');
  898. if (listMap[el.bomType]) {
  899. listMap[el.bomType].push(el);
  900. } else {
  901. listMap[el.bomType] = [el];
  902. }
  903. }
  904. });
  905. if (listMap[2]) {
  906. list.push({ code: 2, name: 'MBOM' });
  907. }
  908. if (listMap[3]) {
  909. list.push({ code: 3, name: 'ABOM' });
  910. }
  911. if (!item.factoriesId) {
  912. this.$set(
  913. this.form.productInfoList[index],
  914. 'factoriesId',
  915. this.factoriesId
  916. );
  917. this.$set(
  918. this.form.productInfoList[index],
  919. 'factoriesName',
  920. this.factoryList?.find(
  921. (factoryData) => factoryData.id === this.factoriesId
  922. )?.name
  923. );
  924. }
  925. this.$set(
  926. this.form.productInfoList[index],
  927. 'producedList',
  928. list
  929. );
  930. }
  931. });
  932. }
  933. this.$forceUpdate();
  934. } else {
  935. this.title = '新增临时生产计划';
  936. }
  937. this.visible = true;
  938. // this.$nextTick(async () => {
  939. // console.log(val.productInfoList);
  940. // this.$set(this.form, 'productInfoList', val.productInfoList);
  941. // this.$set(this.form, 'routingList', val.routingList);
  942. // });
  943. //this.clientEnvironmentId 环境判断 宝悦环境
  944. // if (this.clientEnvironmentId == 4) {
  945. // this.getPlanRoutingNew();
  946. // }
  947. // this.getPlanRoutingNew();
  948. },
  949. addEquipment() {
  950. this.$refs.equipmentRefs.open();
  951. },
  952. async confirmChoose(list) {
  953. list.map((el) => (el.selectionRowShow = false));
  954. if (this.clientEnvironmentId == 4) {
  955. list.map((v) => {
  956. if (v.name.includes('板材')) {
  957. v.produceRoutingId = '1856970794952372226';
  958. v.produceRoutingName = '板材';
  959. v.produceVersionName = '板材';
  960. } else {
  961. (v.produceRoutingId = '1857313733642596353'),
  962. (v.produceRoutingName = '砌块'),
  963. (v.produceVersionName = '砌块');
  964. }
  965. });
  966. }
  967. let ids = this.form.productInfoList.map((item) => item.categoryId);
  968. let result = list
  969. .filter((i) => !ids.includes(i.id))
  970. .map((item, index) => {
  971. return {
  972. categoryId: item.id,
  973. productCode: item.code,
  974. productName: item.name,
  975. productUnitWeight: item.netWeight,
  976. weightUnit: item.weightUnit,
  977. model: item.modelType,
  978. specification: item.specification,
  979. brandNo: item.brandNum,
  980. measuringUnit: item.measuringUnit,
  981. produceRoutingId: item.produceRoutingId,
  982. produceRoutingName: item.produceRoutingName,
  983. produceVersionName: item.produceVersionName,
  984. factoriesId: this.factoriesId,
  985. factoriesName: this.factoryList?.find(
  986. (factoryData) => factoryData.id === this.factoriesId
  987. )?.name
  988. };
  989. });
  990. // this.form.productInfoList = [];
  991. // 取出在弹窗中选中并且不在表格中的数据
  992. // const result = list.filter(
  993. // (i) =>
  994. // this.form.productInfoList.findIndex(
  995. // (p) => p.productCode === i.productCode
  996. // ) === -1
  997. // );
  998. // // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
  999. // const del = this.form.productInfoList.filter(
  1000. // (i) => list.findIndex((p) => p.productCode === i.productCode) === -1
  1001. // );
  1002. // for (let i = this.form.productInfoList.length - 1; i >= 0; i--) {
  1003. // for (let j in del) {
  1004. // if (
  1005. // this.form.productInfoList[i].productCode === del[j].productCode
  1006. // ) {
  1007. // this.form.productInfoList.splice(i, 1);
  1008. // break;
  1009. // }
  1010. // }
  1011. // }
  1012. let promiseAll = [];
  1013. result.forEach(async (item) => {
  1014. let categoryId = item.categoryId;
  1015. promiseAll.push(findBomCategoryByCategoryId(categoryId));
  1016. });
  1017. const resAll = await Promise.all(promiseAll);
  1018. try {
  1019. await result.forEach(async (item, index) => {
  1020. if (resAll[index]) {
  1021. let listMap = {};
  1022. let list = [];
  1023. let arr = [];
  1024. resAll[index].map((el) => {
  1025. if (el.bomType == '2' || el.bomType == '3') {
  1026. console.log(listMap, 'listMap');
  1027. if (listMap[el.bomType]) {
  1028. listMap[el.bomType].push(el);
  1029. } else {
  1030. listMap[el.bomType] = [el];
  1031. }
  1032. }
  1033. });
  1034. if (listMap[2]) {
  1035. list.push({ code: 2, name: 'MBOM' });
  1036. arr = listMap[2];
  1037. item.productType = 2;
  1038. }
  1039. if (listMap[3]) {
  1040. list.push({ code: 3, name: 'ABOM' });
  1041. if (!listMap[2]) {
  1042. arr = listMap[3];
  1043. item.productType = 3;
  1044. }
  1045. }
  1046. if (arr.length > 0) {
  1047. arr.map((el) => (el.bomCategoryId = el.id));
  1048. item.bomCategoryId = arr[0].id;
  1049. await this.changeBomId(arr[0], 0);
  1050. this.$set(item, 'produceRoutingId', arr[0].produceRoutingId);
  1051. this.$set(
  1052. item,
  1053. 'produceVersionName',
  1054. arr[0].produceVersionName
  1055. );
  1056. this.$set(
  1057. item,
  1058. 'produceRoutingName',
  1059. arr[0].produceRoutingName
  1060. );
  1061. console.log(arr[0], 'arr[0]');
  1062. this.$set(item, 'routingList', arr[0].routingList);
  1063. this.$set(item, 'bomCategoryName', arr[0].name);
  1064. this.$set(item, 'bomCategoryVersions', arr[0].versions);
  1065. }
  1066. item.producedList = list;
  1067. item.bomVersionList = arr;
  1068. return item;
  1069. }
  1070. });
  1071. } catch (err) {}
  1072. this.form.productInfoList.push(...result);
  1073. this.changeLineNumber();
  1074. this.$refs.tableRef.setData(this.form.productInfoList);
  1075. //重置
  1076. this.$set(this.form, 'produceType', '');
  1077. this.$set(this.form, 'bomCategoryId', '');
  1078. this.$set(this.form, 'produceRoutingId', '');
  1079. },
  1080. changeLineNumber() {
  1081. this.form.productInfoList.forEach((item, index) => {
  1082. let data = this.form.productInfoList[index - 1];
  1083. this.$set(
  1084. this.form.productInfoList[index],
  1085. 'lineNumber',
  1086. data ? data.lineNumber + 10 : 10
  1087. );
  1088. });
  1089. },
  1090. handleDeleteItem(index) {
  1091. this.$confirm('确定删除当前数据?', '提示')
  1092. .then(() => {
  1093. const newArray = this.form.productInfoList.filter(
  1094. (item, i) => i !== index
  1095. );
  1096. this.form.productInfoList = newArray;
  1097. this.$refs.tableRef.setData(newArray);
  1098. })
  1099. .catch(() => {});
  1100. },
  1101. async getPlanCode() {
  1102. this.loading = true;
  1103. try {
  1104. const code = await getCode('product_code');
  1105. this.$set(this.form, 'code', code);
  1106. } catch (err) {}
  1107. },
  1108. initForm() {
  1109. this.form = {
  1110. timeDimensionPlanType: 3,
  1111. categoryId: '',
  1112. productName: '',
  1113. planType: '',
  1114. moCount: '', // 模具数量
  1115. blockCount: 0, // 块数
  1116. noWordCount: '', // 无字数量
  1117. weight: '',
  1118. isSlotting: '', //是否开槽
  1119. slottingType: '', //开槽类型
  1120. id: '',
  1121. produceType: 2,
  1122. status: 2,
  1123. bomCategoryId: '',
  1124. produceRoutingId: '',
  1125. productInfoList: [],
  1126. requiredFormingNum: ''
  1127. };
  1128. // console.log(this.$refs);
  1129. // this.$refs.tableRef.setData([]);
  1130. },
  1131. changeBomIdFn(bomCategoryId, row) {
  1132. return new Promise((resolve, reject) => {
  1133. bomRoutingList(bomCategoryId).then((res) => {
  1134. let arr = res || [];
  1135. if (arr.length == 0) {
  1136. row.produceRoutingId = '';
  1137. }
  1138. resolve(arr);
  1139. });
  1140. });
  1141. },
  1142. // 选择BOM
  1143. async changeBomId(row, index, bomData) {
  1144. if (bomData) {
  1145. item.bomCategoryName = bomData.name;
  1146. item.bomCategoryVersions = bomData.versions;
  1147. }
  1148. // row.routingList = []
  1149. return await bomRoutingList(row.bomCategoryId).then((res) => {
  1150. let arr = res || [];
  1151. if (arr.length > 0) {
  1152. // this.$nextTick(() => {
  1153. row.produceRoutingName = arr[0].name;
  1154. row.produceVersionName = arr[0].version;
  1155. row.produceRoutingId = arr[0].id;
  1156. row.routingList = arr;
  1157. this.$set(row, 'produceRoutingId', arr[0].id);
  1158. this.$set(
  1159. this.form.productInfoList[index],
  1160. 'produceRoutingId',
  1161. arr[0].id
  1162. );
  1163. row.selectionRowShow = false;
  1164. this.$set(this.form.productInfoList[index], 'routingList', arr);
  1165. // });
  1166. }
  1167. this.$forceUpdate();
  1168. });
  1169. },
  1170. contactDialogSuccess(data) {
  1171. console.log(data, 'data 11');
  1172. // serialNo
  1173. this.form.serialNo = data.serialNo;
  1174. this.$set(this.form, 'customerName', data.name);
  1175. },
  1176. // 清空BOM 跟工艺路线
  1177. wipeData(index) {
  1178. let row = this.form.productInfoList[index];
  1179. row.bomCategoryId = '';
  1180. row.routingList = [];
  1181. row.bomVersionList = [];
  1182. row.produceRoutingId = '';
  1183. row.produceRoutingName = '';
  1184. row.produceVersionName = '';
  1185. row.selectionRowShow = false;
  1186. // this.selectionRowShow = false;
  1187. },
  1188. // 选择生产类型
  1189. changeProductType(row, index) {
  1190. let param = {
  1191. bomType: row.productType,
  1192. categoryId: row.categoryId
  1193. };
  1194. this.wipeData(index);
  1195. // row.bomCategoryId = '';
  1196. // this.form.productInfoList[index].bomVersionList = [];
  1197. bomListByPlan(param).then((res) => {
  1198. let arr = res || [];
  1199. this.$nextTick(() => {
  1200. if (arr.length) {
  1201. row.bomVersionList = arr;
  1202. this.form.productInfoList[index].bomVersionList = arr;
  1203. row.bomCategoryId = arr[0].id;
  1204. this.changeBomId(row, index, arr[0]);
  1205. let arrAll = JSON.parse(JSON.stringify(this.form));
  1206. this.$set(this, 'form', arrAll);
  1207. }
  1208. });
  1209. // this.$set(this.form.productInfoList[index], 'bomVersionList', arr);
  1210. });
  1211. },
  1212. // 参数校验
  1213. parameterVerification() {
  1214. let flag = true;
  1215. this.form.productInfoList.forEach((v) => {
  1216. if (this.isRequired) {
  1217. if (!v.productType) {
  1218. flag = false;
  1219. this.$message.warning('请选择生产类型');
  1220. return;
  1221. }
  1222. if (!v.bomCategoryId) {
  1223. flag = false;
  1224. this.$message.warning('请选择BOM版本');
  1225. return;
  1226. }
  1227. }
  1228. if (!v.produceRoutingId) {
  1229. flag = false;
  1230. this.$message.warning('请选择工艺路线');
  1231. return;
  1232. }
  1233. if (!v.factoriesId) {
  1234. flag = false;
  1235. this.$message.warning('请选择所属工厂');
  1236. return;
  1237. }
  1238. if (v.requiredFormingNum == 0) {
  1239. flag = false;
  1240. this.$message.warning('要求生产数量不能为0');
  1241. return;
  1242. }
  1243. if (!v.requiredFormingNum) {
  1244. flag = false;
  1245. this.$message.warning('请输入要求生产数量');
  1246. return;
  1247. }
  1248. if (!v.moCount && this.clientEnvironmentId == 4) {
  1249. flag = false;
  1250. this.$message.warning('请输入模数');
  1251. return;
  1252. }
  1253. if (!v.blockCount && this.clientEnvironmentId == 4) {
  1254. flag = false;
  1255. this.$message.warning('请输入块数');
  1256. return;
  1257. }
  1258. });
  1259. return flag;
  1260. },
  1261. save(type) {
  1262. this.$refs.form.validate(async (valid) => {
  1263. if (!valid) {
  1264. return false;
  1265. }
  1266. let flag = this.parameterVerification();
  1267. // 必填参数校验
  1268. if (!flag) return;
  1269. // this.
  1270. if (!this.form.id) {
  1271. if (this.form.productInfoList.length) {
  1272. this.form.productInfoList.map((item, index) => {
  1273. if (
  1274. item.weightUnit == 'G' ||
  1275. item.weightUnit == 'g' ||
  1276. item.weightUnit == '克'
  1277. ) {
  1278. let total =
  1279. ((item.requiredFormingNum - 0) * item.productUnitWeight) /
  1280. 1000;
  1281. item.newSumOrderWeight = total.toFixed(2);
  1282. item.newWeightUnit = 'KG';
  1283. } else {
  1284. item.newWeightUnit = item.weightUnit;
  1285. item.newSumOrderWeight = item.requiredFormingNum;
  1286. }
  1287. delete item.selectionRowShow;
  1288. // if (item.bomVersionList && item.bomVersionList.length) {
  1289. // item.bomCategoryName = item.bomVersionList[0].name;
  1290. // item.bomCategoryVersions = item.bomVersionList[0].versions;
  1291. // item.produceRoutingName = item.routingList[0].name;
  1292. // }
  1293. });
  1294. }
  1295. this.form.timeDimensionPlanType = this.type;
  1296. await this.getPlanCode();
  1297. this.loading = true;
  1298. let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
  1299. api(this.form)
  1300. .then((res) => {
  1301. this.$message.success('新增成功!');
  1302. this.visible = false;
  1303. this.initForm();
  1304. this.$emit('close', true);
  1305. })
  1306. .finally(() => {
  1307. this.loading = false;
  1308. });
  1309. } else {
  1310. this.loading = true;
  1311. let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
  1312. // return
  1313. api(this.form)
  1314. .then((res) => {
  1315. this.$message.success('修改成功!');
  1316. this.visible = false;
  1317. this.initForm();
  1318. this.$emit('close', true);
  1319. })
  1320. .finally(() => {
  1321. this.loading = false;
  1322. });
  1323. }
  1324. });
  1325. },
  1326. bomListVersionFn(produceType, categoryId) {
  1327. return new Promise((resolve, reject) => {
  1328. let param = {
  1329. bomType: produceType,
  1330. categoryId: categoryId
  1331. };
  1332. bomListByPlan(param).then((res) => {
  1333. this.bomVersionList = res || [];
  1334. resolve(res || []);
  1335. });
  1336. });
  1337. },
  1338. bomListVersion() {
  1339. let param = {
  1340. bomType: this.form.produceType,
  1341. categoryId: this.form.categoryId
  1342. };
  1343. bomListByPlan(param).then((res) => {
  1344. this.$nextTick(() => {
  1345. this.bomVersionList = res || [];
  1346. console.log(res, 'res 000');
  1347. });
  1348. });
  1349. },
  1350. // 工艺路线
  1351. getPlanRouting() {
  1352. bomRoutingList(this.form.bomCategoryId).then((res) => {
  1353. this.routingList = res || [];
  1354. });
  1355. },
  1356. // 宝悦 工艺路线
  1357. getPlanRoutingNew() {
  1358. // bomRoutingList(this.form.bomCategoryId).then((res) => {
  1359. // this.routingList = res || []
  1360. // })
  1361. },
  1362. tableHandleKeyUp(row, name) {
  1363. // return
  1364. // , index, e, name
  1365. if (name == 'procut') {
  1366. return;
  1367. }
  1368. if (row.specification && this.clientEnvironmentId == 4) {
  1369. let modelArr = row.specification.split('*');
  1370. let modelLong = modelArr[0]; // model规格长度
  1371. let modeWide = modelArr[1]; // model规格宽度
  1372. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1373. modeHight = Number(modeHight);
  1374. if (name === 'moCount') {
  1375. // 模数
  1376. this.$set(row, 'moCount', row.moCount);
  1377. // 计算块数的公式:
  1378. // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
  1379. // 每一模的块数*模数moCount = 总块数
  1380. if (row.productName.includes('板材')) {
  1381. // 块数
  1382. let blockCount =
  1383. Math.floor(600 / modelLong) *
  1384. Math.floor(120 / modeHight) *
  1385. Math.floor(60 / modeWide) *
  1386. row.moCount;
  1387. row['blockCount'] = blockCount;
  1388. // this.$set(row, 'blockCount', blockCount);
  1389. } else if (row.productName.includes('砌块')) {
  1390. let modelLongFixed = (600 / modelLong).toFixed(2);
  1391. modelLongFixed = modelLongFixed.substring(
  1392. 0,
  1393. modelLongFixed.length - 1
  1394. );
  1395. let modeWideFixed = (120 / modeWide).toFixed(2);
  1396. modeWideFixed = modeWideFixed.substring(
  1397. 0,
  1398. modeWideFixed.length - 1
  1399. );
  1400. let modeHightFixed = (60 / modeHight).toFixed(2);
  1401. modeHightFixed = modeHightFixed.substring(
  1402. 0,
  1403. modeHightFixed.length - 1
  1404. );
  1405. let num =
  1406. Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
  1407. row.moCount;
  1408. row['blockCount'] = num;
  1409. }
  1410. let numNew = (
  1411. Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
  1412. row.blockCount
  1413. ).toFixed(5);
  1414. row['requiredFormingNum'] = numNew;
  1415. } else if (name === 'sum') {
  1416. let e = row.requiredFormingNum;
  1417. row.blockCount = Math.floor(
  1418. e / ((modelLong * modeWide * modeHight) / 1000000)
  1419. );
  1420. if (row.productName.includes('板材')) {
  1421. let num = Math.ceil(
  1422. row.blockCount /
  1423. (Math.floor(600 / modelLong) *
  1424. Math.floor(120 / modeHight) *
  1425. Math.floor(60 / modeWide))
  1426. );
  1427. // 48 480 4807 480
  1428. row.moCount = num;
  1429. } else if (row.productName.includes('砌块')) {
  1430. row.moCount = Math.ceil(
  1431. row.blockCount /
  1432. Math.floor(
  1433. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1434. )
  1435. );
  1436. }
  1437. } else if (name === 'blockCount') {
  1438. //块数
  1439. // row.blockCount = row.moCount;
  1440. row.blockCount = row.blockCount;
  1441. if (row.productName.includes('板材')) {
  1442. let moCount = Math.ceil(
  1443. row.blockCount /
  1444. (Math.floor(600 / modelLong) *
  1445. Math.floor(120 / modeHight) *
  1446. Math.floor(60 / modeWide))
  1447. );
  1448. row.moCount = moCount;
  1449. } else if (row.productName.includes('砌块')) {
  1450. let moCount = Math.ceil(
  1451. row.blockCount /
  1452. Math.floor(
  1453. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1454. )
  1455. );
  1456. this.$set(this.form, 'moCount', moCount);
  1457. row.moCount = moCount;
  1458. }
  1459. let a = (
  1460. (Number(row.blockCount) * modelLong * modeWide * modeHight) /
  1461. 1000000
  1462. ).toFixed(5);
  1463. row.requiredFormingNum = a;
  1464. }
  1465. }
  1466. },
  1467. // 数量正则 quantity
  1468. handleQuantityInput(e, row) {
  1469. // 过滤非数字字符(包括负号)
  1470. let value = e.replace(/[^\d.]/g, '');
  1471. // value = value.replace(/-/g, '');
  1472. // 限制不能以 0 开头(除非是 0 本身)
  1473. // if (value.startsWith('0') && value.length > 1) {
  1474. // value = value.slice(1);
  1475. // }
  1476. // 更新绑定值
  1477. row.requiredFormingNum = value;
  1478. this.tableHandleKeyUp(row, 'sum');
  1479. },
  1480. changeProduceType(e) {
  1481. if (this.clientEnvironmentId !== 4) {
  1482. this.form.bomCategoryId = '';
  1483. this.form['bomCategoryName'] = '';
  1484. this.form['bomCategoryVersions'] = '';
  1485. this.bomVersionList = [];
  1486. this.routingList = [];
  1487. this.form.produceRoutingId = '';
  1488. this.form.produceRoutingName = '';
  1489. this.form.produceVersionName = '';
  1490. this.bomListVersion();
  1491. }
  1492. },
  1493. // changeBomId() {
  1494. // this.routingList = [];
  1495. // this.form.produceRoutingId = '';
  1496. // this.form.produceRoutingName = '';
  1497. // this.form.produceVersionName = '';
  1498. // this.bomVersionList.forEach((f) => {
  1499. // if (f.id == this.form.bomCategoryId) {
  1500. // this.$set(this.form, 'bomCategoryName', f.name);
  1501. // this.$set(this.form, 'bomCategoryVersions', f.versions);
  1502. // }
  1503. // });
  1504. // this.getPlanRouting();
  1505. // },
  1506. changeRoute() {
  1507. this.$forceUpdate();
  1508. this.routingList.forEach((f) => {
  1509. if (f.id == this.form.produceRoutingId) {
  1510. this.$set(this.form, 'produceRoutingId', f.id);
  1511. this.$set(this.form, 'produceRoutingName', f.name);
  1512. this.$set(this.form, 'produceVersionName', f.version);
  1513. }
  1514. });
  1515. },
  1516. cancel() {
  1517. this.visible = false;
  1518. this.initForm();
  1519. this.$emit('close');
  1520. },
  1521. // 【开始时间变化时】触发
  1522. handleStartTimeChange(row) {
  1523. // 校验 是否 大于结束时间 wda
  1524. this.checkEndTimeValid(row);
  1525. },
  1526. // 【结束时间变化时】触发
  1527. handleEndTimeChange(row) {
  1528. // 校验 是否 大于结束时间 wda
  1529. this.checkEndTimeValid(row);
  1530. },
  1531. handleCompleteChange(row) {
  1532. const { reqMoldTime } = row;
  1533. if (!row.startTime) {
  1534. row.reqMoldTime = '';
  1535. return this.$message.warning('请选择计划开始时间');
  1536. }
  1537. this.handleComplete(reqMoldTime, row);
  1538. },
  1539. handleComplete(reqMoldTime, row) {
  1540. const startTime = new Date(row.startTime).getTime();
  1541. const completeTime = new Date(reqMoldTime).getTime();
  1542. if (completeTime < startTime) {
  1543. row.reqMoldTime = ''; // 修正为开始时间
  1544. return this.$message.warning(
  1545. '要求完成时间不能早于计划开始时间, 请重新选择要求完成时间'
  1546. );
  1547. }
  1548. },
  1549. // 时间校验
  1550. checkEndTimeValid(row) {
  1551. const { startTime: start, endTime: end } = row;
  1552. this.handleChange(start, end, row);
  1553. // // if (!start || !end) return; // 开始/结束时间未填,跳过
  1554. // const startTime = new Date(start); // 开始时间
  1555. // const endTime = new Date(end); // 结束时间
  1556. // if (endTime < startTime) {
  1557. // row.endTime = new Date(startTime); // 修正为开始时间
  1558. // this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
  1559. // }
  1560. },
  1561. handleChange(start, end, row) {
  1562. const startTime = new Date(start).getTime();
  1563. const endTime = new Date(end).getTime();
  1564. if (endTime < startTime) {
  1565. row.endTime = ''; // 修正为开始时间
  1566. return this.$message.warning(
  1567. '计划结束时间不能早于计划开始时间,请重新选择计划结束时间'
  1568. );
  1569. }
  1570. }
  1571. }
  1572. };
  1573. </script>
  1574. <style lang="scss" scoped>
  1575. .el-form-item {
  1576. margin-bottom: 14px !important;
  1577. }
  1578. .add-product {
  1579. width: 100%;
  1580. display: flex;
  1581. align-items: center;
  1582. justify-content: flex-end;
  1583. font-size: 30px;
  1584. color: #1890ff;
  1585. margin: 10px 0;
  1586. cursor: pointer;
  1587. }
  1588. .header_required {
  1589. .is-required:before {
  1590. content: '*';
  1591. color: #f56c6c;
  1592. margin-right: 4px;
  1593. }
  1594. }
  1595. </style>