inventoryTable.vue 27 KB

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