salesToProductionNewTwo.vue 72 KB

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