diff --git a/apps/src/api/legacy/system.ts b/apps/src/api/legacy/system.ts index 77665bb..97e3625 100644 --- a/apps/src/api/legacy/system.ts +++ b/apps/src/api/legacy/system.ts @@ -214,6 +214,10 @@ export async function updateSysCountryCode(data: Record) { return requestClient.put('/sys/country/code', data); } +export async function addSysCountryCode(data: Record) { + return requestClient.post('/sys/country/code', data); +} + export async function refundAnchorTrackRecordPage(params: Record) { return requestClient.get>>( '/refund-anchor-track-record/page', diff --git a/apps/src/views/operate/system-country.vue b/apps/src/views/operate/system-country.vue index 6a1a83f..ce27cef 100644 --- a/apps/src/views/operate/system-country.vue +++ b/apps/src/views/operate/system-country.vue @@ -9,6 +9,7 @@ import { simpleUploadFile, } from '#/api/legacy/oss'; import { + addSysCountryCode, pageSysCountryCode, updateSysCountryCode, } from '#/api/legacy/system'; @@ -23,6 +24,7 @@ import { Input, Modal, Pagination, + Switch, Table, Tag, message, @@ -37,6 +39,7 @@ const formOpen = ref(false); const submitLoading = ref(false); const uploadLoading = ref(false); const fileInputRef = ref(null); +const formMode = ref<'create' | 'edit'>('edit'); const query = reactive>({ aliasName: '', @@ -47,7 +50,10 @@ const query = reactive>({ const form = reactive>({ aliasName: '', + alphaThree: '', + alphaTwo: '', countryName: '', + countryNumeric: '', countryCodeAliasesInput: '', id: '', nationalFlag: '', @@ -59,6 +65,8 @@ const form = reactive>({ const columns: any[] = [ { dataIndex: 'countryName', key: 'countryName', title: '国家名称', width: 200 }, + { dataIndex: 'alphaTwo', key: 'alphaTwo', title: '二字码', width: 100 }, + { dataIndex: 'alphaThree', key: 'alphaThree', title: '三字码', width: 100 }, { dataIndex: 'aliasName', key: 'aliasName', title: '别名', width: 160 }, { dataIndex: 'countryCodeAliases', key: 'countryCodeAliases', title: '国家码集合', width: 220 }, { dataIndex: 'nationalFlag', key: 'nationalFlag', title: '国旗', width: 120 }, @@ -94,8 +102,12 @@ function handlePageChange(page: number, pageSize: number) { } function openEdit(record: Record) { + formMode.value = 'edit'; form.aliasName = record.aliasName || ''; + form.alphaThree = record.alphaThree || ''; + form.alphaTwo = record.alphaTwo || ''; form.countryName = record.countryName || ''; + form.countryNumeric = record.countryNumeric || ''; form.countryCodeAliasesInput = Array.isArray(record.countryCodeAliases) ? record.countryCodeAliases.join(',') : ''; @@ -108,6 +120,27 @@ function openEdit(record: Record) { formOpen.value = true; } +function resetForm() { + form.aliasName = ''; + form.alphaThree = ''; + form.alphaTwo = ''; + form.countryName = ''; + form.countryNumeric = ''; + form.countryCodeAliasesInput = ''; + form.id = ''; + form.nationalFlag = ''; + form.open = false; + form.phonePrefix = ''; + form.sort = ''; + form.top = 0; +} + +function openCreate() { + resetForm(); + formMode.value = 'create'; + formOpen.value = true; +} + function pickFlag() { fileInputRef.value?.click(); } @@ -128,13 +161,18 @@ async function uploadFlag(event: Event) { } async function saveForm() { - if (!form.id) { - return; - } if (!form.nationalFlag) { message.warning('请上传国旗'); return; } + if (!String(form.alphaTwo || '').trim()) { + message.warning('请填写国家二字码'); + return; + } + if (!String(form.alphaThree || '').trim()) { + message.warning('请填写国家三字码'); + return; + } if (!String(form.countryName || '').trim()) { message.warning('请填写国家名称'); return; @@ -151,15 +189,26 @@ async function saveForm() { try { const payload: Record = { ...form, + alphaThree: String(form.alphaThree || '').trim().toUpperCase(), + alphaTwo: String(form.alphaTwo || '').trim().toUpperCase(), + countryNumeric: form.countryNumeric === '' ? undefined : Number(form.countryNumeric), countryCodeAliases: String(form.countryCodeAliasesInput || '') .split(',') .map((item) => item.trim().toUpperCase()) .filter(Boolean), + phonePrefix: Number(form.phonePrefix), + sort: Number(form.sort), }; delete payload.countryCodeAliasesInput; - await updateSysCountryCode(payload); + if (formMode.value === 'create') { + delete payload.id; + await addSysCountryCode(payload); + } else { + await updateSysCountryCode(payload); + } message.success('保存成功'); formOpen.value = false; + resetForm(); await loadData(); } finally { submitLoading.value = false; @@ -192,6 +241,7 @@ loadData(true); style="width: 220px" /> + @@ -295,6 +345,15 @@ loadData(true); + + + + + + + + + @@ -307,6 +366,9 @@ loadData(true); + + + diff --git a/apps/src/views/statistics/datav.vue b/apps/src/views/statistics/datav.vue index 0d99ea7..fd87044 100644 --- a/apps/src/views/statistics/datav.vue +++ b/apps/src/views/statistics/datav.vue @@ -1,10 +1,14 @@