salesToProductionNewTwo.vue 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982
  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 }}{{ form.measuringUnit }}</el-form-item
  255. >
  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: false,
  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. placeholder="选择日期"
  701. value-format="yyyy-MM-dd"
  702. >
  703. </el-date-picker>
  704. </el-form-item>
  705. </template>
  706. </el-table-column>
  707. <el-table-column label="客户名称" align="center" prop="customerName">
  708. </el-table-column>
  709. <el-table-column label="业务员" align="center" prop="salesman">
  710. </el-table-column>
  711. <el-table-column
  712. label="交付要求"
  713. align="center"
  714. prop="deliveryRequirements"
  715. >
  716. <template slot-scope="{ row }">
  717. {{ getDictValue('交付要求', row.deliveryRequirements) }}
  718. </template>
  719. </el-table-column>
  720. <el-table-column
  721. prop="priority"
  722. label="优先级"
  723. width="100"
  724. align="center"
  725. >
  726. <template slot-scope="{ row, $index }">
  727. <div style="display: flex">
  728. <el-input
  729. v-if="$index == 0"
  730. v-model="row.priority"
  731. type="number"
  732. size="mini"
  733. :min="0"
  734. :max="10"
  735. @change="priorityChange(row)"
  736. style="width: 80px"
  737. ></el-input>
  738. <el-popover
  739. v-if="$index == 0"
  740. placement="right"
  741. width="200"
  742. trigger="hover"
  743. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  744. >
  745. <div class="sort-wrap" slot="reference">
  746. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  747. <i
  748. class="el-icon-caret-bottom"
  749. @click="sortBottom(row)"
  750. ></i>
  751. </div>
  752. </el-popover>
  753. </div>
  754. </template>
  755. </el-table-column>
  756. <el-table-column label="操作" align="center" width="70" fixed="right">
  757. <template slot-scope="scope">
  758. <el-button
  759. type="text"
  760. @click="handleDeleteItem(scope.$index)"
  761. v-if="type != 'edit'"
  762. >删除</el-button
  763. >
  764. </template>
  765. </el-table-column>
  766. </el-table>
  767. <div class="add-product" @click="addEquipment" v-if="type != 'edit'">
  768. <i class="el-icon-circle-plus-outline"></i>
  769. </div>
  770. <el-row :gutter="24">
  771. <el-col v-bind="styleResponsive ? { lg: 24, md: 24 } : { span: 24 }">
  772. <el-form-item label="计划备注:">
  773. <el-input
  774. type="textarea"
  775. :rows="4"
  776. v-model="form.notes"
  777. resize="none"
  778. ></el-input>
  779. </el-form-item>
  780. </el-col>
  781. </el-row>
  782. </el-form>
  783. <AdditionalOrder
  784. ref="additionalRefs"
  785. :productCode="form.productCode"
  786. :selectList="form.salesOrders"
  787. @choose="confirmChoose"
  788. ></AdditionalOrder>
  789. <ProductionVersion
  790. ref="versionRefs"
  791. @changeProduct="changeProduct"
  792. ></ProductionVersion>
  793. <PlanSubmit
  794. ref="submitRefs"
  795. :type="$route.query.type"
  796. :info="form"
  797. @publish="publishData"
  798. ></PlanSubmit>
  799. <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
  800. </el-card>
  801. </div>
  802. </template>
  803. <script>
  804. import validDate from '@/utils/date';
  805. import AdditionalOrder from './components/AdditionalOrder.vue';
  806. import PlanSubmit from './components/plan-submit.vue';
  807. import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
  808. import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
  809. import {
  810. productionToPlan,
  811. saveSaleToPlan,
  812. updateSaleToPlan,
  813. releaseSave,
  814. getInventory,
  815. getUpdateInfoById,
  816. bomRoutingList,
  817. bomListByPlan,
  818. getFactoryList,
  819. getInventoryTotalAPI
  820. } from '@/api/saleOrder';
  821. import {
  822. findBomCategoryByCategoryId,
  823. planIsReview
  824. } from '@/api/productionPlan/index';
  825. import { getByCode } from '@/api/system/dictionary-data';
  826. import { parameterGetByCode } from '@/api/mainData/index';
  827. import dictMixins from '@/mixins/dictMixins';
  828. import { deepClone } from '@/utils/index';
  829. import { getRouteTabKey, removePageTab } from '@/utils/page-tab-util';
  830. import { getCode } from '@/api/codeManagement';
  831. import dayjs from 'dayjs';
  832. import { debounce } from 'lodash';
  833. import { log } from 'bpmn-js-token-simulation';
  834. export default {
  835. mixins: [dictMixins],
  836. components: {
  837. AdditionalOrder,
  838. ProductionVersion,
  839. PlanSubmit,
  840. ProcessRoute
  841. },
  842. data() {
  843. return {
  844. type: this.$route.query.type,
  845. weightList: [
  846. { code: 1, name: 'A' },
  847. { code: 2, name: 'B' },
  848. { code: 3, name: 'C' }
  849. ],
  850. isSlotting: [
  851. { code: 1, name: '是' },
  852. { code: 2, name: '否' }
  853. ], //是否开槽
  854. producedList: [
  855. // { code: 2, name: '加工(MBOM)' }, //2 待确认
  856. // { code: 3, name: '装配(ABOM)' }
  857. ],
  858. form: {
  859. planType: 1,
  860. produceRoutingId: '',
  861. stockCountBase: '',
  862. salesOrders: [],
  863. produceRoutingName: '',
  864. marginCoefficient: '1.0',
  865. batchNo: null,
  866. produceType: '',
  867. bomCategoryId: null,
  868. factoriesId: '',
  869. startTime: '',
  870. endTime: ''
  871. },
  872. marginList: [],
  873. bomVersionList: [],
  874. routingList: [],
  875. init: '1',
  876. factoryList: [],
  877. // 表单验证规则
  878. rules: {
  879. produceRoutingId: [
  880. { required: true, message: '请选择工艺路线', trigger: 'blur' }
  881. ]
  882. // startTime: [
  883. // {
  884. // type: 'date',
  885. // required: true,
  886. // message: '请选择计划开始日期',
  887. // trigger: 'change'
  888. // }
  889. // ],
  890. // endTime: [
  891. // {
  892. // type: 'date',
  893. // required: true,
  894. // message: '请选择计划结束日期',
  895. // trigger: 'change'
  896. // }
  897. // ],
  898. // produceType: [
  899. // { required: true, message: '请选择生产类型', trigger: 'blur' }
  900. // ],
  901. // bomCategoryId: [
  902. // { required: true, message: '请选择BOM版本', trigger: 'blur' }
  903. // ],
  904. // factoriesId: [
  905. // { required: true, message: '请选择所属工厂', trigger: 'change' }
  906. // ]
  907. },
  908. // selection: [],
  909. loading: false,
  910. processingRequired: 0, // 生产类型跟BOM 版本是否必填 1:是 0:否
  911. selectionRowShow: false, // 工艺路线输入框展示 状态
  912. validDate,
  913. modelList: [], // 机型数据
  914. colorList: [], // 颜色数据
  915. isReview: false
  916. };
  917. },
  918. props: {
  919. objData: {
  920. type: Object,
  921. default: {}
  922. }
  923. },
  924. watch: {
  925. objData: {
  926. async handler(val) {
  927. await this.getProducedData();
  928. this.requestDict('按单按库');
  929. this.requestDict('订单类型');
  930. this.requestDict('交付要求');
  931. this.getByCodeFn();
  932. this.getFactoryList();
  933. // 查询库存数量
  934. // this.inventory(val.id);
  935. if (val.type == 'edit') {
  936. this.getPlanInfo(val.id);
  937. } else {
  938. this.getSaleInfo();
  939. }
  940. },
  941. deep: true,
  942. immediate: true
  943. },
  944. 'form.produceType'(newVal, oldVal) {
  945. console.log(newVal, '值');
  946. },
  947. form: {
  948. handler(newVal) {
  949. console.log(newVal, 'newVal 33');
  950. },
  951. deep: true,
  952. immediate: true
  953. }
  954. },
  955. mounted() {
  956. this.mandatoryField();
  957. this.getCodeData();
  958. this.getplannedReleaseRequire('planned_release_require');
  959. },
  960. computed: {
  961. clientEnvironmentId() {
  962. return this.$store.state.user.info.clientEnvironmentId;
  963. },
  964. // 是否开启响应式布局
  965. styleResponsive() {
  966. return this.$store.state.theme.styleResponsive;
  967. },
  968. // 是否必填字段
  969. isRequired() {
  970. // if (this.form.planType == 5) {
  971. // return false;
  972. // }
  973. return this.processingRequired == 1;
  974. },
  975. // 工艺路线 输入框展示跟选择框判断
  976. isRouteSelect() {
  977. if (this.isRequired) {
  978. return true;
  979. }
  980. if (!this.selectionRowShow) {
  981. return true;
  982. }
  983. return false;
  984. },
  985. // 选择按钮的显示
  986. isSelectShow() {
  987. // if (this.form.planType == 5) {
  988. // return true;
  989. // }
  990. return this.processingRequired == 0;
  991. }
  992. },
  993. methods: {
  994. // 获取
  995. async getCodeData() {
  996. let arr1 = await this.getLevelCode('product_model_key');
  997. let arr2 = await this.getLevelCode('product_color_key');
  998. this.modelList = arr1;
  999. this.colorList = arr2;
  1000. },
  1001. async getLevelCode(code) {
  1002. try {
  1003. const res = await getByCode(code);
  1004. if (res.code == 0) {
  1005. let list = Object.values(res.data).map((el) => {
  1006. let k = Object.keys(el)[0];
  1007. let v = Object.values(el)[0];
  1008. return {
  1009. label: v,
  1010. value: k
  1011. };
  1012. });
  1013. return list;
  1014. }
  1015. } catch (err) {
  1016. this.$message.error(err.message);
  1017. }
  1018. },
  1019. async getplannedReleaseRequire(code) {
  1020. parameterGetByCode({ code }).then((res) => {
  1021. if (res) {
  1022. this.isReview = res.value == '1' ? true : false;
  1023. }
  1024. });
  1025. },
  1026. async getProducedData() {
  1027. console.log(111111111111111);
  1028. let query = { ...this.$route.query };
  1029. console.log(query, 'query');
  1030. if (!query.producedList || query.producedList.length == 0) {
  1031. this.producedList = [
  1032. { code: 2, name: 'MBOM' },
  1033. { code: 3, name: 'ABOM' }
  1034. ];
  1035. return;
  1036. }
  1037. const producedList = JSON.parse(this.$route.query.producedList);
  1038. this.producedList = producedList;
  1039. },
  1040. // 初始化时间赋值
  1041. initTime() {
  1042. let data = { ...this.$route.query };
  1043. if (data.startTime) {
  1044. this.$set(this.form, 'startTime', data.startTime);
  1045. }
  1046. if (data.endTime) {
  1047. this.$set(this.form, 'endTime', data.endTime);
  1048. }
  1049. },
  1050. // 是否必填
  1051. mandatoryField() {
  1052. parameterGetByCode({
  1053. code: 'production_plan_code'
  1054. }).then((res) => {
  1055. if (res) {
  1056. this.processingRequired = res.value;
  1057. }
  1058. });
  1059. },
  1060. // 查询库存数量
  1061. inventory(id) {},
  1062. // 验证时间是否超期
  1063. changeDate(item, i) {
  1064. if (this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime)) {
  1065. this.$message.error('客户期望交期大于了要求完成日期');
  1066. }
  1067. },
  1068. isTimeAGreaterThanB(timeA, timeB) {
  1069. return new Date(timeA) > new Date(timeB);
  1070. },
  1071. async getFactoryList() {
  1072. this.factoryList = await getFactoryList();
  1073. this.$nextTick(() => {
  1074. this.form.factoriesId = this.factoryList[0].id;
  1075. });
  1076. },
  1077. async getPlanInfo(id) {
  1078. const data = await getUpdateInfoById(id);
  1079. console.log(data, '订单的data');
  1080. console.log(11111111111111111111111111111);
  1081. this.form = data;
  1082. this.initTime();
  1083. // if (data.startTime) {
  1084. // this.form.startTime = new Date(data.startTime);
  1085. // }
  1086. // if (data.endTime) {
  1087. // this.form.endTime = new Date(data.endTime);
  1088. // }
  1089. if (!data.bomCategoryId || data.bomCategoryId == null) {
  1090. this.form.produceType = '';
  1091. this.selectionRowShow = true;
  1092. } else {
  1093. this.selectionRowShow = false;
  1094. }
  1095. if (data.salesOrders && data.salesOrders.length > 0) {
  1096. this.form.factoriesId = data.salesOrders[0].factoriesId;
  1097. }
  1098. // this.form.factoriesId = data.salesOrders
  1099. // ? data.salesOrders[0].factoriesId
  1100. // : '';
  1101. if (this.clientEnvironmentId != 4) {
  1102. this.bomListVersion();
  1103. // this.getPlanRouting();
  1104. }
  1105. this._getInventory();
  1106. },
  1107. async _getInventory() {
  1108. let code = [this.form.productCode];
  1109. const res = await getInventoryTotalAPI(code);
  1110. this.form.stockCountBase = res[0].stockCountBase;
  1111. },
  1112. getByCodeFn() {
  1113. console.log('78910');
  1114. getByCode('margin_code').then((res) => {
  1115. let _arr = [];
  1116. res.data.map((item) => {
  1117. const key = Object.keys(item)[0];
  1118. const value = item[key];
  1119. _arr.push({ name: key, value: value });
  1120. });
  1121. this.marginList = _arr;
  1122. });
  1123. },
  1124. getPlanRouting() {
  1125. if (this.form.bomCategoryId && this.form.bomCategoryId != 'null') {
  1126. bomRoutingList(this.form.bomCategoryId).then((res) => {
  1127. this.routingList = res || [];
  1128. if (res.length) {
  1129. let id = this.$route.query.produceRoutingId
  1130. ? this.$route.query.produceRoutingId
  1131. : res[0].id;
  1132. this.$nextTick(() => {
  1133. let arr = this.routingList.filter((item) => {
  1134. return item.id == id;
  1135. });
  1136. if (arr.length > 0) {
  1137. this.$set(this.form, 'produceRoutingId', id);
  1138. }
  1139. });
  1140. }
  1141. });
  1142. }
  1143. },
  1144. bomListVersion(type) {
  1145. console.log(type, 'type 传递的参数 33');
  1146. let categoryId = '';
  1147. if (this.form.salesOrders.length) {
  1148. categoryId = this.form.salesOrders[0].categoryId;
  1149. } else if (this.form.categoryId) {
  1150. categoryId = this.form.categoryId;
  1151. } else {
  1152. new Error('缺少产品信息');
  1153. }
  1154. let param = {
  1155. bomType: this.form.produceType || null,
  1156. categoryId: categoryId
  1157. };
  1158. console.log(param, 'param');
  1159. bomListByPlan(param).then((res) => {
  1160. console.log(res, 'res 查出来没');
  1161. this.bomVersionList = res || [];
  1162. if (res.length) {
  1163. let o = res[0];
  1164. if (type == 'init') {
  1165. let query = { ...this.$route.query };
  1166. let id = query.bomCategoryId ? query.bomCategoryId : o.id;
  1167. this.$set(this.form, 'bomCategoryId', id);
  1168. } else {
  1169. this.$set(this.form, 'bomCategoryId', o.id);
  1170. }
  1171. this.changeBomId();
  1172. }
  1173. });
  1174. },
  1175. changeProduceType(type) {
  1176. console.log('111111111111111111111111');
  1177. if (this.clientEnvironmentId == 4) {
  1178. return false;
  1179. }
  1180. this.form.bomCategoryId = null;
  1181. this.form['bomCategoryName'] = '';
  1182. this.form['bomCategoryVersions'] = '';
  1183. this.bomVersionList = [];
  1184. this.routingList = [];
  1185. this.form.produceRoutingId = '';
  1186. this.form.produceRoutingName = '';
  1187. this.form.produceVersionName = '';
  1188. this.selectionRowShow = false; // ****
  1189. if (type == 'init') {
  1190. let queryD = { ...this.$route.query };
  1191. if (queryD.produceRoutingId && !queryD.bomCategoryId) {
  1192. this.form.produceRoutingName = queryD.produceRoutingName;
  1193. this.form.produceRoutingId = queryD.produceRoutingId;
  1194. this.selectionRowShow = true;
  1195. }
  1196. }
  1197. this.bomListVersion(type);
  1198. },
  1199. changeBomId() {
  1200. this.routingList = [];
  1201. this.form.produceRoutingId = '';
  1202. this.form.produceRoutingName = '';
  1203. this.form.produceVersionName = '';
  1204. if (this.bomVersionList.length == 0) {
  1205. this.form.bomCategoryId = '';
  1206. }
  1207. this.bomVersionList.forEach((f) => {
  1208. if (f.id == this.form.bomCategoryId) {
  1209. this.$set(this.form, 'bomCategoryName', f.name);
  1210. this.$set(this.form, 'bomCategoryVersions', f.versions);
  1211. }
  1212. });
  1213. this.getPlanRouting();
  1214. },
  1215. changeRoute() {
  1216. this.$forceUpdate();
  1217. this.routingList.forEach((f) => {
  1218. if (f.id == this.form.produceRoutingId) {
  1219. this.$set(this.form, 'produceRoutingName', f.name);
  1220. this.$set(this.form, 'produceVersionName', f.version);
  1221. }
  1222. });
  1223. },
  1224. getSaleInfo() {
  1225. let params = JSON.parse(this.$route.query.selection);
  1226. productionToPlan(params).then((res) => {
  1227. this.form = deepClone(res);
  1228. console.log(222222222222222222222222, '===');
  1229. this.initTime();
  1230. // this.bomListVersion('init');
  1231. this.form.produceRoutingName =
  1232. res.produceRoutingName || this.$route.query.produceRoutingName;
  1233. this.form.produceRoutingId =
  1234. res.produceRoutingId || this.$route.query.produceRoutingId;
  1235. if (
  1236. !this.form.factoriesId &&
  1237. (res.produceRoutingId || this.$route.query.produceRoutingId)
  1238. ) {
  1239. this.form.factoriesId =
  1240. res.factoriesId || this.$route.query.factoriesId;
  1241. }
  1242. // this.form.produceType =
  1243. // res.produceType || this.$route.query.produceType
  1244. // ? parseInt(this.$route.query.produceType)
  1245. // : null;
  1246. this.form.produceType = this.$route.query.produceType
  1247. ? parseInt(this.$route.query.produceType)
  1248. : res.produceType;
  1249. console.log('this.form', this.form, res);
  1250. this.changeProduceType('init');
  1251. this.form.bomCategoryId =
  1252. res.bomCategoryId || this.$route.query.bomCategoryId;
  1253. // this.changeBomId();
  1254. if (this.clientEnvironmentId == '4') {
  1255. if (this.form.salesOrders[0].productName.includes('板材')) {
  1256. this.changeProduct({
  1257. id: '1856970794952372226',
  1258. name: '板材',
  1259. produceVersionName: '板材'
  1260. });
  1261. } else {
  1262. this.changeProduct({
  1263. id: '1857313733642596353',
  1264. name: '砌块',
  1265. produceVersionName: '砌块'
  1266. });
  1267. }
  1268. }
  1269. this.form.salesOrders.map((item, index) => {
  1270. if (this.clientEnvironmentId == '4') {
  1271. this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
  1272. } else {
  1273. item.planProductNum = item.lackNum;
  1274. item.requiredFormingNum = item.lackNum;
  1275. }
  1276. item.slottingType = item.slottingType && item.slottingType + '';
  1277. item.priority = index + 1;
  1278. item.reqMoldTime = item.deliveryTime;
  1279. if (item.colorKey && typeof item.colorKey == 'string') {
  1280. this.$set(
  1281. this.form.salesOrders[index],
  1282. 'colorKey',
  1283. item.colorKey.split(',')
  1284. );
  1285. }
  1286. if (item.modelKey && typeof item.modelKey == 'string') {
  1287. this.$set(
  1288. this.form.salesOrders[index],
  1289. 'modelKey',
  1290. item.modelKey.split(',')
  1291. );
  1292. }
  1293. // dayjs(
  1294. // new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
  1295. // ).format('YYYY-MM-DD');
  1296. });
  1297. if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
  1298. this.form.planType = 2;
  1299. } else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
  1300. this.form.planType = 1;
  1301. } else {
  1302. this.form.planType = 3;
  1303. }
  1304. this._getInventory();
  1305. });
  1306. this.$forceUpdate();
  1307. },
  1308. itemChange() {
  1309. this.form.salesOrders.map((item, index) => {
  1310. this.$set(
  1311. item,
  1312. 'requiredFormingNum',
  1313. item.planProductNum * (this.form.marginCoefficient || 1)
  1314. );
  1315. });
  1316. },
  1317. factoriesIdFn(e) {
  1318. this.$forceUpdate();
  1319. },
  1320. toInt(planProductNum) {
  1321. return planProductNum * (this.form.marginCoefficient || 1);
  1322. },
  1323. cancel() {
  1324. const key = getRouteTabKey();
  1325. // this.$router.go(-1);
  1326. removePageTab({ key });
  1327. this.$emit('cancel');
  1328. },
  1329. toSubmit() {
  1330. if (!this.form.factoriesId) {
  1331. return this.$message.warning('请选择所属工厂');
  1332. }
  1333. this.form.salesOrders.map((v) => {
  1334. let arrTime = v.deliveryTime && v.deliveryTime.split(' ');
  1335. let arrTimeTow =
  1336. v.produceDeliveryDeadline && v.produceDeliveryDeadline.split(' ');
  1337. v.deliveryTime = arrTime && arrTime[0];
  1338. v.produceDeliveryDeadline = arrTimeTow && arrTimeTow[0];
  1339. // if(v.salesOrders)
  1340. });
  1341. if (this.form.produceType) {
  1342. //查询生产类型
  1343. this.form.produceVersionName = this.producedList.find(
  1344. (v) => v.code == this.form.produceType
  1345. )?.name;
  1346. }
  1347. if (this.form.produceRoutingId && !this.form.produceRoutingName) {
  1348. //查询工艺路线
  1349. this.form.produceRoutingName = this.routingList.find(
  1350. (v) => v.id == this.form.produceRoutingId
  1351. ).name;
  1352. }
  1353. if (this.form.factoriesId) {
  1354. //查询工厂名称
  1355. this.form.factoriesIdName = this.factoryList.find(
  1356. (v) => v.id == this.form.factoriesId
  1357. )?.name;
  1358. }
  1359. // let data = this.form.salesOrders[0];
  1360. if (this.form.salesOrders.length > 1) {
  1361. //多条订单时,拼接批次号(订单数量)
  1362. let arr = [];
  1363. this.form.salesOrders.map((v) => {
  1364. if (v.batchNo) {
  1365. arr.push(v.batchNo);
  1366. }
  1367. });
  1368. this.form.batchNo = arr.toString();
  1369. } else {
  1370. // ((data.productSumWeight /contractNum) * data.planProductNum).toFixed(2);
  1371. this.form.batchNo = this.form.salesOrders[0].batchNo;
  1372. }
  1373. let newSumOrderWeight = 0;
  1374. this.form.salesOrders &&
  1375. this.form.salesOrders.map((el) => {
  1376. let total = (
  1377. (el.productSumWeight / el.contractNum) *
  1378. el.planProductNum
  1379. ).toFixed(2);
  1380. newSumOrderWeight = newSumOrderWeight + (total - 0);
  1381. });
  1382. this.form.newSumOrderWeight = newSumOrderWeight;
  1383. let flag = this.parameterVerification();
  1384. // 必填参数校验
  1385. if (!flag) return;
  1386. this.$refs.form.validate((valid) => {
  1387. if (valid) {
  1388. this.mapList();
  1389. this.$refs.submitRefs.open();
  1390. }
  1391. });
  1392. },
  1393. // 参数校验
  1394. parameterVerification() {
  1395. let flag = true;
  1396. if (!this.form.startTime) {
  1397. this.$message.warning('请选择计划开始时间');
  1398. return false;
  1399. }
  1400. if (!this.form.endTime) {
  1401. this.$message.warning('请选择计划结束时间');
  1402. return false;
  1403. }
  1404. if (this.isRequired) {
  1405. if (!this.form.produceType) {
  1406. flag = false;
  1407. this.$message.warning('请选择生产类型');
  1408. return;
  1409. }
  1410. if (!this.form.bomCategoryId) {
  1411. flag = false;
  1412. this.$message.warning('请选择BOM版本');
  1413. return;
  1414. }
  1415. }
  1416. if (!this.form.produceRoutingId) {
  1417. flag = false;
  1418. this.$message.warning('请选择工艺路线');
  1419. return;
  1420. }
  1421. if (!this.form.salesOrders[0]?.reqMoldTime) {
  1422. flag = false;
  1423. this.$message.warning('请选择要求完成日期');
  1424. return;
  1425. }
  1426. return flag;
  1427. },
  1428. // 对比日期,计算要求生产重量
  1429. mapList() {
  1430. var _sumOrderWeight = 0;
  1431. var requiredFormingNum = 0;
  1432. var productNum = 0;
  1433. this.form.salesOrders.map((item, index) => {
  1434. requiredFormingNum =
  1435. Number(requiredFormingNum) + Number(item.requiredFormingNum);
  1436. if (
  1437. this.form.weightUnit == 'G' ||
  1438. this.form.weightUnit == 'g' ||
  1439. this.form.weightUnit == '克'
  1440. ) {
  1441. this.form.newWeightUnit = 'KG';
  1442. _sumOrderWeight = this.form.newSumOrderWeight / 1000;
  1443. // _sumOrderWeight =
  1444. // (this.form.salesOrders[0].requiredFormingNum *
  1445. // Number(this.form.salesOrders[0].productUnitWeight || 1)) /
  1446. // 1000;
  1447. } else {
  1448. this.form.newWeightUnit = this.form.weightUnit;
  1449. _sumOrderWeight = this.form.newSumOrderWeight;
  1450. // _sumOrderWeight =
  1451. // this.form.salesOrders[0].requiredFormingNum *
  1452. // Number(this.form.salesOrders[0].productUnitWeight || 1);
  1453. }
  1454. productNum += Number(item.planProductNum);
  1455. });
  1456. this.form.productNum = productNum;
  1457. this.form.productUnitWeight =
  1458. this.form.salesOrders[0]?.productUnitWeight;
  1459. this.form.newSumOrderWeight = _sumOrderWeight.toFixed(2);
  1460. this.form.requiredFormingNum = requiredFormingNum;
  1461. const collection = deepClone(this.form.salesOrders);
  1462. const sortedCollection = collection.sort(
  1463. (a, b) => new Date(b.reqMoldTime) - new Date(a.reqMoldTime)
  1464. );
  1465. let latestData = {};
  1466. for (let i = 0; i < sortedCollection.length; i++) {
  1467. const data = sortedCollection[i];
  1468. if (
  1469. !latestData.reqMoldTime ||
  1470. new Date(data.reqMoldTime) >= new Date(latestData.reqMoldTime)
  1471. ) {
  1472. latestData = data;
  1473. }
  1474. }
  1475. this.form.reqMoldTime = latestData.reqMoldTime;
  1476. },
  1477. sortTop(row) {
  1478. row.priority = Number(row.priority) + 1;
  1479. this.priorityChange(row);
  1480. },
  1481. sortBottom(row) {
  1482. if (row.priority <= 1) {
  1483. return;
  1484. }
  1485. row.priority = Number(row.priority) - 1;
  1486. this.priorityChange(row);
  1487. },
  1488. priorityChange(row) {
  1489. if (row.priority > 10) {
  1490. row.priority = 10; // 如果大于 10,则设置为 10
  1491. } else if (row.priority < 0) {
  1492. row.priority = 0; // 如果小于 0,则设置为 0
  1493. }
  1494. this.priorityFn(row);
  1495. },
  1496. priorityFn: debounce(function (row) {}, 800),
  1497. // 删除产品
  1498. handleDeleteItem(index) {
  1499. this.form.salesOrders.splice(index, 1);
  1500. this.changeData();
  1501. },
  1502. addEquipment() {
  1503. let query = { ...this.$route.query };
  1504. let orderType = query.orderType;
  1505. let arr = this.form.salesOrders;
  1506. if (arr && arr.length > 0) {
  1507. if (!orderType && orderType !== '0') {
  1508. orderType = arr[0].orderType;
  1509. }
  1510. }
  1511. this.$refs.additionalRefs.open(orderType);
  1512. },
  1513. openVersion() {
  1514. this.$refs.versionRefs.open();
  1515. },
  1516. changeProduct(data) {
  1517. this.$set(this.form, 'produceRoutingName', data.name);
  1518. this.$set(this.form, 'produceRoutingId', data.id);
  1519. this.$set(this.form, 'produceVersionName', data.produceVersionName);
  1520. },
  1521. // 表格:模数、数量(方)、块数输入框 输入事件
  1522. tableHandleKeyUp(row, index, e, name) {
  1523. if (row.specification && this.clientEnvironmentId == '4') {
  1524. let modelArr = row.specification.split('*');
  1525. let modelLong = modelArr[0]; // model规格长度
  1526. let modeWide = modelArr[1]; // model规格宽度
  1527. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1528. modeHight = Number(modeHight);
  1529. if (name === 'moCount') {
  1530. // 模数
  1531. row.moCount = e;
  1532. // 计算块数的公式:
  1533. // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
  1534. // 每一模的块数*模数moCount = 总块数
  1535. if (row.productName.includes('板材')) {
  1536. row.blockCount =
  1537. Math.floor(600 / modelLong) *
  1538. Math.floor(120 / modeHight) *
  1539. Math.floor(60 / modeWide) *
  1540. row.moCount;
  1541. } else if (row.productName.includes('砌块')) {
  1542. let modelLongFixed = (600 / modelLong).toFixed(2);
  1543. modelLongFixed = modelLongFixed.substring(
  1544. 0,
  1545. modelLongFixed.length - 1
  1546. );
  1547. let modeWideFixed = (120 / modeWide).toFixed(2);
  1548. modeWideFixed = modeWideFixed.substring(
  1549. 0,
  1550. modeWideFixed.length - 1
  1551. );
  1552. let modeHightFixed = (60 / modeHight).toFixed(2);
  1553. modeHightFixed = modeHightFixed.substring(
  1554. 0,
  1555. modeHightFixed.length - 1
  1556. );
  1557. row.blockCount =
  1558. Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
  1559. row.moCount;
  1560. }
  1561. row.planProductNum =
  1562. Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
  1563. row.blockCount;
  1564. } else if (name === 'sum') {
  1565. //方数
  1566. row.planProductNum = e;
  1567. row.blockCount = Math.floor(
  1568. e / ((modelLong * modeWide * modeHight) / 1000000)
  1569. );
  1570. if (row.productName.includes('板材')) {
  1571. row.moCount = Math.ceil(
  1572. row.blockCount /
  1573. (Math.floor(600 / modelLong) *
  1574. Math.floor(120 / modeHight) *
  1575. Math.floor(60 / modeWide))
  1576. );
  1577. } else if (row.productName.includes('砌块')) {
  1578. row.moCount = Math.ceil(
  1579. row.blockCount /
  1580. Math.floor(
  1581. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1582. )
  1583. );
  1584. }
  1585. } else if (name === 'blockCount') {
  1586. //块数
  1587. row.blockCount = e;
  1588. if (row.productName.includes('板材')) {
  1589. row.moCount = Math.ceil(
  1590. row.blockCount /
  1591. (Math.floor(600 / modelLong) *
  1592. Math.floor(120 / modeHight) *
  1593. Math.floor(60 / modeWide))
  1594. );
  1595. } else if (row.productName.includes('砌块')) {
  1596. row.moCount = Math.ceil(
  1597. row.blockCount /
  1598. Math.floor(
  1599. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1600. )
  1601. );
  1602. }
  1603. row.planProductNum =
  1604. (Number(e) * modelLong * modeWide * modeHight) / 1000000;
  1605. }
  1606. }
  1607. row.requiredFormingNum = Number(
  1608. row.planProductNum * (this.form.marginCoefficient || 1)
  1609. ).toFixed(0);
  1610. },
  1611. confirmChoose(list) {
  1612. // 取出在弹窗中选中并且不在表格中的数据
  1613. const result = list.filter(
  1614. (i) => this.form.salesOrders.findIndex((p) => p.id === i.id) === -1
  1615. );
  1616. // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
  1617. const del = this.form.salesOrders.filter(
  1618. (i) => list.findIndex((p) => p.id === i.id) === -1
  1619. );
  1620. for (let i = this.form.salesOrders.length - 1; i >= 0; i--) {
  1621. for (let j in del) {
  1622. if (this.form.salesOrders[i].id === del[j].id) {
  1623. this.form.salesOrders.splice(i, 1);
  1624. }
  1625. }
  1626. }
  1627. let priority =
  1628. this.form.salesOrders[this.form.salesOrders.length - 1]?.priority ||
  1629. 0;
  1630. this.form.salesOrders = this.form.salesOrders.concat(
  1631. result.map((item, index) => {
  1632. item.priority = ++priority;
  1633. item.planProductNum = item.lackNum;
  1634. item.requiredFormingNum = item.lackNum;
  1635. item.reqMoldTime = dayjs(
  1636. new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
  1637. ).format('YYYY-MM-DD');
  1638. return item;
  1639. })
  1640. );
  1641. this.changeData();
  1642. },
  1643. changeData() {
  1644. var planProductNum = 0;
  1645. var productWeight = 0;
  1646. this.form.salesOrders.map((item, index) => {
  1647. item.priority = index + 1;
  1648. planProductNum = planProductNum + item.requiredFormingNum;
  1649. productWeight = productWeight + Number(item.productSumWeight);
  1650. });
  1651. this.$set(this.form, 'codeNum', this.form.salesOrders.length);
  1652. this.$set(this.form, 'contractNum', planProductNum);
  1653. this.$set(this.form, 'sumOrderWeight', productWeight.toFixed(2));
  1654. },
  1655. async publishData(type) {
  1656. if (!this.form.batchNo && this.clientEnvironmentId == 5) {
  1657. this.$message.warning('批次号不能为空');
  1658. return;
  1659. }
  1660. const key = getRouteTabKey();
  1661. let params = deepClone(this.form);
  1662. params.categoryId = params.salesOrders[0]?.categoryId;
  1663. if (this.$route.query.type != 'edit') {
  1664. delete params.id;
  1665. }
  1666. console.log(params, 'params');
  1667. params.salesOrders.forEach((item) => {
  1668. item.colorKey = item.colorKey.toString();
  1669. item.modelKey = item.modelKey.toString();
  1670. });
  1671. if (type === 2) {
  1672. const titleText = this.isReview
  1673. ? '是否发起流程'
  1674. : '发布工单后不可撤回,确定发布吗?';
  1675. const title = this.isReview ? '流程确认' : '发布确认';
  1676. const text = this.isReview ? '流程发布中...' : '工单发布中...';
  1677. this.$confirm(titleText, title).then(async () => {
  1678. const loading = this.$loading({
  1679. lock: true,
  1680. fullscreen: true,
  1681. text
  1682. });
  1683. try {
  1684. const code = await getCode('product_order_code');
  1685. const data = {
  1686. productionPlan: params,
  1687. workOrder: {
  1688. productionPlanCode: params.code,
  1689. code: code,
  1690. // formingNum: params.contractNum,
  1691. formingNum: this.form.requiredFormingNum,
  1692. formingWeight: params.sumOrderWeight,
  1693. produceRoutingId: params.produceRoutingId,
  1694. status: 4,
  1695. model: params.model,
  1696. brandNo: params.brandNo,
  1697. categoryId: params.categoryId,
  1698. productCode: params.productCode,
  1699. productName: params.productName,
  1700. newWeightUnit: this.form.newWeightUnit,
  1701. newSumOrderWeight: this.form.newSumOrderWeight
  1702. }
  1703. };
  1704. if (this.$route.query.type == 'edit') {
  1705. data.workOrder.productionPlanId = params.id;
  1706. }
  1707. const URL = this.isReview ? planIsReview : releaseSave;
  1708. await URL(data)
  1709. // await releaseSave(data)
  1710. .then((res) => {
  1711. if (res === 1) {
  1712. if (this.isReview) {
  1713. this.$message.success('流程已发布!');
  1714. this.$router.push({
  1715. path: '/productionPlan'
  1716. });
  1717. } else {
  1718. this.$message.success('工单已发布!');
  1719. this.$router.push({
  1720. path: '/workOrder'
  1721. });
  1722. }
  1723. } else {
  1724. if (this.isReview) {
  1725. this.$message.success('流程已发布!');
  1726. this.$router.push({
  1727. path: '/productionPlan'
  1728. });
  1729. } else {
  1730. this.$confirm(
  1731. '生产计划创建成功,但工单发布失败。请前往【生产计划】列表【重新发布】工单',
  1732. '提示',
  1733. {
  1734. confirmButtonText: '返回',
  1735. cancelButtonText: '立即前往',
  1736. type: 'warning'
  1737. }
  1738. )
  1739. .then(() => {
  1740. this.$router.push({
  1741. path: '/productionPlan'
  1742. });
  1743. })
  1744. .catch(() => {
  1745. this.$router.go(-1);
  1746. });
  1747. }
  1748. }
  1749. removePageTab({ key });
  1750. })
  1751. .catch(() => {
  1752. this.$message.error('发布失败,请重新发布!');
  1753. });
  1754. } catch (error) {
  1755. this.$message.error(error.message || '发布失败,请重新发布!');
  1756. }
  1757. loading.close();
  1758. });
  1759. } else {
  1760. let request =
  1761. this.$route.query.type == 'edit'
  1762. ? updateSaleToPlan
  1763. : saveSaleToPlan;
  1764. request(params)
  1765. .then(async (res) => {
  1766. // 提交
  1767. this.$router.push({
  1768. path: '/productionPlan'
  1769. });
  1770. removePageTab({ key });
  1771. })
  1772. .catch(() => {
  1773. this.$message.error('提交失败,请重新提交!');
  1774. });
  1775. }
  1776. },
  1777. // 打开工艺路线
  1778. openDialog() {
  1779. // this.selectIndex = index;
  1780. this.$refs.processRouteRef.open();
  1781. },
  1782. // 选择工艺路线
  1783. changeParent(item) {
  1784. this.routingList = [];
  1785. this.bomVersionList = [];
  1786. this.$set(this.form, 'bomCategoryId', null);
  1787. this.$set(this.form, 'model', '');
  1788. this.$set(this.form, 'produceType', '');
  1789. this.$set(this.form, 'produceRoutingName', item.name);
  1790. this.$set(this.form, 'produceRoutingId', item.id);
  1791. this.form.bomCategoryName = '';
  1792. this.form.bomCategoryVersions = '';
  1793. this.selectionRowShow = true;
  1794. },
  1795. // 【开始时间变化时】触发
  1796. handleStartTimeChange(row) {
  1797. this.checkEndTimeValid(row);
  1798. },
  1799. // 【结束时间变化时】触发
  1800. handleEndTimeChange(row) {
  1801. this.checkEndTimeValid(row);
  1802. },
  1803. checkEndTimeValid(row) {
  1804. const { startTime: start, endTime: end } = row;
  1805. if (!start || !end) return; // 开始/结束时间未填,跳过
  1806. const startTime = new Date(start);
  1807. const endTime = new Date(end);
  1808. if (endTime < startTime) {
  1809. row.endTime = new Date(startTime); // 修正为开始时间
  1810. this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
  1811. }
  1812. }
  1813. }
  1814. };
  1815. </script>
  1816. <style lang="scss" scoped>
  1817. .ele-body {
  1818. background: #fff;
  1819. }
  1820. .body-title {
  1821. width: 100%;
  1822. display: flex;
  1823. align-items: center;
  1824. justify-content: space-between;
  1825. }
  1826. .title-left {
  1827. font-size: 20px;
  1828. color: #333;
  1829. }
  1830. .formbox {
  1831. margin: 20px auto;
  1832. }
  1833. .row-intro {
  1834. border-bottom: 1px dashed #ccc;
  1835. margin-bottom: 20px;
  1836. }
  1837. .add-product {
  1838. width: 100%;
  1839. display: flex;
  1840. align-items: center;
  1841. justify-content: flex-end;
  1842. font-size: 30px;
  1843. color: #1890ff;
  1844. margin: 10px 0;
  1845. cursor: pointer;
  1846. }
  1847. .table-item {
  1848. margin-bottom: 0;
  1849. }
  1850. .header_required {
  1851. position: relative;
  1852. }
  1853. .header_required:before {
  1854. content: '*';
  1855. color: #f56c6c;
  1856. position: absolute;
  1857. top: 11px;
  1858. left: 26px;
  1859. }
  1860. .header_time_required {
  1861. position: relative;
  1862. }
  1863. .header_time_required:before {
  1864. content: '*';
  1865. color: #f56c6c;
  1866. position: absolute;
  1867. top: 11px;
  1868. left: 2px;
  1869. }
  1870. ::v-deep .product_info {
  1871. .el-form-item--medium {
  1872. .el-form-item__label {
  1873. line-height: 26px;
  1874. }
  1875. .el-form-item__content {
  1876. line-height: 26px;
  1877. }
  1878. }
  1879. .product_code_name {
  1880. .el-form-item__content {
  1881. white-space: normal;
  1882. word-break: break-all;
  1883. }
  1884. }
  1885. }
  1886. </style>