diff --git a/apps/src/views/operate/components/system-region-select.vue b/apps/src/views/operate/components/system-region-select.vue index e321570..4aa81ba 100644 --- a/apps/src/views/operate/components/system-region-select.vue +++ b/apps/src/views/operate/components/system-region-select.vue @@ -14,6 +14,7 @@ const props = withDefaults( placeholder?: string; sysOrigin: string; value?: any; + valueField?: 'id' | 'regionCode'; }>(), { clearable: false, @@ -22,6 +23,7 @@ const props = withDefaults( multiple: false, placeholder: '请选择', value: '', + valueField: 'id', }, ); @@ -36,7 +38,10 @@ const selectValue = ref(props.value); const regionOptions = computed(() => list.value.map((item) => ({ label: item.regionName || '-', - value: item.id as any, + value: + props.valueField === 'regionCode' + ? (item.regionCode || item.code || item.id) + : (item.id as any), })), ); @@ -67,8 +72,13 @@ watch( function emitChange(value: any) { emit('update:value', value); - const item = - list.value.find((current) => String(current.id) === String(value)) || null; + const item = list.value.find((current) => { + const currentValue = + props.valueField === 'regionCode' + ? current.regionCode || current.code || current.id + : current.id; + return String(currentValue) === String(value); + }) || null; emit('change', value, item); } diff --git a/apps/src/views/operate/region-broadcast.vue b/apps/src/views/operate/region-broadcast.vue index 379b350..2d104b1 100644 --- a/apps/src/views/operate/region-broadcast.vue +++ b/apps/src/views/operate/region-broadcast.vue @@ -342,6 +342,7 @@ async function handleStopWorker() { v-model:value="workerForm.regionCodes" multiple :sys-origin="form.sysOrigin" + value-field="regionCode" placeholder="可多选" />