增加汇率
This commit is contained in:
parent
7510dac801
commit
a73b079333
@ -78,6 +78,13 @@ export async function updatePayOpenCountyShelf(
|
||||
});
|
||||
}
|
||||
|
||||
export async function syncPayOpenCountryCurrencyRates(data: Record<string, any>) {
|
||||
return requestClient.post<Record<string, any>>(
|
||||
'/sys-pay-open-country/sync-currency-rates',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function pagePayChannel(params: Record<string, any>) {
|
||||
return requestClient.get<LegacyPageResult<Record<string, any>>>(
|
||||
'/sys-pay-channel/page',
|
||||
|
||||
@ -8,6 +8,7 @@ import { Page } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
pagePayOpenCounty,
|
||||
syncPayOpenCountryCurrencyRates,
|
||||
updatePayOpenCountryCurrent,
|
||||
updatePayOpenCountryExchangeRate,
|
||||
updatePayOpenCountrySort,
|
||||
@ -41,6 +42,9 @@ const activeRow = ref<Record<string, any>>({});
|
||||
const editOpen = ref(false);
|
||||
const editLoading = ref(false);
|
||||
const editValue = ref('');
|
||||
const syncOpen = ref(false);
|
||||
const syncLoading = ref(false);
|
||||
const syncMarkupPercent = ref('');
|
||||
const editConfig = reactive({
|
||||
field: '' as 'currency' | 'rate' | 'sort' | '',
|
||||
title: '',
|
||||
@ -172,6 +176,34 @@ function openAssociated(row: Record<string, any>) {
|
||||
associatedOpen.value = true;
|
||||
}
|
||||
|
||||
function openSyncRates() {
|
||||
syncMarkupPercent.value = '';
|
||||
syncOpen.value = true;
|
||||
}
|
||||
|
||||
function validateSyncMarkupPercent() {
|
||||
return /^(100(\.0{1,4})?|([1-9]\d?|0)(\.\d{1,4})?)$/.test(syncMarkupPercent.value.trim());
|
||||
}
|
||||
|
||||
async function submitSyncRates() {
|
||||
if (!validateSyncMarkupPercent()) {
|
||||
message.warning('请输入0~100之间的上浮比例,最多四位小数');
|
||||
return;
|
||||
}
|
||||
syncLoading.value = true;
|
||||
try {
|
||||
const result = await syncPayOpenCountryCurrencyRates({
|
||||
markupPercent: syncMarkupPercent.value.trim(),
|
||||
});
|
||||
const skippedText = result?.skippedCount ? `,跳过${result.skippedCount}个` : '';
|
||||
message.success(`同步成功,更新${result?.updatedCount || 0}个国家${skippedText}`);
|
||||
syncOpen.value = false;
|
||||
await loadData();
|
||||
} finally {
|
||||
syncLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
void loadData(true);
|
||||
</script>
|
||||
|
||||
@ -188,6 +220,7 @@ void loadData(true);
|
||||
/>
|
||||
<Button type="primary" @click="countrySelectOpen = true">添加</Button>
|
||||
<Button type="primary" @click="handleSearch">刷新</Button>
|
||||
<Button :loading="syncLoading" @click="openSyncRates">同步全球汇率</Button>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
@ -268,6 +301,19 @@ void loadData(true);
|
||||
>
|
||||
<Input v-model:value="editValue" />
|
||||
</Modal>
|
||||
|
||||
<Modal
|
||||
:confirm-loading="syncLoading"
|
||||
:open="syncOpen"
|
||||
title="同步全球汇率"
|
||||
@cancel="syncOpen = false"
|
||||
@ok="submitSyncRates"
|
||||
>
|
||||
<Input
|
||||
v-model:value="syncMarkupPercent"
|
||||
placeholder="请输入上浮比例,5表示上浮5%"
|
||||
/>
|
||||
</Modal>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user