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

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

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