import React from 'react'; import { Tree, Button, Modal, Form, Input, Radio } from 'antd'; import axios from 'axios'; import { DownOutlined, EyeOutlined, EyeInvisibleOutlined, } from '@ant-design/icons'; import SetLogoImagePath from './SetLogoImagePath' import { createLayer } from '../../../api'; import '../../../index.less'; class LayerData extends React.Component { constructor () { super (); this.state = { treeData: [], layerId: '', isModalOpen: false, addLayer: { id: 0, logoImagePath: '', name: '', note: '', }, } } // 获取基础图层菜单栏 getBasicLayerMenu = (adcode) => { return axios.get('/api/basicMap/getBasicLayerMenu', { params: { adcode: adcode } }).then((e) => { let basicLayeData = e.data.data; let basicLayeList = []; for (var i in basicLayeData) { basicLayeList.push({ key: basicLayeData[i].id, title : basicLayeData[i].name, selectable: false, children: this.getLayerList(basicLayeData[i].layerList, i), }) } this.setState ({ treeData: basicLayeList }) }); } getLayerList = (layerList, i) => { var cLayerList = []; for (let i in layerList) { cLayerList.push({ 'key': i + '-' + layerList[i].id + '-' + new Date(), 'title': layerList[i].name + '(' + layerList[i].geoUnitAmount + ')', 'icon': ({ selected }) => (selected ? [,] : [,]), 'type': layerList[i].type, }) } return cLayerList; } // 选中图层 onLayerSelect = (selectedKeys, info) => { let layerId = info.node.key.split('-')[1]; this.setState({ layerId: layerId }) if (info.node.type === 1 || info.node.type === 4) { this.props.getLayerPoints(layerId, info.selected, info.node.type); } else if (info.node.type === 2) { this.props.getLayerShapes(layerId, info.selected); } } //弹出框事件 showModal = () => { this.setState({ isModalOpen: true }); }; handleOk = (values) => { if (this.state.addLayer.id != 0) { //编辑图层 updateLayer({ id: this.state.addLayer.id, logoImagePath: this.state.addLayer.logoImagePath, name: this.state.addLayer.name, note: this.state.addLayer.note, }).then((e) => { this.setState({ isModalOpen: false }); }) } else { createLayer({ //创建图层 id: this.state.addLayer.id, logoImagePath: this.state.addLayer.logoImagePath, name: this.state.addLayer.name, note: this.state.addLayer.note, }).then((e) => { this.setState({ isModalOpen: false }); }) } }; handleCancel = () => { this.setState({ isModalOpen: false }); }; onLayerNameChange = (e) => { this.setState({ addLayer: { id: this.state.addLayer.id, logoImagePath: this.state.addLayer.logoImagePath, note: this.state.addLayer.note, name: e.target.value, } }) }; onLayerNoteChange = (e) => { this.setState({ addLayer: { id: this.state.addLayer.id, logoImagePath: this.state.addLayer.logoImagePath, name: this.state.addLayer.name, note: e.target.value, } }) }; onLayerIogoImagePathChange = (e) => { this.setState({ addLayer: { id: this.state.addLayer.id, note: this.state.addLayer.note, name: this.state.addLayer.name, logoImagePath: e.target.value, } }) }; //弹出框事件 render() { return (
} treeData={this.state.treeData} onSelect={this.onLayerSelect} />
); } } export default LayerData