inquiryTable.vue 28 KB

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