Commit 6b9f14d6 authored by shaoan123's avatar shaoan123

对接方案配置模块接口

parent 89f2dd41
Pipeline #26431 skipped with stages
.container{
width: 100%;
height: 100vh;
height: calc(100vh - 100px) ;
background-color: #ffffff;
display: flex;
padding: 0.8rem;
......@@ -8,6 +8,7 @@
font-weight: 600;
color: rgba(0, 0, 0, 0.85);
}
overflow-y: scroll;
}
.imgList{
display: flex;
......@@ -77,3 +78,17 @@
color: rgba(0, 0, 0, 0.25);
z-index: 99;
}
.divider{
display: flex;
align-items: center;
line-height: 100%;
padding: 0.5rem;
.dividerIcon{
margin-left: 0.8rem;
color: #4699f4;
cursor: pointer;
}
}
.ant-table {
min-height: 15rem !important;
}
......@@ -3,7 +3,7 @@ import React, { useState, useEffect, Modal } from 'react';
import styles from '../SchemeConfig.less'
import {
GetAllConfig,
DeleteConfig
deleteConfig
} from '@/services/webConfig/api';
import AddModal from './AddModal'
const TileData = props => {
......@@ -85,7 +85,7 @@ const TileData = props => {
const delConfirm = (record) => {
const { servicename = '' } = record;
setTreeLoading(true);
DeleteConfig({
deleteConfig({
servicename: servicename,
terminalType: 'base',
isBaseMap: true
......
......@@ -3,22 +3,14 @@ import { Form, Modal, Input, Select, AutoComplete, Button, notification } from '
import styles from '../SchemeConfig.less'
import {
GetGISServerMapList,
publisService
SetServiceConfig, GetAllConfig
} from '@/services/webConfig/api';
const { Option } = Select;
const AddModal = props => {
const { callBackSubmit = () => { }, type, formObj, visible,solutionNames } = props;
const { callBackSubmit = () => { }, type, formObj, visible, listData } = props;
const [loading, setLoading] = useState(false);
const [workSpace, setWorkSpace] = useState('');
const [serviceName, setServicename] = useState([{
value: 'geoserver',
item: 'geoserver'
}]);
const [workList, setWorkList] = useState([]);
const [gsIp, setGsIp] = useState([]);
const [form] = Form.useForm();
const { Item } = Form;
// 提交
......@@ -27,135 +19,50 @@ const AddModal = props => {
if (validate) {
setLoading(true);
let obj = form.getFieldsValue();
if (type === 'add') {
let query = {
_version: 9999,
gsIP: obj.serviceadress,
gsPort: obj.port,
gsAppName: obj.servicename,
gsUser: obj.user,
gsWorkspaceName: obj.workname,
gsPwd: obj.password,
serviceName: obj.name,
solution: solutionNames,
}
publisService(query,{timeout:120000})
.then(res => {
setLoading(false);
if (res.success) {
form.resetFields();
callBackSubmit();
notification.success({
message: '提示',
duration: 3,
description: '新增成功',
});
setWorkList([])
handlelocalStorage('add',obj.serviceadress, obj.servicename)
} else {
notification.error({
message: '提示',
duration: 3,
description: '新增失败',
});
}
})
.catch(err => {
SetServiceConfig({
schemename: obj.schemename,
terminalType: type === 'add' ? 'web' : 'phone',
isBaseMap: 'false',
jsonCfg: type === 'add' ? JSON.stringify({ type: 'dynamic' }) : JSON.stringify({ isDefault: false })
})
.then(res => {
setLoading(false);
if (res.IsSuccess) {
form.resetFields();
callBackSubmit();
notification.success({
message: '提示',
duration: 3,
description: '新增成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: '新增失败',
description: '新增失败',
});
setLoading(false);
}
})
.catch(err => {
notification.error({
message: '提示',
duration: 3,
description: '新增失败',
});
} else if (type === 'edit') {
handleEdit();
}
setLoading(false);
});
}
});
};
const handleEdit = () => {
// SetServiceConfig({
// servicename: serviceName,
// terminalType: 'base',
// isBaseMap: true,
// jsonCfg: JSON.stringify(query)
// })
// .then(res => {
// setLoading(false);
// if (res.success) {
// form.resetFields();
// callBackSubmit();
// notification.success({
// message: '提示',
// duration: 3,
// description: res.message || '编辑成功',
// });
// } else {
// notification.error({
// message: '提示',
// duration: 3,
// description: res.message || '编辑失败',
// });
// }
// })
// .catch(err => setLoading(false));
};
const onFinish = value => { };
useEffect(() => {
switch (type) {
case 'add':
let gsIp = [];
let localStorageData = handlelocalStorage('get');
if (localStorageData) {
gsIp = localStorageData.map(item => ({
value: item.gsIp,
item: item.gsIp
}));
}
setGsIp(gsIp)
let localIps = ['192.168.12.7', '192.168.19.100']
let port = localIps.includes(gsIp) ? 8080 : 8088
form.setFieldsValue({ servicename: serviceName[0].value, port, ...formObj });
break;
case 'edit':
form.setFieldsValue({ ...formObj });
break;
default:
break;
}
form.setFieldsValue({ schemename: listData[0] });
}, [visible]);
//存储到localstorage
const handlelocalStorage = (type, gsIp, gisAppName) => {
if (!localStorage) return null;
let result = JSON.parse(localStorage.getItem('metaData'))
if (type == 'get') {
return result;
}
if (!result || !result.find(item => item.gsIp == gsIp)) {
if (!result) result = [];
result.push({
gsIp,
gisAppName: [{
value: gisAppName,
item: gisAppName
}]
})
localStorage.setItem('metaData', JSON.stringify(result))
return
}
let data = result.find(item => item.gsIp == gsIp)
let isHasGisAppName = data.gisAppName.find(item => item.value == gisAppName);
if (isHasGisAppName) return;
data.gisAppName.push({
value: gisAppName,
item: gisAppName
})
localStorage.setItem('metaData', JSON.stringify(result))
};
const layout = {
layout: 'horizontal',
......@@ -167,56 +74,10 @@ const AddModal = props => {
},
};
const handleChange = () => { }
//选择工作空间
const selectWorkspace = () => {
let obj = form.getFieldsValue();
form.validateFields(['serviceadress', 'port', 'servicename', 'user', 'password']).then(validate => {
if (validate) {
let query = {
GISServerIP: obj.serviceadress,
GISServerPort: obj.port,
gsAppName: obj.servicename,
gsUser: obj.user,
gsPwd: obj.password,
isGeoServer: true,
_version: 9999,
}
GetGISServerMapList(query).then(res => {
if (Array.isArray(res)) {
const defaultValue= res[0].name||''
form.setFieldsValue({ name:defaultValue,workname:defaultValue});
setWorkList(res)
setWorkSpace(defaultValue)
}
else {
notification.error({
message: '提示',
duration: 3,
description: '获取工作空间失败',
});
}
})
}
})
};
//选择工作空间
const handleWorkspace = (value) => {
form.setFieldsValue({
workname: value,
name:value
})
setWorkSpace(value)
}
const selectIp = (value)=>{
let localIps = ['192.168.12.7', '192.168.19.100']
let port = localIps.includes(value) ? 8080 : 8088
form.setFieldsValue({ port,serviceadress:value });
const handleChange = (value) => {
form.setFieldsValue({ schemename: value});
}
return (
<Modal
title={`${type === 'add' ? '元数据发布' : '编辑'}`}
......@@ -236,66 +97,13 @@ const AddModal = props => {
{visible && (
<Form form={form} {...layout} onFinish={onFinish}>
<Item
label="GIS服务器地址"
name="serviceadress"
label="方案名"
name="schemename"
rules={[{ required: true, message: '请选择服务名' }]}
>
<AutoComplete
placeholder="请输入GIS服务器地址"
options={gsIp}
onSelect={selectIp}
/>
</Item>
<Item
label="GIS服务器端口"
name="port"
rules={[{ required: true, message: '请输入GIS服务器端口' }]}
>
<Input placeholder="请输入GIS服务器端口" allowClear />
</Item>
<Item
label="GIS服务器名"
name="servicename"
rules={[{ required: true, message: '请输入GIS服务器名' }]}
>
<AutoComplete
placeholder="Email"
options={serviceName}
/>
</Item>
<Item
label="用户名称"
name="user"
rules={[{ required: true, message: '请输入用户名称' }]}
>
<Input placeholder="请输入用户名称" allowClear />
</Item>
<Item
label="用户密码"
name="password"
rules={[{ required: true, message: '请输入用户密码' }]}
>
<Input.Password placeholder="请输入用户密码" allowClear />
</Item>
<Item
label="工作空间名称"
name="workname"
rules={[{ required: true, message: '请选择工作空间名称' }]}
>
<div className={styles.imgList}>
<Select onChange={handleWorkspace} value ={workSpace}>
{workList.length ? workList.map((item, index) => { return <Option key={index} value={item.name}>{item.name}</Option> }) : ''}
</Select>
<Button style={{ marginLeft: '0.5rem' }} onClick={() => { selectWorkspace() }}>选择工作空间</Button>
</div>
</Item>
<Item
label="服务名称"
name="name"
rules={[{ required: true, message: '请输入服务名称' }]}
>
<Input placeholder="请输入服务名称" allowClear />
<Select onChange={handleChange}>
{listData.map((item, index) => { return <Option value={item} key={index}>{item}</Option> }) }
</Select>
</Item>
</Form>
)}
......
import { Space, Table, Button, Popconfirm, notification,Divider,Radio } from 'antd';
import { Space, Table, Button, Popconfirm, notification, Divider, Checkbox, Spin } from 'antd';
import React, { useState, useEffect } from 'react';
import styles from '../SchemeConfig.less'
import {
GetVectorService, deleteVectorService,GetAllConfig
PlusOutlined
} from '@ant-design/icons';
import {
deleteConfig, GetAllConfig, setServiceType, SetServiceConfig
} from '@/services/webConfig/api';
import {
UserAddOutlined
} from '@ant-design/icons';
import AddModal from './AddModal'
import { set } from 'immutable';
const VectorData = props => {
const [treeLoading, setTreeLoading] = useState(false);// 弹窗显示
const [schemename, setSchemename] = useState([]);
const [webData, setWebData] = useState([]); // web数据
const [handData, setHandData] = useState([]); //手持数据
const [visible, setVisible] = useState(false); // 弹窗
const [flag, setFlag] = useState(0); // 更新list
const [loading, setLoading] = useState([]); // 更新状态
const [handStatus, setHandStatus] = useState([]); // 更新状态
const [webStatus, setWebStatus] = useState([]); // 更新状态
const [webIndex, setWebIndex] = useState(0); // web默认选中状态
const [handIndex, setHandIndex] = useState(0); // 手持默认选中状态
const [type, setType] = useState('add'); // 弹窗类型
const [checkLoading, setCheckLoading] = useState(false)
const [solutionNames, setSolutionNames] = useState('');
const [formObj, setFormObj] = useState({ user: 'admin', password: 'geoserver' });
const columns = [
......@@ -25,7 +34,12 @@ const VectorData = props => {
key: 'url',
render: (text, record, index) => (
<Space>
<Radio value={record}/>
<Checkbox
checked={webStatus[index]}
onChange={e => {
onChangeCheck(e, record, index);
}}
/>
</Space>
),
},
......@@ -38,11 +52,70 @@ const VectorData = props => {
{
title: '关联角色',
align: 'center',
key :'type',
key: 'type',
render: (text, record, index) => (
<Space>
<div onClick={e => e.stopPropagation()} style={{cursor:'pointer'}}>
<UserAddOutlined />
</div>
</Space>
),
},
{
title: '编辑',
align: 'center',
key: 'schemename',
render: (text, record, index) => (
<Space>
<div onClick={e => e.stopPropagation()}>
<UserAddOutlined />
<Popconfirm
title="是否删除此条方案?"
okText="确认"
cancelText="取消"
onConfirm={() => {
delWebConfirm(record);
}}
>
<Button size="small" danger>
删除
</Button>
</Popconfirm>
</div>
</Space>
),
}
];
const columns1 = [
{
title: '查询方案',
align: 'center',
key: 'url',
render: (text, record, index) => (
<Space>
<Checkbox
checked={handStatus[index]}
onChange={e => {
onChangeHand(e, record, index);
}}
/>
</Space>
),
},
{
title: '方案名',
dataIndex: 'schemename',
key: 'schemename',
align: 'center'
},
{
title: '关联角色',
align: 'center',
key: 'type',
render: (text, record, index) => (
<Space>
<div onClick={e => e.stopPropagation()} style={{cursor:'pointer'}}>
<UserAddOutlined />
</div>
</Space>
),
......@@ -55,11 +128,11 @@ const VectorData = props => {
<Space>
<div onClick={e => e.stopPropagation()}>
<Popconfirm
title="是否删除该矢量数据?"
title="是否删除此条方案?"
okText="确认"
cancelText="取消"
onConfirm={() => {
delConfirm(record);
delhandConfirm(record);
}}
>
<Button size="small" danger>
......@@ -72,39 +145,228 @@ const VectorData = props => {
}
];
//设置web方案
const onChangeCheck = (e, record, index) => {
setCheckLoading(true)
const newLoadings = [...webStatus];
newLoadings.map((item, loadIndex) => {
return loadIndex == index ? newLoadings[loadIndex] = !newLoadings[loadIndex] : newLoadings[loadIndex] = false
})
setWebStatus(newLoadings)
let query = {
schemename: record['schemename'],
type: 'dynamic'
}
if (!newLoadings[index]) {
setServiceType(query).then(res => {
setCheckLoading(false)
if (res.IsSuccess) {
const changehandData = [...webData];
changehandData[index].type = 'dynamic'
setWebData(changehandData)
prompt('success', '设置成功')
} else {
prompt('fail', `${record['schemename']}默认设置时遇到错误:` + res.message)
}
})
return
}
var beforeDefault = webData.findIndex((item) => item['type'] == 'pipenet');
setServiceType({
schemename: record['schemename'],
type: 'pipenet'
}).then(res => {
setCheckLoading(false)
if (res.IsSuccess) {
const changehandData = [...webData];
changehandData[index].type = 'pipenet'
setWebData(changehandData)
if (beforeDefault != -1) {
setServiceType({
schemename: changehandData[beforeDefault].schemename,
type: 'dynamic'
}).then(res => {
setCheckLoading(false)
if (res.IsSuccess) {
const changehandData1 = [...webData];
changehandData1[beforeDefault].type = 'dynamic'
setWebData(changehandData1)
prompt('success', '设置成功')
return;
}
prompt('fail', `${record['schemename']}默认设置时遇到错误:` + res.message)
})
}
}
})
}
//选择手持方案
const onChangeHand = (e, record, index) => {
setCheckLoading(true)
const newLoadings = [...handStatus];
newLoadings.map((item, loadIndex) => {
return loadIndex == index ? newLoadings[loadIndex] = !newLoadings[loadIndex] : newLoadings[loadIndex] = false
})
setHandStatus(newLoadings)
let query = {
schemename: record['schemename'],
terminalType: 'phone',
isBaseMap: false,
jsonCfg: JSON.stringify({
isDefault: newLoadings[index],
})
}
if (!newLoadings[index]) {
SetServiceConfig(query).then(res => {
setCheckLoading(false)
if (res.IsSuccess) {
const changehandData = [...handData];
changehandData[index].isDefault = false
setHandData(changehandData)
prompt('success', '设置成功')
} else {
prompt('fail', `${record['schemename']}默认设置时遇到错误:` + res.message)
}
})
return
}
var beforeDefault = handData.findIndex((item) => item['isDefault']);
SetServiceConfig({
schemename: record['schemename'],
terminalType: 'phone',
isBaseMap: false,
jsonCfg: JSON.stringify({
isDefault: true,
})
}).then(res => {
setCheckLoading(false)
if (res.IsSuccess) {
const changehandData = [...handData];
changehandData[index].isDefault = true
setHandData(changehandData)
if (beforeDefault != -1) {
SetServiceConfig({
schemename: changehandData[beforeDefault].schemename,
terminalType: 'phone',
isBaseMap: false,
jsonCfg: JSON.stringify({
isDefault: false,
})
}).then(res => {
setCheckLoading(false)
if (res.IsSuccess) {
const changehandData1 = [...handData];
changehandData1[beforeDefault].isDefault = false
setHandData(changehandData1)
prompt('success', '设置成功')
return;
}
prompt('fail', `${record['schemename']}默认设置时遇到错误:` + res.message)
})
}
}
})
}
const prompt = (type, content) => {
if (type == 'success') {
notification.success({
message: '提示',
duration: 3,
description: content,
});
}
else {
notification.error({
message: '提示',
duration: 3,
description: content,
});
}
}
const onSubmit = prop => {
setVisible(false);
setFlag(flag + 1)
};
const delConfirm = (record) => {
let query = {
serviceName: record.serviceName,
_version: 9999,
solution: solutionNames
}
deleteVectorService(query).then(res => {
if (res.success) {
//删除web配置方案
const delWebConfirm = (record) => {
deleteConfig({
schemename: record['schemename'],
terminalType: 'web',
isBaseMap: false
}).then(res => {
if (res.IsSuccess) {
prompt('success', '删除成功')
setFlag(flag + 1)
notification.success({
message: '提示',
duration: 3,
description: '删除元数据成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: '删除元数据失败',
});
prompt('fail', '删除失败')
};
})
}
const handleAdd = () => {
setType('add');
setVisible(true);
//删除手持配置方案
const delhandConfirm = (record) => {
deleteConfig({
schemename: record['schemename'],
terminalType: 'phone',
isBaseMap: false
}).then(res => {
if (res.IsSuccess) {
prompt('success', '删除成功')
setFlag(flag + 1)
} else {
prompt('fail', '删除失败')
};
})
}
//添加方案
const addType = (type) => {
setType(type);
let listData = []
type == 'add' ? listData = webData : listData = handData
let webSchemenameArr = [], schemeArr = []
setTreeLoading(true);
GetAllConfig({
terminalType: 'scheme',
isBaseMap: false
}).then(
res => {
if (res && res.Result.length > 0) {
setTreeLoading(false);
listData.map(item => {
webSchemenameArr.push(item.schemename)
})
res.Result.map(item => {
if (!webSchemenameArr.includes(item.schemename))
schemeArr.push(item.schemename)
})
setSchemename(schemeArr)
if (schemeArr.length) {
setVisible(true);
}
else {
notification.warning({
message: '提示',
duration: 3,
description: '请先配置方案',
});
}
} else {
setTreeLoading(false);
notification.warning({
message: '提示',
duration: 3,
description: '请先配置方案',
});
}
}
)
}
useEffect(() => {
renderTile();
......@@ -112,50 +374,106 @@ const VectorData = props => {
// 获取瓦片数据配置数据
const renderTile = () => {
setTreeLoading(true);
//查询方案
//查询手持方案
var schemeConfigQueryRequest = GetAllConfig({
terminalType: 'scheme',
terminalType: 'phone',
isBaseMap: false
})
//查询web方案
//查询web方案
var webSchemeQueryRequest = GetAllConfig({
terminalType: 'web',
isBaseMap: false
})
Promise.all([schemeConfigQueryRequest,webSchemeQueryRequest]).then(res=>{
console.log('res',res);
if(res[0].IsSuccess){
Promise.all([schemeConfigQueryRequest, webSchemeQueryRequest]).then(res => {
console.log('res', res)
if (res[0].IsSuccess) {
let arr = []
res[0].Result.map((item, index) => {
if (item.isDefault) {
arr.push(true)
setHandIndex(index)
} else {
arr.push(false)
}
item.isStatus = 'hand'
return item
})
setHandData(res[0].Result)
setHandStatus(arr)
}
if (res[1].IsSuccess) {
let arr = []
res[1].Result.map((item, index) => {
if (item.type === "pipenet") {
arr.push(true)
setWebIndex(index)
} else {
arr.push(false)
}
item.isStatus = 'web'
return item
})
setWebData(res[1].Result)
setWebStatus(arr)
}
if(res[1].IsSuccess){
setWebData(res[1].Result)
}
})
};
return (
<>
<Divider orientation="left">Web</Divider>
<Table
columns={columns}
dataSource={webData}
bordered
rowKey="schemename"
scroll={{ y: 400 }}
>
</Table>
<Divider orientation="left">手持</Divider>
<Table
columns={columns}
dataSource={handData}
bordered
rowKey="schemename"
scroll={{ y: 400 }}
>
</Table>
<Spin tip="loading..." spinning={checkLoading}>
<div>
<div >
<Divider orientation="left"><div className={styles.divider}> Web <PlusOutlined
onClick={() => { addType('add') }}
className={styles.dividerIcon} /></div></Divider>
<Table
columns={columns}
dataSource={webData}
bordered
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
defaultPageSize: 3,
}}
rowKey="schemename"
scroll={{ y: 400 }}
>
</Table>
</div>
<Divider orientation="left"><div className={styles.divider}>手持 <PlusOutlined
onClick={() => { addType('addHand') }}
className={styles.dividerIcon} /></div> </Divider>
<Table
columns={columns1}
dataSource={handData}
bordered
rowKey="schemename"
scroll={{ y: 400 }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
defaultPageSize: 3,
}}
>
</Table>
</div>
</Spin>
<AddModal
visible={visible}
onCancel={() => setVisible(false)}
callBackSubmit={onSubmit}
type={type}
formObj={formObj}
listData={schemename}
/>
</>
)
}
......
......@@ -169,9 +169,6 @@ export const SetServiceConfig = query =>
export const GetVectorService = () =>
get(`${CITY_SERVICE}/OMS.svc/D_GetVectorService`, { _version: 9999 });
//删除底图配置
export const DeleteConfig = query =>
get(`${CITY_SERVICE}/OMS.svc/DeleteConfig`, query);
//获取元数据的工作空间列表
export const GetGISServerMapList = query =>
......@@ -207,4 +204,10 @@ get(`${CITY_SERVICE}/OMS.svc/BindSchemeBaseMap`, query );
export const unbindSchemeBaseMap = (query) =>
get(`${CITY_SERVICE}/OMS.svc/UnbindSchemeBaseMap`, query );
//设置web状态
export const setServiceType = (query) =>
get(`${CITY_SERVICE}/OMS.svc/SetServiceType`, query );
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