import {ComponentEvent, ExtractPropTypes, PropType} from "@peryl/react-compose"; import {PlainObject} from "@peryl/utils/event"; import {iObjectServicePickConfig} from "../$object/object.service.utils"; import {iObjectService} from "../$object/createObjectService"; import {iObjectHooks} from "./createObjectHooks"; import {EditProps, tEditComputed} from "../../uses/useEdit"; import {TableOptionSpace} from "../AutoTable/utils/TableOption.space"; export const ObjectPropsOption = { ...EditProps, modelValue: { type: [Array, String, Number] as PropType }, // 双向绑定值,单选的时候是显示值,多选时为绑定的数组 option: { type: Object as PropType, required: true }, // TableOption对象 row: { type: Object as PropType }, // 行对象或者说是表单对象,单选完毕时会根据map将选中行的字段值更新到row对象上 bindRowModel: { type: Boolean }, // 绑定row,在单选的情况下选中行数据时,会将行数据通过onUpdateRow事件派发以更新v-model:row的绑定值 map: { type: Object as PropType }, // 映射关系,选择完毕时会根据map将值映射到结果对象中 multiple: { type: Boolean }, // 是否为多选 service: { type: Object as PropType }, // 自定义服务 config: { type: Object as PropType }, // 自定义服务配置 labelField: { type: String, required: true }, // 选中数据中用来显示的字段名 keyField: { type: String, default: 'id' }, // 选中数据中用来做唯一标识的字段名 queryField: { type: String as PropType }, // 输入查询时的字段名 disableFilter: { type: Boolean }, // 禁用输入搜索 searchPlaceholder: { type: String }, // 输入搜索关键词提示 beforeOpenPicker: { type: Function as PropType<() => void | Promise> }, // 打开object弹窗之前 } as const; export type iObjectPropsType = ExtractPropTypes export const ObjectEmitsOption = { onUpdateModelValue: (val?: string | number | any[]) => true, onUpdateRow: (val?: PlainObject) => true, onFocus: (e: FocusEvent) => true, onBlur: (e: FocusEvent) => true, onSelect: (selected: any) => true, onPick: (selected: any) => true, } as const; export type iObjectEventType = ComponentEvent export interface iObjectSelectOption { label: string, val: string, data: PlainObject } export type iObjectCompositionParam = { props: iObjectPropsType, event: iObjectEventType, hooks: iObjectHooks, inputSlots: PlainObject, classes: { value: any[] }, object: iObjectService, loadData: (filterText: string, handler: (options: iObjectSelectOption[]) => void) => void, loading: { value: boolean }, editComputed: tEditComputed, }