Просмотр исходного кода

fix(permission): filter null actions

Lind 3 лет назад
Родитель
Сommit
f4ae2863a5
2 измененных файлов с 36 добавлено и 28 удалено
  1. 0 1
      src/components/BaseCrud/save/index.tsx
  2. 36 27
      src/pages/system/Permission/index.tsx

+ 0 - 1
src/components/BaseCrud/save/index.tsx

@@ -107,7 +107,6 @@ const Save = <T extends Record<string, any>>(props: Props<T>) => {
 
   const save = async () => {
     const values: T = await (customForm || form).submit();
-    console.log(form.values, 'value', values);
     // 特殊处理通知模版
 
     if (service?.getUri().includes('/notifier/template')) {

+ 36 - 27
src/pages/system/Permission/index.tsx

@@ -20,6 +20,7 @@ import { observer } from '@formily/react';
 import SystemConst from '@/utils/const';
 import Token from '@/utils/token';
 import { downloadObject } from '@/utils/util';
+import { onFormSubmitStart } from '@formily/core';
 
 export const service = new Service('permission');
 
@@ -288,33 +289,33 @@ const Permission: React.FC = observer(() => {
           },
         ],
       },
-      status: {
-        title: '状态',
-        'x-decorator': 'FormItem',
-        'x-component': 'Switch',
-        required: true,
-        default: 1,
-        enum: [
-          { label: '1', value: 1 },
-          { label: '0', value: 0 },
-        ],
-      },
-      'properties.assetTypes': {
-        type: 'string',
-        title: '关联资产',
-        'x-decorator': 'FormItem',
-        'x-component': 'Select',
-        name: 'properties.assetTypes',
-        required: false,
-        enum: PermissionModel.assetsTypesList,
-        'x-decorator-props': {
-          tooltip: <div>关联资产为角色权限中的权限分配提供数据支持</div>,
-        },
-        'x-component-props': {
-          showSearch: true,
-          mode: 'multiple',
-        },
-      },
+      // status: {
+      //   title: '状态',
+      //   'x-decorator': 'FormItem',
+      //   'x-component': 'Switch',
+      //   required: true,
+      //   default: 1,
+      //   enum: [
+      //     { label: '1', value: 1 },
+      //     { label: '0', value: 0 },
+      //   ],
+      // },
+      // 'properties.assetTypes': {
+      //   type: 'string',
+      //   title: '关联资产',
+      //   'x-decorator': 'FormItem',
+      //   'x-component': 'Select',
+      //   name: 'properties.assetTypes',
+      //   required: false,
+      //   enum: PermissionModel.assetsTypesList,
+      //   'x-decorator-props': {
+      //     tooltip: <div>关联资产为角色权限中的权限分配提供数据支持</div>,
+      //   },
+      //   'x-component-props': {
+      //     showSearch: true,
+      //     mode: 'multiple',
+      //   },
+      // },
       actions: {
         type: 'array',
         'x-decorator': 'FormItem',
@@ -366,6 +367,7 @@ const Permission: React.FC = observer(() => {
               properties: {
                 name: {
                   type: 'string',
+
                   'x-decorator': 'Editable',
                   'x-component': 'Input',
                 },
@@ -449,6 +451,13 @@ const Permission: React.FC = observer(() => {
         }}
         search={false}
         menu={menu}
+        formEffect={() => {
+          onFormSubmitStart((form) => {
+            form.values.actions = form.values.actions?.filter(
+              (item: any) => Object.keys(item).length > 0,
+            );
+          });
+        }}
         schema={schema}
       />
     </PageContainer>