|
@@ -7,6 +7,7 @@ import { useSelector } from 'react-redux'
|
|
|
import apiObj from '@api/index';
|
|
|
import utils from '@utils/index'
|
|
|
import backIcon from "@images/back.png";
|
|
|
+import del from '@images/icon-del.png'
|
|
|
import DoctorList from "./doctorList"
|
|
|
import Item from 'antd/lib/list/Item';
|
|
|
const { post, api, xPost } = apiObj;
|
|
@@ -167,22 +168,38 @@ function AddData(props) {
|
|
|
// 删除选择标签
|
|
|
function delTag(type, id, i) {
|
|
|
const formData = form.getFieldsValue();
|
|
|
+ const softwareVOS = formData.softwareVOS[index]
|
|
|
if (type == 3) {
|
|
|
- formData.softwareVOS[index].selectedRowKeys.forEach((item, inx) => {
|
|
|
+ softwareVOS.selectedRowKeys.forEach((item, inx) => {
|
|
|
if (item.split('-')[0] == id) {
|
|
|
- formData.softwareVOS[index].selectedRowKeys.splice(inx)
|
|
|
+ softwareVOS.selectedRowKeys.splice(inx)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ softwareVOS.dataAuthDetails.forEach((item, inx) => {
|
|
|
+ if (item.detailId == id) {
|
|
|
+ softwareVOS.dataAuthDetails.splice(inx)
|
|
|
}
|
|
|
})
|
|
|
} else if (type == 1) {
|
|
|
- formData.softwareVOS[index].softwareMenuIds.forEach((item, inx) => {
|
|
|
+ softwareVOS.softwareMenuIds.forEach((item, inx) => {
|
|
|
if (item.split('-')[0] == id) {
|
|
|
- formData.softwareVOS[index].softwareMenuIds.splice(inx)
|
|
|
+ softwareVOS.softwareMenuIds.splice(inx)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ softwareVOS.dataAuthDetails.forEach((item, inx) => {
|
|
|
+ if (item.detailId == id) {
|
|
|
+ softwareVOS.dataAuthDetails.splice(inx)
|
|
|
}
|
|
|
})
|
|
|
} else if (type == 2) {
|
|
|
- formData.softwareVOS[index].softwareMenuIds.forEach((item, inx) => {
|
|
|
+ softwareVOS.softwareMenuIds.forEach((item, inx) => {
|
|
|
if (item.split('-')[1] == id) {
|
|
|
- formData.softwareVOS[index].softwareMenuIds.splice(inx)
|
|
|
+ softwareVOS.softwareMenuIds.splice(inx)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ softwareVOS.dataAuthDetails.forEach((item, inx) => {
|
|
|
+ if (item.detailId == id) {
|
|
|
+ softwareVOS.dataAuthDetails.splice(inx)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -191,6 +208,7 @@ function AddData(props) {
|
|
|
});
|
|
|
tags[index].splice(i)
|
|
|
setTags([...tags])
|
|
|
+ console.log(form.getFieldsValue());
|
|
|
}
|
|
|
function callback(key) {
|
|
|
setKey(key.split('-')[0])
|
|
@@ -230,29 +248,30 @@ function AddData(props) {
|
|
|
detailType: 3
|
|
|
})
|
|
|
});
|
|
|
-
|
|
|
formData.softwareVOS[index].dataAuthDetails = unique(arr)
|
|
|
formData.softwareVOS[index].selectedRowKeys = selectedRowKeys
|
|
|
form.setFieldsValue({
|
|
|
softwareVOS: formData.softwareVOS
|
|
|
});
|
|
|
getTags()
|
|
|
- console.log(form.getFieldsValue())
|
|
|
}
|
|
|
//树形结构选中事件
|
|
|
function checkTreeEvent(idsArr) {
|
|
|
const formData = form.getFieldsValue();
|
|
|
let arr = formData.softwareVOS[index].dataAuthDetails ? formData.softwareVOS[index].dataAuthDetails : []
|
|
|
- let result = idsArr.find(ele => ele.split('-').length == 2)
|
|
|
+ let result = idsArr.filter(ele => {
|
|
|
+ return ele.split('-').length == 2
|
|
|
+ })
|
|
|
if (result) {
|
|
|
- arr.push({
|
|
|
- dataType: 7,
|
|
|
- detailId: result.split('-')[0],
|
|
|
- detailType: 1
|
|
|
+ result.forEach(it => {
|
|
|
+ arr.push({
|
|
|
+ dataType: 7,
|
|
|
+ detailId: it.split('-')[0],
|
|
|
+ detailType: 1
|
|
|
+ })
|
|
|
})
|
|
|
} else {
|
|
|
idsArr.forEach(it => {
|
|
|
- console.log(it)
|
|
|
arr.push({
|
|
|
dataType: 7,
|
|
|
detailId: it.split('-')[1],
|
|
@@ -272,6 +291,7 @@ function AddData(props) {
|
|
|
function getTags() {
|
|
|
const formData = form.getFieldsValue();
|
|
|
let tag = []
|
|
|
+
|
|
|
let softwareMenuIds = formData.softwareVOS[index].softwareMenuIds
|
|
|
let selectedRowKeys = formData.softwareVOS[index].selectedRowKeys
|
|
|
selectedRowKeys && selectedRowKeys.forEach(it => {
|
|
@@ -282,12 +302,16 @@ function AddData(props) {
|
|
|
})
|
|
|
});
|
|
|
if (softwareMenuIds) {
|
|
|
- let result = softwareMenuIds.find(ele => ele.split('-').length == 2)
|
|
|
+ let result = softwareMenuIds.filter(ele => {
|
|
|
+ return ele.split('-').length == 2
|
|
|
+ })
|
|
|
if (result) {
|
|
|
- tag.push({
|
|
|
- id: result.split('-')[0],
|
|
|
- name: result.split('-')[1],
|
|
|
- type: 1
|
|
|
+ result.forEach(it => {
|
|
|
+ tag.push({
|
|
|
+ id: it.split('-')[0],
|
|
|
+ name: it.split('-')[1],
|
|
|
+ type: 1
|
|
|
+ })
|
|
|
})
|
|
|
} else {
|
|
|
softwareMenuIds.forEach(it => {
|
|
@@ -299,6 +323,8 @@ function AddData(props) {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+ console.log(tag);
|
|
|
+
|
|
|
tags[index] = tag
|
|
|
setTags([...tags])
|
|
|
}
|
|
@@ -308,6 +334,19 @@ function AddData(props) {
|
|
|
function swichChange(val) {
|
|
|
form.setFieldsValue({ status: val ? 1 : 0 })
|
|
|
}
|
|
|
+ function delAll() {
|
|
|
+ const formData = form.getFieldsValue();
|
|
|
+ formData.softwareVOS[index].selectedRowKeys = []
|
|
|
+ formData.softwareVOS[index].softwareMenuIds = []
|
|
|
+ formData.softwareVOS[index].dataAuthDetails = []
|
|
|
+ form.setFieldsValue({
|
|
|
+ softwareVOS: formData.softwareVOS
|
|
|
+ });
|
|
|
+ tags[index] = []
|
|
|
+ setTags([...tags])
|
|
|
+ console.log(form.getFieldsValue());
|
|
|
+
|
|
|
+ }
|
|
|
return (
|
|
|
<>
|
|
|
<Breadcrumb separator="">
|
|
@@ -317,8 +356,6 @@ function AddData(props) {
|
|
|
<Breadcrumb.Item>{type == 3 ? '修改' : '新增'}数据权限</Breadcrumb.Item>
|
|
|
</Breadcrumb>
|
|
|
<div className='form-center'>
|
|
|
-
|
|
|
-
|
|
|
<Form labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} form={form} name="nest-messages" onFinish={onFinish} initialValues={initialValues} validateMessages={validateMessages}>
|
|
|
<Form.Item name="name" label="数据权限名称" rules={[{ required: true }]}>
|
|
|
<Input placeholder="请填写数据权限名称" style={{ width: 300 }} />
|
|
@@ -353,7 +390,7 @@ function AddData(props) {
|
|
|
<Input />
|
|
|
</Form.Item>
|
|
|
<Form.Item key={i + "c"} style={{ display: value[index] == 7 && it.id == key ? 'block' : 'none' }}>
|
|
|
- <Card title="已选中" extra={<a href="#">More</a>} >
|
|
|
+ <Card title="已选中" extra={<span onClick={delAll} className='del-all'><img className='del-icon' src={del} />清空所有</span>} >
|
|
|
{tags[index].map((tag, i) => {
|
|
|
return (
|
|
|
<Tag key={i} closable onClose={e => delTag(tag.type, tag.id, i)}>{tag.name}</Tag>
|