Commit 6b9f14d6 authored by shaoan123's avatar shaoan123

对接方案配置模块接口

parent 89f2dd41
Pipeline #26431 skipped with stages
.container{ .container{
width: 100%; width: 100%;
height: 100vh; height: calc(100vh - 100px) ;
background-color: #ffffff; background-color: #ffffff;
display: flex; display: flex;
padding: 0.8rem; padding: 0.8rem;
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
font-weight: 600; font-weight: 600;
color: rgba(0, 0, 0, 0.85); color: rgba(0, 0, 0, 0.85);
} }
overflow-y: scroll;
} }
.imgList{ .imgList{
display: flex; display: flex;
...@@ -77,3 +78,17 @@ ...@@ -77,3 +78,17 @@
color: rgba(0, 0, 0, 0.25); color: rgba(0, 0, 0, 0.25);
z-index: 99; 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'; ...@@ -3,7 +3,7 @@ import React, { useState, useEffect, Modal } from 'react';
import styles from '../SchemeConfig.less' import styles from '../SchemeConfig.less'
import { import {
GetAllConfig, GetAllConfig,
DeleteConfig deleteConfig
} from '@/services/webConfig/api'; } from '@/services/webConfig/api';
import AddModal from './AddModal' import AddModal from './AddModal'
const TileData = props => { const TileData = props => {
...@@ -85,7 +85,7 @@ const TileData = props => { ...@@ -85,7 +85,7 @@ const TileData = props => {
const delConfirm = (record) => { const delConfirm = (record) => {
const { servicename = '' } = record; const { servicename = '' } = record;
setTreeLoading(true); setTreeLoading(true);
DeleteConfig({ deleteConfig({
servicename: servicename, servicename: servicename,
terminalType: 'base', terminalType: 'base',
isBaseMap: true isBaseMap: true
......
...@@ -3,22 +3,14 @@ import { Form, Modal, Input, Select, AutoComplete, Button, notification } from ' ...@@ -3,22 +3,14 @@ import { Form, Modal, Input, Select, AutoComplete, Button, notification } from '
import styles from '../SchemeConfig.less' import styles from '../SchemeConfig.less'
import { import {
GetGISServerMapList, SetServiceConfig, GetAllConfig
publisService
} from '@/services/webConfig/api'; } from '@/services/webConfig/api';
const { Option } = Select; const { Option } = Select;
const AddModal = props => { const AddModal = props => {
const { callBackSubmit = () => { }, type, formObj, visible,solutionNames } = props; const { callBackSubmit = () => { }, type, formObj, visible, listData } = props;
const [loading, setLoading] = useState(false); 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 [form] = Form.useForm();
const { Item } = Form; const { Item } = Form;
// 提交 // 提交
...@@ -27,22 +19,15 @@ const AddModal = props => { ...@@ -27,22 +19,15 @@ const AddModal = props => {
if (validate) { if (validate) {
setLoading(true); setLoading(true);
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
if (type === 'add') { SetServiceConfig({
let query = { schemename: obj.schemename,
_version: 9999, terminalType: type === 'add' ? 'web' : 'phone',
gsIP: obj.serviceadress, isBaseMap: 'false',
gsPort: obj.port, jsonCfg: type === 'add' ? JSON.stringify({ type: 'dynamic' }) : JSON.stringify({ isDefault: false })
gsAppName: obj.servicename, })
gsUser: obj.user,
gsWorkspaceName: obj.workname,
gsPwd: obj.password,
serviceName: obj.name,
solution: solutionNames,
}
publisService(query,{timeout:120000})
.then(res => { .then(res => {
setLoading(false); setLoading(false);
if (res.success) { if (res.IsSuccess) {
form.resetFields(); form.resetFields();
callBackSubmit(); callBackSubmit();
notification.success({ notification.success({
...@@ -50,8 +35,7 @@ const AddModal = props => { ...@@ -50,8 +35,7 @@ const AddModal = props => {
duration: 3, duration: 3,
description: '新增成功', description: '新增成功',
}); });
setWorkList([])
handlelocalStorage('add',obj.serviceadress, obj.servicename)
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
...@@ -68,94 +52,17 @@ const AddModal = props => { ...@@ -68,94 +52,17 @@ const AddModal = props => {
}); });
setLoading(false); setLoading(false);
}); });
} else if (type === 'edit') {
handleEdit();
}
} }
}); });
}; };
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 => { }; const onFinish = value => { };
useEffect(() => { useEffect(() => {
switch (type) { form.setFieldsValue({ schemename: listData[0] });
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;
}
}, [visible]); }, [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 = { const layout = {
layout: 'horizontal', layout: 'horizontal',
...@@ -167,56 +74,10 @@ const AddModal = props => { ...@@ -167,56 +74,10 @@ const AddModal = props => {
}, },
}; };
const handleChange = () => { } const handleChange = (value) => {
form.setFieldsValue({ schemename: value});
//选择工作空间
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 });
}
return ( return (
<Modal <Modal
title={`${type === 'add' ? '元数据发布' : '编辑'}`} title={`${type === 'add' ? '元数据发布' : '编辑'}`}
...@@ -236,66 +97,13 @@ const AddModal = props => { ...@@ -236,66 +97,13 @@ const AddModal = props => {
{visible && ( {visible && (
<Form form={form} {...layout} onFinish={onFinish}> <Form form={form} {...layout} onFinish={onFinish}>
<Item <Item
label="GIS服务器地址" label="方案名"
name="serviceadress" name="schemename"
rules={[{ required: true, message: '请选择服务名' }]} rules={[{ required: true, message: '请选择服务名' }]}
> >
<AutoComplete <Select onChange={handleChange}>
placeholder="请输入GIS服务器地址" {listData.map((item, index) => { return <Option value={item} key={index}>{item}</Option> }) }
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> </Select>
<Button style={{ marginLeft: '0.5rem' }} onClick={() => { selectWorkspace() }}>选择工作空间</Button>
</div>
</Item>
<Item
label="服务名称"
name="name"
rules={[{ required: true, message: '请输入服务名称' }]}
>
<Input placeholder="请输入服务名称" allowClear />
</Item> </Item>
</Form> </Form>
)} )}
......
...@@ -169,9 +169,6 @@ export const SetServiceConfig = query => ...@@ -169,9 +169,6 @@ export const SetServiceConfig = query =>
export const GetVectorService = () => export const GetVectorService = () =>
get(`${CITY_SERVICE}/OMS.svc/D_GetVectorService`, { _version: 9999 }); get(`${CITY_SERVICE}/OMS.svc/D_GetVectorService`, { _version: 9999 });
//删除底图配置
export const DeleteConfig = query =>
get(`${CITY_SERVICE}/OMS.svc/DeleteConfig`, query);
//获取元数据的工作空间列表 //获取元数据的工作空间列表
export const GetGISServerMapList = query => export const GetGISServerMapList = query =>
...@@ -207,4 +204,10 @@ get(`${CITY_SERVICE}/OMS.svc/BindSchemeBaseMap`, query ); ...@@ -207,4 +204,10 @@ get(`${CITY_SERVICE}/OMS.svc/BindSchemeBaseMap`, query );
export const unbindSchemeBaseMap = (query) => export const unbindSchemeBaseMap = (query) =>
get(`${CITY_SERVICE}/OMS.svc/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