|
|
|
@ -11,10 +11,10 @@
|
|
|
|
|
<BasicTable class="ds-table" @register="registerTable" @row-click="onRowClick">
|
|
|
|
|
<template #tableTitle>
|
|
|
|
|
<div class="flex" style="align-items: center;">
|
|
|
|
|
<div style="font-size: 12px;font-weight: bold;margin-right: 15px">结算明细</div>
|
|
|
|
|
<div style="font-size: 12px;font-weight: bold;margin-right: 5px">结算明细</div>
|
|
|
|
|
<a-button class="ml15" type="link" @click="addInfos">
|
|
|
|
|
<span class="iconfont icon-zengjiatianjiajiajian" :style="{ fontSize: '12px' }"></span>
|
|
|
|
|
添加发票明细
|
|
|
|
|
添加结算明细
|
|
|
|
|
</a-button>
|
|
|
|
|
<span style="font-size: 12px;">结算币别</span>
|
|
|
|
|
<a-select size="small" v-model:value="currency" style="width: 150px;margin-left: 15px"
|
|
|
|
@ -30,7 +30,11 @@
|
|
|
|
|
<BasicTable class="ds-table" @register="registerTable1">
|
|
|
|
|
<template #tableTitle>
|
|
|
|
|
<div>
|
|
|
|
|
<span class="bold">费用明细</span>
|
|
|
|
|
<span class="bold">结算费用明细</span>
|
|
|
|
|
<a-button v-if="route.query.type == 'free'" class="ml15" type="link" @click="addInfosFee">
|
|
|
|
|
<span class="iconfont icon-zengjiatianjiajiajian" :style="{ fontSize: '12px' }"></span>
|
|
|
|
|
添加结算费用明细
|
|
|
|
|
</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:bodyCell="{ column, record }">
|
|
|
|
@ -38,18 +42,58 @@
|
|
|
|
|
<span v-if="record.feeType == 1">应收</span>
|
|
|
|
|
<span v-if="record.feeType == 2">应付</span>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-if="column.dataIndex == 'amount'">
|
|
|
|
|
<a-input-number @change="onSelectChangeDetail" :precision="2" size="small" :controls="false"
|
|
|
|
|
:max="record.restAmount" v-model:value="record.amount" />
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div class="main-statistic" v-if="route.query.type == 'free'">
|
|
|
|
|
<span>选中合计:</span>
|
|
|
|
|
<span class="box">
|
|
|
|
|
<span class="title">金额:</span>
|
|
|
|
|
<span class="count">{{ totalAmount }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</BasicTable>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div class="main-statistic">
|
|
|
|
|
<div class="main-statistic" v-if="route.query.type == 'invoice'">
|
|
|
|
|
<span>选中合计:</span>
|
|
|
|
|
<span class="box">
|
|
|
|
|
<span class="title">发票金额:</span>
|
|
|
|
|
<span class="count">{{ rrmb }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="main-statistic" v-if="route.query.type == 'free'">
|
|
|
|
|
<span>选中合计:</span>
|
|
|
|
|
<span class="box">
|
|
|
|
|
<span class="title">未收RMB:</span>
|
|
|
|
|
<span class="count">{{ srmb }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span class="box">
|
|
|
|
|
<span class="title">未付RMB:</span>
|
|
|
|
|
<span class="count">{{ frmb }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span class="box">
|
|
|
|
|
<span class="title">未收USD:</span>
|
|
|
|
|
<span class="count">{{ susd }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span class="box">
|
|
|
|
|
<span class="title">未付USD:</span>
|
|
|
|
|
<span class="count">{{ fusd }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span class="box">
|
|
|
|
|
<span class="title">未收其他:</span>
|
|
|
|
|
<span class="count">{{ sqt }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span class="box">
|
|
|
|
|
<span class="title">未付其他:</span>
|
|
|
|
|
<span class="count">{{ ftq }}</span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:bodyCell="{ column, record }">
|
|
|
|
|
<template v-if="column.key === 'isLocked'">
|
|
|
|
@ -72,7 +116,7 @@
|
|
|
|
|
<span class="bold" style="margin-right: 10px;width:46px;display: inline-block">1{{ item.currencyTo
|
|
|
|
|
}}
|
|
|
|
|
=</span>
|
|
|
|
|
<a-input-number addon-after="RMB" :precision="4" size="small" :controls="false"
|
|
|
|
|
<a-input-number :addon-after="item.currencyFrom" :precision="4" size="small" :controls="false"
|
|
|
|
|
v-model:value="item.reverseRate" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -84,10 +128,10 @@
|
|
|
|
|
import { onMounted, ref, reactive, watch, defineExpose, defineProps, defineEmits, h } from 'vue'
|
|
|
|
|
import { BasicTable, useTable } from '/@/components/Table'
|
|
|
|
|
import {
|
|
|
|
|
InvoiceSettlementGetInvoiceList, InvoiceSettlementGetInvoiceDetails,
|
|
|
|
|
InvoiceSettlementGetInvoiceList, InvoiceSettlementGetInvoiceDetails, PaymentFreeSettlementGetFees,
|
|
|
|
|
InvoiceSettlementGetExchanges, GetExchangeRate, PaymentFreeSettlementGetBizList
|
|
|
|
|
} from '../api'
|
|
|
|
|
import { invoiceTableColums, invoiceSearchFormSchema, invoiceTableDetailColums, freeTableColums, freeSearchFormSchema } from '../columns'
|
|
|
|
|
import { invoiceTableColums, invoiceSearchFormSchema, invoiceTableDetailColums, freeTableColums, freeSearchFormSchema, freeTableDetailColums } from '../columns'
|
|
|
|
|
import { GetFeeCurrencySelectList } from '/@/api/common'
|
|
|
|
|
import feeTable from '/@/components/CostEntry/components/feeTable.vue'
|
|
|
|
|
import { BasicForm, useForm } from '/@/components/Form'
|
|
|
|
@ -96,14 +140,15 @@ import ExchangeRate from './exchangeRate.vue'
|
|
|
|
|
import { useMessage } from '/@/hooks/web/useMessage'
|
|
|
|
|
import { Divider } from 'ant-design-vue'
|
|
|
|
|
import { formatParams } from '/@/hooks/web/common'
|
|
|
|
|
const emits = defineEmits(['updateList', 'refresh'])
|
|
|
|
|
const emits = defineEmits(['updateList', 'refresh','updateListFree'])
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
|
|
import { get } from 'lodash'
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const { createMessage } = useMessage()
|
|
|
|
|
// 未收rmb
|
|
|
|
|
const rrmb = ref(0)
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const [registerTable, { reload, getForm, getSelectRows, setSelectedRowKeys, getDataSource }] = useTable({
|
|
|
|
|
const [registerTable, { getForm, getSelectRows, setSelectedRowKeys }] = useTable({
|
|
|
|
|
api: async (p) => {
|
|
|
|
|
let res = {} as any
|
|
|
|
|
if (route.query.type == 'free') {
|
|
|
|
@ -124,7 +169,7 @@ const [registerTable, { reload, getForm, getSelectRows, setSelectedRowKeys, getD
|
|
|
|
|
},
|
|
|
|
|
columns: getColums(),
|
|
|
|
|
maxHeight: '900',
|
|
|
|
|
rowKey: 'id',
|
|
|
|
|
rowKey: getId(),
|
|
|
|
|
formConfig: {
|
|
|
|
|
labelWidth: 120,
|
|
|
|
|
schemas: getSearch(),
|
|
|
|
@ -137,28 +182,47 @@ const [registerTable, { reload, getForm, getSelectRows, setSelectedRowKeys, getD
|
|
|
|
|
bordered: true,
|
|
|
|
|
showIndexColumn: false,
|
|
|
|
|
canResize: false,
|
|
|
|
|
showTableSetting: false,
|
|
|
|
|
id: '4',
|
|
|
|
|
showTableSetting: true,
|
|
|
|
|
id: getTableId(),
|
|
|
|
|
immediate: false
|
|
|
|
|
})
|
|
|
|
|
const [registerTable1, { getSelectRows: getSelectRowsFee, setProps: setPropsFee, setTableData }] = useTable({
|
|
|
|
|
columns: invoiceTableDetailColums,
|
|
|
|
|
const [registerTable1, { getSelectRows: getSelectRowsDetail, setTableData }] = useTable({
|
|
|
|
|
columns: getColumsDetail(),
|
|
|
|
|
useSearchForm: false,
|
|
|
|
|
showIndexColumn: false,
|
|
|
|
|
pagination: false,
|
|
|
|
|
striped: false,
|
|
|
|
|
rowSelection: {
|
|
|
|
|
onChange: onSelectChangeDetail
|
|
|
|
|
},
|
|
|
|
|
maxHeight: '900',
|
|
|
|
|
rowKey: 'recordId',
|
|
|
|
|
bordered: true,
|
|
|
|
|
indexColumnProps: {
|
|
|
|
|
width: 60,
|
|
|
|
|
},
|
|
|
|
|
showTableSetting: true,
|
|
|
|
|
id: '3',
|
|
|
|
|
id: getTableDetailId(),
|
|
|
|
|
canResize: false,
|
|
|
|
|
immediate: false,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function getTableId() {
|
|
|
|
|
if (route.query.type == 'invoice') {
|
|
|
|
|
return 3
|
|
|
|
|
}
|
|
|
|
|
if (route.query.type == 'free') {
|
|
|
|
|
return 7
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function getTableDetailId() {
|
|
|
|
|
if (route.query.type == 'invoice') {
|
|
|
|
|
return 4
|
|
|
|
|
}
|
|
|
|
|
if (route.query.type == 'free') {
|
|
|
|
|
return 8
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getColums() {
|
|
|
|
|
if (route.query.type == 'invoice') {
|
|
|
|
|
return invoiceTableColums
|
|
|
|
@ -167,6 +231,22 @@ function getColums() {
|
|
|
|
|
return freeTableColums
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function getId() {
|
|
|
|
|
if (route.query.type == 'invoice') {
|
|
|
|
|
return 'id'
|
|
|
|
|
}
|
|
|
|
|
if (route.query.type == 'free') {
|
|
|
|
|
return 'businessId'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function getColumsDetail() {
|
|
|
|
|
if (route.query.type == 'invoice') {
|
|
|
|
|
return invoiceTableDetailColums
|
|
|
|
|
}
|
|
|
|
|
if (route.query.type == 'free') {
|
|
|
|
|
return freeTableDetailColums
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSearch() {
|
|
|
|
|
if (route.query.type == 'invoice') {
|
|
|
|
@ -181,20 +261,41 @@ const currenciesData = ref([]) as any
|
|
|
|
|
const exchangeFlag = ref(false)
|
|
|
|
|
// 行点击事件
|
|
|
|
|
const onRowClick = (record, index) => {
|
|
|
|
|
setSelectedRowKeys([record.id])
|
|
|
|
|
onSelectChange()
|
|
|
|
|
const data = {
|
|
|
|
|
ids: [record.id],
|
|
|
|
|
businessType: record.businessType,
|
|
|
|
|
}
|
|
|
|
|
loading.value = true
|
|
|
|
|
InvoiceSettlementGetInvoiceDetails(data).then(res => {
|
|
|
|
|
if (res.succeeded) {
|
|
|
|
|
setTableData(res.data)
|
|
|
|
|
}
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
if (route.query.type == 'invoice') {
|
|
|
|
|
setSelectedRowKeys([record.id])
|
|
|
|
|
const data = {
|
|
|
|
|
ids: [record.id],
|
|
|
|
|
businessType: record.businessType,
|
|
|
|
|
customerId: record.customerId
|
|
|
|
|
} as any
|
|
|
|
|
InvoiceSettlementGetInvoiceDetails(data).then(res => {
|
|
|
|
|
if (res.succeeded) {
|
|
|
|
|
setTableData(res.data)
|
|
|
|
|
}
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (route.query.type == 'free') {
|
|
|
|
|
setSelectedRowKeys([record.businessId])
|
|
|
|
|
const data = [{
|
|
|
|
|
id: record.businessId,
|
|
|
|
|
businessType: record.businessType,
|
|
|
|
|
customerId: record.customerId
|
|
|
|
|
}] as any
|
|
|
|
|
PaymentFreeSettlementGetFees(data).then(res => {
|
|
|
|
|
if (res.succeeded) {
|
|
|
|
|
setTableData(res.data.items)
|
|
|
|
|
}
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 1. 发票结算就一个按钮 如果结算币别不是rmb就得调接口转换汇率 和前面几个发票页面基本一致的逻辑
|
|
|
|
|
// 2.自由结算 两个按钮 区分费用和业务 如果结算币别和选的币别不一致就调接口换汇率
|
|
|
|
|
// 然后如果是选的费用明细 也就是右边 转换完汇率需要修改金额 汇率这几个字段 和发票一样 弄成原始得啥的
|
|
|
|
|
// 3. 申请结算 还没有
|
|
|
|
|
function addInfos() {
|
|
|
|
|
let arr = getSelectRows() ? getSelectRows() : []
|
|
|
|
|
if (arr.length == 0) {
|
|
|
|
@ -271,30 +372,115 @@ function addInfos() {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const addFreetype = ref('')
|
|
|
|
|
function addInfosFee() {
|
|
|
|
|
let arr = getSelectRowsDetail() ? getSelectRowsDetail() : []
|
|
|
|
|
if (arr.length == 0) {
|
|
|
|
|
createMessage.error('请选择费用明细')
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if (!currency.value) {
|
|
|
|
|
createMessage.error('请选择结算币别')
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
const cuArr = [] as any
|
|
|
|
|
exchangarr.value = []
|
|
|
|
|
arr.forEach(item => {
|
|
|
|
|
if (item.currency !== currency.value) {
|
|
|
|
|
cuArr.push(item)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (cuArr.length > 0) {
|
|
|
|
|
const filteredItems = cuArr.filter((item, index, self) =>
|
|
|
|
|
index === self.findIndex((t) => t.currency === item.currency)
|
|
|
|
|
);
|
|
|
|
|
const promises = filteredItems.map(item => {
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
const data = {
|
|
|
|
|
currencyFrom: currency.value,
|
|
|
|
|
currencyTo: item.currency,
|
|
|
|
|
}
|
|
|
|
|
GetExchangeRate(data).then(res => {
|
|
|
|
|
exchangarr.value.push(res.data)
|
|
|
|
|
resolve(true);
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
return Promise.all(promises).then(() => {
|
|
|
|
|
addFreetype.value = 'right'
|
|
|
|
|
exchangeFlag.value = true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 确定汇率 1.发票结算 不用考虑很多 把exchangeRates整好就行 和前面页面基本一致
|
|
|
|
|
// 自由结算 区分左右两种按钮
|
|
|
|
|
function handleSureExhange() {
|
|
|
|
|
currenciesData.value.forEach(item => {
|
|
|
|
|
item.exchangeRates.forEach(itemC => {
|
|
|
|
|
if (route.query.type == 'invoice') {
|
|
|
|
|
currenciesData.value.forEach(item => {
|
|
|
|
|
item.exchangeRates.forEach(itemC => {
|
|
|
|
|
exchangarr.value.forEach(ite => {
|
|
|
|
|
if (itemC.currency == ite.currencyTo) {
|
|
|
|
|
itemC.exchangeRate = ite.reverseRate
|
|
|
|
|
}
|
|
|
|
|
if (itemC.currency == 'RMB') {
|
|
|
|
|
itemC.exchangeRate = 1
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
openFlag.value = false
|
|
|
|
|
exchangeFlag.value = false
|
|
|
|
|
emits('updateList', currenciesData.value, currency.value)
|
|
|
|
|
}
|
|
|
|
|
if (route.query.type == 'free') {
|
|
|
|
|
const list = JSON.parse(JSON.stringify(getSelectRowsDetail()))
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
exchangarr.value.forEach(ite => {
|
|
|
|
|
if (itemC.currency == ite.currencyTo) {
|
|
|
|
|
itemC.exchangeRate = ite.reverseRate
|
|
|
|
|
}
|
|
|
|
|
if (itemC.currency == 'RMB') {
|
|
|
|
|
itemC.exchangeRate = 1
|
|
|
|
|
if (item.currency == ite.currencyTo) {
|
|
|
|
|
item.exchangeRate = ite.reverseRate
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
openFlag.value = false
|
|
|
|
|
exchangeFlag.value = false
|
|
|
|
|
emits('updateList', currenciesData.value, currency.value)
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
item.originalCurrency = item.currency
|
|
|
|
|
item.currency = currency.value
|
|
|
|
|
item.originalAmount = item.amount
|
|
|
|
|
item.amount = Number((Number(item.amount) * Number(item.exchangeRate)).toFixed(2))
|
|
|
|
|
})
|
|
|
|
|
emits('updateListFree', list, currency.value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const srmb = ref(0)
|
|
|
|
|
const frmb = ref(0)
|
|
|
|
|
const susd = ref(0)
|
|
|
|
|
const fusd = ref(0)
|
|
|
|
|
const sqt = ref(0)
|
|
|
|
|
const ftq = ref(0)
|
|
|
|
|
function onSelectChange(selectedRowKeys) {
|
|
|
|
|
const list = getSelectRows()
|
|
|
|
|
console.log(list)
|
|
|
|
|
rrmb.value = 0
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
rrmb.value += Number(item.applyAmount)
|
|
|
|
|
})
|
|
|
|
|
srmb.value = 0
|
|
|
|
|
frmb.value = 0
|
|
|
|
|
susd.value = 0
|
|
|
|
|
fusd.value = 0
|
|
|
|
|
sqt.value = 0
|
|
|
|
|
ftq.value = 0
|
|
|
|
|
if (route.query.type == 'free') {
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
srmb.value += Number(item.unchargedRMB)
|
|
|
|
|
frmb.value += Number(item.unpaidRMB)
|
|
|
|
|
susd.value += Number(item.unchargedUSD)
|
|
|
|
|
fusd.value += Number(item.unpaidUSD)
|
|
|
|
|
sqt.value += Number(item.unchargedOther)
|
|
|
|
|
ftq.value += Number(item.unpaidOther)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (route.query.type == 'invoice') {
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
rrmb.value += Number(item.applyAmount)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
const openFlag = ref(false)
|
|
|
|
|
const opneType = ref('')
|
|
|
|
@ -308,6 +494,16 @@ function init() {
|
|
|
|
|
}
|
|
|
|
|
}, 200)
|
|
|
|
|
}
|
|
|
|
|
const totalAmount = ref(0)
|
|
|
|
|
function onSelectChangeDetail() {
|
|
|
|
|
const list = getSelectRowsDetail()
|
|
|
|
|
if (route.query.type == 'free') {
|
|
|
|
|
totalAmount.value = 0
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
totalAmount.value += Number(item.amount)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const currency = ref('')
|
|
|
|
|
const currencyList = ref([]) as any
|
|
|
|
|
onMounted(() => {
|
|
|
|
|