inventoryTableDetails.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343
  1. <template>
  2. <el-form ref="form">
  3. <ele-pro-table
  4. ref="table"
  5. :needPage="false"
  6. :columns="columns"
  7. :datasource="form.datasource"
  8. row-key="id"
  9. height="350"
  10. full-height="calc(100vh - 76px)"
  11. class="time-form"
  12. :selection.sync="selection"
  13. @columns-change="handleColumnChange"
  14. @header-dragend="handleHeaderDragend"
  15. @select="handleSelectionChange"
  16. @select-all="handleSelectionChange"
  17. :cache-key="cacheKeyUrl"
  18. @done="handleDone"
  19. >
  20. <!-- :show-summary="showSummary"
  21. :summary-method="getSummaries" -->
  22. <!-- 原有插槽 -->
  23. <template v-slot:technicalDrawings="scope">
  24. <el-form-item
  25. style="margin-bottom: 20px"
  26. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  27. >
  28. <fileMain
  29. v-model="scope.row.technicalDrawings"
  30. type="view"
  31. lazy-render
  32. defer-modal
  33. ></fileMain>
  34. </el-form-item>
  35. </template>
  36. <!-- 编码:该产品存在替代料时给出“替”标识 -->
  37. <template v-slot:productCode="{ row }">
  38. <div class="replace-code-cell">
  39. <span class="code-text" :title="row.productCode">{{
  40. row.productCode
  41. }}</span>
  42. <el-tooltip v-if="hasReplace(row)" placement="top" effect="dark">
  43. <el-tag type="warning" size="mini" effect="dark">替</el-tag>
  44. <div slot="content" class="replace-tip">
  45. <div
  46. v-for="(item, index) in getReplaceTipLines(row)"
  47. :key="'tip-' + index"
  48. >
  49. {{ item }}
  50. </div>
  51. </div>
  52. </el-tooltip>
  53. </div>
  54. </template>
  55. <template v-slot:customerReqFiles="scope">
  56. <el-form-item
  57. style="margin-bottom: 20px"
  58. :prop="'datasource.' + scope.$index + '.customerReqFiles'"
  59. >
  60. <fileMain
  61. v-model="scope.row.customerReqFiles"
  62. type="view"
  63. lazy-render
  64. defer-modal
  65. ></fileMain>
  66. </el-form-item>
  67. </template>
  68. <template v-slot:industryArtFiles="scope">
  69. <el-form-item
  70. style="margin-bottom: 20px"
  71. :prop="'datasource.' + scope.$index + '.industryArtFiles'"
  72. >
  73. <fileMain
  74. v-model="scope.row.industryArtFiles"
  75. type="view"
  76. lazy-render
  77. defer-modal
  78. ></fileMain>
  79. </el-form-item>
  80. </template>
  81. <template v-slot:otherFiles="scope">
  82. <el-form-item
  83. style="margin-bottom: 20px"
  84. :prop="'datasource.' + scope.$index + '.otherFiles'"
  85. >
  86. <fileMain
  87. v-model="scope.row.otherFiles"
  88. type="view"
  89. lazy-render
  90. defer-modal
  91. ></fileMain>
  92. </el-form-item>
  93. </template>
  94. <template v-slot:customerExpectDeliveryDeadline="scope">
  95. <div v-if="scope.row.arrivalWay == 1 || !scope.row.arrivalWay">
  96. {{ scope.row.customerExpectDeliveryDeadline }}
  97. </div>
  98. <div v-if="scope.row.arrivalWay == 2">
  99. <el-link
  100. type="primary"
  101. :underline="false"
  102. @click.native="handleMethod(scope.row)"
  103. >
  104. 查看分批时间
  105. </el-link>
  106. </div>
  107. </template>
  108. <template v-slot:saleCount="scope">
  109. <el-form-item
  110. style="margin-bottom: 20px"
  111. :prop="'datasource.' + scope.$index + '.' + countObj.countKey"
  112. >
  113. {{ scope.row[countObj.countKey]
  114. }}{{ scope.row[countObj.unitKey] || scope.row.measuringUnit }}
  115. </el-form-item>
  116. </template>
  117. <template v-slot:modelKey="scope">
  118. <el-form-item
  119. style="margin-bottom: 20px"
  120. :prop="'datasource.' + scope.$index + '.modelKey'"
  121. >
  122. {{
  123. scope.row.modelKey
  124. ? Array.isArray(scope.row.modelKey)
  125. ? scope.row.modelKey.join(',')
  126. : scope.row.modelKey
  127. : ''
  128. }}
  129. </el-form-item>
  130. </template>
  131. <template v-slot:colorKey="scope">
  132. <el-form-item
  133. style="margin-bottom: 20px"
  134. :prop="'datasource.' + scope.$index + '.colorKey'"
  135. >
  136. {{
  137. scope.row.colorKey
  138. ? Array.isArray(scope.row.colorKey)
  139. ? scope.row.colorKey.join(',')
  140. : scope.row.colorKey
  141. : ''
  142. }}
  143. </el-form-item>
  144. </template>
  145. <template v-slot:bomAction="scope">
  146. <el-link
  147. type="primary"
  148. :underline="false"
  149. icon="el-icon-document"
  150. @click.native="openBomDetail(scope.row)"
  151. >
  152. BOM详情<span v-if="rowBomCount(scope.row)">({{ rowBomCount(scope.row) }})</span>
  153. </el-link>
  154. </template>
  155. <!-- 表头工具栏 -->
  156. <template v-slot:toolbar>
  157. <div class="headbox">
  158. <div class="pricebox">
  159. <span class="amount" v-if="showSummary"
  160. >数量合计:{{ allQuantity }}</span
  161. >
  162. <span class="amount" v-if="isAllPrice">总计:{{ allPrice }}元</span>
  163. <span class="amount" v-if="isDiscountTotalPrice"
  164. >优惠后总金额:{{ form.discountTotalPrice }}元</span
  165. >
  166. </div>
  167. </div>
  168. </template>
  169. </ele-pro-table>
  170. <timeDialog ref="timeDialogRef" :view="true"></timeDialog>
  171. </el-form>
  172. </template>
  173. <script>
  174. import dictMixins from '@/mixins/dictMixins';
  175. import { lbjtList } from '@/enum/dict.js';
  176. import { contactQueryByCategoryIdsAPI } from '@/api/saleManage/contact';
  177. import timeDialog from '@/components/timeDialog/index.vue';
  178. import tabMixins from '@/mixins/tableColumnsMixin';
  179. import { levelList, pricingWayList, quoteTypeOp } from '@/enum/dict.js';
  180. import {
  181. getInventoryTotalAPI,
  182. buildInventoryTotalQueryKey,
  183. matchInventoryTotal
  184. } from '@/api/wms';
  185. import { getSummaries } from '@/utils/util.js';
  186. import {
  187. getAllQuantity,
  188. getAllPrice,
  189. getAllDiscountPrice,
  190. formatPrice
  191. } from '@/BIZComponents/setProduct.js';
  192. const dayjs = require('dayjs');
  193. export default {
  194. mixins: [dictMixins, tabMixins],
  195. components: {
  196. timeDialog
  197. },
  198. props: {
  199. isReelSpecification: {
  200. type: Boolean,
  201. default: false
  202. },
  203. // 是否显示「操作」列(BOM详情):只有报价单详情传 true,其它单据不受影响
  204. showBomDetail: {
  205. default: false,
  206. type: Boolean
  207. },
  208. isDiscountTotalPrice: {
  209. default: false,
  210. type: Boolean
  211. },
  212. isGuaranteePeriod: {
  213. default: true,
  214. type: Boolean
  215. },
  216. isDiscount: {
  217. //折让
  218. type: Boolean,
  219. default: true
  220. },
  221. isCustomerMark: {
  222. //客户代号必填
  223. type: Boolean,
  224. default: false
  225. },
  226. pageName: {
  227. default: ''
  228. },
  229. isChangeCount: {
  230. //默认计算
  231. type: Boolean,
  232. default: true
  233. },
  234. contractBookType: {
  235. //合同类型 1销售 2采购
  236. type: [String, Number],
  237. default: 1
  238. },
  239. isArrivalWay: {
  240. //分批到货时间
  241. type: Boolean,
  242. default: false
  243. },
  244. // 父组件多数不传,必须有非空默认值(空串会让缓存键退化成 'Cols')
  245. cacheKeyUrl: {
  246. type: String,
  247. default: 'eom-BIZComponents-inventoryTableDetails'
  248. },
  249. //是否显示订单编码
  250. isOrderNo: {
  251. type: Boolean,
  252. default: false
  253. },
  254. //显示库存
  255. isWms: {
  256. type: Boolean,
  257. default: false
  258. },
  259. // 替代料信息:{ 产品编码: [{ docNo, replaceCode, replaceName }] }
  260. // 订单详情等上层场景由父组件聚合下发,用于编码列的“替”标识
  261. replaceInfoMap: {
  262. type: Object,
  263. default: () => ({})
  264. },
  265. //
  266. isAllPrice: {
  267. type: Boolean,
  268. default: true
  269. },
  270. maxHeight: {
  271. default: 350
  272. },
  273. countObj: {
  274. type: Object,
  275. default: () => {
  276. return {
  277. countKey: 'saleCount',
  278. unitKey: 'saleUnit',
  279. unitIdKey: 'saleUnitId'
  280. };
  281. }
  282. },
  283. //是否显示生产要求
  284. isProductionRequirements: {
  285. type: Boolean,
  286. default: false
  287. },
  288. // 强制隐藏生产要求列:用于后端明细表没有该字段的单据(如报价单)
  289. isHideProductionRequirements: {
  290. type: Boolean,
  291. default: false
  292. },
  293. // 是否勾选
  294. isSelected: {
  295. type: Boolean,
  296. default: false
  297. },
  298. // 选中的列表返显
  299. selectedIds: {
  300. type: Array,
  301. default: () => {
  302. return [];
  303. }
  304. },
  305. //是否显示增重重量
  306. isIncreaseTotalWeight: {
  307. type: Boolean,
  308. default: false
  309. },
  310. quoteType: {
  311. type: Number,
  312. default: 1
  313. },
  314. showSummary: {
  315. type: Boolean,
  316. default: false
  317. },
  318. showSortLine: {
  319. type: Boolean,
  320. default: false
  321. }
  322. },
  323. data() {
  324. return {
  325. allPrice: 0,
  326. allQuantity: 0,
  327. supplierObj: [],
  328. form: {
  329. discountTotalPrice: 0,
  330. datasource: []
  331. },
  332. columnsVersion: 1,
  333. // 新增:存储data中的type值,用于控制新增字段显示
  334. dataType: null,
  335. selection: [],
  336. quoteTypeOp
  337. };
  338. },
  339. computed: {
  340. columns() {
  341. console.log(this.quoteType, 'this.quoteType');
  342. // 触发 mixin 重算 + 应用列宽
  343. this.columnsVersion;
  344. // 基础列(新增字段之前的列)
  345. const baseColumns = [
  346. {
  347. width: 45,
  348. type: 'index',
  349. columnKey: 'index',
  350. align: 'center'
  351. },
  352. {
  353. width: 45,
  354. type: 'selection',
  355. columnKey: 'selection',
  356. align: 'center',
  357. selectable: (row, index) => {
  358. return !row.sendTotalCount;
  359. }
  360. },
  361. {
  362. minWidth: 100,
  363. prop: 'sortCode',
  364. slot: 'sortCode',
  365. label: '排序',
  366. isNone: !this.showSortLine,
  367. showOverflowTooltip: true,
  368. align: 'center'
  369. },
  370. {
  371. minWidth: 200,
  372. prop: 'orderNo',
  373. label: '订单编码',
  374. showOverflowTooltip: true,
  375. align: 'center',
  376. isNone: !this.isOrderNo
  377. },
  378. {
  379. width: 280,
  380. prop: 'productName',
  381. label: '名称',
  382. slot: 'productName',
  383. headerSlot: 'headerProductName',
  384. align: 'center'
  385. },
  386. {
  387. width: 150,
  388. prop: 'productCode',
  389. label: '编码',
  390. slot: 'productCode',
  391. align: 'center'
  392. },
  393. {
  394. width: 200,
  395. prop: 'productCategoryName',
  396. label: '类型',
  397. slot: 'productCategoryName',
  398. align: 'center'
  399. },
  400. {
  401. width: 120,
  402. prop: 'specification',
  403. label: '规格',
  404. slot: 'specification',
  405. align: 'center'
  406. },
  407. {
  408. width: 140,
  409. prop: 'pricingWay',
  410. label: '计价方式',
  411. align: 'center',
  412. fixed: 'left',
  413. isNone: this.quoteType === 2,
  414. formatter: (row, column) => {
  415. return pricingWayList.find((item) => item.id == row.pricingWay)
  416. ?.name;
  417. }
  418. }
  419. ];
  420. // 条件显示的新增字段列(仅当quoteType为2时显示)
  421. const additionalColumns =
  422. this.quoteType === 2
  423. ? [
  424. // 新增字段:厚度
  425. {
  426. width: 150,
  427. prop: 'thickNess',
  428. label: '厚度',
  429. slot: 'thickNess',
  430. formatter: (row, column) => {
  431. if (row.thickNess) {
  432. return row.thickNess + ' mm';
  433. }
  434. },
  435. align: 'center'
  436. },
  437. // 新增字段:平方数
  438. {
  439. width: 150,
  440. prop: 'squareNumber',
  441. label: '平方数',
  442. formatter: (row, column) => {
  443. if (row.squareNumber) {
  444. return row.squareNumber + 'm²';
  445. }
  446. },
  447. align: 'center'
  448. },
  449. // 新增字段:加工费(未税)
  450. {
  451. width: 150,
  452. prop: 'processingFeeBeforeTax',
  453. label: '加工费(未税)',
  454. formatter: (row, column) => {
  455. if (row.processingFeeBeforeTax) {
  456. return row.processingFeeBeforeTax + ' 元';
  457. }
  458. },
  459. align: 'center'
  460. },
  461. // 新增字段:包装费(未税)
  462. {
  463. width: 150,
  464. prop: 'packagingFeeNotTaxed',
  465. label: '包装费(未税)',
  466. formatter: (row, column) => {
  467. if (row.packagingFeeNotTaxed) {
  468. return row.packagingFeeNotTaxed + ' 元';
  469. }
  470. },
  471. align: 'center'
  472. },
  473. // 新增字段:运输费(未税)
  474. {
  475. width: 150,
  476. prop: 'transportationFeeWithoutTax',
  477. label: '运输费(未税)',
  478. formatter: (row, column) => {
  479. if (row.transportationFeeWithoutTax) {
  480. return row.transportationFeeWithoutTax + ' 元';
  481. }
  482. },
  483. align: 'center'
  484. },
  485. // 新增字段:未税小计
  486. {
  487. width: 150,
  488. prop: 'quotationSubtotalBeforeTax',
  489. label: '未税小计',
  490. align: 'center',
  491. formatter: (row, column) => {
  492. if (row.quotationSubtotalBeforeTax) {
  493. return row.quotationSubtotalBeforeTax + ' 元';
  494. }
  495. }
  496. },
  497. // 新增字段:税率(%)
  498. {
  499. width: 150,
  500. prop: 'extraTax',
  501. label: '税率(%)',
  502. align: 'center',
  503. formatter: (row, column) => {
  504. return row.extraTax;
  505. }
  506. },
  507. // 新增字段:含税小计
  508. {
  509. width: 150,
  510. prop: 'quotationSubtotalTax',
  511. label: '含税小计',
  512. align: 'center',
  513. formatter: (row, column) => {
  514. if (row.quotationSubtotalTax) {
  515. return row.quotationSubtotalTax + ' 元';
  516. }
  517. }
  518. }
  519. ]
  520. : [];
  521. // 剩余列(新增字段之后的列)
  522. const remainingColumns = [
  523. {
  524. width: 200,
  525. prop: 'customerMark',
  526. label: this.contractBookType == 1 ? '客户代号' : '供应商代号',
  527. slot: 'customerMark',
  528. headerSlot: 'headerCustomerMark',
  529. isNone: this.quoteType === 2,
  530. align: 'center'
  531. },
  532. {
  533. minWidth: 240,
  534. prop: 'taskName',
  535. label: '工序',
  536. slot: 'taskName',
  537. align: 'center'
  538. },
  539. {
  540. minWidth: 160,
  541. prop: 'productionCodes',
  542. label: '生产编号',
  543. isNone: this.quoteType === 2,
  544. align: 'center'
  545. },
  546. {
  547. minWidth: 280,
  548. prop: 'productionRequirements',
  549. label: '生产要求',
  550. align: 'center',
  551. isNone:
  552. this.isHideProductionRequirements ||
  553. (!this.isProductionRequirements && this.quoteType === 2)
  554. },
  555. {
  556. minWidth: 280,
  557. prop: 'cuttingLength',
  558. label: '裁线米段',
  559. align: 'center',
  560. slot: 'cuttingLength',
  561. isNone: this.quoteType === 2
  562. },
  563. {
  564. minWidth: 120,
  565. prop: 'entrustedEnterpriseId',
  566. label: '受托企业',
  567. slot: 'entrustedEnterpriseId',
  568. isNone: !this.isCustomerMark,
  569. align: 'center',
  570. showOverflowTooltip: true,
  571. formatter: (row, column) => {
  572. return (
  573. this.supplierObj[row.productId]?.find(
  574. (item) => item.id === row.entrustedEnterpriseId
  575. )?.name || ''
  576. );
  577. }
  578. },
  579. {
  580. width: 180,
  581. prop: 'saleCount',
  582. label: '数量',
  583. slot: 'saleCount',
  584. headerSlot: 'headerTotalCount',
  585. align: 'center'
  586. },
  587. {
  588. width: 120,
  589. prop: 'packingSpecification',
  590. align: 'center',
  591. label: '包装规格',
  592. isNone: this.quoteType === 2,
  593. showOverflowTooltip: true
  594. },
  595. {
  596. width: 150,
  597. prop: 'totalCount',
  598. label: '计量数量',
  599. slot: 'totalCount',
  600. isNone: this.quoteType === 2,
  601. headerSlot: 'headerTotalCount',
  602. formatter: (row, column) => {
  603. if (row.totalCount) {
  604. return row.totalCount + ' ' + (row.measuringUnit || '');
  605. }
  606. },
  607. align: 'center'
  608. },
  609. {
  610. width: 120,
  611. prop: 'warehouseName',
  612. label: '仓库名称',
  613. slot: 'warehouseName',
  614. align: 'center'
  615. },
  616. {
  617. minWidth: 160,
  618. prop: 'stockCountBase',
  619. label: '库存数量',
  620. showOverflowTooltip: true,
  621. align: 'center',
  622. isNone: !this.isWms
  623. },
  624. {
  625. minWidth: 160,
  626. prop: 'availableCountBase',
  627. label: this.isWms ? '可用数量' : '库存数量',
  628. showOverflowTooltip: true,
  629. align: 'center'
  630. },
  631. {
  632. minWidth: 140,
  633. prop: 'sendTotalCount',
  634. label: '已发货数量',
  635. slot: 'sendTotalCount',
  636. align: 'center',
  637. isNone: this.pageName != 'send',
  638. formatter: (row, column) => {
  639. if (row.sendTotalCount) {
  640. return row.sendTotalCount + ' ' + (row.measuringUnit || '');
  641. }
  642. }
  643. },
  644. {
  645. minWidth: 140,
  646. prop: 'notSendTotalCount',
  647. label: '未发货数量',
  648. slot: 'notSendTotalCount',
  649. isNone: this.pageName != 'send',
  650. align: 'center',
  651. formatter: (row, column) => {
  652. if (row.notSendTotalCount) {
  653. return row.notSendTotalCount + ' ' + (row.measuringUnit || '');
  654. }
  655. }
  656. },
  657. {
  658. width: 140,
  659. prop: 'singleWeight',
  660. label: '单重',
  661. slot: 'singleWeight',
  662. headerSlot: 'headerSingleWeight',
  663. formatter: (row, column) => {
  664. if (row.singleWeight) {
  665. return row.singleWeight + ' ' + (row.weightUnit || '');
  666. }
  667. },
  668. align: 'center'
  669. },
  670. {
  671. width: 140,
  672. prop: 'totalWeight',
  673. label: '总重',
  674. slot: 'totalWeight',
  675. formatter: (row, column) => {
  676. if (row.totalWeight) {
  677. return row.totalWeight + ' ' + (row.weightUnit || '');
  678. }
  679. },
  680. align: 'center'
  681. },
  682. {
  683. width: 180,
  684. prop: 'increaseTotalWeight',
  685. label: '增重重量',
  686. isNone: this.quoteType === 2 || !this.isIncreaseTotalWeight,
  687. formatter: (row, column) => {
  688. if (row.increaseTotalWeight) {
  689. return row.increaseTotalWeight + ' ' + (row.weightUnit || '');
  690. }
  691. },
  692. align: 'center'
  693. },
  694. {
  695. width: 160,
  696. prop: 'goodsPriceType',
  697. label: '价格类型',
  698. isNone: this.quoteType === 2,
  699. formatter: (row, column) => {
  700. return this.getDictValue('商品价格类型', row.goodsPriceType);
  701. },
  702. align: 'center'
  703. },
  704. {
  705. width: 200,
  706. prop: 'singlePrice',
  707. label: '单价',
  708. slot: 'singlePrice',
  709. isNone: this.quoteType === 2,
  710. headerSlot: 'headerSinglePrice',
  711. align: 'center'
  712. },
  713. {
  714. width: 160,
  715. prop: 'taxRate',
  716. label: '税率',
  717. isNone: this.quoteType === 2,
  718. formatter: (_row, _column, cellValue) => {
  719. return _row.taxRate ? _row.taxRate + '%' : '';
  720. },
  721. align: 'center'
  722. },
  723. {
  724. width: 150,
  725. prop: 'notaxSinglePrice',
  726. label: '不含税单价',
  727. isNone: this.quoteType === 2,
  728. slot: 'notaxSinglePrice',
  729. align: 'center'
  730. },
  731. {
  732. width: 140,
  733. prop: 'quoteWay',
  734. label: '报价方式',
  735. align: 'center',
  736. isNone: !this.isDiscount,
  737. formatter: (_row, _column, cellValue) => {
  738. return (
  739. this.quoteTypeOp.find((item) => item.value == _row.quoteWay)
  740. ?.label || ''
  741. );
  742. }
  743. },
  744. {
  745. width: 140,
  746. prop: 'discountRatio',
  747. label: '折让比例',
  748. align: 'center',
  749. isNone: !this.isDiscount,
  750. formatter: (_row, _column, cellValue) => {
  751. return _row.discountRatio ? _row.discountRatio + '%' : '';
  752. }
  753. },
  754. {
  755. width: 160,
  756. prop: 'discountSinglePrice',
  757. label: '折让单价',
  758. align: 'center',
  759. isNone: !this.isDiscount,
  760. formatter: (_row, _column, cellValue) => {
  761. return _row.discountSinglePrice
  762. ? Number(_row.discountSinglePrice).toFixed(2)
  763. : '';
  764. }
  765. },
  766. {
  767. width: 120,
  768. prop: 'totalPrice',
  769. label: '合计',
  770. slot: 'totalPrice',
  771. formatter: (row, column) => {
  772. if (row.totalPrice) {
  773. return row.totalPrice + ' 元';
  774. }
  775. },
  776. align: 'center'
  777. },
  778. {
  779. width: 160,
  780. prop: 'discountTotalPrice',
  781. label: '折让合计',
  782. align: 'center',
  783. isNone: !this.isDiscount,
  784. formatter: (_row, _column, cellValue) => {
  785. return _row.discountTotalPrice
  786. ? Number(_row.discountTotalPrice).toFixed(2)
  787. : '';
  788. }
  789. },
  790. {
  791. minWidth: 120,
  792. prop: 'goodsLevel',
  793. label: '物品级别',
  794. isNone: this.quoteType === 2,
  795. formatter: (_row, _column, cellValue) => {
  796. return levelList.find((item) => item.value == _row.goodsLevel)
  797. ?.label;
  798. },
  799. align: 'center'
  800. },
  801. {
  802. width: 110,
  803. prop: 'batchNo',
  804. label: '批次号',
  805. slot: 'batchNo',
  806. isNone: this.quoteType === 2,
  807. align: 'center'
  808. },
  809. {
  810. width: 150,
  811. prop: 'reelSpecification',
  812. label: '盘具',
  813. isNone: !this.isReelSpecification,
  814. showOverflowTooltip: true,
  815. align: 'center'
  816. },
  817. {
  818. width: 160,
  819. prop: 'productBrand',
  820. label: '牌号',
  821. slot: 'productBrand',
  822. isNone: this.quoteType === 2,
  823. align: 'center'
  824. },
  825. {
  826. width: 120,
  827. prop: 'modelType',
  828. label: '型号',
  829. slot: 'modelType',
  830. isNone: this.quoteType === 2,
  831. align: 'center'
  832. },
  833. {
  834. minWidth: 120,
  835. prop: 'modelKey',
  836. label: '机型',
  837. slot: 'modelKey',
  838. isNone: this.quoteType === 2,
  839. showOverflowTooltip: true,
  840. align: 'center'
  841. },
  842. {
  843. minWidth: 120,
  844. prop: 'colorKey',
  845. slot: 'colorKey',
  846. showOverflowTooltip: true,
  847. label: '颜色',
  848. isNone: this.quoteType === 2,
  849. align: 'center'
  850. },
  851. {
  852. width: 120,
  853. prop: 'imgCode',
  854. align: 'center',
  855. label: '图号/件号',
  856. isNone: this.quoteType === 2,
  857. showOverflowTooltip: true
  858. },
  859. {
  860. prop: 'provenance',
  861. label: '产地',
  862. slot: 'provenance',
  863. align: 'center',
  864. isNone: this.quoteType === 2,
  865. minWidth: 200,
  866. showOverflowTooltip: true,
  867. formatter: (row, column) => {
  868. return row.provenance && row.provenance.length
  869. ? row.provenance
  870. .map((item) => this.getDictValue('产地', item))
  871. .join(',')
  872. : '';
  873. }
  874. },
  875. {
  876. width: 120,
  877. prop: 'produceType',
  878. align: 'center',
  879. label: '属性类型',
  880. isNone: this.quoteType === 2,
  881. showOverflowTooltip: true,
  882. formatter: (row, column) => {
  883. if (row.produceType) {
  884. return row.produceType
  885. .map((item) => {
  886. return lbjtList[item];
  887. })
  888. .toString();
  889. }
  890. }
  891. },
  892. {
  893. width: 160,
  894. prop: 'arrivalWay',
  895. label: '到货方式',
  896. align: 'center',
  897. isNone: !this.isArrivalWay || this.quoteType === 2,
  898. formatter: (_row, _column, cellValue) => {
  899. return _row.arrivalWay == 1
  900. ? '一次性到货'
  901. : _row.arrivalWay == 2
  902. ? '分批到货'
  903. : '';
  904. }
  905. },
  906. {
  907. width: 160,
  908. prop: 'customerExpectDeliveryDeadline',
  909. label: this.contractBookType == 1 ? '客户期望交期' : '交付日期',
  910. slot: 'customerExpectDeliveryDeadline',
  911. align: 'center'
  912. },
  913. {
  914. width: 160,
  915. prop: 'produceDeliveryDeadline',
  916. label: '生产交付交期',
  917. slot: 'produceDeliveryDeadline',
  918. isNone: this.contractBookType != 1,
  919. headerSlot: 'headerProduceDeliveryDeadline',
  920. align: 'center'
  921. },
  922. {
  923. width: 200,
  924. prop: 'guaranteePeriod',
  925. label: '有效期',
  926. isNone: this.quoteType === 2,
  927. slot: 'guaranteePeriod',
  928. align: 'center',
  929. formatter: (_row, _column, cellValue) => {
  930. return (
  931. (_row.guaranteePeriod || '') + _row.guaranteePeriodUnitName
  932. );
  933. }
  934. },
  935. {
  936. width: 200,
  937. prop: 'guaranteePeriodDeadline',
  938. label: '有效期截止日期',
  939. isNone: !this.isGuaranteePeriod || this.quoteType === 2,
  940. slot: 'guaranteePeriodDeadline',
  941. align: 'center'
  942. },
  943. {
  944. width: 220,
  945. prop: 'customerReqFiles',
  946. label: '客户需求',
  947. slot: 'customerReqFiles',
  948. isNone: this.quoteType === 2,
  949. align: 'center'
  950. },
  951. {
  952. width: 100,
  953. prop: 'density',
  954. isNone: this.quoteType === 2,
  955. label: '密度',
  956. align: 'center'
  957. },
  958. {
  959. width: 150,
  960. prop: 'productType',
  961. isNone: this.quoteType === 2,
  962. label: '生产加工方式',
  963. align: 'center',
  964. formatter: (_row, _column, cellValue) => {
  965. return _row.productType == 2
  966. ? '加工'
  967. : _row.productType == 3
  968. ? '装配'
  969. : '';
  970. }
  971. },
  972. {
  973. width: 130,
  974. prop: 'technicalAnswerName',
  975. label: '技术答疑人',
  976. isNone: this.quoteType === 2,
  977. slot: 'technicalAnswerName',
  978. align: 'center'
  979. },
  980. {
  981. width: 220,
  982. prop: 'technicalParams',
  983. label: '技术参数',
  984. isNone: this.quoteType === 2,
  985. slot: 'technicalParams',
  986. align: 'center'
  987. },
  988. {
  989. width: 240,
  990. prop: 'technicalDrawings',
  991. label: '技术图纸',
  992. slot: 'technicalDrawings',
  993. align: 'center'
  994. },
  995. {
  996. width: 120,
  997. prop: 'drawingVersion',
  998. isNone: this.quoteType === 2,
  999. label: '图纸版本',
  1000. align: 'center'
  1001. },
  1002. {
  1003. width: 240,
  1004. prop: 'technologyRouteName',
  1005. label: '工艺路线',
  1006. isNone: this.quoteType === 2,
  1007. slot: 'technologyRouteName',
  1008. align: 'center'
  1009. },
  1010. {
  1011. width: 240,
  1012. prop: 'industryArtFiles',
  1013. label: '工艺附件',
  1014. isNone: this.quoteType === 2,
  1015. slot: 'industryArtFiles',
  1016. align: 'center'
  1017. },
  1018. {
  1019. width: 240,
  1020. prop: 'otherFiles',
  1021. label: '其他附件',
  1022. slot: 'otherFiles',
  1023. isNone: this.quoteType === 2,
  1024. align: 'center'
  1025. },
  1026. {
  1027. width: 220,
  1028. prop: 'remark',
  1029. label: '备注',
  1030. slot: 'remark',
  1031. align: 'center'
  1032. }
  1033. ];
  1034. // 合并所有列,统一应用列宽缓存(无缓存时保持默认宽度)
  1035. const mergedColumns = [
  1036. ...baseColumns,
  1037. ...additionalColumns,
  1038. ...remainingColumns
  1039. ].filter((item) => !item.isNone);
  1040. if (this.showBomDetail) {
  1041. mergedColumns.push({
  1042. width: 130,
  1043. columnKey: 'bomAction',
  1044. label: '操作',
  1045. slot: 'bomAction',
  1046. fixed: 'right',
  1047. align: 'center'
  1048. });
  1049. }
  1050. return this.applyColumnWidth(mergedColumns);
  1051. }
  1052. },
  1053. created() {
  1054. this.requestDict('产地');
  1055. this.requestDict('商品价格类型');
  1056. },
  1057. methods: {
  1058. // 取该产品的替代料信息(按产品编码聚合,可能对应多张发货单)
  1059. getReplaceList(row) {
  1060. const map = this.replaceInfoMap || {};
  1061. const list = row && row.productCode ? map[row.productCode] : null;
  1062. return Array.isArray(list) ? list : [];
  1063. },
  1064. // 父组件聚合到了替代关系,或行上直接带 isReplace,都算“有替代料”
  1065. hasReplace(row) {
  1066. return this.getReplaceList(row).length > 0 || row?.isReplace == 1;
  1067. },
  1068. // tooltip 文案:有明细就列出发货单与替代料,否则给通用提示
  1069. getReplaceTipLines(row) {
  1070. const list = this.getReplaceList(row);
  1071. if (list.length) {
  1072. return list.map(
  1073. (item) =>
  1074. `发货单 ${item.docNo || '-'}:由 ${item.replaceCode || '-'}` +
  1075. `${item.replaceName ? '(' + item.replaceName + ')' : ''} 替代`
  1076. );
  1077. }
  1078. return ['该产品存在替代料,发货时以对应发货单的替代料为准'];
  1079. },
  1080. getSummaries(param) {
  1081. return getSummaries(param, ['saleCount'], ' ');
  1082. },
  1083. handleDone() {
  1084. if (this.isSelected) {
  1085. console.log('selectedIds~~~~~', this.selectedIds);
  1086. this.$refs.table.setSelectedRowKeys(this.selectedIds);
  1087. }
  1088. },
  1089. handleSelectionChange(val) {
  1090. console.log(val, 'val');
  1091. this.$emit('selection-change', val);
  1092. },
  1093. async getSupplierObj(productList, queryName) {
  1094. try {
  1095. let categoryIds = productList
  1096. .filter((item) => item[queryName])
  1097. .map((item) => item[queryName]);
  1098. return await contactQueryByCategoryIdsAPI({
  1099. categoryIds,
  1100. isQueryEE: 1
  1101. });
  1102. } catch (e) {
  1103. return Promise.resolve({});
  1104. }
  1105. },
  1106. // 返回列表数据
  1107. getTableValue() {
  1108. let comitDatasource = this.form.datasource;
  1109. if (comitDatasource.length === 0) return [];
  1110. comitDatasource.forEach((v) => {
  1111. if (v.guaranteePeriodUnitCode) {
  1112. v.guaranteePeriodUnitName = this.getDictValue(
  1113. '保质期单位',
  1114. v.guaranteePeriodUnitCode
  1115. );
  1116. }
  1117. v.technicalDrawings = v.technicalDrawings ? v.technicalDrawings : [];
  1118. v.customerReqFiles = v.customerReqFiles || [];
  1119. v.industryArtFiles = v.industryArtFiles || [];
  1120. v.otherFiles = v.otherFiles || [];
  1121. });
  1122. return comitDatasource;
  1123. },
  1124. handleMethod(row) {
  1125. this.$refs.timeDialogDialogRef.open(row);
  1126. },
  1127. /**
  1128. * 取第一个有效金额,全部无效时回退到 fallback。
  1129. * 注意不能直接用 ||,否则接口正常返回的 0 会被当成无效值跳过。
  1130. */
  1131. pickAmount(candidates, fallback) {
  1132. const hit = candidates.find(
  1133. (v) => v !== null && v !== undefined && v !== '' && !isNaN(Number(v))
  1134. );
  1135. const num = Number(hit === undefined ? fallback : hit);
  1136. return isNaN(num) ? 0 : formatPrice(num);
  1137. },
  1138. // 汇总:总计 / 数量合计 / 优惠后总金额
  1139. setAmount(data = {}) {
  1140. this.allQuantity =
  1141. getAllQuantity(this.form.datasource, this.countObj) || 0;
  1142. // 总计:优先用接口返回的总金额,接口未返回时按明细行合计兜底
  1143. this.allPrice = this.pickAmount(
  1144. [data.totalAmount, data.totalPrice, data?.contractVO?.totalPrice],
  1145. getAllPrice(this.form.datasource)
  1146. );
  1147. if (this.isDiscountTotalPrice) {
  1148. // 优惠后总金额:接口未返回时按明细行折让合计兜底,无折让时等于总计
  1149. this.form.discountTotalPrice = this.pickAmount(
  1150. [
  1151. data.payAmount,
  1152. data.discountTotalPrice,
  1153. data?.contractVO?.discountTotalPrice
  1154. ],
  1155. Number(getAllDiscountPrice(this.form.datasource)) ||
  1156. Number(this.allPrice)
  1157. );
  1158. }
  1159. },
  1160. setDeliveryDays() {
  1161. console.log(this.form.datasource, 'this.form.datasource');
  1162. this.form.datasource.forEach((item, i) => {
  1163. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  1164. item.guaranteePeriodUnitCode
  1165. );
  1166. this.$set(
  1167. this.form.datasource[i],
  1168. 'guaranteePeriodDeadline',
  1169. guaranteePeriodUnitName != 'second'
  1170. ? this.setDay(item.guaranteePeriod, guaranteePeriodUnitName)
  1171. : ''
  1172. );
  1173. });
  1174. },
  1175. guaranteePeriodUnit(code) {
  1176. return code == 3
  1177. ? 'day'
  1178. : code == 4
  1179. ? 'month'
  1180. : code == 5
  1181. ? 'year'
  1182. : 'second';
  1183. },
  1184. setDay(addDay, dateType = 'day') {
  1185. console.log(addDay);
  1186. return dayjs(this.contractStartDate || new Date())
  1187. .add(addDay, dateType)
  1188. .format('YYYY-MM-DD');
  1189. },
  1190. //修改回显
  1191. rowBomCount(row) {
  1192. return row && Array.isArray(row.bomList) ? row.bomList.length : 0;
  1193. },
  1194. // 交给父组件(报价单详情)打开 BOM 详情弹窗
  1195. openBomDetail(row) {
  1196. this.$emit('showBomDetail', row);
  1197. },
  1198. async putTableValue(data) {
  1199. console.log(data, 'data');
  1200. // 存储data中的type值,用于控制新增字段显示
  1201. this.dataType = data.type;
  1202. let productList =
  1203. (data &&
  1204. (data.redressProductList ||
  1205. data.quoteProductList ||
  1206. data.productList ||
  1207. data.detailList)) ||
  1208. [];
  1209. console.log(productList, 'productList~~~~~~');
  1210. if (productList) {
  1211. productList.forEach((item) => {
  1212. // 处理机型/颜色
  1213. if (item.modelKey && typeof item.modelKey === 'string') {
  1214. item.modelKey = item.modelKey;
  1215. }
  1216. if (item.colorKey && typeof item.colorKey === 'string') {
  1217. item.colorKey = item.colorKey;
  1218. }
  1219. });
  1220. this.form.datasource = productList;
  1221. this.setAmount(data);
  1222. if (this.isWms) {
  1223. let codeList = this.form.datasource
  1224. .filter((item) => item.productCode)
  1225. .map((item) => buildInventoryTotalQueryKey(item));
  1226. //获取仓库库存
  1227. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  1228. this.form.datasource
  1229. .filter((item) => item.productCode)
  1230. .forEach((item) => {
  1231. let find =
  1232. inventoryTotalList.find((key) =>
  1233. matchInventoryTotal(item, key)
  1234. ) || {};
  1235. this.form.datasource;
  1236. this.$set(
  1237. item,
  1238. 'stockCountBase',
  1239. find.stockCountBase == null ? 0 : find.stockCountBase
  1240. );
  1241. this.$set(
  1242. item,
  1243. 'availableCountBase',
  1244. find.availableCountBase == null ? 0 : find.availableCountBase
  1245. );
  1246. });
  1247. }
  1248. this.supplierObj = await this.getSupplierObj(
  1249. productList,
  1250. 'productId'
  1251. );
  1252. this.$refs.table && this.$refs.table.reload();
  1253. }
  1254. }
  1255. // 列头拖拽结束 - 保存列宽到本地缓存
  1256. }
  1257. };
  1258. </script>
  1259. <style lang="scss" scoped>
  1260. .replace-code-cell {
  1261. display: flex;
  1262. flex-direction: column;
  1263. align-items: center;
  1264. line-height: 1.5;
  1265. }
  1266. .code-text {
  1267. max-width: 100%;
  1268. overflow: hidden;
  1269. text-overflow: ellipsis;
  1270. white-space: nowrap;
  1271. }
  1272. .headbox {
  1273. display: flex;
  1274. justify-content: space-between;
  1275. align-items: center;
  1276. .amount {
  1277. font-size: 14px;
  1278. font-weight: bold;
  1279. padding-right: 30px;
  1280. }
  1281. }
  1282. .time-form .el-form-item {
  1283. margin-bottom: 0 !important;
  1284. }
  1285. ::v-deep .period {
  1286. display: flex;
  1287. .borderleftnone {
  1288. .el-input--medium .el-input__inner {
  1289. border-top-right-radius: 0;
  1290. border-bottom-right-radius: 0;
  1291. }
  1292. }
  1293. .borderrightnone {
  1294. .el-input--medium .el-input__inner {
  1295. border-top-left-radius: 0;
  1296. border-bottom-left-radius: 0;
  1297. }
  1298. }
  1299. }
  1300. ::v-deep .time-form tbody > tr:hover > td {
  1301. background-color: transparent !important;
  1302. }
  1303. ::v-deep .time-form .el-table tr {
  1304. background-color: #ffffff;
  1305. }
  1306. .pricebox {
  1307. display: flex;
  1308. justify-content: flex-start;
  1309. align-items: center;
  1310. font-weight: bold;
  1311. }
  1312. </style>