Procházet zdrojové kódy

fix(user): save user dept

Lind před 3 roky
rodič
revize
6f5d3df3d2

+ 1 - 1
package.json

@@ -73,7 +73,7 @@
     "@jetlinks/pro-table": "^2.63.9",
     "@umijs/route-utils": "^1.0.36",
     "ahooks": "^2.10.9",
-    "antd": "^4.17.0-alpha.9",
+    "antd": "^4.18.8",
     "braft-editor": "^2.3.9",
     "classnames": "^2.2.6",
     "dexie": "^3.0.3",

+ 10 - 5
src/pages/system/User/Save/index.tsx

@@ -5,7 +5,7 @@ import { createForm } from '@formily/core';
 import { createSchemaField } from '@formily/react';
 import React, { useEffect, useState } from 'react';
 import * as ICONS from '@ant-design/icons';
-import { Form, FormItem, Input, Password, Select, Switch } from '@formily/antd';
+import { Form, FormItem, Input, Password, Select, Switch, TreeSelect } from '@formily/antd';
 import type { ISchema } from '@formily/json-schema';
 import { PlusOutlined } from '@ant-design/icons';
 import { action } from '@formily/reactive';
@@ -33,6 +33,7 @@ const Save = (props: Props) => {
     api(field).then(
       action.bound!((resp: Response<any>) => {
         field.dataSource = resp.result?.map((item: Record<string, unknown>) => ({
+          ...item,
           label: item.name,
           value: item.id,
         }));
@@ -43,7 +44,6 @@ const Save = (props: Props) => {
 
   const getUser = async () => {
     if (props.data.id) {
-      console.log('id');
       const response: Response<UserItem> = await service.queryDetail(props.data?.id);
       if (response.status === 200) {
         const temp = response.result as UserItem;
@@ -73,6 +73,7 @@ const Save = (props: Props) => {
       Password,
       Switch,
       Select,
+      TreeSelect,
     },
     scope: {
       icon(name: any) {
@@ -245,12 +246,17 @@ const Save = (props: Props) => {
       orgIdList: {
         title: '部门',
         'x-decorator': 'FormItem',
-        'x-component': 'Select',
+        'x-component': 'TreeSelect',
         'x-component-props': {
-          mode: 'multiple',
+          multiple: true,
           showArrow: true,
           filterOption: (input: string, option: any) =>
             option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
+          fieldNames: {
+            label: 'name',
+            value: 'id',
+          },
+          treeNodeFilterProp: 'name',
         },
         'x-decorator-props': {
           addonAfter: (
@@ -259,7 +265,6 @@ const Save = (props: Props) => {
                 const tab: any = window.open(`${origin}/#/system/department?save=true`);
                 tab!.onTabSaveSuccess = (value: any) => {
                   form.setFieldState('orgIdList', (state) => {
-                    console.log(value, 'value');
                     state.dataSource = state.dataSource?.concat([
                       { label: value.name, value: value.id },
                     ]);

+ 5 - 2
src/pages/system/User/index.tsx

@@ -181,11 +181,14 @@ const User = observer(() => {
       <Card style={{ marginBottom: '20px' }}>
         <SearchComponent
           field={columns}
-          onSearch={(data) => setParam({ terms: data, total: null })}
+          onSearch={(data) => {
+            actionRef.current?.reset?.();
+            setParam({ terms: data, total: null });
+          }}
           target="user"
           onReset={() => {
-            setParam({});
             actionRef.current?.reset?.();
+            setParam({});
           }}
         />
       </Card>