Merge branch 'feat/combolist'

This commit is contained in:
aalizzwell 2022-10-03 17:26:25 +08:00
commit fa17e1efbb
3 changed files with 83 additions and 27 deletions

View File

@ -1,5 +1,6 @@
import { defineComponent, SetupContext } from 'vue'; import { defineComponent, SetupContext } from 'vue';
import { comboListProps, ComboListProps } from './combo-list.props'; import { comboListProps, ComboListProps } from './combo-list.props';
import { ButtonEdit } from '../../button-edit';
export default defineComponent({ export default defineComponent({
name: 'FComboList', name: 'FComboList',
props: comboListProps, props: comboListProps,
@ -7,7 +8,9 @@ export default defineComponent({
setup(props: ComboListProps, context: SetupContext) { setup(props: ComboListProps, context: SetupContext) {
return () => { return () => {
return ( return (
<div id={props.id}>combo-list</div> <>
<ButtonEdit id={props.id} />
</>
); );
}; };
} }

View File

@ -1,55 +1,99 @@
import { ExtractPropTypes } from "vue"; import { ExtractPropTypes } from "vue";
import { ViewType, EnumTypeProp } from './types'; import { ViewType, EnumType, Type } from './types';
/**
*
*/
export const comboListProps = { export const comboListProps = {
/** /**
* *
*/ */
id: String, id: Type(String),
/** /**
* *
* false * `false`
*/ */
disabled: { disabled: Type({ default: false, type: Boolean }),
type: Boolean,
default: false
},
/** /**
* *
* false * `false`
*/ */
readonly: { readonly: Type({ default: false, type: Boolean }),
type: Boolean,
default: false
},
/** /**
* *
*/ */
maxLength: Number, maxLength: Type(Number),
/** /**
* *
*/ */
placeholder: String, placeholder: Type(String),
/** /**
* *
* *
*/ */
enableClear: { enableClear: Type({ default: true, type: Boolean }),
type: Boolean,
default: true
},
/** /**
* *
* *
*/ */
enableTitle: { enableTitle: Type({ default: true, type: Boolean }),
type: Boolean,
default: true
},
/** /**
* *
* text | tagViewType.Text * text | tag`ViewType.Text``text`
*/ */
viewType: EnumTypeProp(ViewType.Text, ViewType), viewType: EnumType(ViewType.Text, ViewType),
/**
*
*/
mapFields: Type(Object),
/**
*
*/
data: Type(Array),
/**
* id字段
* `id`
*/
idField: Type({ default: 'id', type: String }),
/**
*
* `id`
*/
valueField: Type({ default: 'id', type: String }),
/**
*
* `label`
*/
textField: Type({ default: 'label', type: String }),
/**
*
* `false`
*/
multiSelect: Type({default: false, type: Boolean}),
/**
*
*/
uri: Type(String),
/**
*
* `200`
*/
maxHeight: Type({default: 200, type: Number}),
/**
*
* `false`
*/
remoteSearch: Type({default: false, type: Boolean}),
/**
*
* `true`
*/
hidePanelOnClear: Type({default: true, type: Boolean}),
/**
*
* `,`
*/
separator: Type({default: ',', type: String}),
}; };
export type ComboListProps = ExtractPropTypes<typeof comboListProps>; export type ComboListProps = ExtractPropTypes<typeof comboListProps>;

View File

@ -1,3 +1,4 @@
import { Prop } from 'vue';
/** /**
* *
*/ */
@ -6,12 +7,20 @@ export enum ViewType {
Tag = 'tag' Tag = 'tag'
}; };
/** /**
* *
* @param options options
* @returns
*/
export function Type<T, D>(options: Prop<T, D>) {
return options;
}
/**
*
* @param defaultValue * @param defaultValue
* @param enumType * @param enumType
* @returns * @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 { return {
default: defaultValue, default: defaultValue,
validator: (value: T) => Object.values(enumType).includes(value) validator: (value: T) => Object.values(enumType).includes(value)