| | |
| | | |
| | | import type { ComponentPropsMap, ComponentType } from './component'; |
| | | |
| | | import { h } from 'vue'; |
| | | import { h, watch } from 'vue'; |
| | | |
| | | import { IconifyIcon } from '@vben/icons'; |
| | | import { $te } from '@vben/locales'; |
| | |
| | | |
| | | import { DictTag } from '#/components/dict-tag'; |
| | | import { $t } from '#/locales'; |
| | | import { automaticApproval } from '#/store/audit-policy'; |
| | | import { isAuditField } from '#/utils/audit-ui-policy'; |
| | | |
| | | import { useVbenForm } from './form'; |
| | | |
| | |
| | | export * from '#/components/table-action'; |
| | | export const useVbenVxeGrid = <T extends Record<string, any>>( |
| | | ...rest: Parameters<typeof useGrid<T, ComponentType, ComponentPropsMap>> |
| | | ) => useGrid<T, ComponentType, ComponentPropsMap>(...rest); |
| | | ) => { |
| | | const options = rest[0]; |
| | | const columns = options.gridOptions?.columns; |
| | | const schema = options.formOptions?.schema; |
| | | const applyPolicy = () => ({ |
| | | ...(columns ? { gridOptions: { columns: columns.filter((item) => !automaticApproval.value || !isAuditField(item)) } } : {}), |
| | | ...(schema ? { formOptions: { schema: schema.filter((item) => !automaticApproval.value || !isAuditField(item)) } } : {}), |
| | | }); |
| | | const result = useGrid<T, ComponentType, ComponentPropsMap>(options); |
| | | watch(automaticApproval, () => result[1].setState(applyPolicy()), { immediate: true }); |
| | | return result; |
| | | }; |
| | | |
| | | export type * from '@vben/plugins/vxe-table'; |