fix: repair team edit region select

This commit is contained in:
hy 2026-04-18 18:11:52 +08:00
parent aec6962175
commit f7e92e440f
2 changed files with 13 additions and 25 deletions

View File

@ -1,7 +1,6 @@
<script lang="ts" setup>
import { reactive, ref, watch } from 'vue';
import { regionConfigTable } from '#/api/legacy/system';
import { updateTeamProfile } from '#/api/legacy/team';
import {
@ -11,17 +10,17 @@ import {
FormItem,
Input,
Modal,
Select,
SelectOption,
Switch,
message,
} from 'antdv-next';
import SystemRegionSelect from '#/views/operate/components/system-region-select.vue';
import TeamCountrySelect from './team-country-select.vue';
const props = defineProps<{
open: boolean;
profile: null | Record<string, any>;
sysOrigin?: string;
}>();
const emit = defineEmits<{
@ -49,7 +48,6 @@ function createForm() {
const saving = ref(false);
const initialRegion = ref('');
const regionOptions = ref<Array<Record<string, any>>>([]);
const selectedRegion = ref<Record<string, any> | null>(null);
const form = reactive(createForm());
@ -66,27 +64,24 @@ watch(
form.setting = props.profile.setting
? { ...createForm().setting, ...props.profile.setting }
: createForm().setting;
form.sysOrigin = String(props.profile.sysOrigin || props.sysOrigin || '');
initialRegion.value = String(form.region || '');
selectedRegion.value = null;
await loadRegions(String(props.profile.sysOrigin || ''));
},
{ immediate: true },
);
async function loadRegions(sysOrigin: string) {
if (!sysOrigin) {
regionOptions.value = [];
return;
}
regionOptions.value = await regionConfigTable({ sysOrigin });
}
function handleCountryChange(_value: number | string, row: Record<string, any> | null) {
form.country.countryId = row?.id || '';
form.country.countryCode = row?.alphaTwo || row?.alphaThree || '';
form.country.countryName = row?.aliasName || row?.countryName || '';
}
function handleRegionChange(value: string, row: Record<string, any> | null) {
form.region = value;
selectedRegion.value = row;
}
async function submitPayload() {
const payload = JSON.parse(JSON.stringify(form));
await updateTeamProfile(payload);
@ -147,20 +142,12 @@ async function handleSubmit() {
<Form layout="vertical">
<FormItem label="区域">
<Select option-label-prop="label"
<SystemRegionSelect
v-model:value="form.region"
:sys-origin="form.sysOrigin"
placeholder="区域"
@change="(value: string) => selectedRegion = regionOptions.find((item) => String(item.id) === String(value)) || null"
>
<SelectOption
v-for="item in regionOptions"
:key="item.id"
:label="item.regionName"
:value="item.id"
>
{{ item.regionName }}
</SelectOption>
</Select>
@change="handleRegionChange"
/>
</FormItem>
<FormItem label="国家">
<TeamCountrySelect

View File

@ -550,6 +550,7 @@ watch(
<TeamEditDrawer
:open="editOpen"
:profile="activeRow?.teamProfile || null"
:sys-origin="activeRow?.sysOrigin || query.sysOrigin"
@close="editOpen = false"
@success="handleEditSuccess"
/>