Commit 50fbbb21 authored by 皮倩雯's avatar 皮倩雯

fix: '二维底图方案配置'

parent 90a4b27a
Pipeline #52157 waiting for manual action with stages
......@@ -43,12 +43,21 @@
.schemeItem,
.schemeBtn {
width: 302px;
display: flex;
align-items: center;
}
.schemeBtn1 {
width: 260px;
justify-content: center;
display: flex;
align-items: center;
}
.schemeBtn {
width: 12rem;
width: 234px;
justify-content: center;
display: flex;
align-items: center;
}
.mapItem {
display: flex;
......@@ -57,7 +66,16 @@
height: 2.2rem;
align-items: center;
margin: 0.5rem 0;
width: 14.5rem;
// width: 14.5rem;
}
.mapItem1 {
display: flex;
border: 1px solid #ccc;
border-radius: 4px;
height: 2.2rem;
align-items: center;
margin: 0.5rem 0;
width: 18.8rem;
}
.defaultTile {
background: #ccc;
......@@ -69,15 +87,48 @@
width: 3rem;
justify-content: center;
}
.defaultTile1 {
background: #4699f4;
color: white;
height: 100%;
display: flex;
align-items: center;
width: 3rem;
justify-content: center;
}
.mapText {
width: 10rem;
width: 14rem;
text-align: center;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
padding-left: 5px;
padding-right: 5px;
}
.mapText1 {
width: 13rem;
text-align: center;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
padding-left: 5px;
padding-right: 5px;
}
.mapIcon {
margin-left: 4px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
margin-top: 5px;
}
.mapIcon1 {
margin-left: 4px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
margin-top: 5px;
}
.activeTile {
background-color: #4699f4;
......@@ -104,12 +155,16 @@
.cardsList {
display: flex;
flex-wrap: wrap;
height: calc(100vh - 120px);
height: calc(100vh - 234px);
overflow-y: scroll;
}
.cardsList1 {
display: flex;
flex-wrap: wrap;
}
.cardItem {
width: 18rem;
height: 26rem;
width: 21rem;
height: 22rem;
margin: 0 2rem;
}
.tileContainer {
......@@ -119,6 +174,11 @@
overflow: auto !important;
}
}
.TileConfigContainer {
.ant-card-head {
background-color: #ecf5ff;
}
}
.solutionContainer {
.ant-table-body {
height: calc(100vh - 250px) !important;
......
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable indent */
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, notification, InputNumber, Tooltip } from 'antd';
import {
GettMaplayer,
GetVectorService,
SetServiceConfig,
bindSchemeBaseMap,
SetBaseMapschemeName,
} from '@/services/webConfig/api';
import { InfoCircleOutlined } from '@ant-design/icons';
const { Item } = Form;
const { Option } = Select;
const AddProjectModal = props => {
const { callBackSubmit = () => {}, type, formObj, visible, serviceList, cardData, all } = props;
const [loading, setLoading] = useState(false);
const [baseMap, setBaseMap] = useState([]);
const [pipeArr, setPipeArr] = useState([]);
const [arr, setArr] = useState([]);
const [form] = Form.useForm();
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
if (type === 'add') {
// let aa = cardData.find(i => i.schemename == formObj.schemename);
// aa.baseMap.push(obj.serverName);
// aa.baseMapDetail.push({ servicename: obj.serverName, zoom: obj.zoom });
// let query = {
// schemename: formObj.schemename,
// terminalType: 'baseMapscheme',
// isBaseMap: 'false',
// jsonCfg: JSON.stringify({
// baseMap: aa.baseMap,
// baseMapDetail: aa.baseMapDetail,
// }),
// };
// SetServiceConfig(query)
// .then(res => {
// setLoading(false);
// if (res.msg === 'Ok') {
// form.resetFields();
// callBackSubmit();
// prompt('success', '瓦片新增成功');
// } else {
// prompt('fail', '瓦片新增失败');
// }
// })
// .catch(err => {
// setLoading(false);
// });
let data = {
schemename: formObj.schemename,
servicename: obj.serverName,
zoom: obj.zoom,
};
SetBaseMapschemeName(data)
.then(res => {
setLoading(false);
if (res.code === 0) {
form.resetFields();
callBackSubmit();
prompt('success', '瓦片新增成功');
} else {
prompt('fail', '瓦片新增失败');
}
})
.catch(err => {
setLoading(false);
});
} else {
handleEdit();
}
}
});
};
const prompt = (type, content) => {
if (type == 'success') {
notification.success({
message: '提示',
duration: 3,
description: content,
});
} else {
notification.error({
message: '提示',
duration: 3,
description: content,
});
}
};
const handleEdit = () => {
let obj = form.getFieldsValue();
// let query = {
// schemename: obj.schemename,
// terminalType: 'baseMapscheme',
// isBaseMap: 'false',
// jsonCfg: JSON.stringify({
// baseMap: [obj.baseMap],
// alpha: 1,
// }),
// };
let data = {
schemename: obj.schemename,
servicename: obj.baseMap,
zoom: 0,
};
SetBaseMapschemeName(data)
.then(res => {
setLoading(false);
if (res.code === 0) {
form.resetFields();
callBackSubmit();
prompt('success', '方案新增成功');
} else {
prompt('fail', '方案新增失败');
}
})
.catch(err => {
setLoading(false);
});
// SetServiceConfig(query)
// .then(res => {
// setLoading(false);
// if (res.msg === 'Ok') {
// form.resetFields();
// callBackSubmit();
// prompt('success', '方案新增成功');
// } else {
// prompt('fail', '方案新增失败');
// }
// })
// .catch(err => {
// setLoading(false);
// });
};
const onFinish = value => {};
useEffect(() => {
console.log(type);
switch (type) {
case 'add':
addTile();
break;
case 'schemeAdd':
pipeNetwork();
break;
default:
break;
}
}, [visible]);
// 添加瓦片
const addTile = () => {
let aa = cardData.find(i => i.schemename == formObj.schemename);
console.log(aa);
let arrNew = [];
aa.baseMapDetail.map(i => {
arrNew.push(i.zoom);
});
console.log(arrNew);
setArr(arrNew);
form.setFieldsValue({
serverName: serviceList[0],
});
};
// 获取管网及默认底图
const pipeNetwork = () => {
form.resetFields();
let req1 = GettMaplayer({ terminalType: 'base', isBaseMap: true });
let req2 = GetVectorService();
let pipeArr = [],
baseMap = [];
Promise.all([req1, req2]).then(res => {
if (res[0].msg === 'Ok') {
(res[0].data.general.baseMap.layers || []).map(item => {
baseMap.push(item.servicename);
});
}
if (res[1].msg === 'Ok') {
(res[1].data.VectorList || []).map(item => {
pipeArr.push(item.ServiceName.split('.')[0]);
});
}
setPipeArr(pipeArr);
setBaseMap(baseMap);
form.setFieldsValue({
baseMap: baseMap[0],
});
});
};
const layout = {
layout: 'horizontal',
labelCol: {
span: 4,
},
wrapperCol: {
span: 18,
},
};
// 选择服务名
const handleChange = () => {};
// 选择管网
const handleService = value => {
form.setFieldsValue({
label: value,
// url: `http://{IP}/PandaGIS/MapServer/Export?mapServerName=${value}`,
url: `http://{IP}/CityInterface/rest/services/MapServer.svc/${value}`,
});
};
// 选择底图
const handleBaseMap = () => {};
return (
<Modal
title={`${type === 'add' ? '添加底图' : '添加底图方案'}`}
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: '150px' }}
width="700px"
destroyOnClose
maskClosable={false}
cancelText="取消"
okText="确认"
{...props}
onOk={() => onSubmit()}
confirmLoading={loading}
forceRender={true}
getContainer={false}
>
{visible && (
<Form form={form} {...layout} onFinish={onFinish}>
{type === 'add' ? (
<>
<Item
label="服务名"
name="serverName"
rules={[{ required: true, message: '请输入服务名' }]}
>
<Select onChange={handleChange}>
{serviceList.length
? serviceList.map((item, index) => {
return (
<Option key={index} value={item}>
{item}
</Option>
);
})
: ''}
</Select>
</Item>
<Item
label={
<div>
<Tooltip title="同一底图方案中的不同底图缩放级别不能相同">
<InfoCircleOutlined
style={{
color: 'rgb(24, 144, 255)',
marginLeft: '0px',
marginRight: '5px',
}}
/>
</Tooltip>
<span>缩放级别</span>
</div>
}
name="zoom"
rules={[
{ required: true, message: '请输入缩放级别' },
{
validator: (rule, value) => {
const obj = form.getFieldsValue().zoom;
console.log(obj);
if (arr.indexOf(obj) != -1) {
console.log(111);
return Promise.reject('已存在该缩放级别的底图');
}
return Promise.resolve();
},
},
]}
>
<InputNumber min={0} />
</Item>
</>
) : (
<>
<Item
label="方案名"
name="schemename"
rules={[{ required: true, message: '请输入方案名' }]}
>
<Input placeholder="请输入方案名" allowClear />
</Item>
<Item
label="默认底图"
name="baseMap"
rules={[{ required: true, message: '请选择底图' }]}
>
<Select onChange={handleBaseMap}>
{baseMap.length
? baseMap.map((item, index) => {
return (
<Option key={index} value={item}>
{item}
</Option>
);
})
: ''}
</Select>
</Item>
</>
)}
</Form>
)}
</Modal>
);
};
export default AddProjectModal;
/* eslint-disable prefer-promise-reject-errors */
/*
* @Description:
* @Author: leizhe
* @Date: 2022-05-25 15:07:30
* @LastEditTime: 2022-06-02 17:20:19
* @LastEditors: leizhe
*/
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, notification, InputNumber, Tooltip } from 'antd';
import {
GettMaplayer,
GetVectorService,
SetServiceConfig,
bindSchemeBaseMap,
SetBaseMapschemeName,
} from '@/services/webConfig/api';
import { InfoCircleOutlined } from '@ant-design/icons';
const { Item } = Form;
const { Option } = Select;
const BaseMap = props => {
const { visible, onCancel, keepItem, keepProject, callBackSubmit = () => {} } = props;
const [arr, setArr] = useState([]);
const [form] = Form.useForm();
// 删除瓦片
useEffect(() => {
console.log(keepItem);
console.log(keepProject);
if (visible) {
let list = [];
keepItem.baseMapDetail.map(i => {
list.push(i.zoom);
});
setArr(list);
let aa = keepItem.baseMapDetail.find(i => i.servicename == keepProject);
form.setFieldsValue({ zoom: aa.zoom });
} else {
form.resetFields();
}
}, [visible]);
const onSubmit = () => {
form.validateFields().then(validate => {
if (validate) {
let obj = form.getFieldsValue();
// let aa = keepItem.baseMapDetail.find(i => i.servicename == keepProject);
// console.log(aa);
// aa.zoom = obj.zoom;
// let query = {
// schemename: keepItem.schemename,
// terminalType: 'baseMapscheme',
// isBaseMap: 'false',
// jsonCfg: JSON.stringify({
// baseMap: keepItem.baseMap,
// baseMapDetail: keepItem.baseMapDetail,
// }),
// };
// SetServiceConfig(query)
// .then(res => {
// if (res.msg === 'Ok') {
// form.resetFields();
// callBackSubmit();
// prompt('success', '编辑成功');
// } else {
// prompt('fail', '编辑失败');
// }
// })
// .catch(err => {});
let data = {
schemename: keepItem.schemename,
servicename: keepProject,
zoom: obj.zoom,
};
SetBaseMapschemeName(data).then(res => {
if (res.code === 0) {
form.resetFields();
callBackSubmit();
prompt('success', '编辑成功');
} else {
prompt('fail', '编辑失败');
}
});
}
});
};
const prompt = (type, content) => {
if (type == 'success') {
notification.success({
message: '提示',
duration: 3,
description: content,
});
} else {
notification.error({
message: '提示',
duration: 3,
description: content,
});
}
};
const layout = {
layout: 'horizontal',
labelCol: {
span: 7,
},
wrapperCol: {
span: 15,
},
};
const title = (
<>
<span>编辑</span>
<span style={{ color: 'rgb(24, 144, 255)' }}>{keepProject}</span>
<span>的缩放级别</span>
</>
);
return (
<Modal
title={title}
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: '150px' }}
width="400px"
destroyOnClose
maskClosable={false}
cancelText="取消"
okText="确认"
{...props}
onOk={() => onSubmit()}
forceRender={true}
getContainer={false}
>
<Form form={form} {...layout} onFinish={onSubmit}>
<Item
label={
<div>
<Tooltip title="同一底图方案中的不同底图缩放级别不能相同">
<InfoCircleOutlined
style={{
color: 'rgb(24, 144, 255)',
marginLeft: '0px',
marginRight: '5px',
}}
/>
</Tooltip>
<span>缩放级别</span>
</div>
}
style={{ marginTop: '20px' }}
name="zoom"
rules={[
{ required: true, message: '请输入缩放级别' },
{
validator: (rule, value) => {
const obj = form.getFieldsValue().zoom;
console.log(obj);
if (arr.indexOf(obj) != -1) {
console.log(111);
return Promise.reject('已存在该缩放级别的底图');
}
return Promise.resolve();
},
},
]}
>
<InputNumber min={0} style={{ width: '150px' }} />
</Item>
</Form>
</Modal>
);
};
export default BaseMap;
import { Space, Table, Button, Popconfirm, notification, Spin } from 'antd';
/* eslint-disable indent */
import { Space, Table, Button, Popconfirm, notification, Spin, Divider, Tooltip } from 'antd';
import React, { useState, useEffect } from 'react';
import { PlusOutlined, UserAddOutlined } from '@ant-design/icons';
import AutoResponsive from 'autoresponsive-react';
import styles from '../SchemeConfig.less';
import { GettMaplayer, deleteConfig } from '@/services/webConfig/api';
import { GettMaplayer, deleteConfig, GetMaplayerByTerminalType } from '@/services/webConfig/api';
import AddModal from './AddModal';
import EditModal from './EditModal';
import NewEditModal from './NewEditModal';
import Cards from './card';
import AddProjectModal from './AddProjectModal';
const TileData = props => {
const [treeLoading, setTreeLoading] = useState(false); // 弹窗显示
const [tileData, setTileData] = useState([]); // table表格数据
const [cardData, setCardData] = useState([]);
const [visible, setVisible] = useState(false); // 弹窗
const [projectVisible, setProjectVisible] = useState(false);
const [addVisible, setAddVisible] = useState(false); // 弹窗
const [editVisible, setEditVisible] = useState(false);
const [type, setType] = useState(''); // 弹窗类型
......@@ -16,6 +23,8 @@ const TileData = props => {
const [flag, setFlag] = useState(0); // 弹窗类型
const [baseMap, setBaseMap] = useState([]); // 底图数据
const [name, setName] = useState([]);
const [flagAdd, setFlagAdd] = useState(0);
const [type1, setType1] = useState('');
const columns = [
{
title: '服务名',
......@@ -74,6 +83,22 @@ const TileData = props => {
),
},
];
useEffect(() => {
setTreeLoading(true);
GetMaplayerByTerminalType({
terminalType: 'baseMapscheme',
isBaseMap: false,
}).then(res => {
console.log('res', res);
if (res.msg === 'Ok') {
setTreeLoading(false);
setCardData(res.data.baseMapscheme.optionalLayer.layers);
} else {
setTreeLoading(false);
}
});
}, [flagAdd]);
const changebaseMap = record => {
setType('edit');
setFormObj(record);
......@@ -85,6 +110,11 @@ const TileData = props => {
setAddVisible(false);
};
const onSubmitProject = prop => {
setProjectVisible(false);
setFlagAdd(flagAdd + 1);
};
const delConfirm = record => {
const { servicename = '' } = record;
setTreeLoading(true);
......@@ -118,16 +148,17 @@ const TileData = props => {
});
};
const handleAdd = () => {
if (baseMap.length) {
setType('add');
setAddVisible(true);
} else {
notification.warning({
message: '提示',
duration: 3,
description: '地图类型已都存在,可编辑修改',
});
}
// console.log(baseMap);
// if (baseMap.length) {
setType('add');
setAddVisible(true);
// } else {
// notification.warning({
// message: '提示',
// duration: 3,
// description: '地图类型已都存在,可编辑修改',
// });
// }
};
useEffect(() => {
renderTile();
......@@ -170,59 +201,127 @@ const TileData = props => {
});
};
const addType = () => {
setType1('schemeAdd');
setProjectVisible(true);
};
const onDeletebaseMap = value => {
setFlagAdd(flagAdd + 1);
};
return (
<div className={styles.tileContainer}>
<Spin tip="loading..." spinning={treeLoading}>
<div className={styles.tileBtn}>
<Button
type="primary"
onClick={() => {
handleAdd();
}}
>
新增
</Button>
</div>
<div style={{ height: 'calc(100vh - 220px)', width: '100%' }}>
<div style={{ height: 'calc(100vh - 153px)', overflowY: 'scroll' }}>
<Spin tip="loading..." spinning={treeLoading}>
{/* <div className={styles.tileBtn}>
<Button
type="primary"
onClick={() => {
handleAdd();
}}
>
新增
</Button>
</div> */}
<Divider orientation="left">
<div className={styles.divider}>
{' '}
底图{' '}
<Tooltip title="新增底图">
<PlusOutlined
onClick={() => {
handleAdd();
}}
style={{ marginTop: '5px', marginLeft: '10px', color: '#4699f4' }}
/>
</Tooltip>
</div>
</Divider>
<Table
columns={columns}
dataSource={tileData}
bordered
rowKey="servicename"
scroll={{ y: 600 }}
pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
}}
pagination={false}
// scroll={{ y: 600 }}
// pagination={{
// showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
// }}
/>
</div>
<Divider orientation="left" style={{ marginTop: '50px' }}>
<div className={styles.divider}>
底图分级显示方案{' '}
<Tooltip title="新增底图方案">
<PlusOutlined
onClick={() => {
addType();
}}
style={{ marginTop: '5px', marginLeft: '10px', color: '#4699f4' }}
/>
</Tooltip>
</div>{' '}
</Divider>
<div className={styles.cardsList1}>
{/* <AutoResponsive
itemMargin="10"
containerWidth="100%"
itemClassName="item"
gridWidth="100"
transitionDuration=".5"
> */}
{cardData && cardData.length
? cardData.map((item, index) => {
return (
<div
className={styles.cardItem}
key={index}
span={5}
offset={2}
style={{ marginBottom: '1rem' }}
>
<Cards item={item} deletebaseMaps={onDeletebaseMap} cardData={cardData} />
</div>
);
})
: ''}
{/* </AutoResponsive> */}
</div>
<AddModal
visible={addVisible}
onCancel={() => setAddVisible(false)}
callBackSubmit={onSubmit}
type={type}
formObj={formObj}
baseMap={baseMap}
name={name}
/>
<EditModal
visible={visible}
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
formObj={formObj}
baseMap={baseMap}
/>
<NewEditModal
visible={editVisible}
onCancel={() => setEditVisible(false)}
callBackSubmit={onSubmit}
type={type}
formObj={formObj}
baseMap={baseMap}
name={name}
/>
</Spin>
<AddModal
visible={addVisible}
onCancel={() => setAddVisible(false)}
callBackSubmit={onSubmit}
type={type}
formObj={formObj}
baseMap={baseMap}
name={name}
/>
<EditModal
visible={visible}
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
formObj={formObj}
baseMap={baseMap}
/>
<NewEditModal
visible={editVisible}
onCancel={() => setEditVisible(false)}
callBackSubmit={onSubmit}
type={type}
formObj={formObj}
baseMap={baseMap}
name={name}
/>
<AddProjectModal
visible={projectVisible}
onCancel={() => setProjectVisible(false)}
callBackSubmit={onSubmitProject}
type={type1}
formObj={formObj}
/>
</Spin>
</div>
</div>
);
};
......
/* eslint-disable indent */
/* eslint-disable object-shorthand */
import React, { useState, useEffect } from 'react';
import classnames from 'classnames';
import { Popconfirm, notification, Card, Button, message, Tooltip } from 'antd';
import {
DeletMapServicename,
GettMaplayer,
SetServiceConfig,
deleteConfig,
} from '@/services/webConfig/api';
import { CloseOutlined, PlusOutlined, EditOutlined } from '@ant-design/icons';
import AddModal from './AddProjectModal';
import MapScope from '@/components/MapScope';
import { createGuid } from '@/utils/transformUtil';
import BaseMap from './BaseMap';
import styles from '../SchemeConfig.less';
const CardData = props => {
const { deletebaseMaps = () => {}, item, cardData } = props;
const [visible, setVisible] = useState(false); // 弹窗
const [flag, setFlag] = useState(0); // 状态更新
const [type, setType] = useState(''); // 弹窗类型
const [formObj, setFormObj] = useState({});
const [serviceList, setServiceList] = useState([]);
const [all, setAll] = useState([]);
const [mapScopeVisible, setMapScopeVisible] = useState(false);
const [baseMapVisible, setBaseMapVisible] = useState(false);
const [keepItem, setKeepItem] = useState('');
const [keepProject, setKeepProject] = useState('');
// 删除瓦片
useEffect(() => {
console.log(props.item);
}, []);
const deletebaseMap = (item, baseMapItem) => {
DeletMapServicename({ schemename: item.schemename, servicename: baseMapItem }).then(res => {
if (res.code === 0) {
notification.success({
message: '提示',
duration: 3,
description: '底图删除成功',
});
deletebaseMaps();
} else {
notification.error({
message: '提示',
duration: 3,
description: '底图删除失败',
});
}
});
};
// 删除方案
const deleteTile = item => {
deleteConfig({
schemename: item.schemename,
terminalType: 'baseMapscheme',
isBaseMap: false,
}).then(res => {
if (res.msg === 'Ok') {
notification.success({
message: '提示',
duration: 3,
description: '方案删除成功',
});
deletebaseMaps();
} else {
notification.error({
message: '提示',
duration: 3,
description: '方案删除失败',
});
}
});
};
const onSubmit = prop => {
setVisible(false);
setBaseMapVisible(false);
deletebaseMaps();
};
// 增加瓦片
const addTile = value => {
let serverList = [];
setFormObj(value);
if (JSON.stringify(value) != '{}') {
GettMaplayer({ terminalType: 'base', isBaseMap: true }).then(res => {
if (res.msg === 'Ok') {
res.data.general.baseMap.layers.map(item => {
console.log(value);
console.log(value.baseMap);
console.log(item.servicename);
if (value.baseMap.indexOf(item.servicename) == -1) {
serverList.push(item.servicename);
}
});
}
if (serverList.length) {
setServiceList(serverList);
setAll(res.data.general.baseMap.layers);
setType('add');
setVisible(true);
} else {
notification.warning({
message: '提示',
duration: 3,
description: '请先在基础配置-配置底图',
});
}
});
}
};
const submitExtent = (extent, areaName, flag) => {
if (flag === 0) {
notification.warn({
message: '提交失败',
description: '请框选范围',
});
return;
}
const jsConfig = {
extent: extent,
areaName: areaName,
boundColor: '#86c8f8',
boundWidth: '10px',
backgroundColor: '#000000',
backgroundOpacity: '0.6',
};
SetServiceConfig({
schemename: item.schemename,
terminalType: 'web',
isBaseMap: false,
jsonCfg: JSON.stringify(jsConfig),
}).then(res => {
if (res.msg === 'Ok') {
setMapScopeVisible(false);
message.info('范围设置成功');
}
});
};
const pick = (schemename, index) => {
SetServiceConfig({
schemename: schemename,
terminalType: 'scheme',
isBaseMap: false,
jsonCfg: JSON.stringify({
defaultBaseMap: index,
}),
}).then(res => {
if (res.msg === 'Ok') {
deletebaseMaps();
message.info('设置成功');
} else {
message.warning(res.msg);
}
});
};
const editBaseMap = () => {
setBaseMapVisible(true);
};
return (
<div className={styles.TileConfigContainer}>
<Card
title={
<div>
<span className={styles.schemeName}>方案名</span>
{props.item.schemename}
</div>
}
extra={
<a href="#">
<Popconfirm
title="是否删除该方案?"
okText="确认"
cancelText="取消"
onConfirm={() => {
deleteTile(props.item);
}}
>
<CloseOutlined />
</Popconfirm>{' '}
</a>
}
style={{ width: 360 }}
>
{/* <p>
<span className={styles.schemeName}>管网</span> {props.item.servicename}
</p> */}
{/* <div>
<span className={styles.schemeName}>范围</span>
<Button
style={{ width: '12rem', marginBottom: '0.5rem' }}
onClick={() => setMapScopeVisible(true)}
>
选择范围
</Button>
</div> */}
<div className={styles.schemeItem}>
<span className={styles.schemeName}>底图</span>
<Button className={styles.schemeBtn1} onClick={() => addTile(props.item)}>
{' '}
<PlusOutlined />
添加底图
</Button>
</div>
<div style={{ overflowY: 'scroll', height: '11.4rem' }}>
{props.item.baseMapDetail && props.item.baseMapDetail.length
? props.item.baseMapDetail.map((baseMapItem, baseindex) => {
return (
<div className={styles.mapItem1} key={baseindex}>
<div
// onClick={() => pick(props.item.schemename, baseindex)}
// className={classnames({
// [styles.defaultTile]: true,
// [styles.activeTile]: baseindex == props.item.defaultBaseMap,
// })}
className={styles.defaultTile1}
>
{baseMapItem.zoom}
</div>
<div className={styles.mapText1}>
<Tooltip title={baseMapItem.servicename}>{baseMapItem.servicename}</Tooltip>
</div>
<div className={styles.mapIcon1}>
<EditOutlined
onClick={() => {
editBaseMap();
setKeepItem(props.item);
setKeepProject(baseMapItem.servicename);
}}
/>
</div>
<div className={styles.mapIcon1}>
<Popconfirm
title="是否删除该底图?"
okText="确认"
cancelText="取消"
onConfirm={() => {
deletebaseMap(props.item, baseMapItem.servicename);
}}
>
<CloseOutlined />
</Popconfirm>{' '}
</div>
</div>
);
})
: ''}
</div>
</Card>
<AddModal
visible={visible}
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
serviceList={serviceList}
formObj={formObj}
cardData={cardData}
all={all}
/>
<MapScope
mapId={createGuid()}
visible={mapScopeVisible}
onCancel={() => setMapScopeVisible(false)}
confirmModal={submitExtent}
schemename={props.item.schemename}
title={props.item.schemename}
/>
<BaseMap
visible={baseMapVisible}
onCancel={() => setBaseMapVisible(false)}
callBackSubmit={onSubmit}
keepItem={keepItem}
keepProject={keepProject}
/>
</div>
);
};
export default CardData;
......@@ -136,7 +136,7 @@ const VectorData = props => {
getSolutionList({
_version: 9999,
}).then(res => {
setSolutionNames(res.currentSolution);
setSolutionNames(res.data.currentSolution);
});
};
const onSubmit = prop => {
......
......@@ -5,6 +5,7 @@ import {
GetVectorService,
SetServiceConfig,
bindSchemeBaseMap,
GetbaseMapschemeName,
} from '@/services/webConfig/api';
const { Item } = Form;
const { Option } = Select;
......@@ -13,6 +14,7 @@ const AddModal = props => {
const [loading, setLoading] = useState(false);
const [baseMap, setBaseMap] = useState([]);
const [pipeArr, setPipeArr] = useState([]);
const [list, setList] = useState([]);
const [form] = Form.useForm();
// 提交
......@@ -30,9 +32,9 @@ const AddModal = props => {
if (res.code === 0) {
form.resetFields();
callBackSubmit();
prompt('success', '瓦片新增成功');
prompt('success', '底图方案新增成功');
} else {
prompt('fail', '瓦片新增失败');
prompt('fail', '底图方案新增失败');
}
});
} else {
......@@ -102,6 +104,7 @@ const AddModal = props => {
// 添加瓦片
const addTile = () => {
console.log(formObj);
form.setFieldsValue({
serverName: serviceList[0],
});
......@@ -109,14 +112,14 @@ const AddModal = props => {
// 获取管网及默认底图
const pipeNetwork = () => {
form.resetFields();
let req1 = GettMaplayer({ terminalType: 'base', isBaseMap: true });
let req1 = GetbaseMapschemeName();
let req2 = GetVectorService();
let pipeArr = [],
baseMap = [];
Promise.all([req1, req2]).then(res => {
if (res[0].msg === 'Ok') {
(res[0].data.general.baseMap.layers || []).map(item => {
baseMap.push(item.servicename);
if (res[0].code === 0) {
(res[0].data || []).map(item => {
baseMap.push(item);
});
}
if (res[1].msg === 'Ok') {
......@@ -156,7 +159,7 @@ const AddModal = props => {
const handleBaseMap = () => {};
return (
<Modal
title={`${type === 'add' ? '添加底图' : '添加方案'}`}
title={`${type === 'add' ? '添加底图方案' : '添加方案'}`}
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: '150px' }}
width="700px"
......@@ -215,9 +218,9 @@ const AddModal = props => {
<Input placeholder="请输入url" allowClear />
</Item>
<Item
label="默认底图"
label="默认底图方案"
name="baseMap"
rules={[{ required: true, message: '请选择底图' }]}
rules={[{ required: true, message: '请选择底图方案' }]}
>
<Select onChange={handleBaseMap}>
{baseMap.length
......
/* eslint-disable indent */
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, notification } from 'antd';
import {
GettMaplayer,
GetVectorService,
SetServiceConfig,
bindSchemeBaseMap,
} from '@/services/webConfig/api';
const { Item } = Form;
const { Option } = Select;
const AddModal = props => {
const { callBackSubmit = () => {}, type, formObj, visible, serviceList } = props;
const [loading, setLoading] = useState(false);
const [baseMap, setBaseMap] = useState([]);
const [pipeArr, setPipeArr] = useState([]);
const [form] = Form.useForm();
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
if (type === 'add') {
bindSchemeBaseMap({
schemename: formObj.schemename,
basemapName: obj.serverName,
}).then(res => {
setLoading(false);
if (res.code === 0) {
form.resetFields();
callBackSubmit();
prompt('success', '瓦片新增成功');
} else {
prompt('fail', '瓦片新增失败');
}
});
} else {
handleEdit();
}
}
});
};
const prompt = (type, content) => {
if (type == 'success') {
notification.success({
message: '提示',
duration: 3,
description: content,
});
} else {
notification.error({
message: '提示',
duration: 3,
description: content,
});
}
};
const handleEdit = () => {
let obj = form.getFieldsValue();
let query = {
schemename: obj.schemename,
terminalType: 'scheme',
isBaseMap: 'false',
jsonCfg: JSON.stringify({
baseMap: [obj.baseMap],
servicename: obj.servicename,
label: obj.label,
url: obj.url,
alpha: 1,
}),
};
SetServiceConfig(query)
.then(res => {
setLoading(false);
if (res.msg === 'Ok') {
form.resetFields();
callBackSubmit();
prompt('success', '方案新增成功');
} else {
prompt('fail', '方案新增失败');
}
})
.catch(err => {
setLoading(false);
});
};
const onFinish = value => {};
useEffect(() => {
switch (type) {
case 'add':
addTile();
break;
case 'schemeAdd':
pipeNetwork();
break;
default:
break;
}
}, [visible]);
// 添加瓦片
const addTile = () => {
form.setFieldsValue({
serverName: serviceList[0],
});
};
// 获取管网及默认底图
const pipeNetwork = () => {
form.resetFields();
let req1 = GettMaplayer({ terminalType: 'base', isBaseMap: true });
let req2 = GetVectorService();
let pipeArr = [],
baseMap = [];
Promise.all([req1, req2]).then(res => {
if (res[0].msg === 'Ok') {
(res[0].data.general.baseMap.layers || []).map(item => {
baseMap.push(item.servicename);
});
}
if (res[1].msg === 'Ok') {
(res[1].data.VectorList || []).map(item => {
pipeArr.push(item.ServiceName.split('.')[0]);
});
}
setPipeArr(pipeArr);
setBaseMap(baseMap);
form.setFieldsValue({
baseMap: baseMap[0],
});
});
};
const layout = {
layout: 'horizontal',
labelCol: {
span: 4,
},
wrapperCol: {
span: 18,
},
};
// 选择服务名
const handleChange = () => {};
// 选择管网
const handleService = value => {
form.setFieldsValue({
label: value,
// url: `http://{IP}/PandaGIS/MapServer/Export?mapServerName=${value}`,
url: `http://{IP}/CityInterface/rest/services/MapServer.svc/${value}`,
});
};
// 选择底图
const handleBaseMap = () => {};
return (
<Modal
title={`${type === 'add' ? '添加底图' : '添加方案'}`}
bodyStyle={{ width: '100%', minHeight: '100px' }}
style={{ top: '150px' }}
width="700px"
destroyOnClose
maskClosable={false}
cancelText="取消"
okText="确认"
{...props}
onOk={() => onSubmit()}
confirmLoading={loading}
forceRender={true}
getContainer={false}
>
{visible && (
<Form form={form} {...layout} onFinish={onFinish}>
{type === 'add' ? (
<Item label="服务名" name="serverName">
<Select onChange={handleChange}>
{serviceList.length
? serviceList.map((item, index) => {
return (
<Option key={index} value={item}>
{item}
</Option>
);
})
: ''}
</Select>
</Item>
) : (
<>
<Item
label="方案名"
name="schemename"
rules={[{ required: true, message: '请输入方案名' }]}
>
<Input placeholder="请输入方案名" allowClear />
</Item>
<Item label="管网" name="servicename">
<Select onChange={handleService}>
{pipeArr.length
? pipeArr.map((item, index) => {
return (
<Option key={index} value={item}>
{item}
</Option>
);
})
: ''}
</Select>
</Item>
<Item label="标签" name="label">
<Input placeholder="请输入标签" allowClear />
</Item>
<Item label="url" name="url">
<Input placeholder="请输入url" allowClear />
</Item>
<Item
label="默认底图"
name="baseMap"
rules={[{ required: true, message: '请选择底图' }]}
>
<Select onChange={handleBaseMap}>
{baseMap.length
? baseMap.map((item, index) => {
return (
<Option key={index} value={item}>
{item}
</Option>
);
})
: ''}
</Select>
</Item>
</>
)}
</Form>
)}
</Modal>
);
};
export default AddModal;
......@@ -2,45 +2,58 @@
/* eslint-disable object-shorthand */
import React, { useState, useEffect } from 'react';
import classnames from 'classnames';
import styles from '../../SchemeConfig.less';
import { Popconfirm, notification, Card, Button, message } from 'antd';
import { Popconfirm, notification, Card, Button, message, Tooltip } from 'antd';
import {
unbindSchemeBaseMap,
GettMaplayer,
SetServiceConfig,
deleteConfig,
GetbaseMapschemeName,
} from '@/services/webConfig/api';
import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
import { CloseOutlined, PlusOutlined, GlobalOutlined, BlockOutlined } from '@ant-design/icons';
import AddModal from '../AddModal';
import MapScope from '@/components/MapScope';
import { createGuid } from '@/utils/transformUtil';
import AddModalBase from '../AddModalBase';
import styles from '../../SchemeConfig.less';
const CardData = props => {
const { deletebaseMaps = () => {}, item } = props;
const { deletebaseMaps = () => {}, item, cardFlag, keepData } = props;
const [visible, setVisible] = useState(false); // 弹窗
const [basevisible, setBaseVisible] = useState(false); // 弹窗
const [flag, setFlag] = useState(0); // 状态更新
const [type, setType] = useState(''); // 弹窗类型
const [formObj, setFormObj] = useState({});
const [serviceList, setServiceList] = useState([]);
const [mapScopeVisible, setMapScopeVisible] = useState(false);
const [cardData, setCardData] = useState([]);
// 删除瓦片
useEffect(() => {
// GettMaplayer({ terminalType: 'base', isBaseMap: true }).then(res => {
// if (res.msg === 'Ok') {
// let arr = [];
// res.data.general.baseMap.layers.map(i => {
// arr.push(i.servicename);
// });
// }
// });
setCardData(keepData);
console.log(props.item);
}, []);
}, [cardFlag]);
const deletebaseMap = (item, baseMapItem) => {
unbindSchemeBaseMap({ schemename: item.schemename, basemapName: baseMapItem }).then(res => {
if (res.code === 0) {
notification.success({
message: '提示',
duration: 3,
description: '底图删除成功',
description: '底图方案删除成功',
});
deletebaseMaps();
} else {
notification.error({
message: '提示',
duration: 3,
description: '底图删除失败',
description: '底图方案删除失败',
});
}
});
......@@ -71,9 +84,53 @@ const CardData = props => {
const onSubmit = prop => {
setVisible(false);
deletebaseMaps();
setBaseVisible(false);
};
// 增加瓦片
const addTile = value => {
let serverList = [];
setFormObj(value);
if (JSON.stringify(value) != '{}') {
GettMaplayer({ terminalType: 'base', isBaseMap: true }).then(res => {
if (res.msg === 'Ok') {
res.data.general.baseMap.layers.map(item => {
if (value.baseMap.indexOf(item.servicename) == -1) {
serverList.push(item.servicename);
}
});
}
let arr = [];
GetbaseMapschemeName().then(resdata => {
if (resdata.data.length) {
resdata.data.map(i => {
if (value.baseMap.indexOf(i) == -1) {
arr.push(i);
}
});
if (arr.length) {
setServiceList(arr);
setType('add');
setVisible(true);
} else {
notification.warning({
message: '提示',
duration: 3,
description: '请先在底图配置-配置底图分级显示方案',
});
}
} else {
notification.warning({
message: '提示',
duration: 3,
description: '请先在底图配置-配置底图分级显示方案',
});
}
});
});
}
};
const addTileBase = value => {
let serverList = [];
setFormObj(value);
if (JSON.stringify(value) != '{}') {
......@@ -88,7 +145,7 @@ const CardData = props => {
if (serverList.length) {
setServiceList(serverList);
setType('add');
setVisible(true);
setBaseVisible(true);
} else {
notification.warning({
message: '提示',
......@@ -127,13 +184,16 @@ const CardData = props => {
}
});
};
const pick = (schemename, index) => {
const pick = (schemename, baseMapItem) => {
console.log(props.item.defaultOldBaseMap);
let i = props.item.defaultOldBaseMap.indexOf(baseMapItem);
console.log(i);
SetServiceConfig({
schemename: schemename,
terminalType: 'scheme',
isBaseMap: false,
jsonCfg: JSON.stringify({
defaultBaseMap: index,
defaultBaseMap: i,
}),
}).then(res => {
if (res.msg === 'Ok') {
......@@ -167,7 +227,7 @@ const CardData = props => {
</Popconfirm>{' '}
</a>
}
style={{ width: 300 }}
style={{ width: 360 }}
>
<p>
<span className={styles.schemeName}>管网</span> {props.item.servicename}
......@@ -182,31 +242,49 @@ const CardData = props => {
</Button>
</div> */}
<div className={styles.schemeItem}>
<span className={styles.schemeName}>底图</span>
{/* <span className={styles.schemeName}>底图方案</span> */}
<Button className={styles.schemeBtn} onClick={() => addTile(props.item)}>
{' '}
<PlusOutlined />
添加瓦片
<BlockOutlined />
添加底图方案
</Button>
<Button className={styles.schemeBtn} onClick={() => addTileBase(props.item)}>
{' '}
<GlobalOutlined />
添加底图
</Button>
</div>
<div style={{ overflowY: 'scroll', maxHeight: '11.4rem' }}>
<div style={{ overflowY: 'scroll', height: '11.4rem' }}>
{props.item.baseMap && props.item.baseMap.length
? props.item.baseMap.map((baseMapItem, baseindex) => {
return (
<div className={styles.mapItem} key={baseindex}>
<div
onClick={() => pick(props.item.schemename, baseindex)}
onClick={() => pick(props.item.schemename, baseMapItem)}
className={classnames({
[styles.defaultTile]: true,
[styles.activeTile]: baseindex == props.item.defaultBaseMap,
})}
>
默认
{cardData.indexOf(baseMapItem) == -1 ? (
<BlockOutlined style={{ marginTop: '5px' }} />
) : (
<GlobalOutlined style={{ marginTop: '5px' }} />
)}
</div>
<div className={styles.mapText}>
<Tooltip title={baseMapItem}>{baseMapItem}</Tooltip>
</div>
<div className={styles.mapText}>{baseMapItem}</div>
<div className={styles.mapIcon}>
<Popconfirm
title="是否删除该底图?"
title={
cardData.indexOf(baseMapItem) == -1 ? (
<span>是否删除该底图方案?</span>
) : (
<span>是否删除该底图?</span>
)
}
okText="确认"
cancelText="取消"
onConfirm={() => {
......@@ -230,6 +308,14 @@ const CardData = props => {
serviceList={serviceList}
formObj={formObj}
/>
<AddModalBase
visible={basevisible}
onCancel={() => setBaseVisible(false)}
callBackSubmit={onSubmit}
type={type}
serviceList={serviceList}
formObj={formObj}
/>
<MapScope
mapId={createGuid()}
visible={mapScopeVisible}
......
......@@ -2,14 +2,14 @@
* @Description:
* @Author: leizhe
* @Date: 2022-01-13 10:47:32
* @LastEditTime: 2022-04-22 11:45:53
* @LastEditTime: 2022-06-02 18:06:20
* @LastEditors: leizhe
*/
/* eslint-disable indent */
import { Button, Spin } from 'antd';
import React, { useState, useEffect } from 'react';
import styles from '../SchemeConfig.less';
import { GetMaplayerByTerminalType } from '@/services/webConfig/api';
import { GetMaplayerByTerminalType, GettMaplayer } from '@/services/webConfig/api';
import AddModal from './AddModal';
import Cards from './components/card';
const VectorData = props => {
......@@ -17,14 +17,17 @@ const VectorData = props => {
const [tileData, setTileData] = useState([]); // 页面初始化数据
const [visible, setVisible] = useState(false); // 弹窗
const [flag, setFlag] = useState(0); // 状态更新
const [cardFlag, setCardFlag] = useState(false); // 状态更新
const [type, setType] = useState(''); // 弹窗类型
const [formObj, setFormObj] = useState({});
const [keepData, setKeepData] = useState([]);
const onSubmit = prop => {
setVisible(false);
setFlag(flag + 1);
};
const onDeletebaseMap = value => {
setCardFlag(false);
setFlag(flag + 1);
};
const handleAdd = () => {
......@@ -34,22 +37,50 @@ const VectorData = props => {
useEffect(() => {
renderTile();
}, [flag]);
// 获取瓦片数据配置数据
const renderTile = () => {
setTreeLoading(true);
GetMaplayerByTerminalType({
terminalType: 'scheme',
isBaseMap: false,
}).then(res => {
console.log('res', res);
if (res.msg === 'Ok') {
}).then(resdata => {
if (resdata.msg === 'Ok') {
setTreeLoading(false);
setTileData(res.data.scheme.optionalLayer.layers);
GettMaplayer({ terminalType: 'base', isBaseMap: true }).then(res => {
if (res.msg === 'Ok') {
resdata.data.scheme.optionalLayer.layers.map((j, index) => {
let arr = [];
res.data.general.baseMap.layers.map(i => {
arr.push(i.servicename);
});
setKeepData(arr);
let data = [];
let aa = [];
j.baseMap.map(k => {
if (arr.indexOf(k) != -1) {
data.push(k);
} else {
aa.push(k);
}
});
let bb = aa.concat(data);
let i = bb.indexOf(j.baseMap[j.defaultBaseMap]);
resdata.data.scheme.optionalLayer.layers[index].defaultOldBaseMap = j.baseMap;
resdata.data.scheme.optionalLayer.layers[index].baseMap = bb;
resdata.data.scheme.optionalLayer.layers[index].defaultBaseMap = i;
});
setTileData(resdata.data.scheme.optionalLayer.layers);
}
});
} else {
setTreeLoading(false);
}
});
};
useEffect(() => {
setCardFlag(true);
}, [tileData]);
return (
<>
<div className={styles.tileBtn}>
......@@ -63,8 +94,9 @@ const VectorData = props => {
</Button>
</div>
<Spin tip="loading..." spinning={treeLoading}>
<div style={{ height: 'calc(100vh - 230px)', width: '100%' }}>
<div style={{ height: 'calc(100vh - 216px)', width: '100%' }}>
<div className={styles.cardsList}>
{/* {console.log(tileData)} */}
{tileData && tileData.length
? tileData.map((item, index) => {
return (
......@@ -75,7 +107,12 @@ const VectorData = props => {
offset={2}
style={{ marginBottom: '1rem' }}
>
<Cards item={item} deletebaseMaps={onDeletebaseMap} />
<Cards
item={item}
cardFlag={cardFlag}
deletebaseMaps={onDeletebaseMap}
keepData={keepData}
/>
</div>
);
})
......
......@@ -149,8 +149,13 @@ export const GetMaplayerByTerminalType = query =>
// 获取全部
export const GettMaplayer = query => get(`${PUBLISH_SERVICE}/Maplayer/GetMaplayer`, query);
// 添加底图方案
export const SetBaseMapschemeName = param =>
post(`${PUBLISH_SERVICE}/Maplayer/SetBaseMapschemeName`, param);
// 设置底图数据
export const SetServiceConfig = query => get(`${PUBLISH_SERVICE}/Maplayer/SetServiceConfig`, query);
export const SetServiceConfig = query =>
post(`${PUBLISH_SERVICE}/Maplayer/SetServiceConfig`, query);
// 获取方矢量数据列表
export const GetVectorService = () =>
......@@ -165,7 +170,8 @@ export const publisService = (query, timeout) =>
get(`${PANDA_GIS}/MetaData/D_Publish_GS_Service`, query, timeout);
// 解决方案名称
export const getSolutionList = query => get(`${PANDA_GIS}/MetaData/W5_GetSolutionList`, query);
export const getSolutionList = query =>
get(`${PUBLISH_SERVICE}/PlatformCenter/GetSolutionList`, query);
// 删除元数据
export const deleteVectorService = query =>
......@@ -185,10 +191,19 @@ export const bindSchemeBaseMap = query =>
// 删除瓦片
export const unbindSchemeBaseMap = query =>
get(`${PUBLISH_SERVICE}/Maplayer/UnBindSchemeBaseMap`, query);
// 删除底图分级显示方案
export const DeletMapServicename = query =>
get(`${PUBLISH_SERVICE}/Maplayer/DeletMapServicename`, query);
// 获取底图分级显示方案名
export const GetbaseMapschemeName = query =>
get(`${PUBLISH_SERVICE}/Maplayer/GetbaseMapschemeName`, query);
// 设置web状态
export const setServiceType = query => get(`${PANDA_GIS}/MetaData/SetServiceType`, query);
// 设置web的默认方案
export const SetDefaultsSchemeName = param =>
post(`${PUBLISH_SERVICE}/Maplayer/SetDefaultsSchemeName`, param);
// 获取角色
export const getUserRelationList = query =>
get(`${CITY_SERVICE}/OMS.svc/WebGIS_GetUserRelationList`, query);
......@@ -290,3 +305,6 @@ export const GetGridSetList = param =>
export const GetCustomBaseMapByName = param =>
get(`${CITY_SERVICE}/MapServer.svc/GetCustomBaseMapByName?_version=9999`, param);
export const DragSingleWebsite = param =>
get(`${CITY_SERVICE}/OMS.svc/Web4_DragSingleWebsite?_version=9999&_dc=1653360044919`, param);
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