Commit a4b09401 authored by 田翔's avatar 田翔

fix: 区域任务控件完善

parent 2698d54e
{
"name": "panda-xform",
"version": "6.0.47",
"description": "6.0.47 多分组自动隐藏BUG修复",
"version": "6.0.48",
"description": "6.0.48 区域任务控件完善",
"keywords": [
"panda-xform"
],
......
import React, { useState, useEffect, useRef, useMemo } from 'react'
import { Input, Button, Tree, Spin, Table } from 'antd'
import { Input, Button, Tree, Spin, Table, message } from 'antd'
import { CompassOutlined, DownOutlined } from '@ant-design/icons'
import styles from './index.less'
import {
......@@ -17,6 +17,18 @@ import Drag from '../../../components/Drag'
import { isJson, isObject, getNanoid, mercatorToLngLat } from '../../../../utils'
import { FetchAreaList, GetAreaLayerTaskData, GetAccountConfigInfo, GetAccountPageList } from '../../../../apis/process'
const getRings = (rings) => {
rings = rings.map(ring => {
if (ring.length > 1) {
if (ring[0][0] != ring[ring.length - 1][0] || ring[0][1] != ring[ring.length - 1][1]) {
ring.push(ring[0])
}
}
return ring
})
return rings
}
const AreaTask = (props) => {
const codes = window?.pandaXform?.codes || { 工单编号: '', 事件编号: '', }
......@@ -46,8 +58,8 @@ const AreaTask = (props) => {
const [config, setConfig] = useState({ accountFieids: [], formJson: '' })
const { accountFieids, formJson } = config
const [dataSource, setDataSource] = useState([])
const [layerCount, setLayerCount] = useState([])
const viewRef = useRef(null)
const layers = useRef(null)
const treeData = useMemo(() => {
const ListToTree = (List, rootValue) => {
......@@ -108,6 +120,7 @@ const AreaTask = (props) => {
if (areaPolygon) {
let geometry = geomUtils.toGeometry(JSON.parse(areaPolygon))
setRings({ rings: geometry.rings })
getGISDataCount({ rings: geometry.rings })
let layer = new Graphic({
geometry: geometry,
symbol: new SimpleFillSymbol({
......@@ -119,12 +132,14 @@ const AreaTask = (props) => {
}),
})
viewRef.current.goTo({ target: geometry, zoom: viewRef.current.zoom > 20 ? 20 : viewRef.current.zoom > 15 ? viewRef.current.zoom : 15 }, { duration: 500 })
if (layers?.current) {
viewRef?.current?.map.remove(layers.current)
let graphicsLayer = viewRef.current.map.layers.find((lyr) => lyr.id == 'newDrawLayer')
if (graphicsLayer) {
graphicsLayer.removeAll()
} else {
graphicsLayer = new GraphicsLayer({ id: 'newDrawLayer' })
viewRef.current.map.add(graphicsLayer)
}
layers.current = new GraphicsLayer()
layers.current.add(layer)
viewRef.current.map.add(layers.current)
graphicsLayer.add(layer)
}
}
......@@ -137,9 +152,14 @@ const AreaTask = (props) => {
}),
})
layers.current = new GraphicsLayer()
layers.current.add(layer)
view.map.add(layers.current)
let graphicsLayer = viewRef.current.map.layers.find((lyr) => lyr.id == 'newDrawLayer')
if (graphicsLayer) {
graphicsLayer.removeAll()
} else {
graphicsLayer = new GraphicsLayer({ id: 'newDrawLayer' })
view.map.add(graphicsLayer)
}
graphicsLayer.add(layer)
}
}, 2000)
}
......@@ -158,11 +178,10 @@ const AreaTask = (props) => {
const getPoints = (view) => {
if (view) {
view.map.remove(layers.current)
drawTool.activate({
view,
action: 'polygon',
target: 'erroSendUpWidget',// 随便写
target: 'newDrawLayer',// 随便写
toolTip: '左键选择位置',
drawEnd: geometry => {
setRings({ rings: geometry.rings })
......@@ -172,9 +191,17 @@ const AreaTask = (props) => {
}),
})
layers.current = new GraphicsLayer()
layers.current.add(layer)
view.map.add(layers.current)
let graphicsLayer = view.map.layers.find((lyr) => lyr.id == 'newDrawLayer')
if (graphicsLayer) {
graphicsLayer.removeAll()
} else {
graphicsLayer = new GraphicsLayer({ id: 'newDrawLayer' })
view.map.add(graphicsLayer)
}
graphicsLayer.add(layer)
drawTool.deactivate()
getGISDataCount({ rings: getRings(geometry.rings) })
setSelectedKeys([])
},
// rightClick: () => { getPoints(view, coordGetLayer) }
})
......@@ -182,7 +209,6 @@ const AreaTask = (props) => {
}
const start = () => {
setSelectedKeys([])
getPoints(viewRef.current)
}
......@@ -195,6 +221,32 @@ const AreaTask = (props) => {
setVisible(false)
}
const getGISDataCount = async (rings) => {
let layerWhere = []
if (layerName?.length) {
layerName.forEach(v => {
layerWhere.push({ layerName: v, where: [] })
})
}
let paramas = {
mapServerName: service,
geometry: JSON.stringify(rings),
geometryType: 'civGeometryPolygon',
layerWhereList: layerWhere
}
const { code, data } = await GetAreaLayerTaskData(paramas)
if (code === 0) {
let array = []
if (layerName?.length) {
layerName.forEach(v => {
let count = data.filter(s => s['gis图层'] === v)?.length || 0
array.push({ layerName: v, layerCount: count })
})
}
setLayerCount(array)
}
}
const getGISData = async () => {
window.relationForm = { configs: [], data: [] }
let layerWhere = []
......@@ -209,7 +261,7 @@ const AreaTask = (props) => {
geometryType: 'civGeometryPolygon',
layerWhereList: layerWhere
}
const { code, data } = await GetAreaLayerTaskData(paramas)
const { code, data, msg } = await GetAreaLayerTaskData(paramas)
if (code === 0) {
let items = []
let array = []
......@@ -240,6 +292,8 @@ const AreaTask = (props) => {
})
window.relationForm = { configs: [{ ...schema, '台账名称': schema.accountName, '映射字段': [{ fromField: '工单编号', toField: '工单编号' }] }], data: items }
setDataSource(array)
} else {
message.error(msg)
}
}
......@@ -257,10 +311,15 @@ const AreaTask = (props) => {
const { code, data } = await FetchAreaList({ userID: userID, sourceType: '管网巡检,DMA分区' })
if (code === '0') {
setAreaList(data)
if (value && !isNaN(value)) {
setTimeout(() => {
onSelect([Number(value)], data)
}, 2000)
if (value) {
if (!isNaN(value)) {
setTimeout(() => {
onSelect([Number(value)], data)
}, 2000)
}
if (isJson(value)) {
getGISDataCount({ rings: getRings(JSON.parse(value).rings) })
}
}
}
}
......@@ -416,14 +475,30 @@ const AreaTask = (props) => {
client={token ? client : 'sandbox'}
/>
</div>
<div className={styles.description}>
<div>
<span>说明:</span>
<span style={{ marginLeft: '5px' }}>已选中区域内对象</span>
</div>
{
layerCount.map(v => {
return (
<div>
<span>{v.layerName}:</span>
<span style={{ marginLeft: '5px' }}>{v.layerCount}</span>
</div>
)
})
}
</div>
<Button
style={{ position: 'absolute', zIndex: '99', right: '10px', top: '10px' }}
type='primary'
onClick={start}
>
开始绘制
</Button>
</div>
<Button
style={{ position: 'absolute', zIndex: '99', right: '10px', top: '10px' }}
type='primary'
onClick={start}
>
开始绘制
</Button>
</div>
</Spin>
</div>
......
......@@ -64,6 +64,17 @@
position: relative;
width: calc(100% - 250px);
height: 100%;
.description {
position: absolute;
left: 10px;
top: 10px;
background: white;
padding: 10px;
border-radius: 2px;
font-weight: bold;
color: red;
}
}
}
\ No newline at end of file
......@@ -169,7 +169,7 @@ const AreaTaskShine = (props) => {
onCancel={() => setVisible(false)}
>
<Form name="dynamic_form_nest_item" form={form} autoComplete="off" labelCol={{ span: 5 }}>
<Form.Item label='gis反馈台账' name='accountName' rules={[{ required: true, message: 'gis反馈台账必填', }]}>
<Form.Item label='GIS反馈台账' name='accountName' rules={[{ required: true, message: 'gis反馈台账必填', }]}>
<Select
showSearch
options={accountList.map(v => ({ label: v.name, value: v.name }))}
......@@ -219,7 +219,6 @@ const AreaTaskShine = (props) => {
marginBottom: '5px',
justifyContent: 'center',
position: 'relative',
left: index === 0 ? '-11px' : '',
}}
align="baseline"
>
......
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