diff --git a/src/components/CostEntry/components/feeColumns.tsx b/src/components/CostEntry/components/feeColumns.tsx index a0cccab3..bb4dfdc1 100644 --- a/src/components/CostEntry/components/feeColumns.tsx +++ b/src/components/CostEntry/components/feeColumns.tsx @@ -66,11 +66,11 @@ export const feeColumns = [ export const feeApplyColumns = [ { title: '客户名称', - width: 150, + width: 100, dataIndex: 'customerName' }, { title: '收付', - width: 80, + width: 50, dataIndex: 'feeType', customRender: ({ record }) => { if (record.feeType == 1) { @@ -83,23 +83,23 @@ export const feeApplyColumns = [ } }, { title: '费用名称', - width: 150, + width: 90, dataIndex: 'feeName' }, { title: '金额', - width: 100, + width: 80, dataIndex: 'amount' }, { title: '币别', - width: 100, + width: 60, dataIndex: 'currency' }, { title: '未结金额', - width: 100, + width: 80, dataIndex: 'restAmount' }, { title: '本次申请金额', - width: 130, + width: 100, dataIndex: 'applyAmount' }, { title: '原始汇率', diff --git a/src/components/CostEntry/components/feeTable.vue b/src/components/CostEntry/components/feeTable.vue index 4fb72132..a3903aee 100644 --- a/src/components/CostEntry/components/feeTable.vue +++ b/src/components/CostEntry/components/feeTable.vue @@ -21,7 +21,7 @@ v-model:value="record.applyAmount" :min="0" :max="record.restAmount" - :step="0.000001" + :step="0.01" string-mode @change="amountChange($event, record)" @click.native.stop="handleInputClick" diff --git a/src/views/finance/paymentSettlement/api.ts b/src/views/finance/paymentSettlement/api.ts index 0fd28a1e..cae309af 100644 --- a/src/views/finance/paymentSettlement/api.ts +++ b/src/views/finance/paymentSettlement/api.ts @@ -12,7 +12,8 @@ enum Api { info = '/feeApi/PaymentSettlement/Get', delete = '/feeApi/PaymentSettlement/Delete', GetApplicationList = '/feeApi/PaymentSettlement/GetApplicationList', - GetApplicationDetailsById = '/feeApi/PaymentSettlement/GetApplicationDetailsById' + GetApplicationDetailsById = '/feeApi/PaymentSettlement/GetApplicationDetailsById', + GetExchanges = '/feeApi/PaymentSettlement/GetExchanges' } // 列表 (Auth) export function GetList(data: PageRequest) { @@ -64,3 +65,12 @@ export function GetApplicationDetailsById(params) { params }) } + +// 根据申请单获取费用币别 +export function GetExchanges(data: PageRequest) { + return request({ + url: Api.GetExchanges, + method: 'post', + data + }) +} diff --git a/src/views/finance/paymentSettlement/detail/components/businessTable.vue b/src/views/finance/paymentSettlement/detail/components/businessTable.vue index 2b557174..5c9b3b61 100644 --- a/src/views/finance/paymentSettlement/detail/components/businessTable.vue +++ b/src/views/finance/paymentSettlement/detail/components/businessTable.vue @@ -49,14 +49,6 @@ > - import { onMounted, ref, reactive, watch, defineExpose, defineProps, defineEmits, h } from 'vue' import { BasicTable, useTable } from '/@/components/Table' - import { GetApplicationList, Save } from '../../api' + import { GetApplicationList, Save, GetExchanges } from '../../api' import { businessColumns, searchFormSchema, currencyFormSchema } from '../columns' import feeTable from './feeTable.vue' import { BasicForm, useForm } from '/@/components/Form' @@ -140,10 +132,8 @@ const allFeeData = {} const feeTabel = ref(null) const historyChange = async (v) => { - console.log(v) if (v.length > 1) { - console.log(getDataSource()) - const a = getDataSource().filter(item => { + const a = getDataSource().filter((item) => { return item.id == v[0] })[0] const b = getDataSource().filter(item => { @@ -222,51 +212,54 @@ // } } // 保存填写汇率并提交 - const saveExchangeRate = (list) => { - feeTableData.value.forEach(row => { - list.forEach(item => { - if (row.currency == item.currency) { - row.exchangeRate = item.value - } + const saveExchangeRate = (data) => { + // 按业务申请 + const currencyConf = {} + data.list.forEach(item => { + currencyConf[item.currency] = item.value + }) + bPostData.value.documents.forEach(item => { + item.exchangeRates.forEach(row => { + row.exchangeRate = currencyConf[row.currency] }) }) - emit('save', feeTableData.value) + loading.value = true + Save(bPostData.value).then(res => { + loading.value = false + if (res.succeeded) { + createMessage.success('添加成功!') + if (res?.data?.id) { + emit('refresh', res.data.id) + } + } + }).catch(() => { + loading.value = false + }) } + // 提交的数据 + const bPostData = ref({}) // 按业务添加费用申请 - const addInfos = () => { + const addInfos = async () => { const selectRows = getSelectRows() - if (props.formData.customerId) { - let flag = false - selectRows.forEach(item => { - if (item.customerId == props.formData.customerId) { - flag = true - } - }) - if (!flag) { - return createMessage.warning('没有选择要添加的业务!') - } - } else { - if (state.historyRowKeys.length == 0 ) { - return createMessage.warning('没有选择要添加的业务!') - } + // 主单是否有币别 + const currency = getFieldsValue().currency + if (selectRows.length == 0) { + return createMessage.warning('没有选择要添加的业务!') } - if (!props.formData.currency) { - // 原币申请 - const postData = { - description: '按申请单增加添加费用明细', - settlement: props.formData, - documents: getSelectRows() - } + // 原币申请 + const postData = { + description: '按申请单增加添加费用明细', + settlement: props.formData, + documents: getSelectRows() + } + if (!currency) { loading.value = true Save(postData).then(async (res) => { loading.value = false if (res.succeeded) { createMessage.success('添加成功!') if (res?.data?.id) { - await props.setFieldsValue({ - ...res.data - }) - emit('refresh') + emit('refresh', res.data.id) } } }).catch(() => { @@ -274,32 +267,46 @@ }) } else { // 转换汇率申请 + props.setFieldsValue({ + currency + }) // 合并所有选择过的费用明细 - let feeList = [] - for(var key in allFeeData) { - feeList = [...feeList, ...allFeeData[key]] - } - // 汇率换算申请 let currencyList = [] - // 过滤出所有跟业务币别不一致的币别 - feeList.forEach((item, index) => { - if (item.currency != props.formData.currency) { - currencyList.push({ - currency: item.currency, - feeType: item.feeType, - // 正向汇率 - value: null, - // 逆向汇率 - value1: null + // 根据申请单获取所有币别 + 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 + }) + } }) } + selectRows.forEach(row => { + if (item.id == row.id) { + item.settlementOther = row.settlementOther + item.settlementRMB = row.settlementRMB + item.settlementUSD = row.settlementUSD + } + }) }) + // 过滤出所有跟业务币别不一致的币别 currencyList = Array.from(new Set(currencyList.map(item => item.currency))).map(currency => { return currencyList.find(item => item.currency === currency) }) - // 币别不同触发换算 - feeTableData.value = feeList - exchangeRate.value.init(props.formData.currency, currencyList) + postData.documents = items + bPostData.value = postData + exchangeRate.value.init(currency, currencyList) } } diff --git a/src/views/finance/paymentSettlement/detail/components/feeTable.vue b/src/views/finance/paymentSettlement/detail/components/feeTable.vue index babb4a44..9da162f8 100644 --- a/src/views/finance/paymentSettlement/detail/components/feeTable.vue +++ b/src/views/finance/paymentSettlement/detail/components/feeTable.vue @@ -7,7 +7,7 @@ @@ -15,17 +15,15 @@