inventoryTable.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. <template>
  2. <div>
  3. <!-- <div v-for="(item) in datasource" style="margin-bottom: 10px">
  4. <div>
  5. <div style="margin-bottom: 10px;font-weight: bold;">
  6. <div>
  7. <el-divider direction="vertical"></el-divider>
  8. <span><span>{{ index + 1 }}</span> 销售订单:</span>
  9. <span>{{ item.orderNo }}</span>
  10. <el-divider direction="vertical"></el-divider> -->
  11. <!-- <span>计价方式:</span>
  12. <span> {{ item.pricingWay == 1 ? '按数量计费' : '按重量计费' }}</span> -->
  13. <!-- <el-divider direction="vertical"></el-divider> -->
  14. <!-- <span>总金额:</span>
  15. <span>{{item.amountTotalPrice}}</span>
  16. <el-divider direction="vertical"></el-divider>
  17. <span>应收金额:</span>
  18. <span>{{item.amountReceivablePrice}}</span>
  19. <el-divider direction="vertical"></el-divider>
  20. <span>应付金额:</span>
  21. <span>{{item.amountPayablePrice}}</span>
  22. </div>
  23. </div>
  24. <template v-if="item.orderType!=6">
  25. <div v-for="(j,i) in item.subList" :key="i">
  26. <ele-pro-table :show-summary="true" :summary-method="getSummaries" ref="table" row-key="id" :needPage="false"
  27. :columns="getColumns(j)" max-height="500px" style="margin-bottom: 10px"
  28. :sub-title="getTitle(j)" :toolkit="[]" :datasource="j.detailList"
  29. cache-key="systemRoleTable17-11121" class="time-form">
  30. <template v-slot:action="{ row,$index }">
  31. <el-popconfirm class="ele-action" title="确定要删除吗?" @confirm="remove(index,$index,'line')">
  32. <template v-slot:reference>
  33. <el-link type="danger" v-if="dialogType!=='view'" :underline="false" icon="el-icon-delete">
  34. 删除
  35. </el-link>
  36. </template>
  37. </el-popconfirm>
  38. </template>
  39. </ele-pro-table>
  40. </div>
  41. </template>
  42. <div v-else>
  43. <ele-pro-table :show-summary="true" :summary-method="getSummaries" ref="table" row-key="id" :needPage="false"
  44. :columns="getColumns({subType:10})" sub-title="赔付订单" max-height="500px" style="margin-bottom: 10px"
  45. :toolkit="[]" :datasource="item.detailList"
  46. cache-key="systemRoleTable17-11121" class="time-form">
  47. <template v-slot:action="{ row,$index }">
  48. <el-popconfirm class="ele-action" title="确定要删除吗?" @confirm="remove(index,$index,'line')">
  49. <template v-slot:reference>
  50. <el-link type="danger" v-if="dialogType!=='view'" :underline="false" icon="el-icon-delete">
  51. 删除
  52. </el-link>
  53. </template>
  54. </el-popconfirm>
  55. </template> -->
  56. <!-- <template v-slot:productName="{ row,$index }">-->
  57. <!-- <el-popover-->
  58. <!-- placement="right"-->
  59. <!-- width="60%"-->
  60. <!-- trigger="hover">-->
  61. <!-- <ele-pro-table ref="childrenTable"-->
  62. <!-- row-key="id"-->
  63. <!-- max-height="300px"-->
  64. <!-- :needPage="false" :columns="childrenColumns" :toolkit="[]"-->
  65. <!-- :datasource="row.productList"-->
  66. <!-- cache-key="systemRoleTable17-222" class="time-form">-->
  67. <!-- </ele-pro-table>-->
  68. <!-- <el-button type="text" slot="reference">{{ row.productName }}</el-button>-->
  69. <!-- </el-popover>-->
  70. <!-- </template>-->
  71. <!-- </ele-pro-table>
  72. </div>
  73. </div>
  74. </div> -->
  75. <el-collapse v-model="activeNames">
  76. <el-collapse-item v-for="(item, index) in datasource" :key="index" :name="index">
  77. <template slot="title">
  78. <div class="collapse-title">
  79. <div class="collapse-title-left"><span class="collapse-title-index">{{ index + 1 }}</span> {{ type === 'purchase' ? '采购订单' : '销售订单' }}:{{ item.orderNo }}</div>
  80. <div class="collapse-title-right">
  81. <span>订单金额:{{ item.orderAmount || 0 }}元</span>
  82. <span>已对账金额:{{ item.statementAmount || 0 }}元</span>
  83. <span>未对账金额:{{ item.unStatementAmount || 0 }}元</span>
  84. <span>本次对账金额:{{ item.amountTotalPrice || 0 }}元</span>
  85. </div>
  86. </div>
  87. </template>
  88. <div>
  89. <el-tabs type="border-card">
  90. <el-tab-pane :label="type === 'purchase' ? '收货单' : '发货单'">
  91. <el-form :ref="'form' + index" :model="item">
  92. <ele-pro-table :show-summary="false" :summary-method="getSummaries" ref="table" row-key="id" :needPage="false"
  93. :columns="getColumns(item, 'deliveryProducts')" max-height="500px" style="margin-bottom: 10px" :datasource="item.deliveryProducts || []"
  94. cache-key="systemRoleTable17-11121" class="time-form">
  95. <template v-slot:toolbar>
  96. <div class="headbox">
  97. <div>
  98. <span class="amount">对账金额合计:{{ getSummariesA(item.deliveryProducts || []) }}元</span>
  99. </div>
  100. </div>
  101. </template>
  102. <template v-slot:singlePrice="scope">
  103. <el-form-item
  104. style="margin-bottom: 20px"
  105. :prop="'deliveryProducts.' + scope.$index + '.singlePrice'"
  106. :rules="{
  107. required: true,
  108. message: '请输入正确的单价',
  109. trigger: 'change'
  110. }"
  111. >
  112. <el-input
  113. v-model="scope.row.singlePrice"
  114. placeholder="请输入"
  115. @input="changeCount(scope.row, scope.$index, item, index)"
  116. :disabled="item.orderCategory != 4 || dialogType === 'view'"
  117. type="number"
  118. >
  119. <template slot="append">元</template>
  120. </el-input>
  121. </el-form-item>
  122. </template>
  123. <template v-slot:taxRate="scope">
  124. <el-form-item
  125. :prop="'deliveryProducts.' + scope.$index + '.taxRate'"
  126. :rules="{
  127. required: isTaxRate == 1 ? true : false,
  128. message: '请输入税率',
  129. trigger: 'change'
  130. }"
  131. >
  132. <el-input
  133. v-model="scope.row.taxRate"
  134. placeholder="请输入"
  135. type="number"
  136. @input="getNotaxSinglePrice(scope.row, scope.$index)"
  137. :disabled="item.orderCategory != 4 || dialogType === 'view'"
  138. >
  139. <template slot="append">%</template>
  140. </el-input>
  141. </el-form-item>
  142. </template>
  143. <template v-slot:discountRatio="scope">
  144. <el-form-item
  145. :prop="'deliveryProducts.' + scope.$index + '.discountRatio'"
  146. :rules="{
  147. required: true,
  148. message: '请输入折让比例',
  149. trigger: 'change'
  150. }"
  151. >
  152. <el-input
  153. v-model="scope.row.discountRatio"
  154. placeholder="请输入"
  155. type="number"
  156. :min="0"
  157. :max="100"
  158. :disabled="item.orderCategory != 4 || dialogType === 'view'"
  159. @input="getDiscountRatioPrice(scope.row, scope.$index)"
  160. >
  161. <template slot="append">%</template>
  162. </el-input>
  163. </el-form-item>
  164. </template>
  165. <template v-slot:action="{ row,$index }">
  166. <el-popconfirm class="ele-action" title="确定要删除吗?" @confirm="remove(index,$index,'line')">
  167. <template v-slot:reference>
  168. <el-link type="danger" v-if="dialogType!=='view'" :underline="false" icon="el-icon-delete">
  169. 删除
  170. </el-link>
  171. </template>
  172. </el-popconfirm>
  173. </template>
  174. </ele-pro-table>
  175. </el-form>
  176. </el-tab-pane>
  177. <el-tab-pane label="退货单">
  178. <ele-pro-table :show-summary="false" :summary-method="getSummaries" ref="table" row-key="id" :needPage="false"
  179. :columns="getColumns(item, 'returnProducts')" max-height="500px" style="margin-bottom: 10px" :datasource="item.returnProducts || []"
  180. cache-key="systemRoleTable17-11122" class="time-form">
  181. <template v-slot:toolbar>
  182. <div class="headbox">
  183. <div>
  184. <span class="amount">对账金额合计:{{ getSummariesA(item.returnProducts || []) }}元</span>
  185. </div>
  186. </div>
  187. </template>
  188. <template v-slot:action="{ row,$index }">
  189. <el-popconfirm class="ele-action" title="确定要删除吗?" @confirm="remove(index,$index,'line')">
  190. <template v-slot:reference>
  191. <el-link type="danger" v-if="dialogType!=='view'" :underline="false" icon="el-icon-delete">
  192. 删除
  193. </el-link>
  194. </template>
  195. </el-popconfirm>
  196. </template>
  197. </ele-pro-table>
  198. </el-tab-pane>
  199. </el-tabs>
  200. </div>
  201. </el-collapse-item>
  202. </el-collapse>
  203. <!-- <el-row v-if="dialogType=='view'" style="margin-top: 10px">-->
  204. <!-- <el-col :span="6" style="float: right;">-->
  205. <!-- <el-descriptions class="margin-top" direction="vertical" :column="3" size="small" border>-->
  206. <!-- <el-descriptions-item label="本期应收款总额">{{ dataForm.amountReceivablePrice }}</el-descriptions-item>-->
  207. <!-- <el-descriptions-item label="截止上期欠款">-->
  208. <!-- <template>{{ dataForm.previousPeriodEndDebt }}</template>-->
  209. <!-- </el-descriptions-item>-->
  210. <!-- </el-descriptions>-->
  211. <!-- </el-col>-->
  212. <!-- </el-row>-->
  213. </div>
  214. </template>
  215. <script>
  216. import dictMixins from '@/mixins/dictMixins';
  217. import { pricingWayList } from '@/enum/dict';
  218. import { parameterGetByCode } from '@/api/main/index.js';
  219. import { changeCount } from '@/BIZComponents/setProduct.js';
  220. export default {
  221. mixins: [dictMixins],
  222. components: {},
  223. props: ['datasource', 'dialogType', 'dataForm', 'type'],
  224. computed: {
  225. getColumns() {
  226. return (item, type)=>{
  227. let basicFields = [
  228. {
  229. width: 60,
  230. label: '序号',
  231. type: 'index',
  232. columnKey: 'index',
  233. align: 'center',
  234. fixed: 'left'
  235. },
  236. {
  237. minWidth: 130,
  238. prop: 'statementSubOrderNo',
  239. label: type == 'deliveryProducts'? this.type === 'purchase'?'收货单编码':'发货单编码':'退货单编码',
  240. align: 'center',
  241. slot: 'statementSubOrderNo',
  242. showOverflowTooltip: true
  243. },
  244. {
  245. minWidth: 130,
  246. prop: 'productOperateTime',
  247. label: type == 'deliveryProducts'? this.type === 'purchase'?'收货日期':'发货日期':'退货日期',
  248. align: 'center',
  249. slot: 'productOperateTime',
  250. showOverflowTooltip: true
  251. },
  252. {
  253. minWidth: 120,
  254. prop: 'productCode',
  255. label: '产品编码',
  256. slot: 'productCode',
  257. align: 'center',
  258. showOverflowTooltip: true
  259. },
  260. {
  261. minWidth: 140,
  262. prop: 'productName',
  263. label: '产品名称',
  264. slot: 'productName',
  265. align: 'center',
  266. showOverflowTooltip: true
  267. },
  268. // {
  269. // minWidth: 140,
  270. // prop: 'subType',
  271. // label: '退货产品类型',
  272. // slot: 'subType',
  273. // align: 'center',
  274. // show:j.subType==11,
  275. // showOverflowTooltip: true,formatter(_row, _column, cellValue){
  276. // return cellValue==12?'实物赔偿':'原货'
  277. // }
  278. // },
  279. {
  280. minWidth: 100,
  281. prop: 'specification',
  282. label: '规格',
  283. align: 'center',
  284. slot: 'specification',
  285. showOverflowTooltip: true
  286. },
  287. {
  288. minWidth: 100,
  289. prop: 'modelType',
  290. label: '型号',
  291. align: 'center',
  292. slot: 'modelType',
  293. showOverflowTooltip: true
  294. },
  295. // {
  296. // prop: 'provenance',
  297. // label: '产地',
  298. // slot: 'provenance',
  299. // align: 'center',
  300. // // show:this.contractBookType==2,
  301. // minWidth: 200,
  302. // showOverflowTooltip: true,
  303. // formatter: (row, column) => {
  304. // return row.provenance && row.provenance.length
  305. // ? row.provenance
  306. // .map((item) => this.getDictValue('产地', item ))
  307. // .join(',')
  308. // : '';
  309. // }
  310. // },
  311. {
  312. minWidth: 100,
  313. prop: 'pricingWay',
  314. label: '计价方式',
  315. align: 'center',
  316. slot: 'pricingWay',
  317. showOverflowTooltip: true,
  318. formatter: (_row, _column, cellValue) => {
  319. let pricingWay = pricingWayList.find(item => item.id == cellValue)
  320. return pricingWay ? pricingWay.name : ''
  321. }
  322. },
  323. {
  324. minWidth: 100,
  325. prop: 'totalCount',
  326. label: '数量',
  327. align: 'center',
  328. slot: 'totalCount'
  329. },
  330. {
  331. minWidth: 120,
  332. prop: 'measuringUnit',
  333. label: '计量单位',
  334. align: 'center',
  335. slot: 'measuringUnit'
  336. },
  337. {
  338. width: 100,
  339. prop: 'receiveTotalWeight',
  340. label: '收货总重',
  341. slot: 'receiveTotalWeight',
  342. align: "center"
  343. },
  344. {
  345. width: 100,
  346. prop: 'sendTotalWeight',
  347. label: '发货总重',
  348. slot: 'sendTotalWeight',
  349. align: "center",
  350. headerSlot: 'headerTotalCount'
  351. },
  352. {
  353. width: 100,
  354. prop: 'increaseTotalWeight',
  355. label: '增重重量',
  356. slot: 'increaseTotalWeight',
  357. align: "center"
  358. },
  359. {
  360. width: 100,
  361. prop: 'weightUnit',
  362. label: '重量单位',
  363. slot: 'weightUnit',
  364. align: "center"
  365. },
  366. {
  367. minWidth: 160,
  368. prop: 'singlePrice',
  369. label: '单价',
  370. align: 'center',
  371. slot: 'singlePrice',
  372. },
  373. {
  374. minWidth: 160,
  375. prop: 'taxRate',
  376. label: '税率',
  377. align: 'center',
  378. slot: 'taxRate',
  379. },
  380. {
  381. width: 140,
  382. prop: 'noTaxSinglePrice',
  383. label: '不含税单价',
  384. align: 'center'
  385. },
  386. {
  387. minWidth: 120,
  388. prop: 'totalPrice',
  389. label: '合计',
  390. slot: 'totalPrice',
  391. align: 'center',
  392. },
  393. {
  394. minWidth: 160,
  395. prop: 'discountRatio',
  396. label: '折让比例',
  397. align: 'center',
  398. slot: 'discountRatio',
  399. },
  400. {
  401. minWidth: 100,
  402. prop: 'discountSinglePrice',
  403. label: '折让单价',
  404. align: 'center',
  405. },
  406. {
  407. minWidth: 120,
  408. prop: 'discountTotalPrice',
  409. label: '折让合计',
  410. slot: 'discountTotalPrice',
  411. align: 'center',
  412. },
  413. ]
  414. let permissionType = {
  415. // 'financeLeader': [
  416. // {
  417. // minWidth: 130,
  418. // prop: 'receivedPrice',
  419. // label: '已收款金额',
  420. // align: 'center',
  421. // slot: 'receivedPrice',
  422. // headerSlot: 'headerReceivedPrice'
  423. // },
  424. // {
  425. // minWidth: 130,
  426. // prop: 'receivablePrice',
  427. // label: '应收款金额',
  428. // align: 'center',
  429. // slot: 'receivablePrice',
  430. // },
  431. // {
  432. // minWidth: 140,
  433. // prop: 'receivableDate',
  434. // label: '应收款日期',
  435. // align: 'center',
  436. // slot: 'receivableDate',
  437. // headerSlot: 'headerReceivableDate'
  438. // },
  439. // {
  440. // minWidth: 130,
  441. // prop: 'invoicedPrice',
  442. // label: '已开票金额',
  443. // align: 'center',
  444. // slot: 'invoicedPrice',
  445. // headerSlot: 'headerInvoicedPrice'
  446. // },
  447. // {
  448. // minWidth: 130,
  449. // prop: 'notInvoicedPrice',
  450. // label: '未开票金额',
  451. // align: 'center',
  452. // slot: 'notInvoicedPrice'
  453. // },
  454. // ],
  455. // 'leader': [
  456. // {
  457. // minWidth: 130,
  458. // prop: 'receivedPrice',
  459. // label: '已收款金额',
  460. // align: 'center',
  461. // slot: 'receivedPrice'
  462. // },
  463. // {
  464. // minWidth: 130,
  465. // prop: 'receivablePrice',
  466. // label: '应收款金额',
  467. // align: 'center',
  468. // slot: 'receivablePrice'
  469. // },
  470. // {
  471. // minWidth: 140,
  472. // prop: 'receivableDate',
  473. // label: '应收款日期',
  474. // align: 'center',
  475. // slot: 'receivableDate'
  476. // },
  477. // {
  478. // minWidth: 130,
  479. // prop: 'invoicedPrice',
  480. // label: '已开票金额',
  481. // align: 'center',
  482. // slot: 'invoicedPrice'
  483. // },
  484. // {
  485. // minWidth: 130,
  486. // prop: 'notInvoicedPrice',
  487. // label: '未开票金额',
  488. // align: 'center',
  489. // slot: 'notInvoicedPrice'
  490. // },
  491. // ],
  492. // 'uploadReceipt': [
  493. // {
  494. // minWidth: 130,
  495. // prop: 'receivedPrice',
  496. // label: '已收款金额',
  497. // align: 'center',
  498. // slot: 'receivedPrice'
  499. // },
  500. // {
  501. // minWidth: 130,
  502. // prop: 'receivablePrice',
  503. // label: '应收款金额',
  504. // align: 'center',
  505. // slot: 'receivablePrice'
  506. // },
  507. // {
  508. // minWidth: 140,
  509. // prop: 'receivableDate',
  510. // label: '应收款日期',
  511. // align: 'center',
  512. // slot: 'receivableDate'
  513. // },
  514. // {
  515. // minWidth: 130,
  516. // prop: 'invoicedPrice',
  517. // label: '已开票金额',
  518. // align: 'center',
  519. // slot: 'invoicedPrice'
  520. // },
  521. // {
  522. // minWidth: 130,
  523. // prop: 'notInvoicedPrice',
  524. // label: '未开票金额',
  525. // align: 'center',
  526. // slot: 'notInvoicedPrice'
  527. // },
  528. // ],
  529. }
  530. permissionType[this.taskDefinitionKey] && basicFields.push(...permissionType[this.taskDefinitionKey])
  531. return basicFields
  532. }
  533. },
  534. getTitle(){
  535. return (item, type)=>{
  536. // let title=this.subTypeList[j.subType]+(j.statementSubOrderCode||'')+' '
  537. // if(j.subType==11&&j.subExecType){
  538. // if(j.subExecType=='10'){
  539. // title=title+' 退货方式:全部原货 '
  540. // }
  541. // if(j.subExecType=='20'){
  542. // title=title+' 退货方式:部分原货+实物赔偿'
  543. // }
  544. // if(j.subExecType=='30'){
  545. // title=title+' 退货方式:部分原货+现金赔偿 '+' 赔偿金额:'+j.amountPayablePrice
  546. // }
  547. // if(j.subExecType=='40'){
  548. // title=title+' 退货方式:全部实物赔偿'
  549. // }
  550. // if(j.subExecType=='50'){
  551. // title=title+' 退货方式:全部现金赔偿 '+' 赔偿金额:'+j.amountPayablePrice
  552. // }
  553. // }
  554. console.log(item[type])
  555. const total = item[type]?.reduce((prev, curr) => {
  556. console.log(curr.discountTotalPrice)
  557. return prev + Number(curr.discountTotalPrice || 0) + '元';
  558. }, 0);
  559. return `对账金额合计:${total}`
  560. }
  561. },
  562. getFHDatasource() {
  563. return (item)=>{
  564. return item.subList?.detailList
  565. }
  566. },
  567. clientEnvironmentId() {
  568. return this.$store.state.user.info.clientEnvironmentId;
  569. },
  570. },
  571. data() {
  572. return {
  573. isTaxRate: 0,
  574. activeNames: [],
  575. rules: {},
  576. form: {},
  577. subTypeList:{
  578. 10:'发货单:',
  579. 11:'退货单:',
  580. 12:'实物赔偿清单:',
  581. 30:'调拨单:',
  582. },
  583. subColumnsTypeList:{
  584. 10: '发货',
  585. 11: '退货',
  586. 30: '调拨'
  587. },
  588. };
  589. },
  590. watch: {
  591. datasource: {
  592. handler(newVal, oldVal) {
  593. if (newVal.length > 0) {
  594. this.activeNames = newVal.map((item, index) => index);
  595. console.log('this.activeNames~~~', this.activeNames)
  596. }
  597. },
  598. deep: true
  599. }
  600. },
  601. created(){
  602. this.requestDict('产地');
  603. // 税率是否必填//0否 1是
  604. parameterGetByCode({
  605. code: 'eom_saleOrder_order-taxRate'
  606. }).then((res) => {
  607. this.isTaxRate = res.value;
  608. });
  609. },
  610. mounted() {
  611. // this.activeNames = this.datasource.map((item, index) => index.toString());
  612. // console.log('activeNames~~~', this.activeNames)
  613. },
  614. methods: {
  615. //改变数量
  616. changeCount(item, index, row, tableIndex) {
  617. console.log('changeCount~~~', item)
  618. console.log('this.datasource[index]~~~', this.datasource[index])
  619. // row.totalPrice = parseFloat((item.totalCount * item.singlePrice).toFixed(2))
  620. if (item.singlePrice && item.totalCount) {
  621. // this.$set(
  622. // this.datasource[index],
  623. // 'totalPrice',
  624. // parseFloat((item.totalCount * item.singlePrice).toFixed(2))
  625. // );
  626. item.totalPrice = parseFloat((item.totalCount * item.singlePrice).toFixed(2))
  627. } else {
  628. // this.$set(this.form.datasource[index], 'totalPrice', '');
  629. item.totalPrice = ''
  630. }
  631. this.getNotaxSinglePrice(item, index);
  632. this.getDiscountRatioPrice(item, index, row, tableIndex);
  633. this.$forceUpdate();
  634. // if (this.clientEnvironmentId == 4 && !isBlockCount) {
  635. // this.tableHandleKeyUp(row, index, 'sum');
  636. // }
  637. },
  638. //计算不含税单价
  639. getNotaxSinglePrice(item, index) {
  640. if (item.singlePrice && item.taxRate) {
  641. // this.$set(
  642. // this.datasource[index],
  643. // 'noTaxSinglePrice',
  644. // parseFloat(
  645. // (item.singlePrice / (1 + item.taxRate / 100)).toFixed(2)
  646. // )
  647. // );
  648. item.noTaxSinglePrice = parseFloat(
  649. (item.singlePrice / (1 + item.taxRate / 100)).toFixed(2)
  650. )
  651. item.noTaxTotalPrice = parseFloat(
  652. (item.totalCount * item.noTaxSinglePrice).toFixed(2)
  653. )
  654. } else {
  655. // this.$set(this.form.datasource[index], 'noTaxSinglePrice', '');
  656. item.noTaxSinglePrice = ''
  657. item.noTaxTotalPrice = ''
  658. }
  659. },
  660. // 计算折让单价,折让总价
  661. getDiscountRatioPrice(item, index, row, tableIndex) {
  662. if (item.singlePrice && item.discountRatio) {
  663. // this.$set(
  664. // this.datasource[index],
  665. // 'discountSinglePrice',
  666. // parseFloat(
  667. // (item.singlePrice * (item.discountRatio / 100)).toFixed(2)
  668. // )
  669. // );
  670. item.discountSinglePrice = parseFloat(
  671. (item.singlePrice * (item.discountRatio / 100)).toFixed(2)
  672. )
  673. // this.$set(
  674. // this.datasource[index],
  675. // 'discountTotalPrice',
  676. // parseFloat(
  677. // (item.totalPrice * (item.discountRatio / 100)).toFixed(2)
  678. // )
  679. // );
  680. item.discountTotalPrice = parseFloat(
  681. (item.totalPrice * (item.discountRatio / 100)).toFixed(2)
  682. )
  683. } else {
  684. // this.$set(this.datasource[index], 'discountSinglePrice', 0);
  685. // this.$set(this.datasource[index], 'discountTotalPrice', 0);
  686. item.discountSinglePrice = ''
  687. item.discountTotalPrice = ''
  688. }
  689. console.log('row~~~', row, tableIndex)
  690. row.unStatementAmount = this.datasource[tableIndex].deliveryProducts.reduce((prev, curr) => {
  691. return prev + Number(curr.discountTotalPrice || 0)
  692. }, 0)
  693. row.amountTotalPrice = this.datasource[tableIndex].deliveryProducts.reduce((prev, curr) => {
  694. return prev + Number(curr.discountTotalPrice || 0)
  695. }, 0)
  696. this.$emit('changeDiscountPrice', row.amountTotalPrice, tableIndex)
  697. },
  698. remove(tableIndex, lineIndex, delType) {
  699. let params = {
  700. tableIndex,
  701. lineIndex,
  702. delType
  703. }
  704. this.$emit('handleRemove', params)
  705. },
  706. getSummaries(param) {
  707. const {columns, data} = param;
  708. const sums = [];
  709. let fields = ['totalPrice', 'notInvoicedPrice', 'invoicedPrice', 'receivablePrice', 'receivedPrice', 'discountTotalPrice']
  710. columns.forEach((column, index) => {
  711. if (index === 0) {
  712. sums[index] = '合计';
  713. return;
  714. }
  715. const values = fields.includes(column.property) ? data.map(item => Number(item[column.property])) : []
  716. if (!values.every(value => isNaN(value))) {
  717. sums[index] = values.reduce((prev, curr) => {
  718. const value = Number(curr);
  719. if (!isNaN(value)) {
  720. return prev + curr;
  721. } else {
  722. return prev;
  723. }
  724. }, 0);
  725. sums[index] = (sums[index]).toFixed(2)
  726. } else {
  727. sums[index] = '';
  728. }
  729. });
  730. return sums;
  731. },
  732. getSummariesA(table) {
  733. return table.reduce((prev, curr) => {
  734. return prev + Number(curr.discountTotalPrice || 0)
  735. }, 0)
  736. },
  737. getValidForm() {
  738. return new Promise((resolve, reject) => {
  739. const validationPromises = [];
  740. this.datasource.forEach((item, index) => {
  741. validationPromises.push(
  742. new Promise((formResolve, formReject) => {
  743. const formRef = this.$refs['form' + index];
  744. console.log(formRef, 'formRef');
  745. // 处理表单引用可能是数组的情况
  746. const actualFormRef = Array.isArray(formRef) ? formRef[0] : formRef;
  747. if (actualFormRef && typeof actualFormRef.validate === 'function') {
  748. actualFormRef.validate((valid, errors) => {
  749. if (!valid) {
  750. formReject({ index, errors });
  751. } else {
  752. formResolve(true);
  753. }
  754. });
  755. } else {
  756. // 如果表单引用不存在或没有validate方法,检查数据直接验证
  757. if (!item.singlePrice || !item.taxRate || !item.discountRatio) {
  758. formReject({ index, message: `缺少必填字段` });
  759. } else {
  760. formResolve(true);
  761. }
  762. }
  763. })
  764. );
  765. });
  766. Promise.all(validationPromises)
  767. .then(() => {
  768. resolve(true);
  769. })
  770. .catch(error => {
  771. console.error('表单验证失败:', error);
  772. if (error.message) {
  773. this.$message.error(error.message);
  774. } else {
  775. this.$message.error(`表单未填写完整`);
  776. }
  777. reject(false);
  778. });
  779. });
  780. }
  781. }
  782. };
  783. </script>
  784. <style lang="scss" scoped>
  785. .collapse-title {
  786. display: flex;
  787. justify-content: space-between;
  788. align-items: center;
  789. width: 96%;
  790. }
  791. .collapse-title-left {
  792. display: flex;
  793. /* justify-content: center; */
  794. align-items: center;
  795. font-size: 16px;
  796. }
  797. .collapse-title-index {
  798. width: 24px;
  799. height: 24px;
  800. background: #63a103;
  801. display: inline-block;
  802. text-align: center;
  803. line-height: 24px;
  804. border-radius: 50%;
  805. color: #fff;
  806. margin-right: 10px;
  807. font-size: 14px;
  808. }
  809. .collapse-title-right {
  810. display:grid;
  811. grid-auto-flow: column;
  812. gap: 18px;
  813. }
  814. .headbox {
  815. display: flex;
  816. justify-content: space-between;
  817. align-items: center;
  818. .amount {
  819. font-size: 14px;
  820. font-weight: bold;
  821. padding-right: 30px;
  822. }
  823. }
  824. .time-form .el-form-item {
  825. margin-bottom: 0 !important;
  826. }
  827. ::v-deep .period {
  828. display: flex;
  829. .borderleftnone {
  830. .el-input--medium .el-input__inner {
  831. border-top-right-radius: 0;
  832. border-bottom-right-radius: 0;
  833. }
  834. }
  835. .borderrightnone {
  836. .el-input--medium .el-input__inner {
  837. border-top-left-radius: 0;
  838. border-bottom-left-radius: 0;
  839. }
  840. }
  841. }
  842. ::v-deep .time-form tbody > tr:hover > td {
  843. background-color: transparent !important;
  844. }
  845. ::v-deep .time-form .el-table tr {
  846. background-color: #ffffff;
  847. }
  848. .pricebox {
  849. display: flex;
  850. justify-content: flex-start;
  851. align-items: center;
  852. font-weight: bold;
  853. }
  854. ::v-deep.el-divider {
  855. margin: 10px;
  856. font-weight: bold;
  857. }
  858. </style>