salesToProduction.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. <template>
  2. <el-dialog
  3. :title="
  4. type == 1
  5. ? '返修返工转生产计划'
  6. : type == 2
  7. ? '返修返工转生产订单'
  8. : '返修返工转生产工单'
  9. "
  10. :visible.sync="dialog"
  11. :before-close="handleClose"
  12. :close-on-click-modal="true"
  13. :close-on-press-escape="false"
  14. append-to-body
  15. width="100%"
  16. >
  17. <div class="ele-body">
  18. <el-card shadow="never">
  19. <el-form
  20. ref="form"
  21. :model="form"
  22. :rules="rules"
  23. label-width="90px"
  24. class="formbox"
  25. >
  26. <el-row :gutter="24">
  27. <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
  28. <el-form-item label="计划类型:">
  29. <DictSelection
  30. dictName="订单计划类型"
  31. clearable
  32. v-model="form.planType"
  33. >
  34. </DictSelection>
  35. </el-form-item>
  36. </el-col>
  37. <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
  38. <el-form-item label="工艺路线:" prop="produceRoutingName">
  39. <el-input
  40. @click.native="openVersion"
  41. placeholder="请选择工艺路线"
  42. readonly
  43. v-model="form.produceRoutingName"
  44. ></el-input>
  45. </el-form-item>
  46. </el-col>
  47. <el-col v-bind="styleResponsive ? { lg: 3, md: 6 } : { span: 3 }">
  48. <el-form-item label="使用改型:" prop="modification">
  49. <el-checkbox
  50. v-model="form.modification"
  51. :true-label="1"
  52. :false-label="0"
  53. ></el-checkbox>
  54. </el-form-item>
  55. </el-col>
  56. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  57. <el-form-item label="余量系数:" prop="marginCoefficient">
  58. <!-- <DictSelection
  59. @itemChange="itemChange"
  60. style="width: 200px"
  61. dictName="余量系数"
  62. v-model="form.marginCoefficient"
  63. ></DictSelection> -->
  64. <el-select filterable allow-create @change="itemChange" v-model="form.marginCoefficient">
  65. <el-option
  66. v-for="(item, index) in marginList"
  67. :key="index"
  68. :label="item.name"
  69. :value="item.value"
  70. />
  71. </el-select>
  72. </el-form-item>
  73. </el-col>
  74. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  75. <el-form-item label="原批号:">{{ form.oldBatchNo }}</el-form-item>
  76. </el-col>
  77. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  78. <el-form-item label="批号:" prop="batchNo">
  79. <el-input
  80. v-model.number="form.batchNo"
  81. size="small"
  82. style="width: 100%"
  83. placeholder="请输入批号"
  84. ></el-input>
  85. </el-form-item>
  86. </el-col>
  87. <el-col
  88. v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }"
  89. v-if="type == 3"
  90. >
  91. <el-form-item label="班组:" prop="teamId">
  92. <el-select v-model="form.teamId" @change="teamChange">
  93. <el-option
  94. v-for="item in teamList"
  95. :value="item.id"
  96. :key="item.id"
  97. :label="item.name"
  98. ></el-option>
  99. </el-select>
  100. </el-form-item>
  101. </el-col>
  102. </el-row>
  103. <el-row :gutter="24" class="row-intro">
  104. <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
  105. <el-form-item label="销售单数量:">{{
  106. form.codeNum
  107. }}</el-form-item>
  108. </el-col>
  109. <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
  110. <el-form-item label="订单总数量:">{{
  111. form.contractNum
  112. }}</el-form-item>
  113. </el-col>
  114. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  115. <el-form-item label="订单总重量:">{{
  116. form.sumOrderWeight
  117. }}</el-form-item>
  118. </el-col>
  119. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  120. <el-form-item label="产品编码:">{{
  121. form.productCode
  122. }}</el-form-item>
  123. </el-col>
  124. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  125. <el-form-item label="牌号:">{{ form.brandNo }}</el-form-item>
  126. </el-col>
  127. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  128. <el-form-item label="型号:">{{ form.model }}</el-form-item>
  129. </el-col>
  130. <el-col v-bind="styleResponsive ? { lg: 3, md: 12 } : { span: 3 }">
  131. <el-form-item label="库存数量:">{{
  132. form.stockCountBase
  133. }}</el-form-item>
  134. </el-col>
  135. </el-row>
  136. <el-table :data="form.salesOrders" border>
  137. <el-table-column label="序号" align="center" width="60">
  138. <template slot-scope="scope">
  139. <span>{{ scope.$index + 1 }}</span>
  140. </template>
  141. </el-table-column>
  142. <!-- <el-table-column
  143. label="销售订单号"
  144. align="center"
  145. prop=""
  146. width="120"
  147. sortable
  148. >
  149. </el-table-column> -->
  150. <!-- <el-table-column label="行号" align="center" prop="lineNumber">
  151. </el-table-column> -->
  152. <el-table-column
  153. label="产品名称"
  154. align="center"
  155. prop="productNameNew"
  156. >
  157. </el-table-column>
  158. <el-table-column label="合同数量" align="center" prop="contractNum">
  159. </el-table-column>
  160. <el-table-column
  161. label="合同重量"
  162. align="center"
  163. prop="productSumWeight"
  164. >
  165. <template slot-scope="scope">
  166. {{ scope.row.productSumWeight }} {{ form.weightUnit }}
  167. </template>
  168. </el-table-column>
  169. <el-table-column
  170. label="规格"
  171. align="center"
  172. prop="specificationNew"
  173. >
  174. </el-table-column>
  175. <el-table-column label="欠交数量" align="center" prop="lackNum">
  176. </el-table-column>
  177. <el-table-column
  178. label="计划生产数量"
  179. align="center"
  180. prop="productNum"
  181. width="140"
  182. >
  183. <template slot-scope="scope">
  184. <el-form-item
  185. label-width="0px"
  186. :prop="'salesOrders.' + scope.$index + '.productNum'"
  187. :rules="{
  188. required: true,
  189. message: '请输入计划生产数量',
  190. trigger: 'blur'
  191. }"
  192. class="table-item"
  193. >
  194. <el-input
  195. :disabled="isMoCount"
  196. v-model.number="scope.row.productNum"
  197. size="small"
  198. @input="
  199. tableHandleKeyUp(scope.row, scope.$index, $event, 'sum')
  200. "
  201. style="width: 100%"
  202. placeholder="输入数量"
  203. ></el-input>
  204. </el-form-item>
  205. </template>
  206. </el-table-column>
  207. <el-table-column
  208. label="要求生产数量"
  209. align="center"
  210. prop="requiredFormingNum"
  211. width="140"
  212. >
  213. <template slot-scope="scope">
  214. <el-form-item
  215. label-width="0px"
  216. :prop="'salesOrders.' + scope.$index + '.requiredFormingNum'"
  217. :rules="{
  218. required: true,
  219. message: '请输入要求生产数量',
  220. trigger: 'blur'
  221. }"
  222. class="table-item"
  223. >
  224. <el-input
  225. v-model.number="scope.row.requiredFormingNum"
  226. size="small"
  227. disabled
  228. style="width: 100%"
  229. placeholder="输入数量"
  230. ></el-input>
  231. </el-form-item>
  232. </template>
  233. </el-table-column>
  234. <el-table-column
  235. label="模数"
  236. align="center"
  237. width="100"
  238. v-if="isMoCount"
  239. >
  240. <template slot-scope="scope">
  241. <div>
  242. <el-input
  243. disabled
  244. style="width: 100%"
  245. size="small"
  246. v-model="scope.row.moCount"
  247. oninput="value=value.replace(/[^0-9.]/g,'')"
  248. @input="
  249. tableHandleKeyUp(
  250. scope.row,
  251. scope.$index,
  252. $event,
  253. 'moCount'
  254. )
  255. "
  256. placeholder="请输入"
  257. >
  258. </el-input>
  259. </div>
  260. </template>
  261. </el-table-column>
  262. <el-table-column align="center" width="100" v-if="isMoCount">
  263. <template slot="header">
  264. <span style="color: red">*</span>
  265. <span>块数</span>
  266. </template>
  267. <template slot-scope="scope">
  268. <el-form-item
  269. label-width="0px"
  270. :prop="'salesOrders.' + scope.$index + '.blockCount'"
  271. :rules="{
  272. required: true,
  273. message: '请输入块数',
  274. trigger: 'blur'
  275. }"
  276. class="table-item"
  277. >
  278. <el-input
  279. size="small"
  280. style="width: 100%"
  281. oninput="value=value.replace(/[^0-9.]/g,'')"
  282. @input="
  283. tableHandleKeyUp(
  284. scope.row,
  285. scope.$index,
  286. $event,
  287. 'blockCount'
  288. )
  289. "
  290. v-model="scope.row.blockCount"
  291. placeholder="请输入"
  292. ></el-input>
  293. </el-form-item>
  294. </template>
  295. </el-table-column>
  296. <el-table-column label="权重等级" align="center" width="120" v-if="isMoCount">
  297. <template slot-scope="scope">
  298. <div>
  299. <el-select v-model="scope.row.weight" style="width: 100%">
  300. <el-option
  301. v-for="item of weightList"
  302. :key="item.code"
  303. :label="item.name"
  304. :value="item.code"
  305. ></el-option>
  306. </el-select>
  307. </div>
  308. </template>
  309. </el-table-column>
  310. <el-table-column
  311. align="center"
  312. width="120"
  313. label="是否开槽"
  314. v-if="isMoCount"
  315. >
  316. <template slot-scope="scope">
  317. <div>
  318. <el-select
  319. style="width: 100%"
  320. v-model="scope.row.isSlotting"
  321. placeholder="请选择"
  322. >
  323. <el-option
  324. v-for="item of isSlotting"
  325. :key="item.code"
  326. :label="item.name"
  327. :value="item.code"
  328. />
  329. </el-select>
  330. </div>
  331. </template>
  332. </el-table-column>
  333. <el-table-column
  334. align="center"
  335. width="120"
  336. label="开槽类型"
  337. v-if="isMoCount"
  338. >
  339. <template slot-scope="scope">
  340. <DictSelection
  341. dictName="开槽类型"
  342. v-model="scope.row.slottingType"
  343. v-if="scope.row.isSlotting == 1"
  344. >
  345. </DictSelection>
  346. </template>
  347. </el-table-column>
  348. <el-table-column
  349. label="按单按库"
  350. align="center"
  351. prop="orderLibraryType"
  352. >
  353. <template slot-scope="{ row }">
  354. {{ getDictValue('按单按库', row.orderLibraryType) }}
  355. </template>
  356. </el-table-column>
  357. <el-table-column label="订单类型" align="center" prop="orderType">
  358. <template slot-scope="{ row }">
  359. <DictSelection
  360. dictName="订单类型"
  361. clearable
  362. v-model="row.orderType"
  363. >
  364. </DictSelection>
  365. </template>
  366. </el-table-column>
  367. <el-table-column
  368. label="交付日期"
  369. align="center"
  370. prop="deliveryTime"
  371. width="160"
  372. >
  373. </el-table-column>
  374. <el-table-column
  375. label="要求生产日期"
  376. align="center"
  377. prop="reqMoldTime"
  378. width="180"
  379. >
  380. <template slot-scope="scope">
  381. <el-form-item
  382. label-width="0px"
  383. :prop="'salesOrders.' + scope.$index + '.reqMoldTime'"
  384. :rules="{
  385. required: true,
  386. message: '请选择要求生产日期',
  387. trigger: 'blur'
  388. }"
  389. class="table-item"
  390. >
  391. <el-date-picker
  392. style="width: 100%"
  393. v-model="scope.row.reqMoldTime"
  394. :pickerOptions="{
  395. disabledDate: (time) =>
  396. time.getTime() <
  397. new Date(new Date().setHours(0, 0, 0, 0)).getTime()
  398. }"
  399. type="date"
  400. placeholder="选择日期"
  401. value-format="yyyy-MM-dd"
  402. >
  403. </el-date-picker>
  404. <!-- <el-date-picker
  405. style="width: 100%;"
  406. v-model="scope.row.reqMoldTime"
  407. type="datetime"
  408. placeholder="选择日期"
  409. value-format="yyyy-MM-dd HH:mm:ss">
  410. </el-date-picker> -->
  411. </el-form-item>
  412. </template>
  413. </el-table-column>
  414. <el-table-column
  415. label="客户名称"
  416. align="center"
  417. prop="customerName"
  418. >
  419. </el-table-column>
  420. <el-table-column label="业务员" align="center" prop="salesman">
  421. </el-table-column>
  422. <el-table-column
  423. label="交付要求"
  424. align="center"
  425. prop="deliveryRequirements"
  426. >
  427. <template slot-scope="{ row }">
  428. {{ getDictValue('交付要求', row.deliveryRequirements) }}
  429. </template>
  430. </el-table-column>
  431. <el-table-column
  432. prop="priority"
  433. label="优先级"
  434. width="100"
  435. align="center"
  436. :min="0"
  437. :max="10"
  438. >
  439. <template slot-scope="{ row, $index }">
  440. <el-input
  441. v-if="$index == 0"
  442. v-model="row.priority"
  443. type="number"
  444. size="mini"
  445. @change="priorityChange(row)"
  446. ></el-input>
  447. <el-popover
  448. v-if="$index == 0"
  449. placement="right"
  450. width="200"
  451. trigger="hover"
  452. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  453. >
  454. <div class="sort-wrap" slot="reference">
  455. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  456. <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
  457. </div>
  458. </el-popover>
  459. </template>
  460. </el-table-column>
  461. </el-table>
  462. <el-row :gutter="24" style="margin-top: 15px">
  463. <el-col
  464. v-bind="styleResponsive ? { lg: 24, md: 24 } : { span: 24 }"
  465. >
  466. <el-form-item label="计划备注:">
  467. <el-input
  468. type="textarea"
  469. :rows="4"
  470. v-model="form.notes"
  471. resize="none"
  472. ></el-input>
  473. </el-form-item>
  474. </el-col>
  475. </el-row>
  476. </el-form>
  477. <!-- <AdditionalOrder
  478. ref="additionalRefs"
  479. :productCode="form.productCode"
  480. :selectList="form.salesOrders"
  481. @choose="confirmChoose"
  482. ></AdditionalOrder> -->
  483. <ProductionVersion
  484. ref="versionRefs"
  485. @changeProduct="changeProduct"
  486. ></ProductionVersion>
  487. </el-card>
  488. </div>
  489. <div class="btns">
  490. <el-button type="primary" size="small" @click="toSubmit">提交</el-button>
  491. <el-button size="small" @click="handleClose">取消</el-button>
  492. </div>
  493. </el-dialog>
  494. </template>
  495. <script>
  496. // import AdditionalOrder from './EquipmentDialog.vue';
  497. import ProductionVersion from '@/components/ProductionVersion/ProductionVersion.vue';
  498. import { transformation } from '@/api/unacceptedProduct/index';
  499. import { debounce } from 'lodash';
  500. import { getByCode } from '@/api/system/dictionary-data';
  501. import dictMixins from '@/mixins/dictMixins';
  502. import { getteampage } from '@/api/produceWord';
  503. import dayjs from 'dayjs';
  504. export default {
  505. mixins: [dictMixins],
  506. components: {
  507. ProductionVersion
  508. },
  509. data() {
  510. return {
  511. dialog: false,
  512. type: '',
  513. teamList: [],
  514. isMoCount: false,
  515. weightList: [
  516. { code: 1, name: 'A' },
  517. { code: 2, name: 'B' },
  518. { code: 3, name: 'C' }
  519. ],
  520. isSlotting: [
  521. { code: 1, name: '是' },
  522. { code: 2, name: '否' }
  523. ], //是否开槽
  524. form: {
  525. planType: '',
  526. produceRoutingId: '',
  527. stockCountBase: '',
  528. salesOrders: [],
  529. produceRoutingName: '',
  530. marginCoefficient: '1.0',
  531. oldBatchNo: '',
  532. batchNo: ''
  533. },
  534. // 表单验证规则
  535. rules: {
  536. produceRoutingName: [
  537. { required: true, message: '请选择工艺路线', trigger: 'change' }
  538. ]
  539. },
  540. // selection: [],
  541. loading: false,
  542. marginList: []
  543. };
  544. },
  545. computed: {
  546. // 是否开启响应式布局
  547. styleResponsive() {
  548. return this.$store.state.theme.styleResponsive;
  549. }
  550. },
  551. created() {
  552. this.requestDict('按单按库');
  553. this.requestDict('订单类型');
  554. this.requestDict('交付要求');
  555. this._teamPage();
  556. this.getByCodeFn();
  557. },
  558. methods: {
  559. async _teamPage() {
  560. const res = await getteampage({
  561. page: 1,
  562. size: -1
  563. });
  564. this.teamList = res.list;
  565. },
  566. getByCodeFn() {
  567. getByCode('margin_code').then((res) => {
  568. let _arr = [];
  569. res.data.map((item) => {
  570. const key = Object.keys(item)[0];
  571. const value = item[key];
  572. _arr.push({ name: key, value: value });
  573. });
  574. console.log(_arr)
  575. this.marginList = _arr;
  576. });
  577. },
  578. open(row, type) {
  579. this.type = type;
  580. this.dialog = true;
  581. let contractNum=0
  582. let data = JSON.parse(JSON.stringify(row));
  583. data.forEach((item) => {
  584. if (
  585. item.productNameNew.includes('板材') ||
  586. item.productNameNew.includes('砌块')
  587. ) {
  588. this.isMoCount = true;
  589. item.blockCount = item.sumNew;
  590. this.tableHandleKeyUp(item, '', item.blockCount, 'blockCount');
  591. } else {
  592. item.contractNum = item.sumNew;
  593. item.lackNum = item.sumNew;
  594. item['productNum'] = item.sumNew;
  595. item.requiredFormingNum = item.sumNew;
  596. contractNum+=Number(item.sumNew)
  597. }
  598. });
  599. this.form.oldBatchNo = data[0].batchNo;
  600. this.form.contractNum = contractNum
  601. this.form.productCode = data[0].productCodeNew;
  602. this.form.brandNo = data[0].brandNo;
  603. this.form.model = data[0].model;
  604. this.form.salesOrders = data;
  605. },
  606. itemChange() {
  607. this.form.salesOrders.map((item, index) => {
  608. this.$set(
  609. item,
  610. 'requiredFormingNum',
  611. item.productNum * (this.form.marginCoefficient || 1)
  612. );
  613. });
  614. },
  615. teamChange(id) {
  616. this.form.teamName = this.teamList.find((item) => (item.id = id)).name;
  617. },
  618. toInt(productNum) {
  619. return productNum * (this.form.marginCoefficient || 1);
  620. },
  621. handleClose() {
  622. this.dialog = false;
  623. this.isMoCount=false
  624. this.$refs.form= {
  625. planType: '',
  626. produceRoutingId: '',
  627. stockCountBase: '',
  628. salesOrders: [],
  629. produceRoutingName: '',
  630. marginCoefficient: '1.0',
  631. oldBatchNo: '',
  632. batchNo: ''
  633. }
  634. },
  635. toSubmit() {
  636. this.$refs.form.validate(async (valid) => {
  637. if(valid){
  638. let data = JSON.parse(JSON.stringify(this.form.salesOrders));
  639. data.forEach((item) => {
  640. item.produceRoutingId = this.form.produceRoutingId;
  641. item.notes = this.form.notes;
  642. item.planType = this.form.planType;
  643. item.produceRoutingName = this.form.produceRoutingName;
  644. item.teamName = this.form.teamName;
  645. item.teamId = this.form.teamId;
  646. item.batchNo = this.form.batchNo;
  647. item.productName = item.productNameNew;
  648. item.productCode = item.productCodeNew;
  649. item.specification = item.specificationNew;
  650. });
  651. // console.log(data)
  652. // return
  653. const res = await transformation(data, this.type);
  654. if (res.code == 0) {
  655. this.handleClose();
  656. this.$emit('success');
  657. }
  658. }
  659. });
  660. },
  661. sortTop(row) {
  662. row.priority = Number(row.priority) + 1;
  663. this.priorityChange(row);
  664. },
  665. sortBottom(row) {
  666. if (row.priority <= 1) {
  667. return;
  668. }
  669. row.priority = Number(row.priority) - 1;
  670. this.priorityChange(row);
  671. },
  672. priorityChange(row) {
  673. if (row.priority > 10) {
  674. row.priority = 10; // 如果大于 10,则设置为 10
  675. } else if (row.priority < 0) {
  676. row.priority = 0; // 如果小于 0,则设置为 0
  677. }
  678. this.priorityFn(row);
  679. },
  680. priorityFn: debounce(function (row) {}, 800),
  681. openVersion() {
  682. this.$refs.versionRefs.open();
  683. },
  684. changeProduct(data) {
  685. this.$set(this.form, 'produceRoutingName', data.name);
  686. this.$set(this.form, 'produceRoutingId', data.id);
  687. this.$set(this.form, 'produceVersionName', data.produceVersionName);
  688. },
  689. // 表格:模数、数量(方)、块数输入框 输入事件
  690. tableHandleKeyUp(row, index, e, name) {
  691. row.requiredFormingNum = this.toInt(row.productNum);
  692. if (!this.isMoCount) {
  693. return;
  694. }
  695. // console.log(row);
  696. let modelArr = row.specificationNew.split('*');
  697. let modelLong = modelArr[0]; // model规格长度
  698. let modeWide = modelArr[1]; // model规格宽度
  699. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  700. modeHight = Number(modeHight);
  701. if (name === 'moCount') {
  702. // 模数
  703. row.moCount = e;
  704. // 计算块数的公式:
  705. // (一模6米长度 / model规格长度) * (一模1.2米宽度 / model规格宽度) = 每一模的块数
  706. // 每一模的块数*模数moCount = 总块数
  707. if (row.productNameNew.includes('板材')) {
  708. row.blockCount =
  709. Math.floor(600 / modelLong) *
  710. Math.floor(120 / modeHight) *
  711. Math.floor(60 / modeWide) *
  712. row.moCount;
  713. } else if (row.productNameNew.includes('砌块')) {
  714. let modelLongFixed = (600 / modelLong).toFixed(2);
  715. modelLongFixed = modelLongFixed.substring(
  716. 0,
  717. modelLongFixed.length - 1
  718. );
  719. let modeWideFixed = (120 / modeWide).toFixed(2);
  720. modeWideFixed = modeWideFixed.substring(0, modeWideFixed.length - 1);
  721. let modeHightFixed = (60 / modeHight).toFixed(2);
  722. modeHightFixed = modeHightFixed.substring(
  723. 0,
  724. modeHightFixed.length - 1
  725. );
  726. row.blockCount =
  727. Math.floor(modelLongFixed * modeWideFixed * modeHightFixed) *
  728. row.moCount;
  729. }
  730. row.productNum =
  731. ((modelLong * modeWide * modeHight) / 1000000).toFixed(5) *
  732. row.blockCount;
  733. } else if (name === 'sum') {
  734. //方数
  735. row.productNum = e;
  736. row.blockCount = Math.floor(
  737. e / ((modelLong * modeWide * modeHight) / 1000000)
  738. );
  739. // console.log(e,'row.blockCount')
  740. // console.log(modelLong,'row.blockCount')
  741. // console.log(modeWide,'row.blockCount')
  742. // console.log(modeHight,'row.blockCount')
  743. if (row.productNameNew.includes('板材')) {
  744. row.moCount = Math.ceil(
  745. row.blockCount /
  746. (Math.floor(600 / modelLong) *
  747. Math.floor(120 / modeHight) *
  748. Math.floor(60 / modeWide))
  749. );
  750. } else if (row.productNameNew.includes('砌块')) {
  751. row.moCount = Math.ceil(
  752. row.blockCount /
  753. Math.floor(
  754. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  755. )
  756. );
  757. }
  758. } else if (name === 'blockCount') {
  759. //块数
  760. row.blockCount = e;
  761. if (row.productNameNew.includes('板材')) {
  762. row.moCount = Math.ceil(
  763. row.blockCount /
  764. (Math.floor(600 / modelLong) *
  765. Math.floor(120 / modeHight) *
  766. Math.floor(60 / modeWide))
  767. );
  768. } else if (row.productNameNew.includes('砌块')) {
  769. row.moCount = Math.ceil(
  770. row.blockCount /
  771. Math.floor(
  772. (600 / modelLong) * (120 / modeHight) * (60 / modeWide)
  773. )
  774. );
  775. }
  776. row.productNum = (
  777. (Number(e) * modelLong * modeWide * modeHight) /
  778. 1000000
  779. ).toFixed(5);
  780. }
  781. row.requiredFormingNum = this.toInt(row.productNum);
  782. }
  783. // confirmChoose(list) {
  784. // // 取出在弹窗中选中并且不在表格中的数据
  785. // const result = list.filter(
  786. // (i) => this.form.salesOrders.findIndex((p) => p.id === i.id) === -1
  787. // );
  788. // // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
  789. // const del = this.form.salesOrders.filter(
  790. // (i) => list.findIndex((p) => p.id === i.id) === -1
  791. // );
  792. // for (let i = this.form.salesOrders.length - 1; i >= 0; i--) {
  793. // for (let j in del) {
  794. // if (this.form.salesOrders[i].id === del[j].id) {
  795. // this.form.salesOrders.splice(i, 1);
  796. // }
  797. // }
  798. // }
  799. // let priority =
  800. // this.form.salesOrders[this.form.salesOrders.length - 1]?.priority || 0;
  801. // this.form.salesOrders = this.form.salesOrders.concat(
  802. // result.map((item, index) => {
  803. // item.priority = ++priority;
  804. // item.productNum = item.lackNum;
  805. // item.requiredFormingNum = item.lackNum;
  806. // item.reqMoldTime = dayjs(
  807. // new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
  808. // ).format('YYYY-MM-DD');
  809. // return item;
  810. // })
  811. // );
  812. // this.changeData();
  813. // },
  814. // changeData() {
  815. // var productNum = 0;
  816. // var productWeight = 0;
  817. // this.form.salesOrders.map((item, index) => {
  818. // item.priority = index + 1;
  819. // productNum = productNum + item.requiredFormingNum;
  820. // productWeight = productWeight + Number(item.productSumWeight);
  821. // });
  822. // this.$set(this.form, 'codeNum', this.form.salesOrders.length);
  823. // this.$set(this.form, 'contractNum', productNum);
  824. // this.$set(this.form, 'sumOrderWeight', productWeight.toFixed(2));
  825. // },
  826. }
  827. };
  828. </script>
  829. <style lang="scss" scoped>
  830. .ele-body {
  831. background: #fff;
  832. }
  833. .btns {
  834. text-align: center;
  835. padding: 10px 0;
  836. }
  837. .body-title {
  838. width: 100%;
  839. display: flex;
  840. align-items: center;
  841. justify-content: space-between;
  842. }
  843. .title-left {
  844. font-size: 20px;
  845. color: #333;
  846. }
  847. .formbox {
  848. margin: 20px auto;
  849. }
  850. .row-intro {
  851. border-bottom: 1px dashed #ccc;
  852. margin-bottom: 20px;
  853. }
  854. .sort-wrap {
  855. i {
  856. font-size: 30px;
  857. cursor: pointer;
  858. }
  859. .el-icon-caret-top {
  860. color: red;
  861. }
  862. .el-icon-caret-bottom {
  863. color: #157a2c;
  864. }
  865. }
  866. .add-product {
  867. width: 100%;
  868. display: flex;
  869. align-items: center;
  870. justify-content: flex-end;
  871. font-size: 30px;
  872. color: #1890ff;
  873. margin: 10px 0;
  874. cursor: pointer;
  875. }
  876. .table-item {
  877. margin-bottom: 0;
  878. }
  879. </style>