Commit 187c5ce4 authored by 皮倩雯's avatar 皮倩雯

fix: '重构事件模块代码'

parent 651866fa
Pipeline #42958 skipped with stages
...@@ -25,7 +25,6 @@ import { ...@@ -25,7 +25,6 @@ import {
Form, Form,
Input, Input,
notification, notification,
message,
Space, Space,
Row, Row,
Col, Col,
...@@ -45,27 +44,13 @@ import { ...@@ -45,27 +44,13 @@ import {
GetCM_Event_QueryEventType, GetCM_Event_QueryEventType,
CM_Event_AddEventTable, CM_Event_AddEventTable,
} from '@/services/standingBook/api'; } from '@/services/standingBook/api';
import { PlusOutlined, DownOutlined, InfoCircleOutlined } from '@ant-design/icons';
import styles from './incident.less'; import styles from './incident.less';
import ChangeAdd from './changeAdd'; import ChangeAdd from './changeAdd';
import ChangeEdit from './changeEdit'; import ChangeEdit from './changeEdit';
import ChangeImage from './ChangeImage';
import ModalDrag from '../../maintenance/ModalDrag';
import { PlusOutlined, DownOutlined, InfoCircleOutlined } from '@ant-design/icons';
import { set } from 'immutable';
import { getRoleGroup } from '@/services/RoleManage/api';
const { Option } = Select; const { Option } = Select;
const AddModal = props => { const AddModal = props => {
const [inputValue, setInputValue] = useState({
SummaryFields: '',
ReportFields: '',
DisplayFields: '',
EditableFields: '',
TransitFields: '',
Roles: '',
RelatedEventFields: '',
pictureFields: '',
});
const { const {
callBackSubmit = () => {}, callBackSubmit = () => {},
visible, visible,
...@@ -456,47 +441,26 @@ const AddModal = props => { ...@@ -456,47 +441,26 @@ const AddModal = props => {
'40840': 'YK', '40840': 'YK',
'40863': 'QJG', '40863': 'QJG',
}); });
const CheckboxGroup = Checkbox.Group;
const defaultCheckedList = ['前端', '手持'];
// const plainOptions = ['前端', '手持']
const [checkedList, setCheckedList] = useState(defaultCheckedList);
const [checkedList1, setCheckedList1] = useState([]); const [checkedList1, setCheckedList1] = useState([]);
const [checkedList2, setCheckedList2] = useState([]);
const [checkedList3, setCheckedList3] = useState([]);
const [checkedList4, setCheckedList4] = useState([]);
const [nu, setNu] = useState([]); const [nu, setNu] = useState([]);
const [nu1, setNu1] = useState([]); const [nu1, setNu1] = useState([]);
const [editable, setEditable] = useState(false); const [editable, setEditable] = useState(false);
const [ReportFromMobile, setReportFromMobile] = useState(false); const [ReportFromMobile, setReportFromMobile] = useState(false);
const [ReportFromWeb, setReportFromWeb] = useState(false); const [ReportFromWeb, setReportFromWeb] = useState(false);
const [chee, setChee] = useState(0); const [chee, setChee] = useState(0);
const [indeterminate, setIndeterminate] = useState(true);
const [checkAll, setCheckAll] = useState(true);
const [pickItem, setPickItem] = useState(''); const [pickItem, setPickItem] = useState('');
const [prefixName, setPrefixName] = useState(''); const [prefixName, setPrefixName] = useState('');
const [selectValue, setSelectValue] = useState(''); const [selectValue, setSelectValue] = useState('');
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [standingTable, setStandingTable] = useState([]); const [standingTable, setStandingTable] = useState([]);
const [filed, setFiled] = useState({}); // 传给子组件列表数据 const [filed, setFiled] = useState({}); // 传给子组件列表数据
const [filed1, setFiled1] = useState({}); // 传给子组件列表数据 const [filed1, setFiled1] = useState({}); // 传给子组件列表数据
const [flag, setFlag] = useState(0); const [flag, setFlag] = useState(0);
const [value, setValue] = useState(''); // 单选 const [value, setValue] = useState(''); // 单选
const [types, setTypes] = useState(''); // 弹窗类型
const [Order, setOrder] = useState(''); // 弹窗类型 const [Order, setOrder] = useState(''); // 弹窗类型
const [Type1, setType1] = useState(''); const [Type1, setType1] = useState('');
const [number, setNumber] = useState('');
const [isVisible, setIsVisible] = useState(false); // 事件权限弹窗 const [isVisible, setIsVisible] = useState(false); // 事件权限弹窗
const [isVisibleEdit, setIsVisibleEdit] = useState(false); // 字段弹框 const [isVisibleEdit, setIsVisibleEdit] = useState(false); // 字段弹框
const [isVisible1, setIsVisible1] = useState(false); // 弹窗
const [characterValue, setCharacterValue] = useState('');
const [form] = Form.useForm(); const [form] = Form.useForm();
const [summaryIsShow, setSummaryIsShow] = useState('none'); // 摘要字段外部字段是否显示 const [summaryIsShow, setSummaryIsShow] = useState('none'); // 摘要字段外部字段是否显示
const [reportIsShow, setReportIsShow] = useState('none'); // 上报字段外部字段是否显示 const [reportIsShow, setReportIsShow] = useState('none'); // 上报字段外部字段是否显示
...@@ -532,19 +496,19 @@ const AddModal = props => { ...@@ -532,19 +496,19 @@ const AddModal = props => {
obj.CreateMode = obj.CreateMode.toString(); obj.CreateMode = obj.CreateMode.toString();
} }
if (editable != true) { if (editable != true) {
inputValue.Editable = false; obj.Editable = false;
} else { } else {
inputValue.Editable = editable; obj.Editable = editable;
} }
if (checkedList3 === true && checkedList4 === true) { if (ReportFromWeb === true && ReportFromMobile === true) {
obj.Reportable = '均可'; obj.Reportable = '均可';
obj.ReportFromMobile = '手持'; obj.ReportFromMobile = '手持';
obj.ReportFromWeb = '前端'; obj.ReportFromWeb = '前端';
} else if (checkedList3 === true) { } else if (ReportFromWeb === true) {
obj.Reportable = '前端'; obj.Reportable = '前端';
obj.ReportFromMobile = ''; obj.ReportFromMobile = '';
obj.ReportFromWeb = '前端'; obj.ReportFromWeb = '前端';
} else if (checkedList4 === true) { } else if (ReportFromMobile === true) {
obj.Reportable = '手持'; obj.Reportable = '手持';
obj.ReportFromMobile = '手持'; obj.ReportFromMobile = '手持';
obj.ReportFromWeb = ''; obj.ReportFromWeb = '';
...@@ -553,25 +517,7 @@ const AddModal = props => { ...@@ -553,25 +517,7 @@ const AddModal = props => {
obj.ReportFromMobile = ''; obj.ReportFromMobile = '';
obj.ReportFromWeb = ''; obj.ReportFromWeb = '';
} }
if (ReportFromWeb === true && ReportFromMobile === true) { if ((obj.Roles == '' || obj.Roles == undefined) && obj.Reportable != '否') {
inputValue.Reportable = '均可';
inputValue.ReportFromMobile = '手持';
inputValue.ReportFromWeb = '前端';
} else if (ReportFromWeb === true) {
inputValue.Reportable = '前端';
inputValue.ReportFromMobile = '';
inputValue.ReportFromWeb = '前端';
} else if (ReportFromMobile === true) {
inputValue.Reportable = '手持';
inputValue.ReportFromMobile = '手持';
inputValue.ReportFromWeb = '';
} else {
inputValue.Reportable = '否';
inputValue.ReportFromMobile = '';
inputValue.ReportFromWeb = '';
}
let data = { ...obj, ...inputValue, Order: maxLength };
if (inputValue.Roles == '' && inputValue.Reportable != '否') {
notification.warning({ notification.warning({
message: '提示', message: '提示',
description: '当允许客户端上报时,须填写事件权限', description: '当允许客户端上报时,须填写事件权限',
...@@ -579,81 +525,56 @@ const AddModal = props => { ...@@ -579,81 +525,56 @@ const AddModal = props => {
} else { } else {
if (type == 'edit') { if (type == 'edit') {
CM_Event_EditEventTable({ CM_Event_EditEventTable({
...inputValue,
ID: formObj.ID, ID: formObj.ID,
Name: obj.Name, ...obj,
Code: obj.Code, Order,
BusinessType: obj.BusinessType, }).then(res => {
TableName: obj.TableName, setLoading(false);
Reportable: inputValue.Reportable, if (res.msg === 'Ok') {
ReportFromWeb: inputValue.ReportFromWeb, form.resetFields();
ReportFromMobile: inputValue.ReportFromMobile, setValue('');
Editable: inputValue.Editable, callBackSubmit();
CreateMode: obj.CreateMode, notification.success({
TopWhere: obj.TopWhere, message: '提示',
ReportPage: obj.ReportPage, duration: 3,
DealPage: obj.DealPage, description: '编辑成功',
RelatedEvents: obj.RelatedEvents, });
InterfaceConfig: obj.InterfaceConfig, } else {
})
.then(res => {
setLoading(false);
if (res.msg === 'Ok') {
form.resetFields();
setValue('');
callBackSubmit();
notification.success({
message: '提示',
duration: 3,
description: '编辑成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
})
.catch(error => {
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 3,
description: '编辑失败', description: res.msg,
}); });
setLoading(false); }
}); });
setFlag(0); setFlag(0);
} }
if (type == 'add') { if (type == 'add') {
CM_Event_AddEventTable(data) if (obj.TransitFields == undefined) {
.then(res => { obj.TransitFields = '';
setLoading(false); }
if (res.msg === 'Ok') { if (obj.Roles == undefined) {
form.resetFields(); obj.Roles = '';
setValue(''); }
callBackSubmit(); CM_Event_AddEventTable({ ...obj, Order: maxLength }).then(res => {
notification.success({ setLoading(false);
message: '提示', if (res.msg === 'Ok') {
duration: 3, form.resetFields();
description: '新增成功', setValue('');
}); callBackSubmit();
} else { notification.success({
notification.error({ message: '提示',
message: '提示', duration: 3,
duration: 3, description: '新增成功',
description: res.msg, });
}); } else {
}
})
.catch(error => {
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 3,
description: '新增失败', description: res.msg,
}); });
setLoading(false); }
}); });
setFlag(0); setFlag(0);
} }
} }
...@@ -670,21 +591,10 @@ const AddModal = props => { ...@@ -670,21 +591,10 @@ const AddModal = props => {
setType1(rember1); setType1(rember1);
form.setFieldsValue({ BusinessType: rember1 }); form.setFieldsValue({ BusinessType: rember1 });
setReportFromWeb(true); setReportFromWeb(true);
setCheckedList3(true);
setChee(0); setChee(0);
setValue(0); setValue(0);
getEventData(); getEventData();
setSelectValue(selectData[0]); setSelectValue(selectData[0]);
setInputValue({
SummaryFields: '',
ReportFields: '',
DisplayFields: '',
EditableFields: '',
TransitFields: '',
Roles: '',
RelatedEventFields: '',
pictureFields: '',
});
setFiled({}); setFiled({});
setFiled1({}); setFiled1({});
form.resetFields(); form.resetFields();
...@@ -695,12 +605,10 @@ const AddModal = props => { ...@@ -695,12 +605,10 @@ const AddModal = props => {
getEventData1(); getEventData1();
GetCM_Event_QueryEventType({ eventTypeId: formObj.ID }).then(res => { GetCM_Event_QueryEventType({ eventTypeId: formObj.ID }).then(res => {
if (res.data.root) { if (res.data.root) {
console.log(res.data.root);
setEditable(res.data.root.Editable); setEditable(res.data.root.Editable);
setReportFromMobile(res.data.root.ReportFromMobile); setReportFromMobile(res.data.root.ReportFromMobile);
setReportFromWeb(res.data.root.ReportFromWeb); setReportFromWeb(res.data.root.ReportFromWeb);
setType1(res.data.root.BusinessType); setType1(res.data.root.BusinessType);
setInputValue({ ...res.data.root });
setOrder(res.data.root.Order); setOrder(res.data.root.Order);
form.setFieldsValue({ ...res.data.root }); form.setFieldsValue({ ...res.data.root });
LoadEventFields({ LoadEventFields({
...@@ -759,16 +667,19 @@ const AddModal = props => { ...@@ -759,16 +667,19 @@ const AddModal = props => {
setReportFromWeb(false); setReportFromWeb(false);
form.resetFields(); form.resetFields();
setValue(''); setValue('');
setInputValue({ setSummaryIsShow('none');
SummaryFields: '', setReportIsShow('none');
ReportFields: '', setDisplayIsShow('none');
DisplayFields: '', setEditableIsShow('none');
EditableFields: '', setTransitIsShow('none');
TransitFields: '', setRelatedEventIsShow('none');
Roles: '', } else if (type == 'add') {
RelatedEventFields: '', setSummaryIsShow('none');
pictureFields: '', setReportIsShow('none');
}); setDisplayIsShow('none');
setEditableIsShow('none');
setTransitIsShow('none');
setRelatedEventIsShow('none');
} }
}, [visible]); }, [visible]);
...@@ -810,7 +721,6 @@ const AddModal = props => { ...@@ -810,7 +721,6 @@ const AddModal = props => {
if (res.data.root) { if (res.data.root) {
setNu(res.data.root); setNu(res.data.root);
setFiled(formateArrDataA(res.data.root, 'group')); setFiled(formateArrDataA(res.data.root, 'group'));
console.log(res.data.root);
ExternalSummaryField(res.data.root); ExternalSummaryField(res.data.root);
ExternalReportField(res.data.root); ExternalReportField(res.data.root);
ExternalDisplayField(res.data.root); ExternalDisplayField(res.data.root);
...@@ -823,168 +733,192 @@ const AddModal = props => { ...@@ -823,168 +733,192 @@ const AddModal = props => {
// 摘要字段外部字段 // 摘要字段外部字段
const ExternalSummaryField = e => { const ExternalSummaryField = e => {
let pp = formateArrDataA(e, 'group'); if (form.getFieldValue().SummaryFields) {
let ab = inputValue.SummaryFields.split(','); let pp = formateArrDataA(e, 'group');
let arr = Object.keys(pp); let ab = form.getFieldValue().SummaryFields.split(',');
let b = []; let arr = Object.keys(pp);
let a = []; let b = [];
arr.map((item, index) => { let a = [];
pp[item].map((i, j) => { arr.map((item, index) => {
b.push(i); pp[item].map((i, j) => {
b.push(i);
});
}); });
}); ab.map((item, index) => {
ab.map((item, index) => { if (b.includes(item) == false) {
if (b.includes(item) == false) { if (item == '') {
if (item == '') { a = [];
a = []; } else {
} else { a.push(item);
a.push(item); }
} }
});
setSummaryValue(a.length);
if (a.length != 0) {
setSummaryIsShow('inline');
} else {
setSummaryIsShow('none');
} }
});
setSummaryValue(a.length);
if (a.length != 0) {
setSummaryIsShow('inline');
} else { } else {
setSummaryIsShow('none'); setSummaryIsShow('none');
} }
}; };
// 上报字段外部字段 // 上报字段外部字段
const ExternalReportField = e => { const ExternalReportField = e => {
let pp = formateArrDataA(e, 'group'); if (form.getFieldValue().ReportFields) {
let ab = inputValue.ReportFields.split(','); let pp = formateArrDataA(e, 'group');
let arr = Object.keys(pp); let ab = form.getFieldValue().ReportFields.split(',');
let b = []; let arr = Object.keys(pp);
let a = []; let b = [];
arr.map((item, index) => { let a = [];
pp[item].map((i, j) => { arr.map((item, index) => {
b.push(i); pp[item].map((i, j) => {
b.push(i);
});
}); });
}); ab.map((item, index) => {
ab.map((item, index) => { if (b.includes(item) == false) {
if (b.includes(item) == false) { if (item == '') {
if (item == '') { a = [];
a = []; } else {
} else { a.push(item);
a.push(item); }
} }
});
setReportValue(a.length);
if (a.length != 0) {
setReportIsShow('inline');
} else {
setReportIsShow('none');
} }
});
setReportValue(a.length);
if (a.length != 0) {
setReportIsShow('inline');
} else { } else {
setReportIsShow('none'); setReportIsShow('none');
} }
}; };
// 显示字段外部字段 // 显示字段外部字段
const ExternalDisplayField = e => { const ExternalDisplayField = e => {
let pp = formateArrDataA(e, 'group'); if (form.getFieldValue().DisplayFields) {
let ab = inputValue.DisplayFields.split(','); let pp = formateArrDataA(e, 'group');
let arr = Object.keys(pp); let ab = form.getFieldValue().DisplayFields.split(',');
let b = []; let arr = Object.keys(pp);
let a = []; let b = [];
arr.map((item, index) => { let a = [];
pp[item].map((i, j) => { arr.map((item, index) => {
b.push(i); pp[item].map((i, j) => {
b.push(i);
});
}); });
}); ab.map((item, index) => {
ab.map((item, index) => { if (b.includes(item) == false) {
if (b.includes(item) == false) { if (item == '') {
if (item == '') { a = [];
a = []; } else {
} else { a.push(item);
a.push(item); }
} }
});
setDisplayValue(a.length);
if (a.length != 0) {
setDisplayIsShow('inline');
} else {
setDisplayIsShow('none');
} }
});
setDisplayValue(a.length);
if (a.length != 0) {
setDisplayIsShow('inline');
} else { } else {
setDisplayIsShow('none'); setDisplayIsShow('none');
} }
}; };
// 编辑字段外部字段 // 编辑字段外部字段
const ExternalEditableField = e => { const ExternalEditableField = e => {
let pp = formateArrDataA(e, 'group'); if (form.getFieldValue().EditableFields) {
let ab = inputValue.EditableFields.split(','); let pp = formateArrDataA(e, 'group');
let arr = Object.keys(pp); let ab = form.getFieldValue().EditableFields.split(',');
let b = []; let arr = Object.keys(pp);
let a = []; let b = [];
arr.map((item, index) => { let a = [];
pp[item].map((i, j) => { arr.map((item, index) => {
b.push(i); pp[item].map((i, j) => {
b.push(i);
});
}); });
}); ab.map((item, index) => {
ab.map((item, index) => { if (b.includes(item) == false) {
if (b.includes(item) == false) { if (item == '') {
if (item == '') { a = [];
a = []; } else {
} else { a.push(item);
a.push(item); }
} }
});
setEditableValue(a.length);
if (a.length != 0) {
setEditableIsShow('inline');
} else {
setEditableIsShow('none');
} }
});
setEditableValue(a.length);
if (a.length != 0) {
setEditableIsShow('inline');
} else { } else {
setEditableIsShow('none'); setEditableIsShow('none');
} }
}; };
// 转单字段外部字段 // 转单字段外部字段
const ExternalTransitField = e => { const ExternalTransitField = e => {
let pp = formateArrDataA(e, 'group'); if (form.getFieldValue().TransitFields) {
let ab = inputValue.TransitFields.split(','); let pp = formateArrDataA(e, 'group');
let arr = Object.keys(pp); let ab = form.getFieldValue().TransitFields.split(',');
let b = []; let arr = Object.keys(pp);
let a = []; let b = [];
arr.map((item, index) => { let a = [];
pp[item].map((i, j) => { arr.map((item, index) => {
b.push(i); pp[item].map((i, j) => {
b.push(i);
});
}); });
}); ab.map((item, index) => {
ab.map((item, index) => { if (b.includes(item) == false) {
if (b.includes(item) == false) { if (item == '') {
if (item == '') { a = [];
a = []; } else {
} else { a.push(item);
a.push(item); }
} }
});
setTransitValue(a.length);
if (a.length != 0) {
setTransitIsShow('inline');
} else {
setTransitIsShow('none');
} }
});
setTransitValue(a.length);
if (a.length != 0) {
setTransitIsShow('inline');
} else { } else {
setTransitIsShow('none'); setTransitIsShow('none');
} }
}; };
// 关联字段外部字段 // 关联字段外部字段
const ExternalRelatedEventField = e => { const ExternalRelatedEventField = e => {
let pp = formateArrDataA(e, 'group'); if (form.getFieldValue().RelatedEventFields) {
let ab = inputValue.RelatedEventFields.split(','); let pp = formateArrDataA(e, 'group');
let arr = Object.keys(pp); let ab = form.getFieldValue().RelatedEventFields.split(',');
let b = []; let arr = Object.keys(pp);
let a = []; let b = [];
arr.map((item, index) => { let a = [];
pp[item].map((i, j) => { arr.map((item, index) => {
b.push(i); pp[item].map((i, j) => {
b.push(i);
});
}); });
}); ab.map((item, index) => {
ab.map((item, index) => { if (b.includes(item) == false) {
if (b.includes(item) == false) { if (item == '') {
if (item == '') { a = [];
a = []; } else {
} else { a.push(item);
a.push(item); }
} }
});
setRelatedEventValue(a.length);
if (a.length != 0) {
setRelatedEventIsShow('inline');
} else {
setRelatedEventIsShow('none');
} }
});
setRelatedEventValue(a.length);
if (a.length != 0) {
setRelatedEventIsShow('inline');
} else { } else {
setRelatedEventIsShow('none'); setRelatedEventIsShow('none');
} }
...@@ -1094,94 +1028,32 @@ const AddModal = props => { ...@@ -1094,94 +1028,32 @@ const AddModal = props => {
} }
return tempObj; return tempObj;
}; };
const onChange = list => {
console.log(list);
setCheckedList(list);
setIndeterminate(!!list.length && list.length < ['前端', '手持'].length);
setCheckAll(list.length === ['前端', '手持'].length);
};
const onCheckAllChange = e => {
setCheckedList(e.target.checked ? ['前端', '手持'] : []);
setIndeterminate(false);
setCheckAll(e.target.checked);
};
const onChange1 = e => { const onChange1 = e => {
setEditable(e.target.checked); setEditable(e.target.checked);
setCheckedList2(e.target.checked); //true
}; };
const onChange2 = e => { const onChange2 = e => {
setValue(e.target.value); setValue(e.target.value);
}; };
const onChange3 = e => { const onChange3 = e => {
setReportFromWeb(e.target.checked); setReportFromWeb(e.target.checked);
setCheckedList3(e.target.checked); //true
}; };
const onChange4 = e => { const onChange4 = e => {
setReportFromMobile(e.target.checked); setReportFromMobile(e.target.checked);
setCheckedList4(e.target.checked); //true
}; };
const onOK = prop => { const onOK = prop => {
setIsVisible(false); setIsVisible(false);
let inputText = { ...inputValue }; let inputText = {};
inputText[prop.pickItem] = prop.str; inputText[prop.pickItem] = prop.str;
setCheckedList1(prop.stt); setCheckedList1(prop.stt);
setInputValue(inputText); form.setFieldsValue(inputText);
// if (prop.isType == 'app') {
// let title = prop.title;
// let selectData = prop.stt;
// let ff = prop.filed22;
// let aa = [];
// let bb = 0;
// title.map((item, index) => {
// console.log(ff[item]);
// aa = [];
// selectData.map((item1, index1) => {
// console.log(item1);
// if (ff[item].indexOf(item1) != -1) {
// aa.push(item1);
// }
// });
// console.log(aa);
// if (item == '外部字段' && aa.length == 0) {
// bb = 0;
// } else {
// // eslint-disable-next-line no-lonely-if
// if (aa.length == 0) {
// bb = 1;
// }
// }
// });
// console.log(aa);
// if (bb == 1) {
// notification.error({
// message: '提示',
// description: '部门站点角色必须都选至少一项',
// });
// } else {
// setIsVisible(false);
// let inputText = { ...inputValue };
// console.log(inputText);
// console.log(prop.str);
// inputText[prop.pickItem] = prop.str;
// setCheckedList1(prop.stt);
// setInputValue(inputText);
// }
// } else {
// setIsVisible(false);
// let inputText = { ...inputValue };
// inputText[prop.pickItem] = prop.str;
// setCheckedList1(prop.stt);
// setInputValue(inputText);
// }
}; };
const onOK1 = prop => { const onOK1 = prop => {
setIsVisibleEdit(false); setIsVisibleEdit(false);
let inputText = { ...inputValue }; let inputText = {};
inputText[prop.pickItem] = prop.str; inputText[prop.pickItem] = prop.str;
setCheckedList1(prop.stt); setCheckedList1(prop.stt);
setInputValue(inputText); form.setFieldsValue(inputText);
// 外部字段提示 // 外部字段提示
if (prop.pickItem == 'SummaryFields') { if (prop.pickItem == 'SummaryFields') {
setSummaryValue(prop.valueArr.length); setSummaryValue(prop.valueArr.length);
...@@ -1232,87 +1104,62 @@ const AddModal = props => { ...@@ -1232,87 +1104,62 @@ const AddModal = props => {
} }
} }
}; };
const oKK = prop => {
setIsVisible1(false);
};
const pickFiled = fileds => { const pickFiled = fileds => {
if (form.getFieldsValue().TableName) { if (form.getFieldsValue().TableName) {
setFlag(flag + 1); setFlag(flag + 1);
} }
let pp = formateArrDataA(nu, 'group'); let pp = formateArrDataA(nu, 'group');
let ab = inputValue[fileds].split(','); if (form.getFieldValue(fileds)) {
let arr = Object.keys(pp); let ab = form.getFieldValue(fileds).split(',');
let b = []; let arr = Object.keys(pp);
let a = []; let b = [];
arr.map((item, index) => { let a = [];
pp[item].map((i, j) => { arr.map((item, index) => {
b.push(i); pp[item].map((i, j) => {
b.push(i);
});
}); });
}); ab.map((item, index) => {
ab.map((item, index) => { if (b.includes(item) == false) {
if (b.includes(item) == false) { if (item == '') {
if (item == '') { a = [];
a = []; } else {
} else { a.push(item);
a.push(item); }
} }
});
if (a.length > 0) {
pp.外部字段 = a;
arr.push('外部字段');
} }
}); setFiled(pp);
if (a.length > 0) { setCheckedList1(form.getFieldValue(fileds).split(','));
pp.外部字段 = a; setPickItem(fileds);
arr.push('外部字段'); setIsVisibleEdit(true);
} else {
setFiled(pp);
setCheckedList1([]);
setPickItem(fileds);
setIsVisibleEdit(true);
} }
console.log(pp);
setFiled(pp);
setTypes('add');
setCharacterValue(inputValue[fileds]);
setCheckedList1(inputValue[fileds].split(','));
setPickItem(fileds);
setIsVisibleEdit(true);
}; };
const pickFiled1 = fileds => { const pickFiled1 = fileds => {
let pp = formateArrDataA1(nu1, 'group'); let pp = formateArrDataA1(nu1, 'group');
let ab = inputValue[fileds].split(','); if (form.getFieldValue(fileds)) {
let arr = Object.keys(pp); setFiled1(pp);
let b = []; setCheckedList1(form.getFieldValue(fileds).split(','));
let a = []; setPickItem(fileds);
arr.map((item, index) => { setIsVisible(true);
pp[item].map((i, j) => { } else {
b.push(i); setFiled1(pp);
}); setCheckedList1([]);
}); setPickItem(fileds);
ab.map((item, index) => { setIsVisible(true);
if (b.includes(item) == false) { }
if (item == '') {
a = [];
} else {
a.push(item);
}
}
});
// if (a.length > 0) {
// pp.外部字段 = a;
// console.log(pp);
// arr.push('外部字段');
// }
setFiled1(pp);
setTypes('app');
setCharacterValue(inputValue[fileds]);
setCheckedList1(inputValue[fileds].split(','));
setPickItem(fileds);
setIsVisible(true);
};
const pickFiled2 = fileds => {
// setCharacterValue(inputValue[fileds])
// setCheckedList1(inputValue[fileds].split(','))
// setPickItem(fileds)
setIsVisible1(true);
};
const changeText = (e, type) => {
let inputText = { ...inputValue };
inputText[type] = e.target.value;
setInputValue(inputText);
}; };
const prefix = e => { const prefix = e => {
let str = e.target.value; let str = e.target.value;
if (typeof str != 'string') { if (typeof str != 'string') {
...@@ -1380,20 +1227,12 @@ const AddModal = props => { ...@@ -1380,20 +1227,12 @@ const AddModal = props => {
const onCancel11 = () => { const onCancel11 = () => {
setIsVisibleEdit(false); setIsVisibleEdit(false);
}; };
const onCancel1 = () => {
setIsVisible1(false);
};
// const title = <ModalDrag title={type === 'add' ? '添加事件类型' : '编辑事件类型'} />
return ( return (
<Drawer <Drawer
title={type === 'add' ? '添加事件类型' : '编辑事件类型'} title={type === 'add' ? '添加事件类型' : '编辑事件类型'}
width="600px" width="600px"
destroyOnClose destroyOnClose
// afterClose={() => {
// setEditable(false);
// setReportFromMobile(false);
// setReportFromWeb(false);
// }}
{...props} {...props}
footer={ footer={
<Space> <Space>
...@@ -1515,11 +1354,7 @@ const AddModal = props => { ...@@ -1515,11 +1354,7 @@ const AddModal = props => {
}, },
]} ]}
> >
<Select <Select placeholder="选择事件主表" onChange={changTable}>
placeholder="选择事件主表"
onChange={changTable}
// defaultValue={selectValue}
>
{standingTable {standingTable
? standingTable.map((item, index) => ( ? standingTable.map((item, index) => (
<Option key={index} value={item.text}> <Option key={index} value={item.text}>
...@@ -1610,7 +1445,7 @@ const AddModal = props => { ...@@ -1610,7 +1445,7 @@ const AddModal = props => {
rules={[ rules={[
{ {
validator: (rule, value) => { validator: (rule, value) => {
if (inputValue.SummaryFields == '') { if (form.getFieldValue().SummaryFields == '') {
return Promise.reject('摘要字段必选'); return Promise.reject('摘要字段必选');
} }
return Promise.resolve(); return Promise.resolve();
...@@ -1618,19 +1453,15 @@ const AddModal = props => { ...@@ -1618,19 +1453,15 @@ const AddModal = props => {
}, },
]} ]}
> >
<div className={styles.filed_listItem}> <div style={{ display: 'flex' }}>
<Input <Form.Item name="SummaryFields" style={{ marginBottom: 0, width: '100%' }}>
style={{ width: '83%' }} <Input placeholder="请选择摘要字段" allowClear />
placeholder="请选择摘要字段" </Form.Item>
onChange={e => changeText(e, 'SummaryFields')}
value={inputValue.SummaryFields}
allowClear
/>
<Button <Button
type="dashed" type="dashed"
onClick={() => pickFiled('SummaryFields')} onClick={() => pickFiled('SummaryFields')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />} icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '0.5rem', width: '4rem' }} style={{ marginLeft: '10px', width: '70px' }}
/> />
</div> </div>
</Item> </Item>
...@@ -1666,7 +1497,7 @@ const AddModal = props => { ...@@ -1666,7 +1497,7 @@ const AddModal = props => {
rules={[ rules={[
{ {
validator: (rule, value) => { validator: (rule, value) => {
if (inputValue.ReportFields == '') { if (form.getFieldValue().ReportFields == '') {
return Promise.reject('上报字段必选'); return Promise.reject('上报字段必选');
} }
return Promise.resolve(); return Promise.resolve();
...@@ -1674,19 +1505,15 @@ const AddModal = props => { ...@@ -1674,19 +1505,15 @@ const AddModal = props => {
}, },
]} ]}
> >
<div className={styles.filed_listItem}> <div style={{ display: 'flex' }}>
<Input <Form.Item name="ReportFields" style={{ marginBottom: 0, width: '100%' }}>
style={{ width: '83%' }} <Input placeholder="请选择上报字段" allowClear />
placeholder="请选择上报字段" </Form.Item>
onChange={e => changeText(e, 'ReportFields')}
value={inputValue.ReportFields}
allowClear
/>
<Button <Button
type="dashed" type="dashed"
onClick={() => pickFiled('ReportFields')} onClick={() => pickFiled('ReportFields')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />} icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '0.5rem', width: '4rem' }} style={{ marginLeft: '10px', width: '70px' }}
/> />
</div> </div>
</Item> </Item>
...@@ -1722,7 +1549,7 @@ const AddModal = props => { ...@@ -1722,7 +1549,7 @@ const AddModal = props => {
rules={[ rules={[
{ {
validator: (rule, value) => { validator: (rule, value) => {
if (inputValue.DisplayFields == '') { if (form.getFieldValue().DisplayFields == '') {
return Promise.reject('显示字段必选'); return Promise.reject('显示字段必选');
} }
return Promise.resolve(); return Promise.resolve();
...@@ -1730,19 +1557,15 @@ const AddModal = props => { ...@@ -1730,19 +1557,15 @@ const AddModal = props => {
}, },
]} ]}
> >
<div className={styles.filed_listItem}> <div style={{ display: 'flex' }}>
<Input <Form.Item name="DisplayFields" style={{ marginBottom: 0, width: '100%' }}>
style={{ width: '83%' }} <Input placeholder="请选择显示字段" allowClear />
placeholder="请选择显示字段" </Form.Item>
onChange={e => changeText(e, 'DisplayFields')}
value={inputValue.DisplayFields}
allowClear
/>
<Button <Button
type="dashed" type="dashed"
onClick={() => pickFiled('DisplayFields')} onClick={() => pickFiled('DisplayFields')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />} icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '0.5rem', width: '4rem' }} style={{ marginLeft: '10px', width: '70px' }}
/> />
</div> </div>
</Item> </Item>
...@@ -1778,7 +1601,7 @@ const AddModal = props => { ...@@ -1778,7 +1601,7 @@ const AddModal = props => {
rules={[ rules={[
{ {
validator: (rule, value) => { validator: (rule, value) => {
if (inputValue.EditableFields == '') { if (form.getFieldValue().EditableFields == '') {
return Promise.reject('编辑字段必选'); return Promise.reject('编辑字段必选');
} }
return Promise.resolve(); return Promise.resolve();
...@@ -1786,19 +1609,15 @@ const AddModal = props => { ...@@ -1786,19 +1609,15 @@ const AddModal = props => {
}, },
]} ]}
> >
<div className={styles.filed_listItem}> <div style={{ display: 'flex' }}>
<Input <Form.Item name="EditableFields" style={{ marginBottom: 0, width: '100%' }}>
style={{ width: '83%' }} <Input placeholder="请选择编辑字段" allowClear />
placeholder="请选择编辑字段" </Form.Item>
onChange={e => changeText(e, 'EditableFields')}
value={inputValue.EditableFields}
allowClear
/>
<Button <Button
type="dashed" type="dashed"
onClick={() => pickFiled('EditableFields')} onClick={() => pickFiled('EditableFields')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />} icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '0.5rem', width: '4rem' }} style={{ marginLeft: '10px', width: '70px' }}
/> />
</div> </div>
</Item> </Item>
...@@ -1822,38 +1641,30 @@ const AddModal = props => { ...@@ -1822,38 +1641,30 @@ const AddModal = props => {
name="TransitFields" name="TransitFields"
labelCol={{ span: 4 }} labelCol={{ span: 4 }}
> >
<div className={styles.filed_listItem}> <div style={{ display: 'flex' }}>
<Input <Form.Item name="TransitFields" style={{ marginBottom: 0, width: '100%' }}>
style={{ width: '83%' }} <Input placeholder="请选择转单字段" allowClear />
placeholder="请选择转单字段" </Form.Item>
onChange={e => changeText(e, 'TransitFields')}
value={inputValue.TransitFields}
allowClear
/>
<Button <Button
type="dashed" type="dashed"
onClick={() => pickFiled('TransitFields')} onClick={() => pickFiled('TransitFields')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />} icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '0.5rem', width: '4rem' }} style={{ marginLeft: '10px', width: '70px' }}
/> />
</div> </div>
</Item> </Item>
</Col> </Col>
<Col span={24}> <Col span={24}>
<Item label="事件权限" name="Roles" labelCol={{ span: 4 }}> <Item label="事件权限" name="Roles" labelCol={{ span: 4 }}>
<div className={styles.filed_listItem}> <div style={{ display: 'flex' }}>
<Input <Form.Item name="Roles" style={{ marginBottom: 0, width: '100%' }}>
style={{ width: '83%' }} <Input placeholder="请选择事件权限" allowClear />
placeholder="请选择事件权限" </Form.Item>
onChange={e => changeText(e, 'Roles')}
value={inputValue.Roles}
allowClear
/>
<Button <Button
type="dashed" type="dashed"
onClick={() => pickFiled1('Roles')} onClick={() => pickFiled1('Roles')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />} icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '0.5rem', width: '4rem' }} style={{ marginLeft: '10px', width: '70px' }}
/> />
</div> </div>
</Item> </Item>
...@@ -1897,19 +1708,15 @@ const AddModal = props => { ...@@ -1897,19 +1708,15 @@ const AddModal = props => {
name="RelatedEventFields" name="RelatedEventFields"
labelCol={{ span: 4 }} labelCol={{ span: 4 }}
> >
<div className={styles.filed_listItem}> <div style={{ display: 'flex' }}>
<Input <Form.Item name="RelatedEventFields" style={{ marginBottom: 0, width: '100%' }}>
style={{ width: '83%' }} <Input placeholder="请选择关联字段" allowClear />
placeholder="请选择关联字段" </Form.Item>
onChange={e => changeText(e, 'RelatedEventFields')}
value={inputValue.RelatedEventFields}
allowClear
/>
<Button <Button
type="dashed" type="dashed"
onClick={() => pickFiled('RelatedEventFields')} onClick={() => pickFiled('RelatedEventFields')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />} icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '0.5rem', width: '4rem' }} style={{ marginLeft: '10px', width: '70px' }}
/> />
</div> </div>
</Item> </Item>
...@@ -1919,25 +1726,6 @@ const AddModal = props => { ...@@ -1919,25 +1726,6 @@ const AddModal = props => {
<Input placeholder="请输入接口配置" /> <Input placeholder="请输入接口配置" />
</Item> </Item>
</Col> </Col>
<Col span={24}>
<Item label="图片表达" name="ImageExpression" labelCol={{ span: 4 }}>
<div className={styles.filed_listItem}>
<Input
style={{ width: '83%' }}
placeholder="请选择图片表达"
onChange={e => changeText(e, 'pictureFields')}
value={inputValue.pictureFields}
allowClear
/>
<Button
type="dashed"
onClick={() => pickFiled2('pictureFields')}
icon={<PlusOutlined style={{ marginTop: '5px' }} />}
style={{ marginLeft: '0.5rem', width: '4rem' }}
/>
</div>
</Item>
</Col>
</Row> </Row>
</Form> </Form>
<ChangeAdd <ChangeAdd
...@@ -1945,13 +1733,8 @@ const AddModal = props => { ...@@ -1945,13 +1733,8 @@ const AddModal = props => {
onCancel={onCancel} onCancel={onCancel}
callBackSubmit={onOK} callBackSubmit={onOK}
newCheckedList={checkedList1} newCheckedList={checkedList1}
isType={types}
filed={filed}
flag={flag}
filed11={filed1} filed11={filed1}
pickItem={pickItem} pickItem={pickItem}
characterValue={characterValue}
formObj={formObj}
/> />
<ChangeEdit <ChangeEdit
visible={isVisibleEdit} visible={isVisibleEdit}
...@@ -1960,12 +1743,9 @@ const AddModal = props => { ...@@ -1960,12 +1743,9 @@ const AddModal = props => {
newCheckedList={checkedList1} newCheckedList={checkedList1}
filed={filed} filed={filed}
flag={flag} flag={flag}
filed11={filed1}
pickItem={pickItem} pickItem={pickItem}
characterValue={characterValue}
formObj={formObj} formObj={formObj}
/> />
<ChangeImage visible={isVisible1} callBackSubmit={oKK} onCancel={onCancel1} />
</Drawer> </Drawer>
); );
}; };
......
...@@ -22,7 +22,7 @@ import styles from './incident.less'; ...@@ -22,7 +22,7 @@ import styles from './incident.less';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const { TabPane } = Tabs; const { TabPane } = Tabs;
const ChangeAdd = props => { const ChangeAdd = props => {
const { callBackSubmit = () => {}, isType, pickItem, visible, filed11, newCheckedList } = props; const { callBackSubmit = () => {}, pickItem, visible, filed11, newCheckedList } = props;
const [title, setTitle] = useState([]); const [title, setTitle] = useState([]);
const [checkedList, setCheckedList] = useState([]); // 选中复选框内容 const [checkedList, setCheckedList] = useState([]); // 选中复选框内容
const [searchWord, setSearchWord] = useState(''); // 关键字 const [searchWord, setSearchWord] = useState(''); // 关键字
...@@ -77,7 +77,6 @@ const ChangeAdd = props => { ...@@ -77,7 +77,6 @@ const ChangeAdd = props => {
stt: data, stt: data,
title, title,
filed22: filed1, filed22: filed1,
isType,
}); });
setKeyValue('0'); setKeyValue('0');
setSearchWord(''); setSearchWord('');
......
...@@ -18,15 +18,7 @@ import DragTable from '@/components/DragTable/DragTable'; ...@@ -18,15 +18,7 @@ import DragTable from '@/components/DragTable/DragTable';
import styles from './incident.less'; import styles from './incident.less';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const EditModal = props => { const EditModal = props => {
const { const { callBackSubmit = () => {}, pickItem, visible, filed, newCheckedList, flag } = props;
callBackSubmit = () => {},
pickItem,
visible,
filed,
characterValue,
newCheckedList,
flag,
} = props;
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [value, setValue] = useState(''); const [value, setValue] = useState('');
const [checkValue, setCheckValue] = useState([]); const [checkValue, setCheckValue] = useState([]);
...@@ -86,8 +78,7 @@ const EditModal = props => { ...@@ -86,8 +78,7 @@ const EditModal = props => {
setCheckedList(checkedListArr); setCheckedList(checkedListArr);
const indeterminateArr = [...indeterminate]; const indeterminateArr = [...indeterminate];
const checkAllArr = [...checkAll]; const checkAllArr = [...checkAll];
indeterminateArr[index] = indeterminateArr[index] = !!list.length && list.length < filed[title].length;
!!list.length && list.length < filed[title].length;
checkAllArr[index] = list.length === filed[title].length; checkAllArr[index] = list.length === filed[title].length;
setIndeterminate(indeterminateArr); setIndeterminate(indeterminateArr);
setCheckAll(checkAllArr); setCheckAll(checkAllArr);
...@@ -239,8 +230,7 @@ const EditModal = props => { ...@@ -239,8 +230,7 @@ const EditModal = props => {
} }
}); });
indeterminateArr.push( indeterminateArr.push(
!!checkArr[index].length && !!checkArr[index].length && checkArr[index].length < filed[item].length,
checkArr[index].length < filed[item].length,
); );
checkAllArr.push(checkArr[index].length === filed[item].length); checkAllArr.push(checkArr[index].length === filed[item].length);
}); });
...@@ -292,10 +282,7 @@ const EditModal = props => { ...@@ -292,10 +282,7 @@ const EditModal = props => {
> >
{visible && ( {visible && (
<div className={styles.listCard}> <div className={styles.listCard}>
<div <div className={styles.cardItem} style={{ borderRight: '1px solid #99bbe8' }}>
className={styles.cardItem}
style={{ borderRight: '1px solid #99bbe8' }}
>
{flag === 0 ? ( {flag === 0 ? (
<> <>
<div className={styles.cardContent}> <div className={styles.cardContent}>
......
...@@ -396,23 +396,14 @@ const incident = () => { ...@@ -396,23 +396,14 @@ const incident = () => {
console.log(tableData[pickItem]); console.log(tableData[pickItem]);
setSortData(tableData[pickItem]); setSortData(tableData[pickItem]);
}; };
// const process = record => {
// setProcessVisible(true);
// setFormObj(record);
// setTitle1(record.name)
// }
const process1 = record => { const process1 = record => {
history.push({ history.push({
pathname: '/bsmanger/workOrder/incidentFlow', pathname: '/bsmanger/workOrder/incidentFlow',
state: { formObj: record, title1: record.name, rember }, state: { formObj: record, title1: record.name, rember },
}); });
}; };
// const auxiliaryView = record => {
// setFormObj(record);
// setViewVisible(true)
// setTitle2(record.name)
// }
const auxiliaryView1 = record => { const auxiliaryView1 = record => {
history.push({ history.push({
pathname: '/bsmanger/workOrder/incidentView', pathname: '/bsmanger/workOrder/incidentView',
...@@ -444,13 +435,6 @@ const incident = () => { ...@@ -444,13 +435,6 @@ const incident = () => {
} }
}); });
}; };
const onOK1 = () => {
setProcessVisible(false);
setFlag(flag + 1);
};
const onOK11 = () => {
setViewVisible(false);
};
return ( return (
<div className={styles.incidentContainer}> <div className={styles.incidentContainer}>
<div className={styles.contentContainers}> <div className={styles.contentContainers}>
...@@ -467,6 +451,7 @@ const incident = () => { ...@@ -467,6 +451,7 @@ const incident = () => {
style={{ style={{
fontSize: '15px ', fontSize: '15px ',
fontWeight: 'bold', fontWeight: 'bold',
marginLeft: '14px',
}} }}
> >
事件列表 事件列表
...@@ -478,7 +463,7 @@ const incident = () => { ...@@ -478,7 +463,7 @@ const incident = () => {
color: '#1890FF', color: '#1890FF',
fontSize: '25px', fontSize: '25px',
verticalAlign: 'middle', verticalAlign: 'middle',
marginLeft: '58%', marginLeft: '51%',
}} }}
/> />
</Tooltip> </Tooltip>
...@@ -582,14 +567,6 @@ const incident = () => { ...@@ -582,14 +567,6 @@ const incident = () => {
callBackSubmit={onSubmit} callBackSubmit={onSubmit}
placement="right" placement="right"
/> />
{/* <ProcessModal
visible={processVisible}
formObj={formObj}
title1={title1}
maxLength={maxLength}
onCancel={() => setProcessVisible(false)}
callBackSubmit={onOK1}
/> */}
<SortModal <SortModal
title="调整顺序" title="调整顺序"
visible={sortVisible} visible={sortVisible}
...@@ -598,13 +575,6 @@ const incident = () => { ...@@ -598,13 +575,6 @@ const incident = () => {
onCancel={() => setSortVisible(false)} onCancel={() => setSortVisible(false)}
callBackSubmit={onOK} callBackSubmit={onOK}
/> />
{/* <ViewModal
formObj={formObj}
visible={viewVisible}
onCancel={() => setViewVisible(false)}
title2={title2}
callBackSubmit={onOK11}
/> */}
</div> </div>
</div> </div>
); );
......
...@@ -589,6 +589,7 @@ const WebDic = () => { ...@@ -589,6 +589,7 @@ const WebDic = () => {
console.log(selectID); console.log(selectID);
if (select.nodeID === selectID) { if (select.nodeID === selectID) {
setSelectID(''); setSelectID('');
setSubData([]);
} }
} }
......
import { Space, Table, Button, Popconfirm, notification, Spin, Modal } from 'antd'; import { Space, Table, Button, Popconfirm, notification, Spin, Modal, Tooltip } from 'antd';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import styles from '../dimensionsConfig.less' import styles from '../dimensionsConfig.less';
import { import { GetBaseMapList, DeleteBaseMap, GetSchemaBaseMapIsLast } from '@/services/webConfig/api';
GetBaseMapList, import AddModal from './AddModal';
DeleteBaseMap,
GetSchemaBaseMapIsLast
} from '@/services/webConfig/api';
import AddModal from './AddModal'
const TileData = props => { const TileData = props => {
const [treeLoading, setTreeLoading] = useState(false);// 弹窗显示 const [treeLoading, setTreeLoading] = useState(false); // 弹窗显示
const [tileData, setTileData] = useState([]); // table表格数据 const [tileData, setTileData] = useState([]); // table表格数据
const [visible, setVisible] = useState(false); // 弹窗 const [visible, setVisible] = useState(false); // 弹窗
const [type, setType] = useState(''); // 弹窗类型 const [type, setType] = useState(''); // 弹窗类型
const [formObj, setFormObj] = useState({}); const [formObj, setFormObj] = useState({});
const [flag, setFlag] = useState(0); // 弹窗类型 const [flag, setFlag] = useState(0); // 弹窗类型
const [baseMap, setBaseMap] = useState([]); //底图数据 const [baseMap, setBaseMap] = useState([]); // 底图数据
const [delVisible, setDelVisible] = useState(false); // 弹窗 const [delVisible, setDelVisible] = useState(false); // 弹窗
const [records, setRecords] = useState({}); // 弹窗 const [records, setRecords] = useState({}); // 弹窗
const columns = [ const columns = [
{ {
title: '名称', title: '名称',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
align: 'center' align: 'center',
},
{
title: '类型',
dataIndex: 'type',
key: 'type',
align: 'center',
},
{
title: '透明度',
dataIndex: 'opacity',
key: 'opacity',
align: 'center',
},
{
title: 'url',
dataIndex: 'url',
key: 'url',
align: 'center',
with: 400,
render: record => (
<Tooltip placement="topLeft" title={record}>
{record}
</Tooltip>
),
onCell: () => ({
style: {
maxWidth: 400,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
cursor: 'pointer',
}, },
{ }),
title: '类型', },
dataIndex: 'type', {
key: 'type', title: '编辑',
align: 'center' align: 'center',
}, render: (text, record) => (
{ <Space>
title: '透明度', <Button
dataIndex: 'opacity', type="primary"
key: 'opacity', size="small"
align: 'center' onClick={() => {
}, changebaseMap(record);
{ }}
title: 'url', >
dataIndex: 'url', 编辑
key: 'url', </Button>
align: 'center', <div onClick={e => e.stopPropagation()}>
with: 400 <Popconfirm
}, title="是否删除该底图?"
{ okText="确认"
title: '编辑', cancelText="取消"
align: 'center', onConfirm={() => {
render: (text, record) => ( delConfirm(record);
<Space> }}
<Button >
type="primary" <Button size="small" danger>
size="small" 删除
onClick={() => { </Button>
changebaseMap(record); </Popconfirm>
}} </div>
> </Space>
编辑 ),
</Button> },
<div onClick={e => e.stopPropagation()}> ];
<Popconfirm
title="是否删除该底图?"
okText="确认"
cancelText="取消"
onConfirm={() => {
delConfirm(record);
}}
>
<Button size="small" danger>
删除
</Button>
</Popconfirm>
</div>
</Space>
),
},
];
const changebaseMap = (record) => {
setType('edit');
setFormObj(record);
setVisible(true);
}
const onSubmit = prop => {
setVisible(false);
setFlag(flag + 1)
};
const delConfirm = (record) => { const changebaseMap = record => {
setRecords(record) setType('edit');
GetSchemaBaseMapIsLast({ type: record.type }).then(res => { setFormObj(record);
if (res.code === 0 && !res.data) { setVisible(true);
setTreeLoading(true); };
DeleteBaseMap({ const onSubmit = prop => {
type: record.type setVisible(false);
}).then(res => { setFlag(flag + 1);
setFlag(flag + 1) };
setTreeLoading(false);
if (res.msg === '') {
// form.resetFields();
// callBackSubmit();
notification.success({
message: '提示',
duration: 3,
description: res.message || '删除成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.message || '删除失败',
});
}
}).catch(err => {
setFlag(flag + 1)
setTreeLoading(false);
})
}
else if (res.code === 0 && res.data) {
setDelVisible(true)
}
})
}
const handleAdd = () => {
if (baseMap.length) {
setType('add');
setVisible(true);
}
else {
notification.warning({
message: '提示',
duration: 3,
description: '地图类型已都存在,可编辑修改',
});
}
} const delConfirm = record => {
useEffect(() => { setRecords(record);
renderTile(); GetSchemaBaseMapIsLast({ type: record.type }).then(res => {
}, [flag]); if (res.code === 0 && !res.data) {
// 获取瓦片数据配置数据
const renderTile = () => {
setTreeLoading(true); setTreeLoading(true);
const baseMapData = ['高德街道', '高德影像', '天地图街道', '天地图影像','百度街道','百度影像', 'mapBox地图', 'arcgis地图']
GetBaseMapList().then(
res => {
if (res.msg === "Ok") {
console.log('res', res.data);
setTreeLoading(false);
setTileData(res.data);
res.data.map((item) => {
let index = baseMapData.indexOf(item.name);
if (index != -1) {
baseMapData.splice(index, 1);
}
})
setBaseMap(baseMapData)
} else {
setTreeLoading(false);
notification.error({
message: '获取失败',
description: res.message,
});
}
}
)
};
const handleOk = () => {
DeleteBaseMap({ DeleteBaseMap({
type: records.type type: record.type,
}).then(res => { })
setFlag(flag + 1) .then(res => {
setFlag(flag + 1);
setTreeLoading(false); setTreeLoading(false);
if (res.msg === '') { if (res.msg === '') {
// form.resetFields(); // form.resetFields();
// callBackSubmit(); // callBackSubmit();
setDelVisible(false) notification.success({
notification.success({ message: '提示',
message: '提示', duration: 3,
duration: 3, description: res.message || '删除成功',
description: res.message || '删除成功', });
});
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 3,
description: res.message || '删除失败', description: res.message || '删除失败',
}); });
} }
}).catch(err => { })
setFlag(flag + 1) .catch(err => {
setFlag(flag + 1);
setTreeLoading(false); setTreeLoading(false);
}) });
} else if (res.code === 0 && res.data) {
setDelVisible(true);
}
});
};
const handleAdd = () => {
if (baseMap.length) {
setType('add');
setVisible(true);
} else {
notification.warning({
message: '提示',
duration: 3,
description: '地图类型已都存在,可编辑修改',
});
} }
return ( };
<> useEffect(() => {
<Spin tip="loading..." spinning={treeLoading}> renderTile();
<div className={styles.tileBtn}> }, [flag]);
<Button type="primary" onClick={() => { // 获取瓦片数据配置数据
handleAdd(); const renderTile = () => {
}} > setTreeLoading(true);
新增 const baseMapData = [
</Button> '高德街道',
</div> '高德影像',
<Table '天地图街道',
columns={columns} '天地图影像',
dataSource={tileData} '百度街道',
bordered '百度影像',
rowKey="type" 'mapBox地图',
scroll={{ y: 400 }} 'arcgis地图',
pagination={{ ];
showTotal: (total, range) => GetBaseMapList().then(res => {
`第${range[0]}-${range[1]} 条/共 ${total} 条` if (res.msg === 'Ok') {
console.log('res', res.data);
}} setTreeLoading(false);
> setTileData(res.data);
</Table> res.data.map(item => {
<Modal let index = baseMapData.indexOf(item.name);
title="删除" if (index != -1) {
visible={delVisible} baseMapData.splice(index, 1);
onOk={handleOk} }
onCancel={() => setDelVisible(false)} });
> setBaseMap(baseMapData);
<p>有方案唯一地图为此地图,删掉此地图,方案也会被删掉,确认是否删除</p> } else {
</Modal> setTreeLoading(false);
<AddModal notification.error({
visible={visible} message: '获取失败',
onCancel={() => setVisible(false)} description: res.message,
callBackSubmit={onSubmit} });
type={type} }
formObj={formObj} });
baseMap={baseMap} };
/> const handleOk = () => {
</Spin> DeleteBaseMap({
</> type: records.type,
) })
} .then(res => {
export default TileData setFlag(flag + 1);
\ No newline at end of file setTreeLoading(false);
if (res.msg === '') {
// form.resetFields();
// callBackSubmit();
setDelVisible(false);
notification.success({
message: '提示',
duration: 3,
description: res.message || '删除成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.message || '删除失败',
});
}
})
.catch(err => {
setFlag(flag + 1);
setTreeLoading(false);
});
};
return (
<>
<Spin tip="loading..." spinning={treeLoading}>
<div className={styles.tileBtn}>
<Button
type="primary"
onClick={() => {
handleAdd();
}}
>
新增
</Button>
</div>
<Table
columns={columns}
dataSource={tileData}
bordered
rowKey="type"
scroll={{ y: 400 }}
pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
}}
/>
<Modal
title="删除"
visible={delVisible}
onOk={handleOk}
onCancel={() => setDelVisible(false)}
>
<p>有方案唯一地图为此地图,删掉此地图,方案也会被删掉,确认是否删除</p>
</Modal>
<AddModal
visible={visible}
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
formObj={formObj}
baseMap={baseMap}
/>
</Spin>
</>
);
};
export default TileData;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment