Bläddra i källkod

fix: 组织架构树选择

outaozhen 3 år sedan
förälder
incheckning
666afba6b6

+ 34 - 2
src/pages/Institutions/Company/Detail/components/Organization.tsx

@@ -176,7 +176,39 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
 
   return (
     <div>
-      {state.organizationList && state.organizationList.length ? (
+      <ProTable<API.OrganizationalStructureListItem>
+        rowKey="ID"
+        actionRef={tRef}
+        columns={columns}
+        dataSource={state.organizationList}
+        defaultExpandAllRows={true}
+        // expandedRowKeys={state.organizationList.map(item => item.key)}
+        // expandedRowRender={expandedRowRender}
+        indentSize={30}
+        search={false}
+        pagination={false}
+        toolbar={{
+          actions: [
+            <Button
+              onClick={() =>
+                setState({
+                  ...state,
+                  visible: true,
+                  currentModalType: ModalType.ADD,
+                  typeEum: titleType.ADD,
+                  defaultFormData: {
+                    dataID: dataID,
+                    structureType: structureType,
+                    parentID: state.parentID
+                  }
+                })
+              }>
+              添加组织
+            </Button>
+          ]
+        }}
+      />
+      {/* {state.organizationList && state.organizationList.length ? (
         <ProTable<API.OrganizationalStructureListItem>
           rowKey="ID"
           actionRef={tRef}
@@ -207,7 +239,7 @@ const Organization: React.FC<OrganizationProps> = ({ dataID, structureType }) =>
             ]
           }}
         />
-      ) : null}
+      ) : null} */}
       <OrganizationModal
         type={state.currentModalType}
         typeEum={state.typeEum}

+ 19 - 14
src/pages/Institutions/Staff/components/StaffDrawer.tsx

@@ -43,6 +43,8 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
   organizationList,
   reload
 }) => {
+  console.log(organizationList)
+
   const form = useForm()
   useEffect(() => {
     if (visible) {
@@ -93,15 +95,24 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
         enumNames: accountTypeList.map(item => item.label)
       })
       form.setSchemaByPath('institution', {
-        enum: organizationList.map(item => item.value),
-        enumNames: organizationList.map(item => item.label)
+        // enum: organizationList.map(item => item.value),
+        // enumNames: organizationList.map(item => item.label),
+        description: '',
+        type: 'string',
+        widget: 'treeSelect',
+        props: {
+          treeDefaultExpandAll: true,
+          treeData: [organizationList.label]
+        }
       })
     })
   }
 
-  const watch = () => {
-    form.setValueByPath('institution', { widget: 'treeSelect' })
-  }
+  // const watch = {
+  //   institution: val => {
+  //     console.log('表单的时时数据为:', val)
+  //   }
+  // }
 
   // const handleOnFinish = () => {
   //   ref.current?.validateFields().then(async values => {
@@ -157,13 +168,7 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
       }}
       title={type === ModalType.ADD ? '新增账号' : '编辑账号'}>
       {schema && (
-        <FormRender
-          form={form}
-          schema={JSON.parse(schema)}
-          onFinish={onFinish}
-          onMount={onMount}
-          watch={watch}
-        />
+        <FormRender form={form} schema={JSON.parse(schema)} onFinish={onFinish} onMount={onMount} />
       )}
       <div>
         <Button onClick={form.submit}>提交</Button>
@@ -185,8 +190,8 @@ export default connect(
       value: item.value
     })),
     organizationList: institutions.organizationType.map(item => ({
-      label: item.name,
-      value: item.dataID
+      label: item
+      // value: item.dataID
     })),
     schema: schemaBase.base[BaseMenuEnum.STAFF]?.schema
   })