diff --git a/src/components/Form/src/Form.vue b/src/components/Form/src/Form.vue index bda7119..84e6e03 100644 --- a/src/components/Form/src/Form.vue +++ b/src/components/Form/src/Form.vue @@ -340,7 +340,7 @@ export default defineComponent({ {{ diff --git a/src/components/Search/src/Search.vue b/src/components/Search/src/Search.vue index c2056ef..f461430 100644 --- a/src/components/Search/src/Search.vue +++ b/src/components/Search/src/Search.vue @@ -37,7 +37,9 @@ const props = defineProps({ model: { type: Object as PropType, default: () => ({}) - } + }, + searchLoading: propTypes.bool.def(false), + resetLoading: propTypes.bool.def(false) }) const emit = defineEmits(['search', 'reset', 'register']) @@ -48,9 +50,10 @@ const visible = ref(true) const formModel = ref({}) const newSchema = computed(() => { - let schema: FormSchema[] = cloneDeep(unref(getProps).schema) - if (unref(getProps).showExpand && unref(getProps).expandField && !unref(visible)) { - const index = findIndex(schema, (v: FormSchema) => v.field === unref(getProps).expandField) + const propsComputed = unref(getProps) + let schema: FormSchema[] = cloneDeep(propsComputed.schema) + if (propsComputed.showExpand && propsComputed.expandField && !unref(visible)) { + const index = findIndex(schema, (v: FormSchema) => v.field === propsComputed.expandField) schema.map((v, i) => { if (i >= index) { v.hidden = true @@ -60,7 +63,7 @@ const newSchema = computed(() => { return v }) } - if (unref(getProps).layout === 'inline') { + if (propsComputed.layout === 'inline') { schema = schema.concat([ { field: 'action', @@ -71,9 +74,11 @@ const newSchema = computed(() => { return (
{ }) const { formRegister, formMethods } = useForm() -const { getElFormExpose, getFormData } = formMethods +const { getElFormExpose, getFormData, getFormExpose } = formMethods // useSearch传入的props const outsideProps = ref({}) @@ -171,8 +176,10 @@ const setSchema = (schemaProps: FormSetProps[]) => { } // 对表单赋值 -const setValues = (data: Recordable = {}) => { +const setValues = async (data: Recordable = {}) => { formModel.value = Object.assign(unref(formModel), data) + const formExpose = await getFormExpose() + formExpose?.setValues(data) } const delSchema = (field: string) => { @@ -227,6 +234,8 @@ defineExpose(defaultExpose) :show-reset="getProps.showReset" :show-search="getProps.showSearch" :show-expand="getProps.showExpand" + :search-loading="getProps.searchLoading" + :reset-loading="getProps.resetLoading" @expand="setVisible" @reset="reset" @search="search" diff --git a/src/components/Search/src/components/ActionButton.vue b/src/components/Search/src/components/ActionButton.vue index f99e0d3..e40cb55 100644 --- a/src/components/Search/src/components/ActionButton.vue +++ b/src/components/Search/src/components/ActionButton.vue @@ -12,7 +12,9 @@ defineProps({ showSearch: propTypes.bool.def(true), showReset: propTypes.bool.def(true), showExpand: propTypes.bool.def(false), - visible: propTypes.bool.def(true) + visible: propTypes.bool.def(true), + searchLoading: propTypes.bool.def(false), + resetLoading: propTypes.bool.def(false) }) const onSearch = () => { @@ -32,12 +34,18 @@ const onExpand = () => { {{ t('common.query') }} - + {{ t('common.reset') }} { getElFormExpose: async () => { await getForm() return unref(elFormRef) + }, + + getFormExpose: async () => { + await getForm() + return unref(formRef) } } diff --git a/src/locales/en.ts b/src/locales/en.ts index 86b48c6..23d6cdf 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -371,7 +371,13 @@ export default { left: 'left', center: 'center', right: 'right', - dynamicOptions: 'Dynamic options' + dynamicOptions: 'Dynamic options', + // 删除单选框 + deleteRadio: 'Delete radio', + // 还原单选框 + restoreRadio: 'Restore radio', + loading: 'Loading', + reset: 'Reset' }, stickyDemo: { sticky: 'Sticky' diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 20c2a95..006e3aa 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -368,7 +368,13 @@ export default { left: '左', center: '中', right: '右', - dynamicOptions: '动态选项' + dynamicOptions: '动态选项', + // 删除单选框 + deleteRadio: '删除单选框', + // 还原单选框 + restoreRadio: '还原单选框', + loading: '加载中', + reset: '重置' }, stickyDemo: { sticky: '黏性' diff --git a/src/views/Components/Form/UseFormDemo.vue b/src/views/Components/Form/UseFormDemo.vue index 1f8cceb..b070941 100644 --- a/src/views/Components/Form/UseFormDemo.vue +++ b/src/views/Components/Form/UseFormDemo.vue @@ -306,7 +306,7 @@ const inoutValidation = async () => { diff --git a/src/views/Components/Search.vue b/src/views/Components/Search.vue index 2c3db31..bc3e860 100644 --- a/src/views/Components/Search.vue +++ b/src/views/Components/Search.vue @@ -11,7 +11,7 @@ import { useSearch } from '@/hooks/web/useSearch' const { t } = useI18n() const { searchRegister, searchMethods } = useSearch() -const { setSchema, setProps } = searchMethods +const { setSchema, setProps, setValues } = searchMethods const schema = reactive([ { @@ -166,6 +166,48 @@ const getDictOne = async () => { const handleSearch = (data: any) => { console.log(data) } + +const delRadio = () => { + setSchema([ + { + field: 'field3', + path: 'remove', + value: true + } + ]) +} + +const restoreRadio = () => { + setSchema([ + { + field: 'field3', + path: 'remove', + value: false + } + ]) +} + +const setValue = () => { + setValues({ + field1: 'Joy' + }) +} + +const searchLoading = ref(false) +const changeSearchLoading = () => { + searchLoading.value = true + setTimeout(() => { + searchLoading.value = false + }, 2000) +} + +const resetLoading = ref(false) +const changeResetLoading = () => { + resetLoading.value = true + setTimeout(() => { + resetLoading.value = false + }, 2000) +} + +