inquiryTable.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. <template>
  2. <el-form :model="form" ref="form">
  3. <ele-pro-table
  4. ref="table"
  5. :needPage="false"
  6. :columns="columns"
  7. :toolkit="[]"
  8. max-height="500px"
  9. :span-method="objectSpanMethod"
  10. :datasource="form.resultList"
  11. cache-key="systemRoleTable17"
  12. class="time-form"
  13. >
  14. <!-- 表头工具栏 -->
  15. <template v-slot:toolbar>
  16. <slot name="generateContracts"></slot>
  17. <el-row type="flex" justify="end" align="middle">
  18. <el-popconfirm
  19. class="ele-action"
  20. title="确定要删除吗?"
  21. @confirm="removeSupplier"
  22. v-if="status !== 'Detail'"
  23. >
  24. <template v-slot:reference>
  25. <el-link
  26. type="danger"
  27. title="删除供应商"
  28. :underline="false"
  29. icon="el-icon-delete"
  30. >
  31. 删除
  32. </el-link>
  33. </template>
  34. </el-popconfirm>
  35. </el-row>
  36. </template>
  37. <template v-slot:supplierName="{ row, $index }">
  38. {{ form.supplierName }}
  39. </template>
  40. <template v-slot:supplierTotalPrice="{ row, $index }">
  41. {{ form.totalPrice }}
  42. </template>
  43. <template v-slot:preferentialPrice="{ row, $index }">
  44. <el-form-item
  45. prop="preferentialPrice"
  46. v-if="status !== 'Detail'"
  47. :rules="{
  48. required: true,
  49. message: '请输入优惠价',
  50. trigger: 'blur'
  51. }"
  52. >
  53. <el-input v-model="form.preferentialPrice"></el-input>
  54. </el-form-item>
  55. <span v-else>
  56. {{ form.preferentialPrice }}
  57. </span>
  58. </template>
  59. <template v-slot:settlementMode="{ row, $index }">
  60. <el-form-item
  61. prop="settlementMode"
  62. :rules="{
  63. required: true,
  64. message: '请输入优惠价',
  65. trigger: 'change'
  66. }"
  67. >
  68. <DictSelection
  69. dictName="结算方式"
  70. clearable
  71. v-model="form.settlementMode"
  72. @itemChange="chaengMode"
  73. :disabled="status == 'Detail'"
  74. >
  75. </DictSelection>
  76. </el-form-item>
  77. </template>
  78. <template v-slot:deliveryDate="{ row, $index }">
  79. <el-form-item
  80. prop="deliveryDate"
  81. v-if="status !== 'Detail'"
  82. :rules="{
  83. required: true,
  84. message: '请选择交货日期',
  85. trigger: 'change'
  86. }"
  87. >
  88. <el-date-picker
  89. style="width: 100%"
  90. clearable
  91. type="date"
  92. :disabled="status == 'Detail'"
  93. v-model="form.deliveryDate"
  94. value-format="yyyy-MM-dd"
  95. placeholder="请选择日期"
  96. @change="deliveryDateChange"
  97. >
  98. </el-date-picker>
  99. </el-form-item>
  100. <span v-else>
  101. {{ form.deliveryDate }}
  102. </span>
  103. </template>
  104. <template v-slot:taxRate="{ row, $index }">
  105. <el-form-item prop="taxRate" v-if="status !== 'Detail'">
  106. <el-input
  107. v-model="form.taxRate"
  108. style="width: 100%"
  109. :disabled="status == 'Detail'"
  110. >
  111. <template slot="suffix">%</template>
  112. </el-input>
  113. </el-form-item>
  114. <span v-else>
  115. {{ form.taxRate }}
  116. </span>
  117. </template>
  118. <template v-slot:files="{ row, $index }">
  119. <el-form-item prop="files">
  120. <fileMain
  121. v-model="row.files"
  122. :type="status == 'Detail' ? 'view' : ''"
  123. ></fileMain>
  124. <!-- <fileUpload-->
  125. <!-- v-if="status != 'Detail'"-->
  126. <!-- v-model="form.files"-->
  127. <!-- module="main"-->
  128. <!-- :showLib="false"-->
  129. <!-- :limit="5"-->
  130. <!-- />-->
  131. <!-- <div-->
  132. <!-- v-if=" form.files && form.files?.length && status == 'Detail' ">-->
  133. <!-- <el-link-->
  134. <!-- v-for="link in form.files"-->
  135. <!-- :key="link.id"-->
  136. <!-- type="primary"-->
  137. <!-- :underline="false"-->
  138. <!-- @click="downloadFile(link)"-->
  139. <!-- >-->
  140. <!-- {{ link.name }}-->
  141. <!-- </el-link-->
  142. <!-- >-->
  143. <!-- </div>-->
  144. </el-form-item>
  145. </template>
  146. <template v-slot:isWinner="{ row, $index }">
  147. <el-form-item
  148. v-if="status !== 'Detail'"
  149. :prop="'resultList.' + $index + '.isWinner'"
  150. :rules="{
  151. required: true,
  152. message: '请输入',
  153. trigger: 'change'
  154. }"
  155. >
  156. <el-select v-model="row.isWinner" :disabled="status == 'Detail'">
  157. <el-option label="是" :value="1"></el-option>
  158. <el-option label="否" :value="0"></el-option>
  159. </el-select>
  160. </el-form-item>
  161. <span v-else>
  162. {{ row.isWinner == 1 ? '是' : '否' }}
  163. </span>
  164. </template>
  165. <template
  166. v-slot:supplierProductName="{ row, $index }"
  167. v-if="status !== 'Detail'"
  168. >
  169. <el-form-item
  170. style="margin-bottom: 20px"
  171. :prop="'resultList.' + $index + '.supplierProductName'"
  172. :rules="{
  173. required: true,
  174. message: '请输入',
  175. trigger: 'change'
  176. }"
  177. >
  178. <el-input
  179. v-model="row.supplierProductName"
  180. placeholder="请输入"
  181. :disabled="status == 'Detail'"
  182. ></el-input>
  183. </el-form-item>
  184. </template>
  185. <template v-slot:supplierProductCode="scope" v-if="status !== 'Detail'">
  186. <el-form-item
  187. style="margin-bottom: 20px"
  188. :prop="'resultList.' + scope.$index + '.supplierProductCode'"
  189. :rules="{
  190. required: false,
  191. message: '请输入',
  192. trigger: 'blur'
  193. }"
  194. >
  195. <el-input
  196. v-model="scope.row.supplierProductCode"
  197. :disabled="status == 'Detail'"
  198. ></el-input>
  199. </el-form-item>
  200. </template>
  201. <template v-slot:deliveryDays="scope" v-if="status !== 'Detail'">
  202. <el-form-item
  203. style="margin-bottom: 20px"
  204. :prop="'resultList.' + scope.$index + '.deliveryDays'"
  205. >
  206. <el-input v-model="scope.row.deliveryDays"></el-input>
  207. </el-form-item>
  208. </template>
  209. <template v-slot:guaranteePeriod="scope" v-if="status !== 'Detail'">
  210. <el-form-item
  211. style="margin-bottom: 20px"
  212. :prop="'resultList.' + scope.$index + '.guaranteePeriod'"
  213. >
  214. <el-input
  215. v-model="scope.row.guaranteePeriod"
  216. :disabled="status == 'Detail'"
  217. ></el-input>
  218. </el-form-item>
  219. </template>
  220. <template v-slot:guaranteePeriodUnitCode="scope">
  221. <el-form-item
  222. style="margin-bottom: 20px"
  223. :prop="'resultList.' + scope.$index + '.guaranteePeriodUnitCode'"
  224. >
  225. <DictSelection
  226. dictName="质保期单位"
  227. clearable
  228. v-model="scope.row.guaranteePeriodUnitCode"
  229. :disabled="status == 'Detail'"
  230. @itemChange="chaengUnitCode"
  231. >
  232. </DictSelection>
  233. </el-form-item>
  234. </template>
  235. <template v-slot:singlePrice="scope" v-if="status !== 'Detail'">
  236. <el-form-item
  237. style="margin-bottom: 20px"
  238. :prop="'resultList.' + scope.$index + '.singlePrice'"
  239. :rules="{
  240. required: true,
  241. message: '请输入',
  242. trigger: 'change'
  243. }"
  244. >
  245. <el-input
  246. @blur="changeGetPrice(scope.row)"
  247. v-model="scope.row.singlePrice"
  248. :disabled="status == 'Detail'"
  249. type="number"
  250. >
  251. <template slot="suffix">元</template>
  252. </el-input>
  253. </el-form-item>
  254. </template>
  255. <template v-slot:totalCount="scope" v-if="status !== 'Detail'">
  256. <el-form-item
  257. :prop="'resultList.' + scope.$index + '.totalCount'"
  258. :rules="{
  259. required: true,
  260. message: '请输入数字',
  261. trigger: 'blur'
  262. }"
  263. >
  264. <el-input
  265. @blur="changeGetPrice(scope.row)"
  266. v-model="scope.row.totalCount"
  267. :disabled="status == 'Detail'"
  268. placeholder="请输入"
  269. type="number"
  270. ></el-input>
  271. </el-form-item>
  272. </template>
  273. <template v-slot:totalPrice="scope">
  274. <span>{{
  275. totalPrice(scope.row.totalCount, scope.row.singlePrice, scope.row)
  276. }}</span>
  277. </template>
  278. <template v-slot:provenance="scope">
  279. <el-form-item :prop="'datasource.' + scope.$index + '.provenance'">
  280. <DictSelection
  281. dictName="产地"
  282. clearable
  283. :disabled="status == 'Detail'"
  284. v-model="scope.row.provenance"
  285. multiple
  286. >
  287. </DictSelection>
  288. </el-form-item>
  289. </template>
  290. <template v-slot:modelType="scope" v-if="status !== 'Detail'">
  291. <el-form-item
  292. style="margin-bottom: 20px"
  293. :prop="'resultList.' + scope.$index + '.modelType'"
  294. >
  295. <el-input
  296. v-model="scope.row.modelType"
  297. :disabled="status == 'Detail'"
  298. ></el-input>
  299. </el-form-item>
  300. </template>
  301. <template v-slot:specification="scope" v-if="status !== 'Detail'">
  302. <el-form-item
  303. style="margin-bottom: 20px"
  304. :prop="'resultList.' + scope.$index + '.specification'"
  305. >
  306. <el-input
  307. v-model="scope.row.specification"
  308. :disabled="status == 'Detail'"
  309. ></el-input>
  310. </el-form-item>
  311. </template>
  312. <!-- <template v-slot:measuringUnit="scope">-->
  313. <!-- <el-form-item-->
  314. <!-- style="margin-bottom: 20px"-->
  315. <!-- :prop="'resultList.' + scope.$index + '.measuringUnit'"-->
  316. <!-- :rules="{-->
  317. <!-- required: false,-->
  318. <!-- message: '请输入',-->
  319. <!-- trigger: 'blur'-->
  320. <!-- }"-->
  321. <!-- >-->
  322. <!-- <el-input-->
  323. <!-- v-model="scope.row.measuringUnit"-->
  324. <!-- placeholder="请输入"-->
  325. <!-- :disabled="true"-->
  326. <!-- ></el-input>-->
  327. <!-- </el-form-item>-->
  328. <!-- </template>-->
  329. <template v-slot:remark="scope" v-if="status !== 'Detail'">
  330. <el-form-item
  331. style="margin-bottom: 20px"
  332. :prop="'resultList.' + scope.$index + '.remark'"
  333. >
  334. <el-input
  335. v-model="scope.row.remark"
  336. type="textarea"
  337. placeholder="请输入"
  338. :disabled="status == 'Detail'"
  339. ></el-input>
  340. </el-form-item>
  341. </template>
  342. <template v-slot:isRequired="{ column }">
  343. <span class="is-required">{{ column.label }}</span>
  344. </template>
  345. </ele-pro-table>
  346. </el-form>
  347. </template>
  348. <script>
  349. import { numberReg } from 'ele-admin';
  350. import dictMixins from '@/mixins/dictMixins';
  351. import fileUpload from '@/components/upload/fileUpload';
  352. import { copyObj } from '@/utils/util';
  353. import { getFile } from '@/api/system/file';
  354. import fileMain from '@/components/addDoc/index.vue';
  355. import { getInventoryTotalAPI } from '@/api/wms';
  356. const defaultColumns = [
  357. {
  358. width: 50,
  359. label: '序号',
  360. type: 'index',
  361. columnKey: 'index',
  362. align: 'center',
  363. fixed: 'left'
  364. },
  365. {
  366. minWidth: 120,
  367. prop: 'supplierName',
  368. label: '供应商',
  369. slot: 'supplierName',
  370. align: 'center',
  371. showOverflowTooltip: true,
  372. isMerge: true,
  373. fixed: 'left'
  374. },
  375. {
  376. minWidth: 80,
  377. prop: 'supplierTotalPrice',
  378. label: '总价',
  379. slot: 'supplierTotalPrice',
  380. align: 'center',
  381. showOverflowTooltip: true,
  382. isMerge: true,
  383. fixed: 'left'
  384. },
  385. {
  386. minWidth: 120,
  387. prop: 'preferentialPrice',
  388. label: '优惠后总价',
  389. slot: 'preferentialPrice',
  390. headerSlot: 'isRequired',
  391. align: 'center',
  392. showOverflowTooltip: true,
  393. isMerge: true,
  394. fixed: 'left'
  395. },
  396. {
  397. minWidth: 120,
  398. prop: 'settlementMode',
  399. label: '结算方式',
  400. slot: 'settlementMode',
  401. headerSlot: 'isRequired',
  402. align: 'center',
  403. showOverflowTooltip: true,
  404. isMerge: true,
  405. fixed: 'left'
  406. },
  407. {
  408. minWidth: 160,
  409. prop: 'deliveryDate',
  410. label: '交货日期',
  411. slot: 'deliveryDate',
  412. headerSlot: 'isRequired',
  413. align: 'center',
  414. showOverflowTooltip: true,
  415. isMerge: true,
  416. fixed: 'left'
  417. },
  418. {
  419. minWidth: 100,
  420. prop: 'productCode',
  421. label: '编码',
  422. slot: 'productCode',
  423. align: 'center',
  424. showOverflowTooltip: true
  425. },
  426. {
  427. minWidth: 100,
  428. prop: 'productName',
  429. label: '产品名称',
  430. slot: 'productName',
  431. align: 'center',
  432. showOverflowTooltip: true
  433. },
  434. {
  435. minWidth: 100,
  436. prop: 'isWinner',
  437. label: '是否中标',
  438. slot: 'isWinner',
  439. align: 'center',
  440. headerSlot: 'isRequired',
  441. showOverflowTooltip: true
  442. },
  443. {
  444. minWidth: 140,
  445. prop: 'supplierProductCode',
  446. label: '供应商产品编码',
  447. slot: 'supplierProductCode',
  448. align: 'center',
  449. showOverflowTooltip: true
  450. },
  451. {
  452. minWidth: 160,
  453. prop: 'supplierProductName',
  454. label: '供应商产品名称',
  455. slot: 'supplierProductName',
  456. headerSlot: 'isRequired',
  457. align: 'center',
  458. showOverflowTooltip: true
  459. },
  460. {
  461. minWidth: 130,
  462. prop: 'totalCount',
  463. label: '购买数量',
  464. slot: 'totalCount',
  465. headerSlot: 'isRequired',
  466. showOverflowTooltip: true,
  467. align: 'center'
  468. },
  469. {
  470. minWidth: 80,
  471. prop: 'availableCountBase',
  472. label: '库存数量',
  473. slot: 'availableCountBase',
  474. align: 'center'
  475. },
  476. {
  477. minWidth: 130,
  478. prop: 'totalCount',
  479. label: '购买数量',
  480. slot: 'totalCount',
  481. headerSlot: 'isRequired',
  482. showOverflowTooltip: true,
  483. align: 'center'
  484. },
  485. {
  486. minWidth: 80,
  487. prop: 'doneTotalCount',
  488. label: '已采数量',
  489. align: 'center'
  490. },
  491. {
  492. minWidth: 80,
  493. prop: 'waitTotalCount',
  494. label: '待采数量',
  495. align: 'center'
  496. },
  497. {
  498. minWidth: 80,
  499. prop: 'measuringUnit',
  500. label: '计量单位',
  501. slot: 'measuringUnit',
  502. showOverflowTooltip: true,
  503. align: 'center'
  504. },
  505. {
  506. minWidth: 140,
  507. prop: 'singlePrice',
  508. label: '采购单价',
  509. slot: 'singlePrice',
  510. headerSlot: 'isRequired',
  511. showOverflowTooltip: true,
  512. align: 'center'
  513. },
  514. {
  515. minWidth: 80,
  516. prop: 'totalPrice',
  517. label: '采购金额',
  518. slot: 'totalPrice',
  519. showOverflowTooltip: true,
  520. align: 'center'
  521. },
  522. {
  523. minWidth: 150,
  524. prop: 'taskName',
  525. label: '工序',
  526. slot: 'taskName',
  527. align: 'center'
  528. },
  529. {
  530. width: 110,
  531. prop: 'batchNo',
  532. label: '批次号',
  533. slot: 'batchNo',
  534. align: 'center'
  535. },
  536. {
  537. prop: 'provenance',
  538. label: '产地',
  539. slot: 'provenance',
  540. align: 'center',
  541. showOverflowTooltip: true,
  542. minWidth: 200
  543. },
  544. {
  545. minWidth: 120,
  546. prop: 'modelType',
  547. label: '型号',
  548. slot: 'modelType',
  549. showOverflowTooltip: true,
  550. align: 'center'
  551. },
  552. {
  553. minWidth: 120,
  554. prop: 'specification',
  555. label: '规格',
  556. slot: 'specification',
  557. showOverflowTooltip: true,
  558. align: 'center'
  559. },
  560. // {
  561. // width: 130,
  562. // prop: 'brand',
  563. // label: '品牌',
  564. // slot: 'brand'
  565. // },
  566. {
  567. minWidth: 80,
  568. prop: 'deliveryDays',
  569. label: '交期(天)',
  570. slot: 'deliveryDays',
  571. showOverflowTooltip: true,
  572. align: 'center'
  573. },
  574. {
  575. minWidth: 100,
  576. prop: 'guaranteePeriod',
  577. label: '质保期',
  578. slot: 'guaranteePeriod',
  579. showOverflowTooltip: true,
  580. align: 'center'
  581. },
  582. {
  583. minWidth: 120,
  584. prop: 'guaranteePeriodUnitCode',
  585. label: '质保期单位',
  586. slot: 'guaranteePeriodUnitCode',
  587. showOverflowTooltip: true,
  588. align: 'center'
  589. },
  590. {
  591. minWidth: 220,
  592. prop: 'remark',
  593. label: '备注',
  594. slot: 'remark',
  595. showOverflowTooltip: true,
  596. align: 'center'
  597. },
  598. {
  599. minWidth: 90,
  600. prop: 'taxRate',
  601. label: '税率',
  602. slot: 'taxRate',
  603. align: 'center',
  604. isMerge: true,
  605. showOverflowTooltip: true
  606. },
  607. {
  608. minWidth: 220,
  609. prop: 'files',
  610. label: '附件',
  611. slot: 'files',
  612. align: 'center',
  613. isMerge: true,
  614. showOverflowTooltip: true
  615. }
  616. ];
  617. export default {
  618. mixins: [dictMixins],
  619. components: {
  620. fileMain,
  621. fileUpload
  622. // headList
  623. },
  624. props: {
  625. obj: {},
  626. status: {
  627. default: 'edit'
  628. },
  629. radio: {
  630. default: ''
  631. },
  632. isUpdate: {
  633. default: false
  634. }
  635. },
  636. data() {
  637. const defaultForm = {
  638. key: null,
  639. endTime: '',
  640. isFirst: 0,
  641. name: ''
  642. };
  643. return {
  644. numberReg,
  645. defaultForm,
  646. radio1: '',
  647. form: {
  648. resultList: [
  649. {
  650. supplierProductCode: '',
  651. deliveryDays: '',
  652. guaranteePeriod: '',
  653. guaranteePeriodUnitCode: '',
  654. guaranteePeriodUnitName: '',
  655. measuringUnit: '',
  656. modelType: '',
  657. productCode: '',
  658. isWinner: '',
  659. remark: '',
  660. singlePrice: '',
  661. specification: '',
  662. supplierProductName: '',
  663. technicalAnswerName: '',
  664. technicalParams: '',
  665. totalCount: '',
  666. totalPrice: ''
  667. }
  668. ]
  669. },
  670. dataList: [],
  671. spanArr: [],
  672. columns: [...defaultColumns]
  673. };
  674. },
  675. computed: {},
  676. watch: {
  677. radio(n, v) {
  678. this.radio1 = n;
  679. }
  680. },
  681. created() {
  682. this.obj.resultList.forEach((item) => {
  683. this.obj['deliveryDate'] =
  684. this.obj.deliveryDate || item.expectReceiveDate;
  685. });
  686. this.form = copyObj(this.obj);
  687. this.radio1 = this.radio;
  688. this.getSpanArr();
  689. this.setDeliveryDays();
  690. this.setIsInquiry();
  691. this.getInventoryTotalAPI();
  692. // this.dataList=copyObj(this.list)
  693. },
  694. methods: {
  695. //计算交期
  696. setDeliveryDays() {
  697. console.log(this.form.resultList);
  698. this.form.resultList.forEach((item, index) => {
  699. let day =
  700. this.form.deliveryDate &&
  701. (new Date(this.form.deliveryDate).getTime() -
  702. new Date().getTime()) /
  703. 1000 /
  704. 60 /
  705. 60 /
  706. 24;
  707. this.$set(
  708. this.form.resultList[index],
  709. 'deliveryDays',
  710. Math.ceil(day) || 1
  711. );
  712. // item.deliveryDays =
  713. });
  714. this.$forceUpdate();
  715. },
  716. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  717. if (this.columns[columnIndex]?.isMerge) {
  718. const _row = this.spanArr[rowIndex]?.supplierName || 0;
  719. const _col = _row > 0 ? 1 : 0;
  720. return {
  721. rowspan: _row,
  722. colspan: _col
  723. };
  724. }
  725. return {
  726. rowspan: 1,
  727. colspan: 1
  728. };
  729. },
  730. async getInventoryTotalAPI() {
  731. let codeList = this.form.resultList.filter((item) => item.productCode).map((item) => item.productCode);
  732. //获取仓库库存
  733. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  734. this.form.resultList.filter((item) => item.productCode).forEach((item, index) => {
  735. let find =
  736. inventoryTotalList.find((key) => key.code == item.productCode) ||
  737. {};
  738. // item.availableCountBase = find.availableCountBase;
  739. this.$set(
  740. this.form.resultList[index],
  741. 'availableCountBase',
  742. find.availableCountBase
  743. );
  744. });
  745. },
  746. setIsInquiry() {
  747. return;
  748. this.$emit('setIsInquiry');
  749. },
  750. deliveryDateChange(row) {
  751. this.$emit('deliveryDateChange', (data) => {
  752. let is = false;
  753. if (data.length > 0) {
  754. data.forEach((item) => {
  755. if (
  756. new Date(this.form.deliveryDate).getTime() >
  757. new Date(item.expectReceiveDate).getTime()
  758. ) {
  759. is = true;
  760. }
  761. });
  762. }
  763. if (is) {
  764. this.$message.error('交货日期大于到货日期');
  765. }
  766. });
  767. this.setDeliveryDays();
  768. },
  769. getSpanArr() {
  770. let pos = 0;
  771. this.spanArr = [];
  772. this.form.resultList.forEach((item, index) => {
  773. if (index === 0) {
  774. let obj = {};
  775. this.columns.forEach((col) => {
  776. if (col.isMerge) {
  777. obj[col.prop] = 1;
  778. }
  779. });
  780. this.spanArr.push(obj);
  781. } else {
  782. let nameSame =
  783. item.supplierName ===
  784. this.form.resultList[index - 1].supplierName;
  785. if (nameSame) {
  786. this.spanArr[pos].supplierName += 1;
  787. this.spanArr.push({
  788. supplierName: 0,
  789. supplierTotalPrice: 0,
  790. preferentialPrice: 0,
  791. settlementMode: 0,
  792. taxRate: 0,
  793. files: 0,
  794. deliveryDate: 0
  795. });
  796. } else {
  797. pos = index;
  798. let obj = {};
  799. this.columns.forEach((col) => {
  800. if (col.isMerge) {
  801. obj[col.prop] = 1;
  802. }
  803. });
  804. this.spanArr.push(obj);
  805. }
  806. // let totalPriceSame = item.totalPrice === this.form.resultList[index - 1].totalPrice;
  807. // if (totalPriceSame) {
  808. // this.spanArr[pos].totalPrice += 1;
  809. // this.spanArr.push({ totalPrice: 0 });
  810. // } else {
  811. // pos = index;
  812. // this.spanArr.push({ totalPrice: 1 });
  813. // }
  814. }
  815. });
  816. },
  817. downloadFile(file) {
  818. getFile({ objectName: file.storePath }, file.name);
  819. },
  820. //
  821. changeGetPrice(row) {
  822. if (row.singlePrice && row.totalCount) {
  823. let num = 0;
  824. this.form.resultList.forEach((item) => {
  825. num += item.totalPrice || 0;
  826. });
  827. this.form.preferentialPrice = parseFloat(num.toFixed(2));
  828. }
  829. this.setIsInquiry();
  830. },
  831. //计算销售金额
  832. totalPrice(a, b, row) {
  833. if (!a || !b) {
  834. return;
  835. }
  836. row.totalPrice = parseFloat((a * b).toFixed(2));
  837. this.totalPriceAll();
  838. return row.totalPrice;
  839. },
  840. //计算销售总价
  841. totalPriceAll() {
  842. let num = 0;
  843. this.form.resultList.forEach((item) => {
  844. num += item.totalPrice || 0;
  845. });
  846. this.form.totalPrice = parseFloat(num.toFixed(2));
  847. // this.form.preferentialPrice = parseFloat(num.toFixed(2));
  848. // console.log(this.form.resultList,'dasdasd')
  849. },
  850. // 返回列表数据
  851. getTableValue() {
  852. return this.form;
  853. },
  854. chaengMode(data) {
  855. this.form.settlementModeName = data.dictValue;
  856. },
  857. chaengUnitCode(data) {
  858. this.form.settlementModeName = data.dictValue;
  859. },
  860. //修改回显
  861. putTableValue(data) {
  862. this.form.resultList = copyObj(data);
  863. this.setDeliveryDays();
  864. this.setIsInquiry();
  865. },
  866. remove(productCode) {
  867. let index = this.form.resultList.findIndex(
  868. (item) => item.productCode == productCode
  869. );
  870. this.form.resultList.splice(index, 1);
  871. this.setIsInquiry();
  872. this.setSort();
  873. },
  874. removeSupplier() {
  875. this.$emit('removeSupplier', this.form.supplierId);
  876. },
  877. // 清空表格
  878. restTable() {
  879. this.form.resultList = [];
  880. },
  881. // 重新排序
  882. setSort() {
  883. this.form.resultList.forEach((n, index) => {
  884. n.key = index + 1;
  885. });
  886. },
  887. validateForm(callback) {
  888. //开始表单校验
  889. this.$refs.form.validate((valid) => {
  890. callback(valid);
  891. });
  892. }
  893. }
  894. };
  895. </script>
  896. <style lang="scss" scoped>
  897. .headbox {
  898. display: flex;
  899. justify-content: space-between;
  900. align-items: center;
  901. .amount {
  902. font-size: 14px;
  903. font-weight: bold;
  904. }
  905. }
  906. .time-form .el-form-item {
  907. margin-bottom: 0 !important;
  908. }
  909. ::v-deep .period {
  910. display: flex;
  911. .borderleftnone {
  912. .el-input--medium .el-input__inner {
  913. border-top-right-radius: 0;
  914. border-bottom-right-radius: 0;
  915. }
  916. }
  917. .borderrightnone {
  918. .el-input--medium .el-input__inner {
  919. border-top-left-radius: 0;
  920. border-bottom-left-radius: 0;
  921. }
  922. }
  923. }
  924. ::v-deep .time-form tbody > tr:hover > td {
  925. background-color: transparent !important;
  926. }
  927. ::v-deep .time-form .el-table tr {
  928. background-color: #ffffff;
  929. }
  930. ::v-deep .el-upload-list--text {
  931. width: 75%;
  932. }
  933. </style>