inquiryTable.vue 33 KB

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