From 33fbe43ff685a364f9f96870372b2ea6e159519e Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Mon, 21 Nov 2022 16:34:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DSearch=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=97=A0=E6=B3=95=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-admin-vue3/package.json | 2 +- .../src/components/Search/src/Search.vue | 10 ++++++++-- yudao-ui-admin-vue3/src/hooks/web/useForm.ts | 3 +++ yudao-ui-admin-vue3/src/hooks/web/useTable.ts | 6 +++++- yudao-ui-admin-vue3/src/views/system/menu/index.vue | 1 - 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/yudao-ui-admin-vue3/package.json b/yudao-ui-admin-vue3/package.json index 5b1ff5f4a..a3e8357c4 100644 --- a/yudao-ui-admin-vue3/package.json +++ b/yudao-ui-admin-vue3/package.json @@ -1,6 +1,6 @@ { "name": "ruoyi-vue-pro-vue3", - "version": "1.6.4.1851", + "version": "1.6.4.1861", "description": "基于vue3、vite3、element-plus、typesScript", "author": "xingyu", "private": false, diff --git a/yudao-ui-admin-vue3/src/components/Search/src/Search.vue b/yudao-ui-admin-vue3/src/components/Search/src/Search.vue index 57427a02a..68d06085e 100644 --- a/yudao-ui-admin-vue3/src/components/Search/src/Search.vue +++ b/yudao-ui-admin-vue3/src/components/Search/src/Search.vue @@ -33,7 +33,11 @@ const props = defineProps({ expand: propTypes.bool.def(false), // 伸缩的界限字段 expandField: propTypes.string.def(''), - inline: propTypes.bool.def(true) + inline: propTypes.bool.def(true), + model: { + type: Object as PropType, + default: () => ({}) + } }) const emit = defineEmits(['search', 'reset']) @@ -62,7 +66,9 @@ const newSchema = computed(() => { return schema }) -const { register, elFormRef, methods } = useForm() +const { register, elFormRef, methods } = useForm({ + model: props.model || {} +}) const search = async () => { await unref(elFormRef)?.validate(async (isValid) => { diff --git a/yudao-ui-admin-vue3/src/hooks/web/useForm.ts b/yudao-ui-admin-vue3/src/hooks/web/useForm.ts index 0d4f68871..356ee8f9c 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useForm.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useForm.ts @@ -41,6 +41,9 @@ export const useForm = (props?: FormProps) => { setProps: async (props: FormProps = {}) => { const form = await getForm() form?.setProps(props) + if (props.model) { + form?.setValues(props.model) + } }, setValues: async (data: Recordable) => { diff --git a/yudao-ui-admin-vue3/src/hooks/web/useTable.ts b/yudao-ui-admin-vue3/src/hooks/web/useTable.ts index 30c90bad3..a5628bb5f 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useTable.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useTable.ts @@ -18,6 +18,8 @@ interface UseTableConfig { exportListApi?: (option: any) => Promise // 返回数据格式配置 response?: ResponseType + // 默认传递的参数 + defaultParams?: Recordable props?: TableProps } @@ -43,7 +45,9 @@ export const useTable = (config?: UseTableConfig) => { // 表格数据 tableList: [], // AxiosConfig 配置 - params: {}, + params: { + ...(config?.defaultParams || {}) + }, // 加载中 loading: true, // 导出加载中 diff --git a/yudao-ui-admin-vue3/src/views/system/menu/index.vue b/yudao-ui-admin-vue3/src/views/system/menu/index.vue index 6fe63f520..16823ff20 100644 --- a/yudao-ui-admin-vue3/src/views/system/menu/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/menu/index.vue @@ -53,7 +53,6 @@ :print-config="{}" :export-config="{}" :data="tableData" - class="xtable" >