salesToProduction.vue 30 KB

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