salesToProductionNewTwo.vue 64 KB

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