salesToProductionNewTwo.vue 65 KB

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