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

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

parent 651866fa
Pipeline #42958 skipped with stages
...@@ -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 = [
...@@ -22,26 +18,40 @@ const TileData = props => { ...@@ -22,26 +18,40 @@ const TileData = props => {
title: '名称', title: '名称',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
align: 'center' align: 'center',
}, },
{ {
title: '类型', title: '类型',
dataIndex: 'type', dataIndex: 'type',
key: 'type', key: 'type',
align: 'center' align: 'center',
}, },
{ {
title: '透明度', title: '透明度',
dataIndex: 'opacity', dataIndex: 'opacity',
key: 'opacity', key: 'opacity',
align: 'center' align: 'center',
}, },
{ {
title: 'url', title: 'url',
dataIndex: 'url', dataIndex: 'url',
key: 'url', key: 'url',
align: 'center', align: 'center',
with: 400 with: 400,
render: record => (
<Tooltip placement="topLeft" title={record}>
{record}
</Tooltip>
),
onCell: () => ({
style: {
maxWidth: 400,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
cursor: 'pointer',
},
}),
}, },
{ {
title: '编辑', title: '编辑',
...@@ -74,28 +84,28 @@ const TileData = props => { ...@@ -74,28 +84,28 @@ const TileData = props => {
</Space> </Space>
), ),
}, },
]; ];
const changebaseMap = (record) => { const changebaseMap = record => {
setType('edit'); setType('edit');
setFormObj(record); setFormObj(record);
setVisible(true); setVisible(true);
} };
const onSubmit = prop => { const onSubmit = prop => {
setVisible(false); setVisible(false);
setFlag(flag + 1) setFlag(flag + 1);
}; };
const delConfirm = (record) => { const delConfirm = record => {
setRecords(record) setRecords(record);
GetSchemaBaseMapIsLast({ type: record.type }).then(res => { GetSchemaBaseMapIsLast({ type: record.type }).then(res => {
if (res.code === 0 && !res.data) { if (res.code === 0 && !res.data) {
setTreeLoading(true); setTreeLoading(true);
DeleteBaseMap({ DeleteBaseMap({
type: record.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();
...@@ -112,51 +122,56 @@ const TileData = props => { ...@@ -112,51 +122,56 @@ const TileData = props => {
description: res.message || '删除失败', description: res.message || '删除失败',
}); });
} }
}).catch(err => {
setFlag(flag + 1)
setTreeLoading(false);
}) })
.catch(err => {
setFlag(flag + 1);
setTreeLoading(false);
});
} else if (res.code === 0 && res.data) {
setDelVisible(true);
} }
else if (res.code === 0 && res.data) { });
setDelVisible(true) };
}
})
}
const handleAdd = () => { const handleAdd = () => {
if (baseMap.length) { if (baseMap.length) {
setType('add'); setType('add');
setVisible(true); setVisible(true);
} } else {
else {
notification.warning({ notification.warning({
message: '提示', message: '提示',
duration: 3, duration: 3,
description: '地图类型已都存在,可编辑修改', description: '地图类型已都存在,可编辑修改',
}); });
} }
};
}
useEffect(() => { useEffect(() => {
renderTile(); renderTile();
}, [flag]); }, [flag]);
// 获取瓦片数据配置数据 // 获取瓦片数据配置数据
const renderTile = () => { const renderTile = () => {
setTreeLoading(true); setTreeLoading(true);
const baseMapData = ['高德街道', '高德影像', '天地图街道', '天地图影像','百度街道','百度影像', 'mapBox地图', 'arcgis地图'] const baseMapData = [
GetBaseMapList().then( '高德街道',
res => { '高德影像',
if (res.msg === "Ok") { '天地图街道',
'天地图影像',
'百度街道',
'百度影像',
'mapBox地图',
'arcgis地图',
];
GetBaseMapList().then(res => {
if (res.msg === 'Ok') {
console.log('res', res.data); console.log('res', res.data);
setTreeLoading(false); setTreeLoading(false);
setTileData(res.data); setTileData(res.data);
res.data.map((item) => { res.data.map(item => {
let index = baseMapData.indexOf(item.name); let index = baseMapData.indexOf(item.name);
if (index != -1) { if (index != -1) {
baseMapData.splice(index, 1); baseMapData.splice(index, 1);
} }
}) });
setBaseMap(baseMapData) setBaseMap(baseMapData);
} else { } else {
setTreeLoading(false); setTreeLoading(false);
notification.error({ notification.error({
...@@ -164,19 +179,19 @@ const TileData = props => { ...@@ -164,19 +179,19 @@ const TileData = props => {
description: res.message, description: res.message,
}); });
} }
} });
)
}; };
const handleOk = () => { const handleOk = () => {
DeleteBaseMap({ DeleteBaseMap({
type: records.type type: records.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) setDelVisible(false);
notification.success({ notification.success({
message: '提示', message: '提示',
duration: 3, duration: 3,
...@@ -189,18 +204,22 @@ const TileData = props => { ...@@ -189,18 +204,22 @@ const TileData = props => {
description: res.message || '删除失败', description: res.message || '删除失败',
}); });
} }
}).catch(err => {
setFlag(flag + 1)
setTreeLoading(false);
}) })
} .catch(err => {
setFlag(flag + 1);
setTreeLoading(false);
});
};
return ( return (
<> <>
<Spin tip="loading..." spinning={treeLoading}> <Spin tip="loading..." spinning={treeLoading}>
<div className={styles.tileBtn}> <div className={styles.tileBtn}>
<Button type="primary" onClick={() => { <Button
type="primary"
onClick={() => {
handleAdd(); handleAdd();
}} > }}
>
新增 新增
</Button> </Button>
</div> </div>
...@@ -211,12 +230,9 @@ const TileData = props => { ...@@ -211,12 +230,9 @@ const TileData = props => {
rowKey="type" rowKey="type"
scroll={{ y: 400 }} scroll={{ y: 400 }}
pagination={{ pagination={{
showTotal: (total, range) => showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
`第${range[0]}-${range[1]} 条/共 ${total} 条`
}} }}
> />
</Table>
<Modal <Modal
title="删除" title="删除"
visible={delVisible} visible={delVisible}
...@@ -235,6 +251,6 @@ const TileData = props => { ...@@ -235,6 +251,6 @@ const TileData = props => {
/> />
</Spin> </Spin>
</> </>
) );
} };
export default TileData export default TileData;
\ No newline at end of file
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