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

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

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