inventoryTable.vue 27 KB

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