diff --git a/src/components/Form/src/hooks/useFormEvents.ts b/src/components/Form/src/hooks/useFormEvents.ts index 41dd40de..9390f7e9 100644 --- a/src/components/Form/src/hooks/useFormEvents.ts +++ b/src/components/Form/src/hooks/useFormEvents.ts @@ -212,22 +212,21 @@ export function useFormEvents({ return } const schema: FormSchema[] = [] - unref(getSchema).forEach((val) => { + updateData.forEach((item) => { let _val - updateData.forEach((item) => { - if (val.field === item.field) { - _val = item + unref(getSchema).forEach((val) => { + if (item.field === val.field) { + _val = val } }) - if (_val !== undefined && val.field === _val.field) { - const newSchema = deepMerge(val, _val) + if (_val !== undefined && item.field === _val.field) { + const newSchema = deepMerge(_val, item) schema.push(newSchema as FormSchema) } else { - schema.push(val) + schema.push(_val) } }) _setDefaultValue(schema) - schemaRef.value = uniqBy(schema, 'field') } diff --git a/src/components/Modal/src/components/ModalClose.vue b/src/components/Modal/src/components/ModalClose.vue index 28e190ea..1219a5e0 100644 --- a/src/components/Modal/src/components/ModalClose.vue +++ b/src/components/Modal/src/components/ModalClose.vue @@ -134,7 +134,7 @@ display: flex; height: 95%; align-items: center; - + justify-content: center; > span { margin-left: 48px; font-size: 16px; diff --git a/src/hooks/component/costomForm.ts b/src/hooks/component/costomForm.ts new file mode 100644 index 00000000..3e5657f8 --- /dev/null +++ b/src/hooks/component/costomForm.ts @@ -0,0 +1,39 @@ +/* + * @Description: 表单,表格通用hook + * @Author: lijj + * @Date: 2024-04-24 10:50:17 + */ + +// 获取表单更改过的字段接口 +import { getFormSetInfoByModule } from '/@/views/baseinfo/formset/api' +// 接口 +import { getColumnSetInfoByModule } from '/@/views/baseinfo/columnset/api' +// 引入表格权限信息(包含id和name) +import { permissionsInfo } from '/@/hooks/web/usePermission' + +/** + * @description: 调用接口更新设置后的表单 + * @param {*} updateSchema (vben提供的更新表单接口) + */ +export function updateFormField(updateSchema) { + getFormSetInfoByModule({ permissionId: permissionsInfo().permissionId }).then(res => { + if (res?.data?.content) { + const content = JSON.parse(res.data.content) + updateSchema(content.columns) + } + }) +} + +/** + * @description: 调用接口更新设置后的表格 + * @param {*} setColumns + */ +export function updateTableField(setColumns) { + getColumnSetInfoByModule({ permissionId: permissionsInfo().permissionId }).then(res => { + const { data } = res + if (data?.content) { + const txt = JSON.parse(data?.content) + setColumns(txt.columns) + } + }) +} \ No newline at end of file diff --git a/src/views/baseinfo/columnset/index.vue b/src/views/baseinfo/columnset/index.vue index c190c05a..4e392622 100644 --- a/src/views/baseinfo/columnset/index.vue +++ b/src/views/baseinfo/columnset/index.vue @@ -65,12 +65,11 @@ // 弹窗内容组件 import TableSet from './components/tableSet.vue' // 接口 - import { getColumnSetList, editColumnSet, getColumnSetInfoByModule } from './api' + import { getColumnSetList, editColumnSet } from './api' // 引入表格列数据 import { columns, searchFormSchema } from './columns' - import { message } from 'ant-design-vue'; - // 引入表格权限信息(包含id和name) - import { permissionsInfo } from '/@/hooks/web/usePermission' + import { message } from 'ant-design-vue' + import { updateTableField } from '/@/hooks/component/costomForm' // 表格设置组件 const TableSetRef = ref() // 模态框boolean @@ -104,17 +103,11 @@ } const colData = ref({}) provide('colData', colData) - const [registerTable, { getForm, getPaginationRef, setColumns }] = useTable({ + const [registerTable, { getForm, getPaginationRef, setColumns }] = useTable({ title: '可设置列表', api: async (p) => { // 如果存在改变的列,设置列 - getColumnSetInfoByModule({ permissionId: permissionsInfo().permissionId }).then(res => { - const { data } = res - if (data?.content) { - const txt = JSON.parse(data?.content) - setColumns(txt.columns) - } - }) + updateTableField(setColumns) const res: API.DataResult = await getColumnSetList(p) return new Promise((resolve) => { resolve({ data: [...res.data], total: res.count }) diff --git a/src/views/baseinfo/formset/component/FormModel.vue b/src/views/baseinfo/formset/component/FormModel.vue index 7d4e3f3f..8ef53167 100644 --- a/src/views/baseinfo/formset/component/FormModel.vue +++ b/src/views/baseinfo/formset/component/FormModel.vue @@ -1,3 +1,8 @@ +