优化修复网站导航的bug
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<!-- 公共参数数据源 -->
|
||||
<template>
|
||||
<a-select
|
||||
:allow-clear="allowClear"
|
||||
show-search
|
||||
optionFilterProp="label"
|
||||
:options="data"
|
||||
:value="value"
|
||||
class="w-full"
|
||||
:placeholder="placeholder"
|
||||
@update:value="updateValue"
|
||||
@change="change"
|
||||
@blur="onBlur"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { listWebsiteField } from '@/api/system/website/field';
|
||||
import { WebsiteField } from '@/api/cms/website/field/model';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:value', value: string): void;
|
||||
(e: 'index', index: number): void;
|
||||
(e: 'blur'): void;
|
||||
(e: 'done', item: WebsiteField): void;
|
||||
}>();
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value?: string;
|
||||
placeholder?: string;
|
||||
allowClear?: boolean;
|
||||
width?: number;
|
||||
index?: number;
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择'
|
||||
}
|
||||
);
|
||||
|
||||
const data = ref<WebsiteField[]>();
|
||||
|
||||
/* 更新选中数据 */
|
||||
const updateValue = (value: string) => {
|
||||
emit('update:value', value);
|
||||
emit('index', Number(props.index));
|
||||
};
|
||||
|
||||
/* 失去焦点 */
|
||||
const onBlur = () => {
|
||||
emit('blur');
|
||||
};
|
||||
|
||||
const change = (e, item) => {
|
||||
emit('done', item);
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
data.value = [];
|
||||
listWebsiteField({}).then((list) => {
|
||||
data.value = list.map((d) => {
|
||||
return {
|
||||
label: d.name,
|
||||
value: d.value
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
reload();
|
||||
</script>
|
||||
Reference in New Issue
Block a user