inventoryTable.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules">
  3. <ele-pro-table
  4. ref="table"
  5. :needPage="false"
  6. :columns="columns"
  7. :toolkit="[]"
  8. max-height="500px"
  9. :datasource="form.datasource"
  10. cache-key="systemRoleTable17"
  11. class="time-form"
  12. >
  13. <!-- 表头工具栏 -->
  14. <template v-slot:toolbar>
  15. <div class="headbox">
  16. <el-button
  17. size="small"
  18. type="primary"
  19. icon="el-icon-plus"
  20. class="ele-btn-icon"
  21. @click="handlAdd"
  22. >
  23. 新增
  24. </el-button>
  25. </div>
  26. </template>
  27. <template v-slot:technicalDrawings="{ row, $index }">
  28. <el-form-item
  29. style="margin-bottom: 20px"
  30. :prop="'datasource.' + $index + '.technicalDrawings'"
  31. >
  32. <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
  33. <!-- <div v-if="row.technicalDrawings && row.technicalDrawings?.length">-->
  34. <!-- <el-link-->
  35. <!-- v-for="link in row.technicalDrawings"-->
  36. <!-- :key="link.id"-->
  37. <!-- type="primary"-->
  38. <!-- :underline="false"-->
  39. <!-- @click="downloadFile(link)"-->
  40. <!-- >-->
  41. <!-- {{ link.name }}-->
  42. <!-- </el-link-->
  43. <!-- >-->
  44. <!-- </div>-->
  45. </el-form-item>
  46. </template>
  47. <template v-slot:remark="{ row, $index }">
  48. <el-form-item
  49. style="margin-bottom: 20px"
  50. :prop="'datasource.' + $index + '.remark'"
  51. >
  52. <el-input
  53. clearable
  54. v-model="row.remark"
  55. type="textarea"
  56. placeholder="请输入"
  57. />
  58. </el-form-item>
  59. </template>
  60. <template v-slot:totalCount="scope">
  61. <el-form-item
  62. style="margin-bottom: 20px"
  63. :prop="'datasource.' + scope.$index + '.totalCount'"
  64. :rules="[
  65. { required: true, message: '请输入数字', trigger: 'blur' },
  66. { validator: validateTotalCount(scope.row), trigger: 'blur' }
  67. ]"
  68. >
  69. <el-input
  70. v-model="scope.row.totalCount"
  71. @input="(val) => changeNum(val, scope.$index, scope.row)"
  72. ></el-input>
  73. </el-form-item>
  74. </template>
  75. <!-- :disabled="!outsourceSendCode" -->
  76. <template v-slot:sendTotalWeight="scope">
  77. <el-form-item
  78. style="margin-bottom: 20px"
  79. :prop="'datasource.' + scope.$index + '.sendTotalWeight'"
  80. :rules="[
  81. {
  82. required: [2, 3].includes(Number(sourceType)) && pricingWay == 2,
  83. message: '请输入数字',
  84. trigger: 'blur'
  85. }
  86. ]"
  87. >
  88. <el-input-number
  89. :controls="false"
  90. v-model="scope.row.sendTotalWeight"
  91. @blur="changeSendTotalWeight(scope.$index)"
  92. style="width: 60%; margin-right: 10px"
  93. >
  94. </el-input-number>
  95. <el-button
  96. size="small"
  97. type="primary"
  98. v-if="[2, 3].includes(Number(sourceType)) && outsourceSendCode"
  99. @click.native="(e) => handleOutBound(e, scope.row, scope.$index)"
  100. >选择
  101. </el-button>
  102. </el-form-item>
  103. </template>
  104. <template v-slot:receiveTotalWeight="scope">
  105. <el-form-item
  106. :prop="'datasource.' + scope.$index + '.receiveTotalWeight'"
  107. >
  108. <el-input-number
  109. :controls="false"
  110. v-model="scope.row.receiveTotalWeight"
  111. style="width: 100%"
  112. >
  113. </el-input-number>
  114. </el-form-item>
  115. </template>
  116. <template v-slot:increaseTotalWeight="scope">
  117. <el-form-item
  118. :prop="'datasource.' + scope.$index + '.increaseTotalWeight'"
  119. >
  120. <el-input-number
  121. :controls="false"
  122. v-model="scope.row.increaseTotalWeight"
  123. style="width: 100%"
  124. >
  125. </el-input-number>
  126. </el-form-item>
  127. </template>
  128. <template v-slot:warehouseId="scope">
  129. <el-form-item
  130. style="margin-bottom: 20px"
  131. :prop="'datasource.' + scope.$index + '.warehouseId'"
  132. :rules="[{ required: true, message: '请选择仓库', trigger: 'blur' }]"
  133. >
  134. <el-select
  135. v-model="scope.row.warehouseId"
  136. placeholder="请选择"
  137. @change="warehouseChange(scope.$index, scope.row)"
  138. >
  139. <el-option
  140. v-for="item in warehouseList"
  141. :key="item.id"
  142. :label="item.name"
  143. :value="item.id"
  144. >
  145. </el-option>
  146. </el-select>
  147. </el-form-item>
  148. </template>
  149. <template v-slot:warehouseNum="scope">
  150. <el-form-item style="margin-bottom: 20px">
  151. {{ scope.row.warehouseNum }}
  152. </el-form-item>
  153. </template>
  154. <template v-slot:headerWarehouseId="{ column }">
  155. <span class="is-required">{{ column.label }}</span>
  156. </template>
  157. <template v-slot:headerTotalCount="{ column }">
  158. <span
  159. :class="{
  160. 'is-required':
  161. [2, 3].includes(Number(sourceType)) && pricingWay == 2
  162. }"
  163. >{{ column.label }}</span
  164. >
  165. </template>
  166. <!-- 操作列 -->
  167. <template v-slot:action="scope">
  168. <el-popconfirm
  169. class="ele-action"
  170. title="确定要删除吗?"
  171. @confirm="remove(scope.$index)"
  172. >
  173. <template v-slot:reference>
  174. <el-link type="danger" :underline="false" icon="el-icon-delete">
  175. 删除
  176. </el-link>
  177. </template>
  178. </el-popconfirm>
  179. </template>
  180. </ele-pro-table>
  181. <product-list
  182. ref="productListRef"
  183. :orderId="orderId"
  184. type="purchase"
  185. @changeParent="changeParent"
  186. :productType="productType"
  187. ></product-list>
  188. <!--出库详情-->
  189. <outbound-details-dialog
  190. v-if="outboundDetailsDialogFlag"
  191. ref="outboundDetailsDialogRef"
  192. :outboundDetailsDialogFlag.sync="outboundDetailsDialogFlag"
  193. @saveDate="saveDate"
  194. ></outbound-details-dialog>
  195. </el-form>
  196. </template>
  197. <script>
  198. import { numberReg } from 'ele-admin';
  199. import productList from '@/views/saleManage/saleOrder/invoice/components/product-list.vue';
  200. import dictMixins from '@/mixins/dictMixins';
  201. import { getWarehouseList } from '@/api/saleManage/saleorder';
  202. import store from '@/store';
  203. import { copyObj } from '@/utils/util';
  204. import { getFile } from '@/api/system/file';
  205. import outboundDetailsDialog from './outboundDetailsDialog.vue';
  206. import { getOutInBySourceBizNoAPI } from '@/api/saleManage/returnGoods';
  207. import fileMain from '@/components/addDoc/index.vue';
  208. export default {
  209. mixins: [dictMixins],
  210. props: {
  211. orderId: String,
  212. outsourceSendCode: String,
  213. pricingWay: [String, Number],
  214. sourceType: [String, Number],
  215. productType: ''
  216. },
  217. components: {
  218. fileMain,
  219. outboundDetailsDialog,
  220. productList
  221. },
  222. data() {
  223. const defaultForm = {
  224. key: null,
  225. endTime: '',
  226. isFirst: 0,
  227. name: '',
  228. startTime: '',
  229. workHour: '',
  230. technicalDrawings: []
  231. // warehouseCode:"",
  232. // warehouseId:'',
  233. // warehouseName:'',
  234. };
  235. return {
  236. discountTotalPrice: 0.0,
  237. allPrice: 0.0,
  238. outboundDetailsDialogFlag: false,
  239. curIndex: undefined,
  240. numberReg,
  241. defaultForm,
  242. warehouseList: [],
  243. form: {
  244. datasource: []
  245. },
  246. oldSendTotalWeightList: [],
  247. outboundInfo: {},
  248. rules: {},
  249. columns: [
  250. {
  251. width: 45,
  252. type: 'index',
  253. columnKey: 'index',
  254. align: 'center',
  255. fixed: 'left'
  256. },
  257. {
  258. width: 200,
  259. prop: 'productName',
  260. label: '名称',
  261. slot: 'productName',
  262. align: 'center'
  263. },
  264. {
  265. width: 120,
  266. prop: 'productCode',
  267. label: '编码',
  268. slot: 'productCode',
  269. align: 'center'
  270. },
  271. {
  272. width: 200,
  273. prop: 'productCategoryName',
  274. label: '类型',
  275. slot: 'productCategoryName',
  276. align: 'center'
  277. },
  278. {
  279. minWidth: 150,
  280. prop: 'taskName',
  281. label: '工序',
  282. slot: 'taskName',
  283. align: 'center'
  284. },
  285. {
  286. width: 110,
  287. prop: 'batchNo',
  288. label: '批次号',
  289. slot: 'batchNo',
  290. align: 'center'
  291. },
  292. {
  293. width: 160,
  294. prop: 'productBrand',
  295. label: '牌号',
  296. slot: 'productBrand',
  297. align: 'center'
  298. },
  299. {
  300. width: 120,
  301. prop: 'modelType',
  302. label: '型号',
  303. slot: 'modelType',
  304. align: 'center'
  305. },
  306. // {
  307. // width: 120,
  308. // prop: 'imgCode',
  309. // align: 'center',
  310. // label: '图号/件号',
  311. // showOverflowTooltip: true
  312. // },
  313. {
  314. width: 120,
  315. prop: 'produceType',
  316. align: 'center',
  317. label: '属性类型',
  318. showOverflowTooltip: true,
  319. formatter: (row, column) => {
  320. return row.produceType && row.produceType.length
  321. ? row.produceType
  322. .map((item) => this.getDictValue('生产类型', item + ''))
  323. .join(',')
  324. : '';
  325. }
  326. },
  327. // {
  328. // width: 120,
  329. // prop: 'approvalNumber',
  330. // align: 'center',
  331. // label: '批准文号',
  332. // showOverflowTooltip: true
  333. // },
  334. {
  335. width: 120,
  336. prop: 'packingSpecification',
  337. align: 'center',
  338. label: '包装规格',
  339. showOverflowTooltip: true
  340. },
  341. {
  342. width: 120,
  343. prop: 'supplierMark',
  344. label: '供应商代号',
  345. slot: 'supplierMark',
  346. align: 'center'
  347. },
  348. {
  349. width: 120,
  350. prop: 'specification',
  351. label: '规格',
  352. slot: 'specification',
  353. align: 'center'
  354. },
  355. {
  356. width: 200,
  357. prop: 'warehouseId',
  358. label: '仓库名称',
  359. slot: 'warehouseId',
  360. headerSlot: 'headerWarehouseId',
  361. align: 'center'
  362. },
  363. {
  364. width: 120,
  365. prop: 'totalCount',
  366. label: '收货数量',
  367. slot: 'totalCount',
  368. headerSlot: 'headerTotalCount',
  369. align: 'center'
  370. },
  371. {
  372. width: 120,
  373. prop: 'orderTotalCount',
  374. label: '采购总数',
  375. slot: 'orderTotalCount',
  376. align: 'center'
  377. },
  378. {
  379. width: 120,
  380. prop: 'receiveTotalCount',
  381. label: '已收货总数',
  382. // slot: 'receiveTotalCount',
  383. align: 'center'
  384. },
  385. {
  386. width: 80,
  387. prop: 'measuringUnit',
  388. label: '计量单位',
  389. slot: 'measuringUnit',
  390. align: 'center'
  391. },
  392. {
  393. width: 120,
  394. prop: 'singleWeight',
  395. label: '单重',
  396. slot: 'singleWeight',
  397. align: 'center'
  398. },
  399. {
  400. width: 200,
  401. prop: 'sendTotalWeight',
  402. label: '发货总重',
  403. slot: 'sendTotalWeight',
  404. align: 'center',
  405. headerSlot: 'headerTotalCount'
  406. },
  407. {
  408. width: 100,
  409. prop: 'receiveTotalWeight',
  410. label: '收货总重',
  411. slot: 'receiveTotalWeight',
  412. align: 'center'
  413. },
  414. {
  415. width: 100,
  416. prop: 'increaseTotalWeight',
  417. label: '增重重量',
  418. slot: 'increaseTotalWeight',
  419. align: 'center'
  420. },
  421. {
  422. width: 100,
  423. prop: 'weightUnit',
  424. label: '重量单位',
  425. slot: 'weightUnit',
  426. align: 'center'
  427. },
  428. {
  429. width: 160,
  430. prop: 'pricingWay',
  431. label: '计价方式',
  432. slot: 'pricingWay',
  433. align: 'center',
  434. formatter: (row, column) => {
  435. return row.pricingWay == 1 ? '按数量计费' : row.pricingWay == 2 ? '按重量计费':'';
  436. }
  437. },
  438. {
  439. width: 160,
  440. prop: 'singlePrice',
  441. label: '单价',
  442. slot: 'singlePrice',
  443. align: 'center'
  444. },
  445. {
  446. width: 120,
  447. prop: 'taxRate',
  448. label: '税率',
  449. formatter: (_row, _column, cellValue) => {
  450. return _row.taxRate
  451. ? _row.taxRate+'%'
  452. : '';
  453. },
  454. align: 'center'
  455. },
  456. {
  457. width: 160,
  458. prop: 'discountSinglePrice',
  459. label: '折后单价',
  460. slot: 'discountSinglePrice',
  461. align: 'center'
  462. },
  463. {
  464. width: 120,
  465. prop: 'totalPrice',
  466. label: '合计',
  467. slot: 'totalPrice',
  468. align: 'center'
  469. },
  470. {
  471. width: 120,
  472. prop: 'discountTotalPrice',
  473. label: '折后合计',
  474. slot: 'discountTotalPrice',
  475. align: 'center'
  476. },
  477. {
  478. prop: 'provenance',
  479. label: '产地',
  480. slot: 'provenance',
  481. align: 'center',
  482. minWidth: 200,
  483. showOverflowTooltip: true,
  484. formatter: (row, column) => {
  485. return row.provenance && row.provenance.length
  486. ? row.provenance
  487. .map((item) => this.getDictValue('产地', item))
  488. .join(',')
  489. : '';
  490. }
  491. },
  492. // {
  493. // width: 80,
  494. // prop: 'deliveryDays',
  495. // label: '交期(天)',
  496. // slot: 'deliveryDays',
  497. // align: 'center'
  498. // },
  499. {
  500. width: 160,
  501. prop: 'deliveryDeadline',
  502. label: '交期截止日期',
  503. slot: 'deliveryDeadline',
  504. align: 'center'
  505. },
  506. {
  507. width: 200,
  508. prop: 'guaranteePeriod',
  509. label: '质保期',
  510. slot: 'guaranteePeriod',
  511. formatter: (_row, _column, cellValue) => {
  512. return (
  513. (_row.guaranteePeriod || '') + _row.guaranteePeriodUnitName
  514. );
  515. },
  516. align: 'center'
  517. },
  518. {
  519. width: 160,
  520. prop: 'guaranteePeriodDeadline',
  521. label: '质保截止日期',
  522. slot: 'guaranteePeriodDeadline',
  523. align: 'center'
  524. },
  525. {
  526. width: 130,
  527. prop: 'technicalAnswerName',
  528. label: '技术答疑人',
  529. slot: 'technicalAnswerName',
  530. align: 'center'
  531. },
  532. {
  533. width: 220,
  534. prop: 'technicalParams',
  535. label: '技术参数',
  536. slot: 'technicalParams',
  537. align: 'center'
  538. },
  539. {
  540. width: 240,
  541. prop: 'technicalDrawings',
  542. label: '技术图纸',
  543. slot: 'technicalDrawings',
  544. align: 'center'
  545. },
  546. {
  547. width: 220,
  548. prop: 'remark',
  549. label: '备注',
  550. slot: 'remark',
  551. align: 'center'
  552. },
  553. {
  554. columnKey: 'action',
  555. label: '操作',
  556. width: 120,
  557. align: 'center',
  558. resizable: false,
  559. slot: 'action',
  560. fixed: 'right',
  561. showOverflowTooltip: true
  562. }
  563. ]
  564. };
  565. },
  566. created() {
  567. this.requestDict('产地');
  568. this.requestDict('生产类型');
  569. getWarehouseList().then((res) => {
  570. this.warehouseList = res;
  571. });
  572. },
  573. computed: {},
  574. methods: {
  575. downloadFile(file) {
  576. getFile({ objectName: file.storePath }, file.name);
  577. },
  578. async warehouseChange(index, row) {
  579. const data = this.warehouseList.find(
  580. (item) => item.id == row.warehouseId
  581. );
  582. // if (warehouseIds.length > 0 && warehouseIds.includes(row.warehouseId)) {
  583. // row.warehouseId = '';
  584. // return this.$message.error('同一个产品不能选择相同的仓库');
  585. // }
  586. this.form.datasource.forEach((item, i) => {
  587. if (row.productCode == item.productCode && !item.warehouseId) {
  588. this.$set(this.form.datasource[i], 'warehouseName', data.name);
  589. this.$set(this.form.datasource[i], 'warehouseCode', data.code);
  590. this.$set(this.form.datasource[i], 'warehouseId', data.id);
  591. }
  592. });
  593. this.$set(this.form.datasource[index], 'warehouseName', data.name);
  594. this.$set(this.form.datasource[index], 'warehouseCode', data.code);
  595. this.$set(this.form.datasource[index], 'warehouseId', data.id);
  596. },
  597. //修改发货总重
  598. changeSendTotalWeight(index) {
  599. this.curIndex = index;
  600. this.setIcreaseTotalWeight();
  601. },
  602. //出库单详情
  603. handleOutBound(e, rows, index) {
  604. this.curIndex = index;
  605. this.outboundDetailsDialogFlag = true;
  606. this.$nextTick(() => {
  607. let row = {
  608. sendNo: this.outsourceSendCode,
  609. productCode: rows.productCode
  610. };
  611. this.$refs.outboundDetailsDialogRef.init(row);
  612. });
  613. },
  614. //选择退货信息回调
  615. saveDate(data = []) {
  616. let totalWeight = data.reduce((num, row) => {
  617. num += Number(row.weight);
  618. return num;
  619. }, 0);
  620. this.$set(
  621. this.form.datasource[this.curIndex],
  622. 'sendTotalWeight',
  623. totalWeight
  624. );
  625. this.setIcreaseTotalWeight();
  626. },
  627. //修改数量更新合计/总重
  628. changeNum(val, index, row) {
  629. this.curIndex = index;
  630. if (row.pricingWay == 2) {
  631. if (val != this.form.datasource[index].orderTotalCount) {
  632. this.$set(this.form.datasource[index], 'sendTotalWeight', '');
  633. this.$set(
  634. this.form.datasource[index],
  635. 'receiveTotalWeight',
  636. Number(val) * Number(this.form.datasource[index].singleWeight)
  637. );
  638. } else {
  639. let find =
  640. this.oldSendTotalWeightList.find(
  641. (key) =>
  642. key.productCode == this.form.datasource[index].productCode
  643. ) || {};
  644. this.$set(
  645. this.form.datasource[index],
  646. 'sendTotalWeight',
  647. find.oldSendTotalWeight || ''
  648. );
  649. this.$set(
  650. this.form.datasource[index],
  651. 'receiveTotalWeight',
  652. Number(val) * Number(this.form.datasource[index].singleWeight)
  653. );
  654. }
  655. this.setIcreaseTotalWeight();
  656. this.getWeightPrice();
  657. } else {
  658. this.$set(
  659. this.form.datasource[index],
  660. 'totalPrice',
  661. (Number(this.form.datasource[index].singlePrice) * val).toFixed(2)
  662. );
  663. this.$set(
  664. this.form.datasource[index],
  665. 'discountTotalPrice',
  666. (
  667. Number(this.form.datasource[index].discountSinglePrice) * val
  668. ).toFixed(2)
  669. );
  670. this.$set(
  671. this.form.datasource[index],
  672. 'receiveTotalWeight',
  673. Number(this.form.datasource[index].totalCount) *
  674. Number(this.form.datasource[index].singleWeight)
  675. );
  676. this.$set(
  677. this.form.datasource[index],
  678. 'increaseTotalWeight',
  679. Number(this.form.datasource[index].totalCount) *
  680. Number(this.form.datasource[index].singleWeight)
  681. );
  682. }
  683. },
  684. getWeightPrice() {
  685. if (this.form.datasource[this.curIndex]['pricingWay'] != 2) {
  686. reutrn;
  687. }
  688. let increaseTotalWeight =
  689. this.form.datasource[this.curIndex].increaseTotalWeight;
  690. let singlePrice = this.form.datasource[this.curIndex].singlePrice;
  691. let discountSinglePrice =
  692. this.form.datasource[this.curIndex].discountSinglePrice;
  693. this.$set(
  694. this.form.datasource[this.curIndex],
  695. 'totalPrice',
  696. (Number(increaseTotalWeight) * Number(singlePrice)).toFixed(2)
  697. );
  698. this.$set(
  699. this.form.datasource[this.curIndex],
  700. 'discountTotalPrice',
  701. (Number(discountSinglePrice) * Number(increaseTotalWeight)).toFixed(2)
  702. );
  703. },
  704. //设置增重总重
  705. setIcreaseTotalWeight() {
  706. let receiveTotalWeight = Number(
  707. this.form.datasource[this.curIndex].receiveTotalWeight
  708. );
  709. let sendTotalWeight = Number(
  710. this.form.datasource[this.curIndex].sendTotalWeight
  711. );
  712. this.$set(
  713. this.form.datasource[this.curIndex],
  714. 'increaseTotalWeight',
  715. (receiveTotalWeight - sendTotalWeight).toFixed(2)
  716. );
  717. this.getWeightPrice();
  718. this.$refs.table.reload();
  719. },
  720. //选择产品回调
  721. changeParent(obj, idx) {
  722. obj.orderTotalCount = obj.orderTotalCount || obj.totalCount;
  723. obj.id = '';
  724. this.$set(
  725. this.form.datasource,
  726. this.form.datasource.length,
  727. copyObj(obj)
  728. );
  729. this.form.datasource.forEach((item, index) => {
  730. item.receiveTotalWeight =
  731. item.receiveTotalWeight ||
  732. Number(item.totalCount) * Number(item.singleWeight) ||
  733. 0;
  734. if (this.outsourceSendCode) {
  735. item.increaseTotalWeight =
  736. Number(item.receiveTotalWeight) - Number(item.sendTotalWeight);
  737. } else {
  738. item.increaseTotalWeight =
  739. item.increaseTotalWeight || item.receiveTotalWeight || 0;
  740. }
  741. item.sendTotalWeight = item.sendTotalWeight || 0;
  742. item.pricingWay=item.pricingWay||this.pricingWay
  743. this.changeNum(item.totalCount, index,item);
  744. });
  745. },
  746. validateTotalCount(row) {
  747. return (rule, value, callback) => {
  748. if (isNaN(value) || Number(value) <= 0) {
  749. // this.$message.error('请输入大于0的数');
  750. callback(new Error('请输入大于0的数字'));
  751. } else if ((row.totalCount+(row.receiveTotalCount||0)) > row.orderTotalCount) {
  752. // this.$message.warning('收货数量大于采购总数量');
  753. callback(new Error('收货数量大于采购总数量'));
  754. } else {
  755. callback();
  756. }
  757. };
  758. },
  759. getTotalCount(row) {
  760. let num = 0;
  761. this.form.datasource
  762. .filter((item) => item.productCode == row.productCode)
  763. .forEach((item) => {
  764. num += Number(item.totalCount);
  765. });
  766. return num;
  767. },
  768. // 返回列表数据
  769. getTableValue() {
  770. let comitDatasource = this.form.datasource;
  771. if (comitDatasource.length === 0) return [];
  772. comitDatasource.forEach(async (v) => {
  773. v.totalCount = Number(v.totalCount);
  774. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  775. ? v.technicalDrawings
  776. : [];
  777. });
  778. return comitDatasource;
  779. },
  780. getPrice() {
  781. return [this.allPrice];
  782. },
  783. //修改回显
  784. async putTableValue(data = [], code) {
  785. this.$nextTick(() => {
  786. this.form.datasource = data;
  787. this.oldSendTotalWeightList = this.form.datasource.map((item) => {
  788. return {
  789. productCode: item.productCode,
  790. oldSendTotalWeight: item.sendTotalWeight
  791. };
  792. });
  793. this.form.datasource.forEach((item, index) => {
  794. item.receiveTotalWeight =
  795. item.receiveTotalWeight ||
  796. Number(item.totalCount) * Number(item.singleWeight) ||
  797. 0;
  798. if (this.outsourceSendCode) {
  799. item.increaseTotalWeight =
  800. Number(item.receiveTotalWeight) - Number(item.sendTotalWeight);
  801. } else {
  802. item.increaseTotalWeight =
  803. item.increaseTotalWeight || item.receiveTotalWeight || 0;
  804. }
  805. item.sendTotalWeight = item.sendTotalWeight || 0;
  806. item.pricingWay=item.pricingWay||this.pricingWay
  807. this.changeNum(item.totalCount, index,item);
  808. });
  809. this.$refs.table.reload();
  810. this.$forceUpdate();
  811. });
  812. },
  813. remove(i) {
  814. this.form.datasource.splice(i, 1);
  815. this.setSort();
  816. },
  817. // 清空表格
  818. restTable() {
  819. this.form.datasource = [];
  820. },
  821. // 重新排序
  822. setSort() {
  823. this.form.datasource.forEach((n, index) => {
  824. n.key = index + 1;
  825. });
  826. },
  827. // 添加
  828. handlAdd() {
  829. if (!this.orderId) return this.$message.error('请先选择订单');
  830. this.$refs.productListRef.open(this.form.datasource);
  831. },
  832. validateForm(callback) {
  833. //开始表单校验
  834. this.$refs.form.validate((valid,obj) => {
  835. if (obj) {
  836. let messages = Object.keys(obj).map((key) => obj[key][0]);
  837. if (messages.length > 0) {
  838. this.$message.warning(messages[0].message);
  839. }
  840. }
  841. callback(valid);
  842. });
  843. }
  844. }
  845. };
  846. </script>
  847. <style lang="scss" scoped>
  848. .headbox {
  849. display: flex;
  850. justify-content: space-between;
  851. align-items: center;
  852. .amount {
  853. font-size: 14px;
  854. font-weight: bold;
  855. padding-right: 30px;
  856. }
  857. }
  858. .time-form .el-form-item {
  859. margin-bottom: 0 !important;
  860. }
  861. ::v-deep .period {
  862. display: flex;
  863. .borderleftnone {
  864. .el-input--medium .el-input__inner {
  865. border-top-right-radius: 0;
  866. border-bottom-right-radius: 0;
  867. }
  868. }
  869. .borderrightnone {
  870. .el-input--medium .el-input__inner {
  871. border-top-left-radius: 0;
  872. border-bottom-left-radius: 0;
  873. }
  874. }
  875. }
  876. ::v-deep .time-form tbody > tr:hover > td {
  877. background-color: transparent !important;
  878. }
  879. ::v-deep .time-form .el-table tr {
  880. background-color: #ffffff;
  881. }
  882. .pricebox {
  883. display: flex;
  884. justify-content: flex-start;
  885. align-items: center;
  886. font-weight: bold;
  887. }
  888. </style>