chore: change enum prop type name
This commit is contained in:
parent
e781133016
commit
ac68cb94d2
|
@ -1,6 +1,9 @@
|
|||
import { ExtractPropTypes } from "vue";
|
||||
import { ViewType, EnumTypeProp } from './types';
|
||||
import { ViewType, EnumType } from './types';
|
||||
|
||||
/**
|
||||
* 下拉列表属性
|
||||
*/
|
||||
export const comboListProps = {
|
||||
/**
|
||||
* 组件标识
|
||||
|
@ -50,6 +53,21 @@ export const comboListProps = {
|
|||
* 可选,下拉列表值展示方式
|
||||
* 支持text | tag,即文本或标签,默认为ViewType.Text,即文本方式
|
||||
*/
|
||||
viewType: EnumTypeProp(ViewType.Text, ViewType),
|
||||
viewType: EnumType(ViewType.Text, ViewType),
|
||||
/**
|
||||
* 可选,字段映射
|
||||
*/
|
||||
mapFields: Object,
|
||||
/**
|
||||
* 下拉数据源
|
||||
*/
|
||||
data: Array,
|
||||
idField: {
|
||||
type: String,
|
||||
default: 'id'
|
||||
},
|
||||
valueField: {
|
||||
|
||||
}
|
||||
};
|
||||
export type ComboListProps = ExtractPropTypes<typeof comboListProps>;
|
|
@ -1,3 +1,4 @@
|
|||
import Constructor, { } from 'vue';
|
||||
/**
|
||||
* 下拉列表展现方式
|
||||
*/
|
||||
|
@ -11,7 +12,7 @@ export enum ViewType {
|
|||
* @param enumType 枚举类型
|
||||
* @returns
|
||||
*/
|
||||
export function EnumTypeProp<T extends string | number>(defaultValue: T, enumType: Record<symbol, T>) {
|
||||
export function EnumType<T extends string | number>(defaultValue: T, enumType: Record<symbol, T>) {
|
||||
return {
|
||||
default: defaultValue,
|
||||
validator: (value: T) => Object.values(enumType).includes(value)
|
||||
|
|
Loading…
Reference in New Issue