|
@@ -1,9 +1,9 @@
|
|
|
import React, { useEffect } from 'react'
|
|
|
import { message, Button, Drawer } from 'antd'
|
|
|
import { connect, useRequest } from 'umi'
|
|
|
-// import consts from '@/utils/consts'
|
|
|
-import { addAccount, updateAccount } from '@/services/api/institution'
|
|
|
-// import DebounceSelect from './DebounceSelect'
|
|
|
+import consts from '@/utils/consts'
|
|
|
+import { addAccount, updateAccount, queryInstitutionList } from '@/services/api/institution'
|
|
|
+import DebounceSelect from './DebounceSelect'
|
|
|
import { delay } from '@/utils/util'
|
|
|
import FormRender, { useForm } from 'form-render'
|
|
|
import { BaseMenuEnum } from '@/pages/Schema/Base'
|
|
@@ -99,6 +99,32 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ const queryInstitutionOptions = async search => {
|
|
|
+ const { code = -1, data = {} } = await queryInstitutionList({
|
|
|
+ search,
|
|
|
+ current: 1,
|
|
|
+ pageSize: 100
|
|
|
+ })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ return data.items.map(item => ({ label: item.name, value: item.ID }))
|
|
|
+ }
|
|
|
+ return []
|
|
|
+ }
|
|
|
+ const { institution } = defaultFormData || {}
|
|
|
+
|
|
|
+ const SiteInput = props => {
|
|
|
+ // console.log('widget props:', props)
|
|
|
+ return (
|
|
|
+ <DebounceSelect
|
|
|
+ className="w-full"
|
|
|
+ fetchOptions={queryInstitutionOptions}
|
|
|
+ showSearch
|
|
|
+ defaultOptions={institution && [{ label: institution.name, value: institution.ID }]}
|
|
|
+ {...props}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
const onMount = () => {
|
|
|
form.setValues({ ...defaultFormData })
|
|
|
delay(80).then(() => {
|
|
@@ -106,13 +132,14 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
|
enum: accountTypeList.map(item => item.value),
|
|
|
enumNames: accountTypeList.map(item => item.label)
|
|
|
})
|
|
|
+ form.setSchemaByPath('institutionID', {
|
|
|
+ type: 'string',
|
|
|
+ widget: 'site'
|
|
|
+ })
|
|
|
})
|
|
|
delay(80).then(() => {
|
|
|
form.setSchemaByPath('organizationalStructureID', {
|
|
|
- // enum: organizationList.map(item => item.value),
|
|
|
- // enumNames: organizationList.map(item => item.label),
|
|
|
- // description: '',
|
|
|
- // type: 'string',
|
|
|
+ type: 'string',
|
|
|
widget: 'treeSelect',
|
|
|
props: {
|
|
|
treeDefaultExpandAll: true,
|
|
@@ -176,7 +203,13 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
|
}}
|
|
|
title={type === ModalType.ADD ? '新增账号' : '编辑账号'}>
|
|
|
{schema && (
|
|
|
- <FormRender form={form} schema={JSON.parse(schema)} onFinish={onFinish} onMount={onMount} />
|
|
|
+ <FormRender
|
|
|
+ form={form}
|
|
|
+ schema={JSON.parse(schema)}
|
|
|
+ onFinish={onFinish}
|
|
|
+ onMount={onMount}
|
|
|
+ widgets={{ site: SiteInput }}
|
|
|
+ />
|
|
|
)}
|
|
|
<div>
|
|
|
<Button onClick={form.submit}>提交</Button>
|