From e6c087debd425edaa8214344855c836faf405f87 Mon Sep 17 00:00:00 2001 From: sunzehua Date: Tue, 24 Sep 2024 08:30:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=A5=A8=E5=BC=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../invoiceIssue/detail/applyInvoice.vue | 66 +++++++++++++------ .../operation/invoiceIssue/detail/index.vue | 12 ++++ 2 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/views/operation/invoiceIssue/detail/applyInvoice.vue b/src/views/operation/invoiceIssue/detail/applyInvoice.vue index c15413d6..e6dc3c7d 100644 --- a/src/views/operation/invoiceIssue/detail/applyInvoice.vue +++ b/src/views/operation/invoiceIssue/detail/applyInvoice.vue @@ -365,6 +365,7 @@ function changeApply() { } } const freeType = ref('') +const currenciesData = ref([]) as any function addDetailFree() { let arr = getSelectRowsFree() ? getSelectRowsFree() : [] if (arr.length == 0) { @@ -379,19 +380,30 @@ function addDetailFree() { customerId: item.customerId }) }) + currenciesData.value = [] + exchangarr.value = [] GetCurrencies(freeList).then(res => { - const cuArr = [] + const cuArr = [] as any + currenciesData.value = res.data res.data.forEach(item => { - if (item != 'RMB') { - cuArr.push(1) - } + item.exchangeRates.forEach(ite => { + if (ite.currency != 'RMB') { + cuArr.push({ + currency: ite.currency, + id: item.id + }) + } + }) }) if (cuArr.length > 0) { - const promises = cuArr.map(item => { + 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: 'RMB', - currencyTo: item, + currencyTo: item.currency, } GetExchangeRate(data).then(res => { exchangarr.value.push(res.data) @@ -447,24 +459,36 @@ function handleSureExhange() { exchangeFlag.value = false } if (route.query.type == 'free') { - let arr = [] as any if (freeType.value == 'left') { - arr = getSelectRowsFree() - } else { - arr = getSelectRowsFeeDetail() + let arr = [] as any + 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 + } + }) + }) + }) + freeFlag.value = false + exchangeFlag.value = false + emits('updateListFreeLeft', currenciesData.value) } - arr.forEach(item => { - exchangarr.value.forEach(ite => { - if (item.currency == item.currencyTo) { - item.exchangeRate = ite.reverseRate - } + if (freeType.value == 'right') { + let arr = [] as any + arr = getSelectRowsFeeDetail() + arr.forEach(item => { + exchangarr.value.forEach(ite => { + if (item.currency == ite.currencyTo) { + item.exchangeRate = ite.reverseRate + } + }) }) - }) - open.value = false - exchangeFlag.value = false - if (freeType.value == 'left') { - emits('updateListFreeLeft', arr) - } else { + freeFlag.value = false + exchangeFlag.value = false emits('updateListFree', arr) } } diff --git a/src/views/operation/invoiceIssue/detail/index.vue b/src/views/operation/invoiceIssue/detail/index.vue index 6deab183..cb0cbc98 100644 --- a/src/views/operation/invoiceIssue/detail/index.vue +++ b/src/views/operation/invoiceIssue/detail/index.vue @@ -684,6 +684,7 @@ function updateListFreeLeft(val){ }, bizList: val, } + loading.value = true FreeInvoiceSave(data).then(res => { if (res.succeeded) { createMessage.success('保存成功') @@ -697,6 +698,9 @@ function updateListFreeLeft(val){ getDetail() } } + loading.value = false + }).catch(()=>{ + loading.value = false }) } function handleUpdate(val) { @@ -708,6 +712,7 @@ function handleUpdate(val) { invoiceDetails: list.value, applications: val, } + loading.value = true GeneralInvoiceSave(data).then(res => { if (res.succeeded) { createMessage.success('保存成功') @@ -721,6 +726,9 @@ function handleUpdate(val) { getDetail() } } + loading.value = false + }).catch(()=>{ + loading.value = false }) } function updateListFree(val) { @@ -737,6 +745,7 @@ function updateListFree(val) { }, details: val, } + loading.value = true FreeInvoiceSave(data).then(res => { if (res.succeeded) { createMessage.success('保存成功') @@ -750,6 +759,9 @@ function updateListFree(val) { getDetail() } } + loading.value = false + }).catch(()=>{ + loading.value = false }) }