| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
- import type { VbenFormSchema } from '#/adapter/form';
- import type { OnActionClickFn } from '#/adapter/vxe-table';
- import type { SystemModel } from '#/api/method/system';
- import { listOrganizationsMethodAll } from '#/api/method/system';
- import { $t } from '#/locales';
- export function useUserSearchFormSchema(): VbenFormSchema[] {
- return [
- {
- component: 'Input',
- fieldName: 'name',
- label: $t('system.organization.name'),
- },
- ];
- }
- export function useUserTableColumns<T = SystemModel.Organization>(
- onActionClick?: OnActionClickFn<T>,
- ): VxeTableGridOptions<T>['columns'] {
- return [
- { type: 'seq', title: $t('table.column.seq'), width: 50 },
- {
- field: 'name',
- title: $t('system.organization.name'),
- minWidth: 100,
- },
- {
- field: 'code',
- title: $t('system.organization.code'),
- minWidth: 100,
- },
- {
- field: 'parentinstitutionSelsourceName',
- title: $t('system.organization.superior'),
- minWidth: 100,
- },
- {
- field: 'createTime',
- title: $t('system.organization.createTime'),
- minWidth: 100,
- },
- {
- field: 'createUser',
- title: $t('system.organization.createUser'),
- minWidth: 100,
- },
- {
- align: 'center',
- cellRender: {
- attrs: {
- nameField: 'name',
- nameTitle: $t('system.user._'),
- onClick: onActionClick,
- },
- name: 'CellOperation',
- },
- field: 'operation',
- fixed: 'right',
- title: $t('table.column.operation'),
- width: 130,
- },
- ];
- }
- export function useUserFormSchema(
- current?: Pick<SystemModel.Organization, 'id' | 'name'>,
- ): VbenFormSchema[] {
- return [
- {
- component: 'Input',
- fieldName: 'name',
- label: $t('system.organization.name'),
- rules: 'required',
- },
- {
- component: 'Input',
- componentProps: {
- placeholder: $t('system.organization.input'),
- },
- fieldName: 'code',
- label: $t('system.organization.code'),
- rules: 'required',
- },
- {
- component: 'ApiSelect',
- componentProps: {
- allowClear: true,
- api: listOrganizationsMethodAll,
- class: 'w-full',
- labelField: 'name',
- valueField: 'pid',
- childrenField: 'children',
- afterFetch: (res: SystemModel.Organization[]) => {
- if (!current) return res;
- return Array.isArray(res)
- ? res.filter(
- (item) => item.pid !== current.id && item.name !== current.name,
- )
- : res;
- },
- },
- fieldName: 'parentInstitutionId',
- label: $t('system.organization.superior'),
- // rules: 'selectRequired',
- },
- ];
- }
|