|
@@ -1,10 +1,20 @@
|
|
-import { useModel } from '@umijs/max';
|
|
|
|
-import { TreeSelect } from 'antd';
|
|
|
|
|
|
+import { useRequest } from '@umijs/max';
|
|
|
|
+import { Select, TreeSelect } from 'antd';
|
|
import { useEffect } from 'react';
|
|
import { useEffect } from 'react';
|
|
|
|
+import { queryDepsV2 } from '@/services/approval';
|
|
|
|
|
|
function DepartmentField(props) {
|
|
function DepartmentField(props) {
|
|
const { value, onChange, disabled = false } = props;
|
|
const { value, onChange, disabled = false } = props;
|
|
- const { depList, run, loading } = useModel('depList');
|
|
|
|
|
|
+ // const { depList, run, loading } = useModel('depList');
|
|
|
|
+ // 新建合同时,选择本部时,需要用另一个接口请求部门数据
|
|
|
|
+ const { data, run, loading } = useRequest(queryDepsV2, {
|
|
|
|
+ manual: true,
|
|
|
|
+ formatResult: (response) => {
|
|
|
|
+ return response.data?.map((item) => {
|
|
|
|
+ return { value: item.ID, label: item.Name };
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
|
|
const onChangeValue = (newValue) => {
|
|
const onChangeValue = (newValue) => {
|
|
onChange(String(newValue));
|
|
onChange(String(newValue));
|
|
@@ -14,7 +24,7 @@ function DepartmentField(props) {
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
return (
|
|
return (
|
|
- <TreeSelect
|
|
|
|
|
|
+ <Select
|
|
showSearch
|
|
showSearch
|
|
// multiple
|
|
// multiple
|
|
allowClear
|
|
allowClear
|
|
@@ -26,7 +36,7 @@ function DepartmentField(props) {
|
|
loading={loading}
|
|
loading={loading}
|
|
style={{ width: '100%' }}
|
|
style={{ width: '100%' }}
|
|
placeholder="请选择部门"
|
|
placeholder="请选择部门"
|
|
- treeData={depList}
|
|
|
|
|
|
+ options={data}
|
|
onChange={onChangeValue}
|
|
onChange={onChangeValue}
|
|
disabled={disabled}
|
|
disabled={disabled}
|
|
/>
|
|
/>
|