|
|
|
@ -97,7 +97,10 @@
|
|
|
|
|
const [registerTable, { reload, getForm, getSelectRowKeys, getPaginationRef, getSelectRows, setSelectedRows, getDataSource }] = useTable({
|
|
|
|
|
api: async (p) => {
|
|
|
|
|
const res = await GetApplicationList(p)
|
|
|
|
|
if (res?.data?.length) state.historyRowKeys = [res.data[0].id]
|
|
|
|
|
if (res?.data?.length) {
|
|
|
|
|
state.historyRowKeys = [res.data[0].id]
|
|
|
|
|
feeTabel.value.init(res.data[0].id)
|
|
|
|
|
}
|
|
|
|
|
setSelectedRows([res.data[0]])
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
resolve({ data: [...res.data], total: res.count })
|
|
|
|
@ -230,12 +233,14 @@
|
|
|
|
|
currencyConf[item.currency] = item.value
|
|
|
|
|
})
|
|
|
|
|
bPostData.value.documents.forEach(item => {
|
|
|
|
|
item['currency'] = getFieldsValue().currency
|
|
|
|
|
item.exchangeRates.forEach(row => {
|
|
|
|
|
row.exchangeRate = currencyConf[row.currency]
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
loading.value = true
|
|
|
|
|
Save(bPostData.value).then(res => {
|
|
|
|
|
console.log(bPostData.value)
|
|
|
|
|
loading.value = false
|
|
|
|
|
if (res.succeeded) {
|
|
|
|
|
createMessage.success('添加成功!')
|
|
|
|
@ -257,85 +262,71 @@
|
|
|
|
|
if (selectRows.length == 0) {
|
|
|
|
|
return createMessage.warning('没有选择要添加的业务!')
|
|
|
|
|
}
|
|
|
|
|
console.log(props.formData)
|
|
|
|
|
// 原币申请
|
|
|
|
|
const postData = {
|
|
|
|
|
description: '按申请单增加添加费用明细',
|
|
|
|
|
settlement: props.formData,
|
|
|
|
|
documents: getSelectRows()
|
|
|
|
|
}
|
|
|
|
|
if (!currency) {
|
|
|
|
|
console.log(postData)
|
|
|
|
|
return
|
|
|
|
|
loading.value = true
|
|
|
|
|
Save(postData).then(async (res) => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
if (res.succeeded) {
|
|
|
|
|
createMessage.success('添加成功!')
|
|
|
|
|
if (res?.data?.id) {
|
|
|
|
|
emit('refresh', res.data.id)
|
|
|
|
|
// 如果主单没有币别设置主单币别
|
|
|
|
|
if (!postData.settlement?.currency) postData.settlement.currency = currency
|
|
|
|
|
// 合并所有选择过的费用明细
|
|
|
|
|
let currencyList = []
|
|
|
|
|
// 根据申请单获取所有币别
|
|
|
|
|
const postCurrency = selectRows.map(item => {
|
|
|
|
|
return {
|
|
|
|
|
id: item.id,
|
|
|
|
|
customerId: item.customerId
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const items = await GetExchanges(postCurrency).then(res => {
|
|
|
|
|
return res.data
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
items.forEach(item => {
|
|
|
|
|
if (item.exchangeRates) {
|
|
|
|
|
item.exchangeRates.forEach(c => {
|
|
|
|
|
if(c.currency != currency) {
|
|
|
|
|
currencyList.push({
|
|
|
|
|
currency: c.currency,
|
|
|
|
|
feeType: 2
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
selectRows.forEach(row => {
|
|
|
|
|
if (item.id == row.id) {
|
|
|
|
|
item.settlementOther = row.settlementOther
|
|
|
|
|
item.settlementRMB = row.settlementRMB
|
|
|
|
|
item.settlementUSD = row.settlementUSD
|
|
|
|
|
item.businessType = 1
|
|
|
|
|
item.customerName = row.customerName
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// 转换汇率申请
|
|
|
|
|
// props.setFieldsValue({
|
|
|
|
|
// currency
|
|
|
|
|
// })
|
|
|
|
|
// 合并所有选择过的费用明细
|
|
|
|
|
let currencyList = []
|
|
|
|
|
// 根据申请单获取所有币别
|
|
|
|
|
const postCurrency = selectRows.map(item => {
|
|
|
|
|
return {
|
|
|
|
|
id: item.id,
|
|
|
|
|
customerId: item.customerId
|
|
|
|
|
if (type == 'rmb') {
|
|
|
|
|
item.settlementUSD = 0
|
|
|
|
|
item.settlementOther = 0
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const items = await GetExchanges(postCurrency).then(res => {
|
|
|
|
|
return res.data
|
|
|
|
|
})
|
|
|
|
|
console.log(items)
|
|
|
|
|
items.forEach(item => {
|
|
|
|
|
if (item.exchangeRates) {
|
|
|
|
|
item.exchangeRates.forEach(c => {
|
|
|
|
|
if(c.currency != currency) {
|
|
|
|
|
currencyList.push({
|
|
|
|
|
currency: c.currency
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (type == 'usd') {
|
|
|
|
|
item.settlementRMB = 0
|
|
|
|
|
item.settlementOther = 0
|
|
|
|
|
}
|
|
|
|
|
selectRows.forEach(row => {
|
|
|
|
|
if (item.id == row.id) {
|
|
|
|
|
item.settlementOther = row.settlementOther
|
|
|
|
|
item.settlementRMB = row.settlementRMB
|
|
|
|
|
item.settlementUSD = row.settlementUSD
|
|
|
|
|
}
|
|
|
|
|
if (type == 'rmb') {
|
|
|
|
|
item.settlementUSD = 0
|
|
|
|
|
item.settlementOther = 0
|
|
|
|
|
}
|
|
|
|
|
if (type == 'usd') {
|
|
|
|
|
item.settlementRMB = 0
|
|
|
|
|
item.settlementOther = 0
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
// 过滤出所有跟业务币别不一致的币别
|
|
|
|
|
currencyList = Array.from(new Set(currencyList.map(item => item.currency))).map(currency => {
|
|
|
|
|
return currencyList.find(item => item.currency === currency)
|
|
|
|
|
})
|
|
|
|
|
postData.documents = items
|
|
|
|
|
bPostData.value = postData
|
|
|
|
|
exchangeRate.value.init(currency, currencyList)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// 过滤出所有跟业务币别不一致的币别
|
|
|
|
|
currencyList = Array.from(new Set(currencyList.map(item => item.currency))).map(currency => {
|
|
|
|
|
return currencyList.find(item => item.currency === currency)
|
|
|
|
|
})
|
|
|
|
|
postData.documents = items
|
|
|
|
|
console.log(postData)
|
|
|
|
|
bPostData.value = postData
|
|
|
|
|
exchangeRate.value.init(currency, currencyList)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
// 如果存在结算对象,则业务数据根据结算对象进行过滤
|
|
|
|
|
if (props.formData?.customerId) {
|
|
|
|
|
await getForm().setFieldsValue({ 'customerId': props.formData.customerId })
|
|
|
|
|
await getForm().setFieldsValue({ 'customerId': props.formData.customerId, customerName: props.formData.customerName })
|
|
|
|
|
setFieldsValue({
|
|
|
|
|
currency: props.formData.currency
|
|
|
|
|
})
|
|
|
|
|