feat: 字典配置前端代码.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<a-select v-model:model-value="value as any"
|
||||
:options="optionData()"
|
||||
:allow-search="true"
|
||||
:loading="loading"
|
||||
:disabled="loading"
|
||||
:filter-option="filterOption"
|
||||
placeholder="请选择配置项" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'dict-key-selector'
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import { SelectOptionData } from '@arco-design/web-vue';
|
||||
import { DictKeyQueryResponse } from '@/api/system/dict-key';
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: Number,
|
||||
loading: Boolean,
|
||||
});
|
||||
|
||||
const emits = defineEmits(['update:modelValue', 'change']);
|
||||
|
||||
const value = computed({
|
||||
get() {
|
||||
return props.modelValue;
|
||||
},
|
||||
set(e) {
|
||||
emits('update:modelValue', e);
|
||||
emits('change', e);
|
||||
}
|
||||
});
|
||||
|
||||
// 选项数据
|
||||
const cacheStore = useCacheStore();
|
||||
const optionData = (): SelectOptionData[] => {
|
||||
return cacheStore.dictKeys.map(s => {
|
||||
return {
|
||||
label: `${s.keyName} - ${s.description || ''}`,
|
||||
value: s.id,
|
||||
origin: s,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
// 搜索
|
||||
const filterOption = (searchValue: string, option: { label: string; }) => {
|
||||
return option.label.toLowerCase().indexOf(searchValue.toLowerCase()) > -1;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user