salesToProductionNewTwo.vue 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686
  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="生产类型:"
  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="所属工厂:">
  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">
  247. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  248. <el-form-item label="销售单数量:">{{ form.codeNum }}</el-form-item>
  249. </el-col>
  250. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  251. <el-form-item label="订单总数量:">{{
  252. form.contractNum
  253. }}</el-form-item>
  254. </el-col>
  255. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 4 }">
  256. <el-form-item label="订单总重量:">{{
  257. form.sumOrderWeight
  258. }}</el-form-item>
  259. </el-col>
  260. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  261. <el-form-item label="产品编码:">{{
  262. form.productCode
  263. }}</el-form-item>
  264. </el-col>
  265. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  266. <el-form-item label="牌号:">{{ form.brandNo }}</el-form-item>
  267. </el-col>
  268. <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 5 }">
  269. <el-form-item label="型号:">{{ form.model }}</el-form-item>
  270. </el-col>
  271. <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 3 }">
  272. <el-form-item label="规格:">{{ form.specification }}</el-form-item>
  273. </el-col>
  274. <!-- <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  275. <el-form-item label="库存数量:">{{
  276. form.stockCountBase
  277. }}</el-form-item>
  278. </el-col> -->
  279. </el-row>
  280. <el-table :data="form.salesOrders" border>
  281. <el-table-column label="序号" align="center" width="60">
  282. <template slot-scope="scope">
  283. <span>{{ scope.$index + 1 }}</span>
  284. </template>
  285. </el-table-column>
  286. <el-table-column
  287. label="销售订单号"
  288. align="center"
  289. prop="code"
  290. width="120"
  291. sortable
  292. >
  293. </el-table-column>
  294. <el-table-column
  295. label="产品名称"
  296. align="center"
  297. prop="productName"
  298. width="120"
  299. >
  300. </el-table-column>
  301. <el-table-column label="行号" align="center" prop="lineNumber">
  302. </el-table-column>
  303. <el-table-column
  304. :label="'订单数量' + (clientEnvironmentId == '4' ? '(方)' : '')"
  305. align="center"
  306. prop="contractNum"
  307. width="120"
  308. >
  309. <template slot-scope="scope">
  310. {{ scope.row.contractNum }} {{ scope.row.measuringUnit }}
  311. </template>
  312. </el-table-column>
  313. <el-table-column
  314. label="订单重量"
  315. align="center"
  316. prop="productSumWeight"
  317. width="120"
  318. >
  319. <template slot-scope="scope">
  320. {{ scope.row.productSumWeight }} {{ form.weightUnit }}
  321. </template>
  322. </el-table-column>
  323. <el-table-column label="规格" align="center" prop="specification">
  324. </el-table-column>
  325. <el-table-column
  326. label="生产编号"
  327. align="center"
  328. prop="productionCodes"
  329. >
  330. </el-table-column>
  331. <el-table-column
  332. :label="'欠交数量' + (clientEnvironmentId == '4' ? '(方)' : '')"
  333. align="center"
  334. prop="lackNum"
  335. >
  336. </el-table-column>
  337. <el-table-column label="批次号" align="center" prop="batchNo">
  338. </el-table-column>
  339. <el-table-column
  340. :label="'计划生产数量' + (clientEnvironmentId == '4' ? '(方)' : '')"
  341. align="center"
  342. prop="planProductNum"
  343. width="140"
  344. >
  345. <template slot-scope="scope">
  346. <el-form-item
  347. label-width="0px"
  348. :prop="'salesOrders.' + scope.$index + '.planProductNum'"
  349. :rules="{
  350. required: true,
  351. message: '请输入计划生产数量',
  352. trigger: 'blur'
  353. }"
  354. class="table-item"
  355. >
  356. <el-input
  357. v-model.number="scope.row.planProductNum"
  358. size="small"
  359. type="number"
  360. style="width: 100%"
  361. @input="
  362. tableHandleKeyUp(scope.row, scope.$index, $event, 'sum')
  363. "
  364. placeholder="输入数量"
  365. ></el-input>
  366. </el-form-item>
  367. </template>
  368. </el-table-column>
  369. <el-table-column
  370. :label="'要求生产数量' + (clientEnvironmentId == '4' ? '(方)' : '')"
  371. align="center"
  372. prop="requiredFormingNum"
  373. width="120"
  374. >
  375. <template slot-scope="scope">
  376. <el-form-item
  377. label-width="0px"
  378. :prop="'salesOrders.' + scope.$index + '.requiredFormingNum'"
  379. :rules="{
  380. required: true,
  381. message: '请输入要求生产数量',
  382. trigger: 'blur'
  383. }"
  384. class="table-item"
  385. >
  386. <el-input
  387. v-model.number="scope.row.requiredFormingNum"
  388. size="small"
  389. disabled
  390. oninput="value=value.replace(/[^\d]/g,'')"
  391. style="width: 100%"
  392. placeholder="输入数量"
  393. ></el-input>
  394. </el-form-item>
  395. </template>
  396. </el-table-column>
  397. <el-table-column
  398. label="模数"
  399. align="center"
  400. width="100"
  401. v-if="clientEnvironmentId == '4'"
  402. >
  403. <template slot-scope="scope">
  404. <div>
  405. <el-input
  406. style="width: 100%"
  407. size="small"
  408. v-model="scope.row.moCount"
  409. oninput="value=value.replace(/[^0-9.]/g,'')"
  410. @input="
  411. tableHandleKeyUp(scope.row, scope.$index, $event, 'moCount')
  412. "
  413. placeholder="请输入"
  414. >
  415. </el-input>
  416. </div>
  417. </template>
  418. </el-table-column>
  419. <el-table-column
  420. align="center"
  421. width="100"
  422. v-if="clientEnvironmentId == '4'"
  423. >
  424. <template slot="header">
  425. <span style="color: red">*</span>
  426. <span>块数</span>
  427. </template>
  428. <template slot-scope="scope">
  429. <div>
  430. <el-input
  431. size="small"
  432. style="width: 100%"
  433. oninput="value=value.replace(/[^0-9.]/g,'')"
  434. @input="
  435. tableHandleKeyUp(
  436. scope.row,
  437. scope.$index,
  438. $event,
  439. 'blockCount'
  440. )
  441. "
  442. v-model="scope.row.blockCount"
  443. placeholder="请输入"
  444. ></el-input>
  445. </div>
  446. </template>
  447. </el-table-column>
  448. <el-table-column
  449. label="权重等级"
  450. align="center"
  451. width="120"
  452. v-if="clientEnvironmentId == '4'"
  453. >
  454. <template slot-scope="scope">
  455. <div>
  456. <el-select v-model="scope.row.weight" style="width: 100%">
  457. <el-option
  458. v-for="item of weightList"
  459. :key="item.code"
  460. :label="item.name"
  461. :value="item.code"
  462. ></el-option>
  463. </el-select>
  464. </div>
  465. </template>
  466. </el-table-column>
  467. <el-table-column
  468. align="center"
  469. width="120"
  470. label="是否开槽"
  471. v-if="clientEnvironmentId == '4'"
  472. >
  473. <template slot-scope="scope">
  474. <div>
  475. <el-select
  476. style="width: 100%"
  477. v-model="scope.row.isSlotting"
  478. placeholder="请选择"
  479. >
  480. <el-option
  481. v-for="item of isSlotting"
  482. :key="item.code"
  483. :label="item.name"
  484. :value="item.code"
  485. />
  486. </el-select>
  487. </div>
  488. </template>
  489. </el-table-column>
  490. <el-table-column
  491. align="center"
  492. width="120"
  493. label="开槽类型"
  494. v-if="clientEnvironmentId == '4'"
  495. >
  496. <template slot-scope="scope">
  497. <DictSelection
  498. dictName="开槽类型"
  499. v-model="scope.row.slottingType"
  500. v-if="scope.row.isSlotting == 1"
  501. >
  502. </DictSelection>
  503. </template>
  504. </el-table-column>
  505. <el-table-column
  506. label="按单按库"
  507. align="center"
  508. prop="orderLibraryType"
  509. >
  510. <template slot-scope="{ row }">
  511. {{ getDictValue('按单按库', row.orderLibraryType) }}
  512. </template>
  513. </el-table-column>
  514. <el-table-column label="订单类型" align="center" prop="orderType">
  515. <template slot-scope="{ row }">
  516. {{ getDictValue('订单类型', row.orderType) }}
  517. </template>
  518. </el-table-column>
  519. <el-table-column
  520. label="客户期望交期"
  521. align="center"
  522. prop="deliveryTime"
  523. width="160"
  524. >
  525. <template slot-scope="scope">
  526. <el-form-item
  527. label-width="0px"
  528. :prop="'salesOrders.' + scope.$index + '.deliveryTime'"
  529. :rules="{
  530. required: true,
  531. message: '请选择客户期望交期',
  532. trigger: 'blur'
  533. }"
  534. class="table-item"
  535. >
  536. <el-date-picker
  537. style="width: 100%"
  538. v-model="scope.row.deliveryTime"
  539. @change="changeDate(scope.row, scope.$index)"
  540. :pickerOptions="{
  541. disabledDate: (time) =>
  542. time.getTime() <
  543. new Date(new Date().setHours(0, 0, 0, 0)).getTime()
  544. }"
  545. type="date"
  546. placeholder="选择日期"
  547. value-format="yyyy-MM-dd"
  548. >
  549. </el-date-picker>
  550. </el-form-item>
  551. </template>
  552. </el-table-column>
  553. <el-table-column label="生产交期" align="center" width="160">
  554. <template slot-scope="scope">
  555. <el-form-item
  556. label-width="0px"
  557. :rules="{
  558. required: true,
  559. message: '请选择生产交期',
  560. trigger: 'blur'
  561. }"
  562. class="table-item"
  563. >
  564. <el-date-picker
  565. style="width: 100%"
  566. v-model="scope.row.produceDeliveryDeadline"
  567. @change="changeDate(scope.row, scope.$index)"
  568. :pickerOptions="{
  569. disabledDate: (time) =>
  570. time.getTime() <
  571. new Date(new Date().setHours(0, 0, 0, 0)).getTime()
  572. }"
  573. type="date"
  574. placeholder="选择日期"
  575. value-format="yyyy-MM-dd"
  576. disabled
  577. >
  578. </el-date-picker>
  579. </el-form-item>
  580. </template>
  581. </el-table-column>
  582. <el-table-column
  583. label="要求完成日期"
  584. align="center"
  585. prop="reqMoldTime"
  586. width="180"
  587. >
  588. <template slot-scope="scope">
  589. <el-form-item
  590. label-width="0px"
  591. :prop="'salesOrders.' + scope.$index + '.reqMoldTime'"
  592. :rules="{
  593. required: true,
  594. message: '请选择要求完成日期',
  595. trigger: 'blur'
  596. }"
  597. class="table-item"
  598. >
  599. <el-date-picker
  600. style="width: 100%"
  601. v-model="scope.row.reqMoldTime"
  602. :pickerOptions="{
  603. disabledDate: (time) =>
  604. time.getTime() <
  605. new Date(new Date().setHours(0, 0, 0, 0)).getTime()
  606. }"
  607. type="date"
  608. disabled
  609. placeholder="选择日期"
  610. value-format="yyyy-MM-dd"
  611. >
  612. </el-date-picker>
  613. </el-form-item>
  614. </template>
  615. </el-table-column>
  616. <el-table-column label="客户名称" align="center" prop="customerName">
  617. </el-table-column>
  618. <el-table-column label="业务员" align="center" prop="salesman">
  619. </el-table-column>
  620. <el-table-column
  621. label="交付要求"
  622. align="center"
  623. prop="deliveryRequirements"
  624. >
  625. <template slot-scope="{ row }">
  626. {{ getDictValue('交付要求', row.deliveryRequirements) }}
  627. </template>
  628. </el-table-column>
  629. <el-table-column
  630. prop="priority"
  631. label="优先级"
  632. width="100"
  633. align="center"
  634. >
  635. <template slot-scope="{ row, $index }">
  636. <div style="display: flex">
  637. <el-input
  638. v-if="$index == 0"
  639. v-model="row.priority"
  640. type="number"
  641. size="mini"
  642. :min="0"
  643. :max="10"
  644. @change="priorityChange(row)"
  645. style="width: 80px"
  646. ></el-input>
  647. <el-popover
  648. v-if="$index == 0"
  649. placement="right"
  650. width="200"
  651. trigger="hover"
  652. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  653. >
  654. <div class="sort-wrap" slot="reference">
  655. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  656. <i
  657. class="el-icon-caret-bottom"
  658. @click="sortBottom(row)"
  659. ></i>
  660. </div>
  661. </el-popover>
  662. </div>
  663. </template>
  664. </el-table-column>
  665. <el-table-column label="操作" align="center" width="70" fixed="right">
  666. <template slot-scope="scope">
  667. <el-button
  668. type="text"
  669. @click="handleDeleteItem(scope.$index)"
  670. v-if="type != 'edit'"
  671. >删除</el-button
  672. >
  673. </template>
  674. </el-table-column>
  675. </el-table>
  676. <div class="add-product" @click="addEquipment" v-if="type != 'edit'">
  677. <i class="el-icon-circle-plus-outline"></i>
  678. </div>
  679. <el-row :gutter="24">
  680. <el-col v-bind="styleResponsive ? { lg: 24, md: 24 } : { span: 24 }">
  681. <el-form-item label="计划备注:">
  682. <el-input
  683. type="textarea"
  684. :rows="4"
  685. v-model="form.notes"
  686. resize="none"
  687. ></el-input>
  688. </el-form-item>
  689. </el-col>
  690. </el-row>
  691. </el-form>
  692. <AdditionalOrder
  693. ref="additionalRefs"
  694. :productCode="form.productCode"
  695. :selectList="form.salesOrders"
  696. @choose="confirmChoose"
  697. ></AdditionalOrder>
  698. <ProductionVersion
  699. ref="versionRefs"
  700. @changeProduct="changeProduct"
  701. ></ProductionVersion>
  702. <PlanSubmit
  703. ref="submitRefs"
  704. :type="$route.query.type"
  705. :info="form"
  706. @publish="publishData"
  707. ></PlanSubmit>
  708. <ProcessRoute ref="processRouteRef" @changeParent="changeParent" />
  709. </el-card>
  710. </div>
  711. </template>
  712. <script>
  713. import validDate from '@/utils/date';
  714. import AdditionalOrder from './components/AdditionalOrder.vue';
  715. import PlanSubmit from './components/plan-submit.vue';
  716. import ProductionVersion from '@/components/CreatePlan/ProductionVersion2.vue';
  717. import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
  718. import {
  719. productionToPlan,
  720. saveSaleToPlan,
  721. updateSaleToPlan,
  722. releaseSave,
  723. getInventory,
  724. getUpdateInfoById,
  725. bomRoutingList,
  726. bomListByPlan,
  727. getFactoryList,
  728. getInventoryTotalAPI
  729. } from '@/api/saleOrder';
  730. import { getByCode } from '@/api/system/dictionary-data';
  731. import { parameterGetByCode } from '@/api/mainData/index';
  732. import dictMixins from '@/mixins/dictMixins';
  733. import { deepClone } from '@/utils/index';
  734. import { getRouteTabKey, removePageTab } from '@/utils/page-tab-util';
  735. import { getCode } from '@/api/codeManagement';
  736. import dayjs from 'dayjs';
  737. import { debounce } from 'lodash';
  738. export default {
  739. mixins: [dictMixins],
  740. components: {
  741. AdditionalOrder,
  742. ProductionVersion,
  743. PlanSubmit,
  744. ProcessRoute
  745. },
  746. data() {
  747. return {
  748. type: this.$route.query.type,
  749. weightList: [
  750. { code: 1, name: 'A' },
  751. { code: 2, name: 'B' },
  752. { code: 3, name: 'C' }
  753. ],
  754. isSlotting: [
  755. { code: 1, name: '是' },
  756. { code: 2, name: '否' }
  757. ], //是否开槽
  758. producedList: [
  759. { code: 2, name: '加工(MBOM)' }, //2 待确认
  760. { code: 3, name: '装配(ABOM)' }
  761. ],
  762. form: {
  763. planType: 1,
  764. produceRoutingId: '',
  765. stockCountBase: '',
  766. salesOrders: [],
  767. produceRoutingName: '',
  768. marginCoefficient: '1.0',
  769. batchNo: null,
  770. produceType: '',
  771. bomCategoryId: null,
  772. factoriesId: '',
  773. startTime: '',
  774. endTime: ''
  775. },
  776. marginList: [],
  777. bomVersionList: [],
  778. routingList: [],
  779. factoryList: [],
  780. // 表单验证规则
  781. rules: {
  782. produceRoutingId: [
  783. { required: true, message: '请选择工艺路线', trigger: 'blur' }
  784. ],
  785. // startTime: [
  786. // {
  787. // type: 'date',
  788. // required: true,
  789. // message: '请选择计划开始日期',
  790. // trigger: 'change'
  791. // }
  792. // ],
  793. // endTime: [
  794. // {
  795. // type: 'date',
  796. // required: true,
  797. // message: '请选择计划结束日期',
  798. // trigger: 'change'
  799. // }
  800. // ],
  801. // produceType: [
  802. // { required: true, message: '请选择生产类型', trigger: 'blur' }
  803. // ],
  804. // bomCategoryId: [
  805. // { required: true, message: '请选择BOM版本', trigger: 'blur' }
  806. // ],
  807. factoriesId: [
  808. { required: true, message: '请选择所属工厂', trigger: 'change' }
  809. ]
  810. },
  811. // selection: [],
  812. loading: false,
  813. processingRequired: 0, // 生产类型跟BOM 版本是否必填 1:是 0:否
  814. selectionRowShow: false, // 工艺路线输入框展示 状态
  815. validDate
  816. };
  817. },
  818. props: {
  819. objData: {
  820. type: Object,
  821. default: {}
  822. }
  823. },
  824. watch: {
  825. objData: {
  826. handler(val) {
  827. this.requestDict('按单按库');
  828. this.requestDict('订单类型');
  829. this.requestDict('交付要求');
  830. this.getByCodeFn();
  831. this.getFactoryList();
  832. // 查询库存数量
  833. // this.inventory(val.id);
  834. if (val.type == 'edit') {
  835. this.getPlanInfo(val.id);
  836. } else {
  837. this.getSaleInfo();
  838. }
  839. },
  840. deep: true,
  841. immediate: true
  842. },
  843. 'form.produceType'(newVal, oldVal) {
  844. console.log(newVal, '值');
  845. }
  846. },
  847. mounted() {
  848. this.mandatoryField();
  849. },
  850. computed: {
  851. clientEnvironmentId() {
  852. return this.$store.state.user.info.clientEnvironmentId;
  853. },
  854. // 是否开启响应式布局
  855. styleResponsive() {
  856. return this.$store.state.theme.styleResponsive;
  857. },
  858. // 是否必填字段
  859. isRequired() {
  860. // if (this.form.planType == 5) {
  861. // return false;
  862. // }
  863. return this.processingRequired == 1;
  864. },
  865. // 工艺路线 输入框展示跟选择框判断
  866. isRouteSelect() {
  867. if (this.isRequired) {
  868. return true;
  869. }
  870. if (!this.selectionRowShow) {
  871. return true;
  872. }
  873. return false;
  874. },
  875. // 选择按钮的显示
  876. isSelectShow() {
  877. // if (this.form.planType == 5) {
  878. // return true;
  879. // }
  880. return this.processingRequired == 0;
  881. }
  882. },
  883. methods: {
  884. // 是否必填
  885. mandatoryField() {
  886. parameterGetByCode({
  887. code: 'production_plan_code'
  888. }).then((res) => {
  889. if (res) {
  890. this.processingRequired = res.value;
  891. }
  892. });
  893. },
  894. // 查询库存数量
  895. inventory(id) {},
  896. // 验证时间是否超期
  897. changeDate(item, i) {
  898. if (this.isTimeAGreaterThanB(item.deliveryTime, item.reqMoldTime)) {
  899. this.$message.error('交付时间大于了要求完成日期');
  900. }
  901. },
  902. isTimeAGreaterThanB(timeA, timeB) {
  903. return new Date(timeA) > new Date(timeB);
  904. },
  905. async getFactoryList() {
  906. this.factoryList = await getFactoryList();
  907. this.$nextTick(() => {
  908. this.form.factoriesId = this.factoryList[0].id;
  909. });
  910. },
  911. async getPlanInfo(id) {
  912. const data = await getUpdateInfoById(id);
  913. console.log(data, '订单的data');
  914. this.form = data;
  915. // if (data.startTime) {
  916. // this.form.startTime = new Date(data.startTime);
  917. // }
  918. // if (data.endTime) {
  919. // this.form.endTime = new Date(data.endTime);
  920. // }
  921. if (!data.bomCategoryId || data.bomCategoryId == null) {
  922. this.form.produceType = '';
  923. this.selectionRowShow = true;
  924. } else {
  925. this.selectionRowShow = false;
  926. }
  927. if (data.salesOrders && data.salesOrders.length > 0) {
  928. this.form.factoriesId = data.salesOrders[0].factoriesId;
  929. }
  930. // this.form.factoriesId = data.salesOrders
  931. // ? data.salesOrders[0].factoriesId
  932. // : '';
  933. if (this.clientEnvironmentId != 4) {
  934. this.bomListVersion();
  935. // this.getPlanRouting();
  936. }
  937. this._getInventory();
  938. },
  939. async _getInventory() {
  940. let code = [this.form.productCode];
  941. const res = await getInventoryTotalAPI(code);
  942. console.log(res, '这是库存的数据 ---');
  943. this.form.stockCountBase = res[0].stockCountBase;
  944. },
  945. getByCodeFn() {
  946. getByCode('margin_code').then((res) => {
  947. let _arr = [];
  948. res.data.map((item) => {
  949. const key = Object.keys(item)[0];
  950. const value = item[key];
  951. _arr.push({ name: key, value: value });
  952. });
  953. this.marginList = _arr;
  954. });
  955. },
  956. getPlanRouting() {
  957. if (this.form.bomCategoryId && this.form.bomCategoryId != 'null') {
  958. bomRoutingList(this.form.bomCategoryId).then((res) => {
  959. this.routingList = res || [];
  960. if (res.length) {
  961. let id = this.$route.query.produceRoutingId
  962. ? this.$route.query.produceRoutingId
  963. : res[0].id;
  964. this.$nextTick(() => {
  965. let arr = this.routingList.filter((item) => {
  966. return item.id == id;
  967. });
  968. if (arr.length > 0) {
  969. this.$set(this.form, 'produceRoutingId', id);
  970. }
  971. });
  972. }
  973. });
  974. }
  975. },
  976. bomListVersion() {
  977. let categoryId = '';
  978. if (this.form.salesOrders.length) {
  979. categoryId = this.form.salesOrders[0].categoryId;
  980. } else if (this.form.categoryId) {
  981. categoryId = this.form.categoryId;
  982. } else {
  983. new Error('缺少产品信息');
  984. }
  985. let param = {
  986. bomType: this.form.produceType || null,
  987. categoryId: categoryId
  988. };
  989. bomListByPlan(param).then((res) => {
  990. this.bomVersionList = res || [];
  991. if (res.length) {
  992. let o = res[0];
  993. this.$set(this.form, 'bomCategoryId', o.id);
  994. this.changeBomId();
  995. }
  996. });
  997. },
  998. changeProduceType() {
  999. if (this.clientEnvironmentId == 4) {
  1000. return false;
  1001. }
  1002. this.form.bomCategoryId = null;
  1003. this.form['bomCategoryName'] = '';
  1004. this.form['bomCategoryVersions'] = '';
  1005. this.bomVersionList = [];
  1006. this.routingList = [];
  1007. this.form.produceRoutingId = '';
  1008. this.form.produceRoutingName = '';
  1009. this.form.produceVersionName = '';
  1010. this.selectionRowShow = false; // ****
  1011. this.bomListVersion();
  1012. },
  1013. changeBomId() {
  1014. this.routingList = [];
  1015. this.form.produceRoutingId = '';
  1016. this.form.produceRoutingName = '';
  1017. this.form.produceVersionName = '';
  1018. if (this.bomVersionList.length == 0) {
  1019. this.form.bomCategoryId = '';
  1020. }
  1021. this.bomVersionList.forEach((f) => {
  1022. if (f.id == this.form.bomCategoryId) {
  1023. this.$set(this.form, 'bomCategoryName', f.name);
  1024. this.$set(this.form, 'bomCategoryVersions', f.versions);
  1025. }
  1026. });
  1027. this.getPlanRouting();
  1028. },
  1029. changeRoute() {
  1030. this.$forceUpdate();
  1031. this.routingList.forEach((f) => {
  1032. if (f.id == this.form.produceRoutingId) {
  1033. this.$set(this.form, 'produceRoutingName', f.name);
  1034. this.$set(this.form, 'produceVersionName', f.version);
  1035. }
  1036. });
  1037. },
  1038. getSaleInfo() {
  1039. let params = JSON.parse(this.$route.query.selection);
  1040. productionToPlan(params).then((res) => {
  1041. console.log(res, 'resresres');
  1042. this.form = deepClone(res);
  1043. this.bomListVersion();
  1044. console.log(this.bomVersionList, 'this.bomVersionList');
  1045. this.form.produceRoutingName =
  1046. res.produceRoutingName || this.$route.query.produceRoutingName;
  1047. this.form.produceRoutingId =
  1048. res.produceRoutingId || this.$route.query.produceRoutingId;
  1049. this.form.factoriesId =
  1050. res.factoriesId || this.$route.query.factoriesId;
  1051. // this.form.produceType =
  1052. // res.produceType || this.$route.query.produceType
  1053. // ? parseInt(this.$route.query.produceType)
  1054. // : null;
  1055. this.form.produceType = this.$route.query.produceType
  1056. ? parseInt(this.$route.query.produceType)
  1057. : res.produceType;
  1058. this.changeProduceType();
  1059. this.form.bomCategoryId =
  1060. res.bomCategoryId || this.$route.query.bomCategoryId;
  1061. this.changeBomId();
  1062. if (this.clientEnvironmentId == '4') {
  1063. if (this.form.salesOrders[0].productName.includes('板材')) {
  1064. this.changeProduct({
  1065. id: '1856970794952372226',
  1066. name: '板材',
  1067. produceVersionName: '板材'
  1068. });
  1069. } else {
  1070. this.changeProduct({
  1071. id: '1857313733642596353',
  1072. name: '砌块',
  1073. produceVersionName: '砌块'
  1074. });
  1075. }
  1076. }
  1077. this.form.salesOrders.map((item, index) => {
  1078. if (this.clientEnvironmentId == '4') {
  1079. this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
  1080. } else {
  1081. item.planProductNum = item.lackNum;
  1082. item.requiredFormingNum = item.lackNum;
  1083. }
  1084. item.slottingType = item.slottingType && item.slottingType + '';
  1085. item.priority = index + 1;
  1086. item.reqMoldTime = item.deliveryTime;
  1087. // dayjs(
  1088. // new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
  1089. // ).format('YYYY-MM-DD');
  1090. });
  1091. if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
  1092. this.form.planType = 2;
  1093. } else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
  1094. this.form.planType = 1;
  1095. } else {
  1096. this.form.planType = 3;
  1097. }
  1098. this._getInventory();
  1099. });
  1100. this.$forceUpdate();
  1101. },
  1102. itemChange() {
  1103. this.form.salesOrders.map((item, index) => {
  1104. this.$set(
  1105. item,
  1106. 'requiredFormingNum',
  1107. item.planProductNum * (this.form.marginCoefficient || 1)
  1108. );
  1109. });
  1110. },
  1111. factoriesIdFn(e) {
  1112. this.$forceUpdate();
  1113. },
  1114. toInt(planProductNum) {
  1115. return planProductNum * (this.form.marginCoefficient || 1);
  1116. },
  1117. cancel() {
  1118. const key = getRouteTabKey();
  1119. // this.$router.go(-1);
  1120. removePageTab({ key });
  1121. this.$emit('cancel');
  1122. },
  1123. toSubmit() {
  1124. if (!this.form.factoriesId)
  1125. return this.$message.warning('请选择所属工厂');
  1126. this.form.salesOrders.map((v) => {
  1127. let arrTime = v.deliveryTime && v.deliveryTime.split(' ');
  1128. let arrTimeTow =
  1129. v.produceDeliveryDeadline && v.produceDeliveryDeadline.split(' ');
  1130. v.deliveryTime = arrTime && arrTime[0];
  1131. v.produceDeliveryDeadline = arrTimeTow && arrTimeTow[0];
  1132. // if(v.salesOrders)
  1133. });
  1134. if (this.form.produceType) {
  1135. //查询生产类型
  1136. this.form.produceVersionName = this.producedList.find(
  1137. (v) => v.code == this.form.produceType
  1138. )?.name;
  1139. }
  1140. if (this.form.produceRoutingId && !this.form.produceRoutingName) {
  1141. //查询工艺路线
  1142. this.form.produceRoutingName = this.routingList.find(
  1143. (v) => v.id == this.form.produceRoutingId
  1144. ).name;
  1145. }
  1146. if (this.form.factoriesId) {
  1147. //查询工厂名称
  1148. this.form.factoriesIdName = this.factoryList.find(
  1149. (v) => v.id == this.form.factoriesId
  1150. )?.name;
  1151. }
  1152. if (this.form.salesOrders.length > 1) {
  1153. //多条订单时,拼接批次号(订单数量)
  1154. this.form.batchNo = this.form.salesOrders
  1155. .map((v) => v.batchNo + `(生产数量:${v.contractNum})`)
  1156. .join(',');
  1157. } else {
  1158. this.form.batchNo = this.form.salesOrders[0].batchNo;
  1159. }
  1160. let flag = this.parameterVerification();
  1161. // 必填参数校验
  1162. if (!flag) return;
  1163. this.$refs.form.validate((valid) => {
  1164. if (valid) {
  1165. this.mapList();
  1166. this.$refs.submitRefs.open();
  1167. }
  1168. });
  1169. },
  1170. // 参数校验
  1171. parameterVerification() {
  1172. let flag = true;
  1173. if (!this.form.startTime) {
  1174. this.$message.warning('请选择计划开始时间');
  1175. return false;
  1176. }
  1177. if (!this.form.endTime) {
  1178. this.$message.warning('请选择计划结束时间');
  1179. return false;
  1180. }
  1181. if (this.isRequired) {
  1182. if (!this.form.produceType) {
  1183. flag = false;
  1184. this.$message.warning('请选择生产类型');
  1185. return;
  1186. }
  1187. if (!this.form.bomCategoryId) {
  1188. flag = false;
  1189. this.$message.warning('请选择BOM版本');
  1190. return;
  1191. }
  1192. }
  1193. if (!this.form.produceRoutingId) {
  1194. flag = false;
  1195. this.$message.warning('请选择工艺路线');
  1196. return;
  1197. }
  1198. return flag;
  1199. },
  1200. // 对比日期,计算要求生产重量
  1201. mapList() {
  1202. var _sumOrderWeight = 0;
  1203. var requiredFormingNum = 0;
  1204. var productNum = 0;
  1205. this.form.salesOrders.map((item, index) => {
  1206. requiredFormingNum =
  1207. Number(requiredFormingNum) + Number(item.requiredFormingNum);
  1208. if (
  1209. this.form.weightUnit == 'G' ||
  1210. this.form.weightUnit == 'g' ||
  1211. this.form.weightUnit == '克'
  1212. ) {
  1213. this.form.newWeightUnit = 'kg';
  1214. _sumOrderWeight =
  1215. (this.form.salesOrders[0].requiredFormingNum *
  1216. Number(this.form.salesOrders[0].productUnitWeight || 1)) /
  1217. 1000;
  1218. } else {
  1219. this.form.newWeightUnit = this.form.weightUnit;
  1220. _sumOrderWeight =
  1221. this.form.salesOrders[0].requiredFormingNum *
  1222. Number(this.form.salesOrders[0].productUnitWeight || 1);
  1223. }
  1224. productNum += Number(item.planProductNum);
  1225. });
  1226. this.form.productNum = productNum;
  1227. this.form.productUnitWeight =
  1228. this.form.salesOrders[0]?.productUnitWeight;
  1229. this.form.newSumOrderWeight = _sumOrderWeight.toFixed(2);
  1230. this.form.requiredFormingNum = requiredFormingNum;
  1231. const collection = deepClone(this.form.salesOrders);
  1232. const sortedCollection = collection.sort(
  1233. (a, b) => new Date(b.reqMoldTime) - new Date(a.reqMoldTime)
  1234. );
  1235. let latestData = {};
  1236. for (let i = 0; i < sortedCollection.length; i++) {
  1237. const data = sortedCollection[i];
  1238. if (
  1239. !latestData.reqMoldTime ||
  1240. new Date(data.reqMoldTime) >= new Date(latestData.reqMoldTime)
  1241. ) {
  1242. latestData = data;
  1243. }
  1244. }
  1245. this.form.reqMoldTime = latestData.reqMoldTime;
  1246. },
  1247. sortTop(row) {
  1248. row.priority = Number(row.priority) + 1;
  1249. this.priorityChange(row);
  1250. },
  1251. sortBottom(row) {
  1252. if (row.priority <= 1) {
  1253. return;
  1254. }
  1255. row.priority = Number(row.priority) - 1;
  1256. this.priorityChange(row);
  1257. },
  1258. priorityChange(row) {
  1259. if (row.priority > 10) {
  1260. row.priority = 10; // 如果大于 10,则设置为 10
  1261. } else if (row.priority < 0) {
  1262. row.priority = 0; // 如果小于 0,则设置为 0
  1263. }
  1264. this.priorityFn(row);
  1265. },
  1266. priorityFn: debounce(function (row) {}, 800),
  1267. // 删除产品
  1268. handleDeleteItem(index) {
  1269. this.form.salesOrders.splice(index, 1);
  1270. },
  1271. addEquipment() {
  1272. this.$refs.additionalRefs.open(this.form.planType);
  1273. },
  1274. openVersion() {
  1275. this.$refs.versionRefs.open();
  1276. },
  1277. changeProduct(data) {
  1278. this.$set(this.form, 'produceRoutingName', data.name);
  1279. this.$set(this.form, 'produceRoutingId', data.id);
  1280. this.$set(this.form, 'produceVersionName', data.produceVersionName);
  1281. },
  1282. // 表格:模数、数量(方)、块数输入框 输入事件
  1283. tableHandleKeyUp(row, index, e, name) {
  1284. if (row.specification && this.clientEnvironmentId == '4') {
  1285. let modelArr = row.specification.split('*');
  1286. let modelLong = modelArr[0]; // model规格长度
  1287. let modeWide = modelArr[1]; // model规格宽度
  1288. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1289. modeHight = Number(modeHight);
  1290. if (name === 'moCount') {
  1291. // 模数
  1292. row.moCount = e;
  1293. // 计算块数的公式:
  1294. // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
  1295. // 每一模的块数*模数moCount = 总块数
  1296. if (row.productName.includes('板材')) {
  1297. row.blockCount =
  1298. Math.floor(600 / modelLong) *
  1299. Math.floor(120 / modeHight) *
  1300. Math.floor(60 / modeWide) *
  1301. row.moCount;
  1302. } else if (row.productName.includes('砌块')) {
  1303. let modelLongFixed = (600 / modelLong).toFixed(2);
  1304. modelLongFixed = modelLongFixed.substring(
  1305. 0,
  1306. modelLongFixed.length - 1
  1307. );
  1308. let modeWideFixed = (120 / modeWide).toFixed(2);
  1309. modeWideFixed = modeWideFixed.substring(
  1310. 0,
  1311. modeWideFixed.length - 1
  1312. );
  1313. let modeHightFixed = (60 / modeHight).toFixed(2);
  1314. modeHightFixed = modeHightFixed.substring(
  1315. 0,
  1316. modeHightFixed.length - 1
  1317. );
  1318. row.blockCount =
  1319. Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
  1320. row.moCount;
  1321. }
  1322. row.planProductNum =
  1323. Number((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
  1324. row.blockCount;
  1325. } else if (name === 'sum') {
  1326. //方数
  1327. row.planProductNum = e;
  1328. row.blockCount = Math.floor(
  1329. e / ((modelLong * modeWide * modeHight) / 1000000)
  1330. );
  1331. if (row.productName.includes('板材')) {
  1332. row.moCount = Math.ceil(
  1333. row.blockCount /
  1334. (Math.floor(600 / modelLong) *
  1335. Math.floor(120 / modeHight) *
  1336. Math.floor(60 / modeWide))
  1337. );
  1338. } else if (row.productName.includes('砌块')) {
  1339. row.moCount = Math.ceil(
  1340. row.blockCount /
  1341. Math.floor(
  1342. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1343. )
  1344. );
  1345. }
  1346. } else if (name === 'blockCount') {
  1347. //块数
  1348. row.blockCount = e;
  1349. if (row.productName.includes('板材')) {
  1350. row.moCount = Math.ceil(
  1351. row.blockCount /
  1352. (Math.floor(600 / modelLong) *
  1353. Math.floor(120 / modeHight) *
  1354. Math.floor(60 / modeWide))
  1355. );
  1356. } else if (row.productName.includes('砌块')) {
  1357. row.moCount = Math.ceil(
  1358. row.blockCount /
  1359. Math.floor(
  1360. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  1361. )
  1362. );
  1363. }
  1364. row.planProductNum =
  1365. (Number(e) * modelLong * modeWide * modeHight) / 1000000;
  1366. }
  1367. }
  1368. row.requiredFormingNum = Number(
  1369. row.planProductNum * (this.form.marginCoefficient || 1)
  1370. ).toFixed(5);
  1371. },
  1372. confirmChoose(list) {
  1373. // 取出在弹窗中选中并且不在表格中的数据
  1374. const result = list.filter(
  1375. (i) => this.form.salesOrders.findIndex((p) => p.id === i.id) === -1
  1376. );
  1377. // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
  1378. const del = this.form.salesOrders.filter(
  1379. (i) => list.findIndex((p) => p.id === i.id) === -1
  1380. );
  1381. for (let i = this.form.salesOrders.length - 1; i >= 0; i--) {
  1382. for (let j in del) {
  1383. if (this.form.salesOrders[i].id === del[j].id) {
  1384. this.form.salesOrders.splice(i, 1);
  1385. }
  1386. }
  1387. }
  1388. let priority =
  1389. this.form.salesOrders[this.form.salesOrders.length - 1]?.priority ||
  1390. 0;
  1391. this.form.salesOrders = this.form.salesOrders.concat(
  1392. result.map((item, index) => {
  1393. item.priority = ++priority;
  1394. item.planProductNum = item.lackNum;
  1395. item.requiredFormingNum = item.lackNum;
  1396. item.reqMoldTime = dayjs(
  1397. new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
  1398. ).format('YYYY-MM-DD');
  1399. return item;
  1400. })
  1401. );
  1402. this.changeData();
  1403. },
  1404. changeData() {
  1405. var planProductNum = 0;
  1406. var productWeight = 0;
  1407. this.form.salesOrders.map((item, index) => {
  1408. item.priority = index + 1;
  1409. planProductNum = planProductNum + item.requiredFormingNum;
  1410. productWeight = productWeight + Number(item.productSumWeight);
  1411. });
  1412. this.$set(this.form, 'codeNum', this.form.salesOrders.length);
  1413. this.$set(this.form, 'contractNum', planProductNum);
  1414. this.$set(this.form, 'sumOrderWeight', productWeight.toFixed(2));
  1415. },
  1416. async publishData(type) {
  1417. const key = getRouteTabKey();
  1418. let params = deepClone(this.form);
  1419. params.categoryId = params.salesOrders[0]?.categoryId;
  1420. if (this.$route.query.type != 'edit') {
  1421. delete params.id;
  1422. }
  1423. if (type === 2) {
  1424. this.$confirm('发布工单后不可撤回,确定发布吗?', '发布确认').then(
  1425. async () => {
  1426. const loading = this.$loading({
  1427. lock: true,
  1428. fullscreen: true,
  1429. text: '工单发布中...'
  1430. });
  1431. try {
  1432. const code = await getCode('product_order_code');
  1433. const data = {
  1434. productionPlan: params,
  1435. workOrder: {
  1436. productionPlanCode: params.code,
  1437. code: code,
  1438. // formingNum: params.contractNum,
  1439. formingNum: this.form.requiredFormingNum,
  1440. formingWeight: params.sumOrderWeight,
  1441. produceRoutingId: params.produceRoutingId,
  1442. status: 4,
  1443. model: params.model,
  1444. brandNo: params.brandNo,
  1445. categoryId: params.categoryId,
  1446. productCode: params.productCode,
  1447. productName: params.productName,
  1448. newWeightUnit: this.form.newWeightUnit,
  1449. newSumOrderWeight: this.form.newSumOrderWeight
  1450. }
  1451. };
  1452. if (this.$route.query.type == 'edit') {
  1453. data.workOrder.productionPlanId = params.id;
  1454. }
  1455. await releaseSave(data)
  1456. .then((res) => {
  1457. if (res === 1) {
  1458. this.$message.success('工单已发布!');
  1459. this.$router.push({
  1460. path: '/productionPlan'
  1461. });
  1462. } else {
  1463. this.$confirm(
  1464. '生产计划创建成功,但工单发布失败。请前往【生产计划】列表【重新发布】工单',
  1465. '提示',
  1466. {
  1467. confirmButtonText: '返回',
  1468. cancelButtonText: '立即前往',
  1469. type: 'warning'
  1470. }
  1471. )
  1472. .then(() => {
  1473. this.$router.push({
  1474. path: '/productionPlan'
  1475. });
  1476. })
  1477. .catch(() => {
  1478. this.$router.go(-1);
  1479. });
  1480. }
  1481. removePageTab({ key });
  1482. })
  1483. .catch(() => {
  1484. this.$message.error('发布失败,请重新发布!');
  1485. });
  1486. } catch (error) {}
  1487. loading.close();
  1488. }
  1489. );
  1490. } else {
  1491. let request =
  1492. this.$route.query.type == 'edit'
  1493. ? updateSaleToPlan
  1494. : saveSaleToPlan;
  1495. request(params)
  1496. .then(async (res) => {
  1497. // 提交
  1498. this.$router.push({
  1499. path: '/productionPlan'
  1500. });
  1501. removePageTab({ key });
  1502. })
  1503. .catch(() => {
  1504. this.$message.error('提交失败,请重新提交!');
  1505. });
  1506. }
  1507. },
  1508. // 打开工艺路线
  1509. openDialog() {
  1510. // this.selectIndex = index;
  1511. this.$refs.processRouteRef.open();
  1512. },
  1513. // 选择工艺路线
  1514. changeParent(item) {
  1515. this.routingList = [];
  1516. this.bomVersionList = [];
  1517. this.$set(this.form, 'bomCategoryId', null);
  1518. this.$set(this.form, 'model', '');
  1519. this.$set(this.form, 'produceType', '');
  1520. this.$set(this.form, 'produceRoutingName', item.name);
  1521. this.$set(this.form, 'produceRoutingId', item.id);
  1522. this.form.bomCategoryName = '';
  1523. this.form.bomCategoryVersions = '';
  1524. this.selectionRowShow = true;
  1525. },
  1526. // 【开始时间变化时】触发
  1527. handleStartTimeChange(row) {
  1528. this.checkEndTimeValid(row);
  1529. },
  1530. // 【结束时间变化时】触发
  1531. handleEndTimeChange(row) {
  1532. this.checkEndTimeValid(row);
  1533. },
  1534. checkEndTimeValid(row) {
  1535. const { startTime: start, endTime: end } = row;
  1536. if (!start || !end) return; // 开始/结束时间未填,跳过
  1537. const startTime = new Date(start);
  1538. const endTime = new Date(end);
  1539. if (endTime < startTime) {
  1540. row.endTime = new Date(startTime); // 修正为开始时间
  1541. this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
  1542. }
  1543. }
  1544. }
  1545. };
  1546. </script>
  1547. <style lang="scss" scoped>
  1548. .ele-body {
  1549. background: #fff;
  1550. }
  1551. .body-title {
  1552. width: 100%;
  1553. display: flex;
  1554. align-items: center;
  1555. justify-content: space-between;
  1556. }
  1557. .title-left {
  1558. font-size: 20px;
  1559. color: #333;
  1560. }
  1561. .formbox {
  1562. margin: 20px auto;
  1563. }
  1564. .row-intro {
  1565. border-bottom: 1px dashed #ccc;
  1566. margin-bottom: 20px;
  1567. }
  1568. .add-product {
  1569. width: 100%;
  1570. display: flex;
  1571. align-items: center;
  1572. justify-content: flex-end;
  1573. font-size: 30px;
  1574. color: #1890ff;
  1575. margin: 10px 0;
  1576. cursor: pointer;
  1577. }
  1578. .table-item {
  1579. margin-bottom: 0;
  1580. }
  1581. .header_required {
  1582. position: relative;
  1583. }
  1584. .header_required:before {
  1585. content: '*';
  1586. color: #f56c6c;
  1587. position: absolute;
  1588. top: 11px;
  1589. left: 26px;
  1590. }
  1591. .header_time_required {
  1592. position: relative;
  1593. }
  1594. .header_time_required:before {
  1595. content: '*';
  1596. color: #f56c6c;
  1597. position: absolute;
  1598. top: 11px;
  1599. left: 2px;
  1600. }
  1601. </style>