Commit a4b09401 authored by 田翔's avatar 田翔

fix: 区域任务控件完善

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