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