diff --git a/packages/xgen/components/base/PureTable/components/EditPopover/index.less b/packages/xgen/components/base/PureTable/components/EditPopover/index.less index dde7af26..ef87b7ba 100644 --- a/packages/xgen/components/base/PureTable/components/EditPopover/index.less +++ b/packages/xgen/components/base/PureTable/components/EditPopover/index.less @@ -4,18 +4,12 @@ .xgen-popover-inner { width: 376px; - .xgen-form-item { - width: calc(100% - 50px); + .xgen-popover-inner-content { + width: 100%; } - } - .form_item_upload_wrap { - &.video { - .xgen-upload-select-picture-card, - .xgen-upload-list-picture-card-container { - width: 270px; - height: 160px; - } + .xgen-form-item { + width: calc(100% - 50px); } } } diff --git a/packages/xgen/components/base/PureTable/components/EditPopover/index.tsx b/packages/xgen/components/base/PureTable/components/EditPopover/index.tsx index 404f4147..ffa32aaa 100644 --- a/packages/xgen/components/base/PureTable/components/EditPopover/index.tsx +++ b/packages/xgen/components/base/PureTable/components/EditPopover/index.tsx @@ -59,7 +59,7 @@ const Index = (props: IProps) => { ) const view_content = ( -
+
) diff --git a/packages/xgen/components/base/PureTable/components/ViewContent.tsx b/packages/xgen/components/base/PureTable/components/ViewContent.tsx index 3c27949c..c48217af 100644 --- a/packages/xgen/components/base/PureTable/components/ViewContent.tsx +++ b/packages/xgen/components/base/PureTable/components/ViewContent.tsx @@ -10,7 +10,8 @@ interface IProps extends Omit, Component.Bin const Index = (props: IProps) => { const { namespace, primary, field_detail, form_bind, form_value, onSave } = props - if (!field_detail.view?.type) return
请设置字段的view属性
+ if (!field_detail.view?.type) + return
Unknown view type: {field_detail.view?.type}
const props_view_component = { ...field_detail.view.props, diff --git a/packages/xgen/components/edit/AutoComplete/index.tsx b/packages/xgen/components/edit/AutoComplete/index.tsx index e7923ec3..660a1b9e 100644 --- a/packages/xgen/components/edit/AutoComplete/index.tsx +++ b/packages/xgen/components/edit/AutoComplete/index.tsx @@ -56,28 +56,36 @@ const Custom = window.$app.memo((props: ICustom) => { setOptions(parseOptions(props.options)) }, [props.options]) + const fetchOptions = (keywords?: string) => { + if (!xProps?.remote) return + + const api = xProps.remote.api + const params = { ...xProps.remote.params } + if (keywords && keywords.length != 0) params['keywords'] = keywords + axios.get(api, { params }) + .then((res) => { + setOptions(parseOptions(res)) + }) + .catch((err) => { + console.error('[AutoComplete] remote search error', err) + }) + } + const onChange: AutoCompleteProps['onChange'] = (v) => { // Trigger remote search - if (xProps?.remote) { - const api = xProps.remote.api - const params = { ...xProps.remote.params, ['keywords']: v } - axios.get(api, { params }) - .then((res) => { - setOptions(parseOptions(res)) - }) - .catch((err) => { - console.error('[AutoComplete] remote search error', err) - }) - } + fetchOptions(v) if (!props.onChange) return // @ts-ignore props.onChange(v) - setValue(v) } + const onFocus = () => { + fetchOptions() + } + return ( { {...rest_props} options={options} onChange={onChange} + onFocus={onFocus} showSearch={true} > ) diff --git a/packages/xgen/components/edit/Select/index.tsx b/packages/xgen/components/edit/Select/index.tsx index e557385c..430d32e5 100644 --- a/packages/xgen/components/edit/Select/index.tsx +++ b/packages/xgen/components/edit/Select/index.tsx @@ -67,13 +67,18 @@ const Custom = window.$app.memo((props: ICustom) => { setValue(v) } - // Merge the remote api for search - // props.search will be deprecated in the future - const defaultOnSearch: SelectProps['onSearch'] = (v) => { - // Trigger remote search + const fetchRemoteOptions = (selected?: any, keywords?: string) => { if (xProps?.remote) { const api = xProps.remote.api - const params = { ...xProps.remote.params, ['keywords']: v } + const params: Record = { ...xProps.remote.params } + if (keywords && keywords != '') { + params['keywords'] = keywords.trim() + } + + if (selected) { + params['selected'] = selected + } + axios.get(api, { params }) .then((res) => { setOptions(parseOptions(res)) @@ -84,11 +89,26 @@ const Custom = window.$app.memo((props: ICustom) => { } } + const onClear = () => { + setValue(null) + fetchRemoteOptions() + } + + const onFocus = () => { + fetchRemoteOptions(value) // Reset the options when focus + } + + // Merge the remote api for search + // props.search will be deprecated in the future + const defaultOnSearch: SelectProps['onSearch'] = (v) => { + const selected = value ? (Array.isArray(value) ? value : [value]) : [] + fetchRemoteOptions(selected, v) + } + if (rest_props.showSearch) { rest_props.onSearch = rest_props.onSearch ? rest_props.onSearch : defaultOnSearch } - const onClear = () => setValue(null) return (