提交 9bd774f3 作者: ZhangLingKun

功能:账号管理设置单位

上级 0034b71e
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import { InterListType, InterReqType } from '~/api/interface';
import { insertBAccountType, listBAccountPageType } from '~/api/interface/systemManageType';
import { Col, Form, Input, message, Modal, Row, Select, TreeSelect } from 'antd';
import { Col, Form, Input, message, Modal, Row, Select } from 'antd';
import { SystemManageAPI } from '~/api';
// 列表的类型
......@@ -21,6 +21,8 @@ const AddEditModal: React.FC<propType> = (props) => {
};
// 参数
const { title, open, closed, data } = props;
// 单位列表
const [companyList, setCompanyList] = useState<{ label: string; value: number }[]>([]);
// 表单钩子
const [form] = Form.useForm<ReqType>();
// 关闭弹窗
......@@ -56,9 +58,18 @@ const AddEditModal: React.FC<propType> = (props) => {
handleCancel();
}
};
// 获取所属单位
const getCompanyList = async () => {
const res = await SystemManageAPI.listCompanyPage({
pageNo: 1,
pageSize: 9999,
});
setCompanyList(res?.result?.list?.map((i) => ({ label: i.companyName, value: i.id })) || []);
};
// componentDidMount
useEffect(() => {
if (!open) return;
getCompanyList().then();
if (!data) return;
form.setFieldsValue(data);
// console.log('data --->', data);
......@@ -169,17 +180,16 @@ const AddEditModal: React.FC<propType> = (props) => {
wrapperCol={{ span: 18 }}
rules={[{ required: true, message: '请选择所属单位' }]}
name='companyId'
initialValue={1}
// initialValue={1}
>
<TreeSelect
treeData={[{ id: 1, company: '科比特' }]}
<Select
options={companyList}
placeholder='请选择所属单位'
fieldNames={{
children: 'children',
label: 'company',
value: 'id',
}}
allowClear
showSearch
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
/>
</Form.Item>
<Form.Item
......
......@@ -44,6 +44,7 @@ const AddEditModal: React.FC<propType> = (props) => {
province: values?.area?.at(0),
city: values?.area?.at(1),
district: values?.area?.at(2),
companyType: 1,
});
})
.catch((err) => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论