发票开出

szh-new
sunzehua 2 months ago
parent a7f9d309ab
commit e6c087debd

@ -365,6 +365,7 @@ function changeApply() {
} }
} }
const freeType = ref('') const freeType = ref('')
const currenciesData = ref([]) as any
function addDetailFree() { function addDetailFree() {
let arr = getSelectRowsFree() ? getSelectRowsFree() : [] let arr = getSelectRowsFree() ? getSelectRowsFree() : []
if (arr.length == 0) { if (arr.length == 0) {
@ -379,19 +380,30 @@ function addDetailFree() {
customerId: item.customerId customerId: item.customerId
}) })
}) })
currenciesData.value = []
exchangarr.value = []
GetCurrencies(freeList).then(res => { GetCurrencies(freeList).then(res => {
const cuArr = [] const cuArr = [] as any
currenciesData.value = res.data
res.data.forEach(item => { res.data.forEach(item => {
if (item != 'RMB') { item.exchangeRates.forEach(ite => {
cuArr.push(1) if (ite.currency != 'RMB') {
cuArr.push({
currency: ite.currency,
id: item.id
})
} }
}) })
})
if (cuArr.length > 0) { 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) => { return new Promise((resolve) => {
const data = { const data = {
currencyFrom: 'RMB', currencyFrom: 'RMB',
currencyTo: item, currencyTo: item.currency,
} }
GetExchangeRate(data).then(res => { GetExchangeRate(data).then(res => {
exchangarr.value.push(res.data) exchangarr.value.push(res.data)
@ -447,24 +459,36 @@ function handleSureExhange() {
exchangeFlag.value = false exchangeFlag.value = false
} }
if (route.query.type == 'free') { if (route.query.type == 'free') {
let arr = [] as any
if (freeType.value == 'left') { if (freeType.value == 'left') {
arr = getSelectRowsFree() let arr = [] as any
} else { currenciesData.value.forEach(item => {
arr = getSelectRowsFeeDetail() 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)
}
if (freeType.value == 'right') {
let arr = [] as any
arr = getSelectRowsFeeDetail()
arr.forEach(item => { arr.forEach(item => {
exchangarr.value.forEach(ite => { exchangarr.value.forEach(ite => {
if (item.currency == item.currencyTo) { if (item.currency == ite.currencyTo) {
item.exchangeRate = ite.reverseRate item.exchangeRate = ite.reverseRate
} }
}) })
}) })
open.value = false freeFlag.value = false
exchangeFlag.value = false exchangeFlag.value = false
if (freeType.value == 'left') {
emits('updateListFreeLeft', arr)
} else {
emits('updateListFree', arr) emits('updateListFree', arr)
} }
} }

@ -684,6 +684,7 @@ function updateListFreeLeft(val){
}, },
bizList: val, bizList: val,
} }
loading.value = true
FreeInvoiceSave(data).then(res => { FreeInvoiceSave(data).then(res => {
if (res.succeeded) { if (res.succeeded) {
createMessage.success('保存成功') createMessage.success('保存成功')
@ -697,6 +698,9 @@ function updateListFreeLeft(val){
getDetail() getDetail()
} }
} }
loading.value = false
}).catch(()=>{
loading.value = false
}) })
} }
function handleUpdate(val) { function handleUpdate(val) {
@ -708,6 +712,7 @@ function handleUpdate(val) {
invoiceDetails: list.value, invoiceDetails: list.value,
applications: val, applications: val,
} }
loading.value = true
GeneralInvoiceSave(data).then(res => { GeneralInvoiceSave(data).then(res => {
if (res.succeeded) { if (res.succeeded) {
createMessage.success('保存成功') createMessage.success('保存成功')
@ -721,6 +726,9 @@ function handleUpdate(val) {
getDetail() getDetail()
} }
} }
loading.value = false
}).catch(()=>{
loading.value = false
}) })
} }
function updateListFree(val) { function updateListFree(val) {
@ -737,6 +745,7 @@ function updateListFree(val) {
}, },
details: val, details: val,
} }
loading.value = true
FreeInvoiceSave(data).then(res => { FreeInvoiceSave(data).then(res => {
if (res.succeeded) { if (res.succeeded) {
createMessage.success('保存成功') createMessage.success('保存成功')
@ -750,6 +759,9 @@ function updateListFree(val) {
getDetail() getDetail()
} }
} }
loading.value = false
}).catch(()=>{
loading.value = false
}) })
} }

Loading…
Cancel
Save