|
@@ -1,136 +1,174 @@
|
|
|
import { useEffect, useState, useContext } from 'react';
|
|
|
-import { Form, Input, Button, Steps, Tabs, Space, Switch, Breadcrumb, Radio, TreeSelect, Tree, Tag } from 'antd';
|
|
|
+import { Form, Input, Button, Steps, Tabs, Space, Switch, Breadcrumb, Radio, TreeSelect, Tree, Tag, Card, message } from 'antd';
|
|
|
import './index.less';
|
|
|
import DataContext from './data-context';
|
|
|
+import { useSelector } from 'react-redux'
|
|
|
import apiObj from '@api/index';
|
|
|
+import utils from '@utils/index'
|
|
|
import backIcon from "@images/back.png";
|
|
|
import DoctorList from "./doctorList"
|
|
|
+import Item from 'antd/lib/list/Item';
|
|
|
const { post, api, xPost } = apiObj;
|
|
|
const { SHOW_PARENT } = TreeSelect;
|
|
|
+const { organizationData } = utils;
|
|
|
const { Step } = Steps;
|
|
|
const { TabPane } = Tabs;
|
|
|
function AddData(props) {
|
|
|
+ useEffect(() => {
|
|
|
+ getCreateRoles()
|
|
|
+ getHospitalTree()
|
|
|
+ getOrgList()
|
|
|
+ }, []);
|
|
|
const { back } = props;
|
|
|
- const [value, setValue] = useState('1');
|
|
|
- const [treeRloe, setTreeRloe] = useState([]);
|
|
|
- const [tags, setTags] = useState(['Unremovable', 'Tag 2', 'Tag 3']);
|
|
|
const [form] = Form.useForm();
|
|
|
+ const [value, setValue] = useState(['','']);
|
|
|
+ const [key, setKey] = useState('0');
|
|
|
+ const [index, setIndex] = useState('0');
|
|
|
+ const [selectedId, setSelectedId] = useState(['48-胡能杰']);
|
|
|
+ const [treeRloe, setTreeRloe] = useState([]);
|
|
|
+ const [tags, setTags] = useState([]);
|
|
|
+ const [treeData, setTreeData] = useState([]);
|
|
|
const layout = {
|
|
|
labelCol: { span: 3 },
|
|
|
wrapperCol: { span: 20 },
|
|
|
};
|
|
|
- const treeData = [
|
|
|
- {
|
|
|
- title: '0-0',
|
|
|
- key: '0-0',
|
|
|
- children: [
|
|
|
- {
|
|
|
- title: '0-0-0',
|
|
|
- key: '0-0-0',
|
|
|
- children: [
|
|
|
- {
|
|
|
- title: '0-0-0-0',
|
|
|
- key: '0-0-0-0',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-0-0-1',
|
|
|
- key: '0-0-0-1',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-0-0-2',
|
|
|
- key: '0-0-0-2',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-0-1',
|
|
|
- key: '0-0-1',
|
|
|
- children: [
|
|
|
- {
|
|
|
- title: '0-0-1-0',
|
|
|
- key: '0-0-1-0',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-0-1-1',
|
|
|
- key: '0-0-1-1',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-0-1-2',
|
|
|
- key: '0-0-1-2',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-0-2',
|
|
|
- key: '0-0-2',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-1',
|
|
|
- key: '0-1',
|
|
|
- children: [
|
|
|
- {
|
|
|
- title: '0-1-0-0',
|
|
|
- key: '0-1-0-0',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-1-0-1',
|
|
|
- key: '0-1-0-1',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-1-0-2',
|
|
|
- key: '0-1-0-2',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: '0-2',
|
|
|
- key: '0-2',
|
|
|
- },
|
|
|
- ];
|
|
|
const [expandedKeys, setExpandedKeys] = useState(['0-0-0', '0-0-1']);
|
|
|
const [checkedKeys, setCheckedKeys] = useState(['0-0-0']);
|
|
|
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
|
+ const [orgList, setOrgList] = useState([]);
|
|
|
+ const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
|
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
|
-
|
|
|
-
|
|
|
+ const { save, detail } = useContext(DataContext);
|
|
|
+ const staticInfo = useSelector(state => {
|
|
|
+ return state.staticInfo;
|
|
|
+ });
|
|
|
+ const { dataList } = staticInfo;
|
|
|
+ const initialValues = detail || {
|
|
|
+ status: '1'
|
|
|
+ };
|
|
|
+ //获取当前用于所属角色
|
|
|
+ function getCreateRoles() {
|
|
|
+ const params = {
|
|
|
+ softwareId: ''
|
|
|
+ }
|
|
|
+ xPost(api.getCreateRoles, params).then((res) => {
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ const data = res.data.data;
|
|
|
+ let arr = JSON.parse(JSON.stringify(data).replaceAll(/name/g, 'title').replaceAll(/id/g, 'value'))
|
|
|
+ setTreeRloe(arr)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //获取当前用户组织
|
|
|
+ function getHospitalTree() {
|
|
|
+ post(api.getHospitalTree).then((res) => {
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ const data = res.data.data;
|
|
|
+ let arr = data
|
|
|
+ arr = organizationData(arr)
|
|
|
+ setTreeData(arr)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //获取组织列表
|
|
|
+ function getOrgList() {
|
|
|
+ xPost(api.getUserHospitals).then((res) => {
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ const data = res.data.data;
|
|
|
+ const { software } = data;
|
|
|
+ setOrgList(software);
|
|
|
+ setKey(software[0].id)
|
|
|
+ // //默认显示第一个系统的组织
|
|
|
+ // setHisList(software[0] ? software[0].hospitals : []);
|
|
|
+ } else {
|
|
|
+ message.warning(res.data.msg || '获取医院列表失败');
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ message.error("接口出错");
|
|
|
+ });
|
|
|
+ }
|
|
|
const onExpand = (expandedKeysValue) => {
|
|
|
- console.log('onExpand', expandedKeysValue); // if not set autoExpandParent to false, if children expanded, parent can not collapse.
|
|
|
+ //console.log('onExpand', expandedKeysValue); // if not set autoExpandParent to false, if children expanded, parent can not collapse.
|
|
|
// or, you can remove all expanded children keys.
|
|
|
-
|
|
|
setExpandedKeys(expandedKeysValue);
|
|
|
setAutoExpandParent(false);
|
|
|
};
|
|
|
|
|
|
const onCheck = (checkedKeysValue) => {
|
|
|
- console.log('onCheck', checkedKeysValue);
|
|
|
+ // console.log('onCheck', checkedKeysValue);
|
|
|
setCheckedKeys(checkedKeysValue);
|
|
|
};
|
|
|
|
|
|
const onSelect = (selectedKeysValue, info) => {
|
|
|
- console.log('onSelect', info);
|
|
|
setSelectedKeys(selectedKeysValue);
|
|
|
};
|
|
|
const validateMessages = {
|
|
|
- required: '${label} is required!',
|
|
|
- types: {
|
|
|
- email: '${label} is not a valid email!',
|
|
|
- number: '${label} is not a valid number!',
|
|
|
- },
|
|
|
- number: {
|
|
|
- range: '${label} must be between ${min} and ${max}',
|
|
|
- },
|
|
|
+ required: '${label}不能为空',
|
|
|
};
|
|
|
- const onChange = e => {
|
|
|
- console.log('radio checked', e.target.value);
|
|
|
- setValue(e.target.value)
|
|
|
+ const onChange = (e, i) => {
|
|
|
+ let val = value
|
|
|
+ const formData = form.getFieldsValue();
|
|
|
+ let arr = formData.softwareVOS;
|
|
|
+ arr[i] = {
|
|
|
+ id: key,
|
|
|
+ dataAuthDetails: arr[i].dataAuthDetails,
|
|
|
+ };
|
|
|
+ console.log(arr)
|
|
|
+ form.setFieldsValue({
|
|
|
+ softwareVOS: arr
|
|
|
+ });
|
|
|
+ console.log(form.getFieldsValue())
|
|
|
+ val[i] = e.target.value
|
|
|
+ setValue([...val])
|
|
|
+
|
|
|
};
|
|
|
+ // 删除选择标签
|
|
|
+ function delTag(i){
|
|
|
+ console.log(i);
|
|
|
+ console.log(tags);
|
|
|
+ tags.splice(i)
|
|
|
+ selectedRowKeys.splice(i)
|
|
|
+ setTags([...tags])
|
|
|
+ setSelectedRowKeys([...selectedRowKeys])
|
|
|
+ // setDelIndex(i)
|
|
|
+ // DoctorList.alertEvevnt();
|
|
|
+ }
|
|
|
function callback(key) {
|
|
|
- console.log(key);
|
|
|
+ setKey(key.split('-')[0])
|
|
|
+ setIndex(key.split('-')[1])
|
|
|
+ }
|
|
|
+ function callbacks(keys) {
|
|
|
+
|
|
|
}
|
|
|
- const onFinish = (values: any) => {
|
|
|
- console.log(values);
|
|
|
+ function checkDoctEvent(selectedRowKeys){
|
|
|
+ console.log(selectedRowKeys);
|
|
|
+
|
|
|
+ const formData = form.getFieldsValue();
|
|
|
+ let arr = []
|
|
|
+ let tag = []
|
|
|
+ let ids = []
|
|
|
+ selectedRowKeys.forEach(it => {
|
|
|
+ arr.push({
|
|
|
+ dataType:7,
|
|
|
+ detailId:it.split('-')[0],
|
|
|
+ detailType:3
|
|
|
+ })
|
|
|
+ tag.push(it.split('-')[1])
|
|
|
+ ids.push(it.split('-')[0])
|
|
|
+ });
|
|
|
+
|
|
|
+ formData.dataAuthDetails[index] = arr
|
|
|
+ form.setFieldsValue({
|
|
|
+ dataAuthDetails: formData.dataAuthDetails
|
|
|
+ });
|
|
|
+ setSelectedId([...ids])
|
|
|
+ console.log(selectedId);
|
|
|
+
|
|
|
+ setTags([...tag])
|
|
|
+ }
|
|
|
+ const onFinish = value => {
|
|
|
+ console.log(form.getFieldsValue())
|
|
|
+ save(form.getFieldsValue())
|
|
|
};
|
|
|
function swichChange(val) {
|
|
|
form.setFieldsValue({ status: val ? 1 : 0 })
|
|
@@ -143,73 +181,90 @@ function AddData(props) {
|
|
|
<Breadcrumb.Separator />
|
|
|
<Breadcrumb.Item>新增子组织</Breadcrumb.Item>
|
|
|
</Breadcrumb>
|
|
|
- <Form {...layout} name="nest-messages" onFinish={onFinish} validateMessages={validateMessages}>
|
|
|
- <Form.Item name={['user', 'name']} label="数据权限名称" rules={[{ required: true }]}>
|
|
|
+ <Form {...layout} form={form} name="nest-messages" onFinish={onFinish} initialValues={initialValues} validateMessages={validateMessages}>
|
|
|
+ <Form.Item name="name" label="数据权限名称" rules={[{ required: true }]}>
|
|
|
<Input placeholder="请填写数据权限名称" />
|
|
|
</Form.Item>
|
|
|
- <Form.Item name={['user', 'email']} label="权限范围" rules={[{ type: 'email' }]}>
|
|
|
- <Tabs defaultActiveKey="1" onChange={callback} >
|
|
|
- <TabPane tab="AI终末质控系统" key="1">
|
|
|
- <Radio.Group onChange={onChange} value={value} className="radio">
|
|
|
- <Space direction="vertical">
|
|
|
- <Radio value={1}>全部组织</Radio>
|
|
|
- <Radio value={2}>全部科室</Radio>
|
|
|
- <Radio value={3}>全部科室除本科室外</Radio>
|
|
|
- <Radio value={4}>本科室</Radio>
|
|
|
- <Radio value={5}>本医疗组</Radio>
|
|
|
- <Radio value={6}>本人</Radio>
|
|
|
- <Radio value={7}>自定义</Radio>
|
|
|
- </Space>
|
|
|
- </Radio.Group>
|
|
|
- </TabPane>
|
|
|
- <TabPane tab="AI终末质控系统" key="2">
|
|
|
- Content of Tab Pane 2
|
|
|
- </TabPane>
|
|
|
+ <Form.Item label="权限范围" required >
|
|
|
+ <Tabs type="card" onChange={callback} >
|
|
|
+ {
|
|
|
+ orgList.map((it, i) => {
|
|
|
+ return (
|
|
|
+ <TabPane tab={it.name} key={it.id+"-"+i}>
|
|
|
+ <Form.Item
|
|
|
+ key={i}
|
|
|
+ name={['dataAuthDetails', i, 'dataType']} noStyle>
|
|
|
+ <Radio.Group onChange={e => { onChange(e, i) }} value={value[i]} className="radio">
|
|
|
+ <Space direction="vertical">
|
|
|
+ {dataList.map((Item) => {
|
|
|
+ return (
|
|
|
+ <Radio value={Item.name}>{Item.val}</Radio>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </Space>
|
|
|
+ </Radio.Group>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item key={i + "a"} hidden={true} name={['softwareVOS', i, 'id']} noStyle>
|
|
|
+ <Input />
|
|
|
+ </Form.Item>
|
|
|
+ </TabPane>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
</Tabs>
|
|
|
</Form.Item>
|
|
|
- <Form.Item>
|
|
|
- {tags.map((tag, index) => {
|
|
|
- return (
|
|
|
- <Tag>{tag}</Tag>
|
|
|
- );
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- </Form.Item>
|
|
|
+ {value[index] == 7 ?
|
|
|
+ <Form.Item wrapperCol={{ offset: 3, span: 20 }} name={['dataAuthDetails', key, 'dataType']}>
|
|
|
+ <Card title="已选中" extra={<a href="#">More</a>} >
|
|
|
+ {tags.map((tag, i) => {
|
|
|
+ return (
|
|
|
+ <Tag closable onClose={e=>delTag(i)}>{tag}</Tag>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </Card>
|
|
|
+ </Form.Item>
|
|
|
+ :
|
|
|
+ null}
|
|
|
+
|
|
|
+ {value[index] == 7 ?
|
|
|
+ <Form.Item
|
|
|
+ name={['softwareVOS', index, 'dataAuthDetails', index, 'detailId']}
|
|
|
+ wrapperCol={{ offset: 3, span: 20 }}
|
|
|
+ >
|
|
|
+ <Tabs defaultActiveKey="0" onChange={callbacks} >
|
|
|
+ <TabPane tab="可看医生" key="0">
|
|
|
+ <DoctorList data={selectedId} checkDoct={(selectedRowKeys) => checkDoctEvent(selectedRowKeys)}/>
|
|
|
+ </TabPane>
|
|
|
+ <TabPane tab="可看科室" key="1">
|
|
|
+ <Tree
|
|
|
+ checkable
|
|
|
+ onExpand={onExpand}
|
|
|
+ expandedKeys={expandedKeys}
|
|
|
+ autoExpandParent={autoExpandParent}
|
|
|
+ onCheck={onCheck}
|
|
|
+ checkedKeys={checkedKeys}
|
|
|
+ onSelect={onSelect}
|
|
|
+ selectedKeys={selectedKeys}
|
|
|
+ treeData={treeData}
|
|
|
+ />
|
|
|
+ </TabPane>
|
|
|
+ </Tabs>
|
|
|
+ </Form.Item>
|
|
|
+ :
|
|
|
+ null}
|
|
|
|
|
|
<Form.Item
|
|
|
name="roles"
|
|
|
label="所属角色"
|
|
|
- >
|
|
|
- <Tabs defaultActiveKey="1" onChange={callback} >
|
|
|
- <TabPane tab="AI终末质控系统" key="1">
|
|
|
- <DoctorList />
|
|
|
- </TabPane>
|
|
|
- <TabPane tab="AI终末质控系统" key="2">
|
|
|
- <Tree
|
|
|
- checkable
|
|
|
- onExpand={onExpand}
|
|
|
- expandedKeys={expandedKeys}
|
|
|
- autoExpandParent={autoExpandParent}
|
|
|
- onCheck={onCheck}
|
|
|
- checkedKeys={checkedKeys}
|
|
|
- onSelect={onSelect}
|
|
|
- selectedKeys={selectedKeys}
|
|
|
- treeData={treeData}
|
|
|
- />
|
|
|
- </TabPane>
|
|
|
- </Tabs>
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- name="roles"
|
|
|
- label="所属角色"
|
|
|
+ rules={[{ required: true }]}
|
|
|
>
|
|
|
<TreeSelect
|
|
|
showSearch={false}
|
|
|
treeData={treeRloe}
|
|
|
treeCheckable
|
|
|
showCheckedStrategy={SHOW_PARENT}
|
|
|
- placeholder="请选择组织"
|
|
|
+ placeholder="请选择角色"
|
|
|
style={{ width: '100%' }}
|
|
|
/>
|
|
|
</Form.Item>
|