inventoryTable.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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.statementedAmount || 0 }}元</span>
  83. <span>未对账金额:{{ item.unStatementAmount || 0 }}元</span>
  84. <span>本次对账金额:{{ item.statementAmount || 0 }}元</span>
  85. </div>
  86. </div>
  87. </template>
  88. <div>
  89. <el-tabs type="border-card">
  90. <el-tab-pane :label="type == 'purchase' ? '收货单' : '发货单'">
  91. <ele-pro-table :show-summary="false" :summary-method="getSummaries" ref="table" row-key="id" :needPage="false"
  92. :columns="getColumns(item, 'deliveryProducts')" max-height="500px" style="margin-bottom: 10px" :datasource="item.deliveryProducts || []"
  93. cache-key="systemRoleTable17-11121" class="time-form">
  94. <template v-slot:toolbar>
  95. <div class="headbox">
  96. <div>
  97. <span class="amount">对账金额合计:{{ getSummariesA(item.deliveryProducts || []) }}元</span>
  98. </div>
  99. </div>
  100. </template>
  101. <template v-slot:action="{ row,$index }">
  102. <el-popconfirm class="ele-action" title="确定要删除吗?" @confirm="remove(index,$index,'line')">
  103. <template v-slot:reference>
  104. <el-link type="danger" v-if="dialogType!=='view'" :underline="false" icon="el-icon-delete">
  105. 删除
  106. </el-link>
  107. </template>
  108. </el-popconfirm>
  109. </template>
  110. </ele-pro-table>
  111. </el-tab-pane>
  112. <el-tab-pane label="退货单">
  113. <ele-pro-table :show-summary="false" :summary-method="getSummaries" ref="table" row-key="id" :needPage="false"
  114. :columns="getColumns(item, 'returnProducts')" max-height="500px" style="margin-bottom: 10px" :datasource="item.returnProducts || []"
  115. cache-key="systemRoleTable17-11122" class="time-form">
  116. <template v-slot:toolbar>
  117. <div class="headbox">
  118. <div>
  119. <span class="amount">对账金额合计:{{ getSummariesA(item.returnProducts || []) }}元</span>
  120. </div>
  121. </div>
  122. </template>
  123. <template v-slot:action="{ row,$index }">
  124. <el-popconfirm class="ele-action" title="确定要删除吗?" @confirm="remove(index,$index,'line')">
  125. <template v-slot:reference>
  126. <el-link type="danger" v-if="dialogType!=='view'" :underline="false" icon="el-icon-delete">
  127. 删除
  128. </el-link>
  129. </template>
  130. </el-popconfirm>
  131. </template>
  132. </ele-pro-table>
  133. </el-tab-pane>
  134. </el-tabs>
  135. </div>
  136. </el-collapse-item>
  137. </el-collapse>
  138. <!-- <el-row v-if="dialogType=='view'" style="margin-top: 10px">-->
  139. <!-- <el-col :span="6" style="float: right;">-->
  140. <!-- <el-descriptions class="margin-top" direction="vertical" :column="3" size="small" border>-->
  141. <!-- <el-descriptions-item label="本期应收款总额">{{ dataForm.amountReceivablePrice }}</el-descriptions-item>-->
  142. <!-- <el-descriptions-item label="截止上期欠款">-->
  143. <!-- <template>{{ dataForm.previousPeriodEndDebt }}</template>-->
  144. <!-- </el-descriptions-item>-->
  145. <!-- </el-descriptions>-->
  146. <!-- </el-col>-->
  147. <!-- </el-row>-->
  148. </div>
  149. </template>
  150. <script>
  151. import dictMixins from '@/mixins/dictMixins';
  152. import { pricingWayList } from '@/enum/dict';
  153. export default {
  154. mixins: [dictMixins],
  155. components: {},
  156. props: ['datasource', 'dialogType', 'dataForm', 'type'],
  157. computed: {
  158. getColumns() {
  159. return (item, type)=>{
  160. // console.log(this.dataForm)
  161. let basicFields = [
  162. {
  163. width: 60,
  164. label: '序号',
  165. type: 'index',
  166. columnKey: 'index',
  167. align: 'center',
  168. fixed: 'left'
  169. },
  170. {
  171. minWidth: 130,
  172. prop: 'statementSubOrderNo',
  173. label: type == 'deliveryProducts'? this.type == 'purchase'?'收货单编码':'发货单编码':'退货单编码',
  174. align: 'center',
  175. slot: 'statementSubOrderNo',
  176. showOverflowTooltip: true
  177. },
  178. {
  179. minWidth: 130,
  180. prop: 'productOperateTime',
  181. label: type == 'deliveryProducts' ? this.type == 'purchase' ? '收货日期' :'发货日期' : '退货日期',
  182. align: 'center',
  183. slot: 'productOperateTime',
  184. showOverflowTooltip: true
  185. },
  186. {
  187. minWidth: 120,
  188. prop: 'productCode',
  189. label: '产品编码',
  190. slot: 'productCode',
  191. align: 'center',
  192. showOverflowTooltip: true
  193. },
  194. {
  195. minWidth: 140,
  196. prop: 'productName',
  197. label: '产品名称',
  198. slot: 'productName',
  199. align: 'center',
  200. showOverflowTooltip: true
  201. },
  202. // {
  203. // minWidth: 140,
  204. // prop: 'subType',
  205. // label: '退货产品类型',
  206. // slot: 'subType',
  207. // align: 'center',
  208. // show:j.subType==11,
  209. // showOverflowTooltip: true,formatter(_row, _column, cellValue){
  210. // return cellValue==12?'实物赔偿':'原货'
  211. // }
  212. // },
  213. {
  214. minWidth: 100,
  215. prop: 'specification',
  216. label: '规格',
  217. align: 'center',
  218. slot: 'specification',
  219. showOverflowTooltip: true
  220. },
  221. {
  222. minWidth: 100,
  223. prop: 'modelType',
  224. label: '型号',
  225. align: 'center',
  226. slot: 'modelType',
  227. showOverflowTooltip: true
  228. },
  229. // {
  230. // prop: 'provenance',
  231. // label: '产地',
  232. // slot: 'provenance',
  233. // align: 'center',
  234. // // show:this.contractBookType==2,
  235. // minWidth: 200,
  236. // showOverflowTooltip: true,
  237. // formatter: (row, column) => {
  238. // return row.provenance && row.provenance.length
  239. // ? row.provenance
  240. // .map((item) => this.getDictValue('产地', item ))
  241. // .join(',')
  242. // : '';
  243. // }
  244. // },
  245. {
  246. minWidth: 100,
  247. prop: 'pricingWay',
  248. label: '计价方式',
  249. align: 'center',
  250. slot: 'pricingWay',
  251. showOverflowTooltip: true,
  252. formatter: (_row, _column, cellValue) => {
  253. let pricingWay = pricingWayList.find(item => item.id == cellValue)
  254. return pricingWay ? pricingWay.name : ''
  255. }
  256. },
  257. {
  258. minWidth: 100,
  259. prop: 'totalCount',
  260. label: '数量',
  261. align: 'center',
  262. slot: 'totalCount'
  263. },
  264. {
  265. minWidth: 120,
  266. prop: 'measuringUnit',
  267. label: '计量单位',
  268. align: 'center',
  269. slot: 'measuringUnit'
  270. },
  271. {
  272. width: 100,
  273. prop: 'receiveTotalWeight',
  274. label: '收货总重',
  275. slot: 'receiveTotalWeight',
  276. align: "center"
  277. },
  278. {
  279. width: 100,
  280. prop: 'sendTotalWeight',
  281. label: '发货总重',
  282. slot: 'sendTotalWeight',
  283. align: "center",
  284. headerSlot: 'headerTotalCount'
  285. },
  286. {
  287. width: 100,
  288. prop: 'increaseTotalWeight',
  289. label: '增重重量',
  290. slot: 'increaseTotalWeight',
  291. align: "center"
  292. },
  293. {
  294. width: 100,
  295. prop: 'weightUnit',
  296. label: '重量单位',
  297. slot: 'weightUnit',
  298. align: "center"
  299. },
  300. {
  301. minWidth: 90,
  302. prop: 'singlePrice',
  303. label: '单价',
  304. align: 'center',
  305. slot: 'singlePrice',
  306. },
  307. {
  308. minWidth: 100,
  309. prop: 'taxRate',
  310. label: '税率',
  311. align: 'center',
  312. },
  313. {
  314. width: 150,
  315. prop: 'noTaxSinglePrice',
  316. label: '不含税单价',
  317. align: 'center'
  318. },
  319. {
  320. minWidth: 120,
  321. prop: 'totalPrice',
  322. label: '合计',
  323. slot: 'totalPrice',
  324. align: 'center',
  325. },
  326. {
  327. minWidth: 100,
  328. prop: 'discountRatio',
  329. label: '折让比例',
  330. align: 'center',
  331. },
  332. {
  333. minWidth: 100,
  334. prop: 'discountSinglePrice',
  335. label: '折让单价',
  336. align: 'center',
  337. },
  338. {
  339. minWidth: 120,
  340. prop: 'discountTotalPrice',
  341. label: '折让合计',
  342. slot: 'discountTotalPrice',
  343. align: 'center',
  344. },
  345. ]
  346. let permissionType = {
  347. // 'financeLeader': [
  348. // {
  349. // minWidth: 130,
  350. // prop: 'receivedPrice',
  351. // label: '已收款金额',
  352. // align: 'center',
  353. // slot: 'receivedPrice',
  354. // headerSlot: 'headerReceivedPrice'
  355. // },
  356. // {
  357. // minWidth: 130,
  358. // prop: 'receivablePrice',
  359. // label: '应收款金额',
  360. // align: 'center',
  361. // slot: 'receivablePrice',
  362. // },
  363. // {
  364. // minWidth: 140,
  365. // prop: 'receivableDate',
  366. // label: '应收款日期',
  367. // align: 'center',
  368. // slot: 'receivableDate',
  369. // headerSlot: 'headerReceivableDate'
  370. // },
  371. // {
  372. // minWidth: 130,
  373. // prop: 'invoicedPrice',
  374. // label: '已开票金额',
  375. // align: 'center',
  376. // slot: 'invoicedPrice',
  377. // headerSlot: 'headerInvoicedPrice'
  378. // },
  379. // {
  380. // minWidth: 130,
  381. // prop: 'notInvoicedPrice',
  382. // label: '未开票金额',
  383. // align: 'center',
  384. // slot: 'notInvoicedPrice'
  385. // },
  386. // ],
  387. // 'leader': [
  388. // {
  389. // minWidth: 130,
  390. // prop: 'receivedPrice',
  391. // label: '已收款金额',
  392. // align: 'center',
  393. // slot: 'receivedPrice'
  394. // },
  395. // {
  396. // minWidth: 130,
  397. // prop: 'receivablePrice',
  398. // label: '应收款金额',
  399. // align: 'center',
  400. // slot: 'receivablePrice'
  401. // },
  402. // {
  403. // minWidth: 140,
  404. // prop: 'receivableDate',
  405. // label: '应收款日期',
  406. // align: 'center',
  407. // slot: 'receivableDate'
  408. // },
  409. // {
  410. // minWidth: 130,
  411. // prop: 'invoicedPrice',
  412. // label: '已开票金额',
  413. // align: 'center',
  414. // slot: 'invoicedPrice'
  415. // },
  416. // {
  417. // minWidth: 130,
  418. // prop: 'notInvoicedPrice',
  419. // label: '未开票金额',
  420. // align: 'center',
  421. // slot: 'notInvoicedPrice'
  422. // },
  423. // ],
  424. // 'uploadReceipt': [
  425. // {
  426. // minWidth: 130,
  427. // prop: 'receivedPrice',
  428. // label: '已收款金额',
  429. // align: 'center',
  430. // slot: 'receivedPrice'
  431. // },
  432. // {
  433. // minWidth: 130,
  434. // prop: 'receivablePrice',
  435. // label: '应收款金额',
  436. // align: 'center',
  437. // slot: 'receivablePrice'
  438. // },
  439. // {
  440. // minWidth: 140,
  441. // prop: 'receivableDate',
  442. // label: '应收款日期',
  443. // align: 'center',
  444. // slot: 'receivableDate'
  445. // },
  446. // {
  447. // minWidth: 130,
  448. // prop: 'invoicedPrice',
  449. // label: '已开票金额',
  450. // align: 'center',
  451. // slot: 'invoicedPrice'
  452. // },
  453. // {
  454. // minWidth: 130,
  455. // prop: 'notInvoicedPrice',
  456. // label: '未开票金额',
  457. // align: 'center',
  458. // slot: 'notInvoicedPrice'
  459. // },
  460. // ],
  461. }
  462. permissionType[this.taskDefinitionKey] && basicFields.push(...permissionType[this.taskDefinitionKey])
  463. return basicFields
  464. }
  465. },
  466. getTitle(){
  467. return (item, type)=>{
  468. // let title=this.subTypeList[j.subType]+(j.statementSubOrderCode||'')+' '
  469. // if(j.subType==11&&j.subExecType){
  470. // if(j.subExecType=='10'){
  471. // title=title+' 退货方式:全部原货 '
  472. // }
  473. // if(j.subExecType=='20'){
  474. // title=title+' 退货方式:部分原货+实物赔偿'
  475. // }
  476. // if(j.subExecType=='30'){
  477. // title=title+' 退货方式:部分原货+现金赔偿 '+' 赔偿金额:'+j.amountPayablePrice
  478. // }
  479. // if(j.subExecType=='40'){
  480. // title=title+' 退货方式:全部实物赔偿'
  481. // }
  482. // if(j.subExecType=='50'){
  483. // title=title+' 退货方式:全部现金赔偿 '+' 赔偿金额:'+j.amountPayablePrice
  484. // }
  485. // }
  486. console.log(item[type])
  487. const total = item[type]?.reduce((prev, curr) => {
  488. console.log(curr.discountTotalPrice)
  489. return prev + Number(curr.discountTotalPrice || 0) + '元';
  490. }, 0);
  491. return `对账金额合计:${total}`
  492. }
  493. },
  494. },
  495. data() {
  496. return {
  497. activeNames: [],
  498. rules: {},
  499. form: {},
  500. subTypeList:{
  501. 10:'发货单:',
  502. 11:'退货单:',
  503. 12:'实物赔偿清单:',
  504. 30:'调拨单:',
  505. },
  506. subColumnsTypeList:{
  507. 10: '发货',
  508. 11: '退货',
  509. 30: '调拨'
  510. },
  511. };
  512. },
  513. watch: {
  514. datasource: {
  515. handler(newVal, oldVal) {
  516. console.log('newVal~~~', newVal)
  517. if (newVal.length > 0) {
  518. this.activeNames = newVal.map((item, index) => index);
  519. // console.log('this.activeNames~~~', this.activeNames)
  520. }
  521. },
  522. deep: true
  523. }
  524. },
  525. created(){
  526. this.requestDict('产地');
  527. },
  528. mounted() {
  529. // this.activeNames = this.datasource.map((item, index) => index);
  530. },
  531. methods: {
  532. remove(tableIndex, lineIndex, delType) {
  533. let params = {
  534. tableIndex,
  535. lineIndex,
  536. delType
  537. }
  538. this.$emit('handleRemove', params)
  539. },
  540. getSummaries(param) {
  541. const {columns, data} = param;
  542. const sums = [];
  543. let fields = ['totalPrice', 'notInvoicedPrice', 'invoicedPrice', 'receivablePrice', 'receivedPrice', 'discountTotalPrice']
  544. columns.forEach((column, index) => {
  545. if (index === 0) {
  546. sums[index] = '合计';
  547. return;
  548. }
  549. const values = fields.includes(column.property) ? data.map(item => Number(item[column.property])) : []
  550. if (!values.every(value => isNaN(value))) {
  551. sums[index] = values.reduce((prev, curr) => {
  552. const value = Number(curr);
  553. if (!isNaN(value)) {
  554. return prev + curr;
  555. } else {
  556. return prev;
  557. }
  558. }, 0);
  559. sums[index] = (sums[index]).toFixed(2)
  560. } else {
  561. sums[index] = '';
  562. }
  563. });
  564. return sums;
  565. },
  566. getSummariesA(table) {
  567. return table.reduce((prev, curr) => {
  568. return prev + Number(curr.discountTotalPrice || 0)
  569. }, 0)
  570. }
  571. }
  572. };
  573. </script>
  574. <style lang="scss" scoped>
  575. .collapse-title {
  576. display: flex;
  577. justify-content: space-between;
  578. align-items: center;
  579. width: 96%;
  580. }
  581. .collapse-title-left {
  582. display: flex;
  583. /* justify-content: center; */
  584. align-items: center;
  585. font-size: 16px;
  586. }
  587. .collapse-title-index {
  588. width: 24px;
  589. height: 24px;
  590. background: #63a103;
  591. display: inline-block;
  592. text-align: center;
  593. line-height: 24px;
  594. border-radius: 50%;
  595. color: #fff;
  596. margin-right: 10px;
  597. font-size: 14px;
  598. }
  599. .collapse-title-right {
  600. display:grid;
  601. grid-auto-flow: column;
  602. gap: 18px;
  603. }
  604. .headbox {
  605. display: flex;
  606. justify-content: space-between;
  607. align-items: center;
  608. .amount {
  609. font-size: 14px;
  610. font-weight: bold;
  611. padding-right: 30px;
  612. }
  613. }
  614. .time-form .el-form-item {
  615. margin-bottom: 0 !important;
  616. }
  617. ::v-deep .period {
  618. display: flex;
  619. .borderleftnone {
  620. .el-input--medium .el-input__inner {
  621. border-top-right-radius: 0;
  622. border-bottom-right-radius: 0;
  623. }
  624. }
  625. .borderrightnone {
  626. .el-input--medium .el-input__inner {
  627. border-top-left-radius: 0;
  628. border-bottom-left-radius: 0;
  629. }
  630. }
  631. }
  632. ::v-deep .time-form tbody > tr:hover > td {
  633. background-color: transparent !important;
  634. }
  635. ::v-deep .time-form .el-table tr {
  636. background-color: #ffffff;
  637. }
  638. .pricebox {
  639. display: flex;
  640. justify-content: flex-start;
  641. align-items: center;
  642. font-weight: bold;
  643. }
  644. ::v-deep.el-divider {
  645. margin: 10px;
  646. font-weight: bold;
  647. }
  648. </style>