Commit 55bd16b7 authored by 田翔's avatar 田翔

fix: 台账选择器点击行优化

parent f14c61c5
{
"name": "panda-xform",
"version": "4.0.9",
"description": "4.0.9 取消表单设计器校验",
"version": "4.1.0",
"description": "4.1.0 台账选择器点击行优化",
"keywords": [
"panda-xform"
],
......
......@@ -127,7 +127,15 @@ const widgetData = {
type: '附件控件',
},
'Coordinate': {
name: '地图控件',
name: '地图坐标',
type: 'GIS控件',
},
'DrawPath': {
name: '路径控件',
type: 'GIS控件',
},
'DrawArea': {
name: '区域控件',
type: 'GIS控件',
},
'Device': {
......
......@@ -2148,17 +2148,166 @@ const mapWidgets = [
},
},
},
// {
// text: '地图选线',
// name: '地图选线',
// icon: <IconPack.Coordinate />,
// schema: {
// title: '地图选线',
// type: 'string',
// widget: 'DrawPartition',
// placeholder: '绘制地图线段',
// },
// },
{
text: '路径控件',
name: '路径控件',
icon: <IconPack.DrawPath />,
schema: {
title: '路径控件',
type: 'string',
widget: 'DrawPath',
placeholder: '绘制地图路径',
},
setting: {
widget: {
title: '控件类型',
type: 'string',
widget: 'WidgetType',
displayType: 'row',
labelWidth: 75,
},
$id: {
title: '数据源',
type: 'string',
widget: 'FieldNames',
required: true,
},
title: {
title: '展示名称',
required: true,
type: 'string',
},
placeholder: {
title: '提示语',
type: 'string',
},
description: {
title: '字段说明',
type: 'string',
},
hiddenCondition: {
title: '隐藏条件',
type: 'string',
description: '所有形态默认显示',
widget: 'HiddenCondition'
},
required: {
title: '必填',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
disabled: {
title: '只读',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '25%',
},
groupStyle: {
title: '控件样式',
type: 'object',
properties: {}
},
width: {
title: '元素宽度',
type: 'string',
widget: 'percentSlider',
},
labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
},
},
},
{
text: '区域控件',
name: '区域控件',
icon: <IconPack.DrawArea />,
schema: {
title: '区域控件',
type: 'string',
widget: 'DrawArea',
placeholder: '绘制地图区域',
},
setting: {
widget: {
title: '控件类型',
type: 'string',
widget: 'WidgetType',
displayType: 'row',
labelWidth: 75,
},
$id: {
title: '数据源',
type: 'string',
widget: 'FieldNames',
required: true,
},
title: {
title: '展示名称',
required: true,
type: 'string',
},
placeholder: {
title: '提示语',
type: 'string',
},
description: {
title: '字段说明',
type: 'string',
},
hiddenCondition: {
title: '隐藏条件',
type: 'string',
description: '所有形态默认显示',
widget: 'HiddenCondition'
},
required: {
title: '必填',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '33%',
},
disabled: {
title: '只读',
type: 'boolean',
widget: 'checkbox',
default: false,
width: '25%',
},
groupStyle: {
title: '控件样式',
type: 'object',
properties: {}
},
width: {
title: '元素宽度',
type: 'string',
widget: 'percentSlider',
},
labelWidth: {
title: '标签宽度',
description: '默认值110',
default: 110,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
},
},
},
{
text: '设备选择',
name: '设备选择',
......
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1682324829287" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9060" xmlns:xlink="http://www.w3.org/1999/xlink" width="14" height="14"><path d="M333.226667 197.290667l16.725333-83.669334 376.533333 75.178667-16.682666 83.669333zM790.698667 351.872l84.736-10.154667 40.533333 338.901334-84.736 10.154666zM227.285333 831.530667l559.189334-66.816 10.154666 84.736-559.232 66.816zM111.530667 782.08L196.224 225.365333l84.352 12.8-84.693333 556.8z" p-id="9061"></path><path d="M247.466667 277.333333C170.666667 277.333333 106.666667 213.333333 106.666667 136.533333S170.666667 0 247.466667 0 384 64 384 136.533333 324.266667 277.333333 247.466667 277.333333z m0-192c-29.866667 0-55.466667 25.6-55.466667 51.2s25.6 51.2 51.2 51.2S298.666667 166.4 298.666667 136.533333 277.333333 85.333333 247.466667 85.333333zM136.533333 1024C64 1024 0 960 0 887.466667s64-136.533333 136.533333-136.533334c76.8 0 136.533333 64 136.533334 136.533334S213.333333 1024 136.533333 1024z m0-192c-29.866667 0-51.2 25.6-51.2 51.2S110.933333 938.666667 136.533333 938.666667s51.2-25.6 51.2-51.2-21.333333-55.466667-51.2-55.466667zM810.666667 392.533333c-76.8 0-136.533333-64-136.533334-136.533333s64-136.533333 136.533334-136.533333 136.533333 64 136.533333 136.533333-59.733333 136.533333-136.533333 136.533333z m0-192c-29.866667 0-51.2 25.6-51.2 51.2s25.6 51.2 51.2 51.2 51.2-25.6 51.2-51.2-21.333333-51.2-51.2-51.2zM887.466667 917.333333c-76.8 0-136.533333-64-136.533334-136.533333S810.666667 640 887.466667 640s136.533333 64 136.533333 136.533333-64 140.8-136.533333 140.8z m0-192c-29.866667 0-51.2 25.6-51.2 51.2s25.6 51.2 51.2 51.2S938.666667 810.666667 938.666667 780.8s-25.6-55.466667-51.2-55.466667z" p-id="9062"></path></svg>
\ No newline at end of file
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1682324737322" class="icon" viewBox="0 0 1260 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5278" width="17.2265625" height="14" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M875.632259 508.010011C875.632259 508.010011 1100.740849 346.048357 1099.71727 211.408382 1098.772428 94.641667 999.327815 0 875.632259 0 751.857966 0 658.791036 94.877877 651.468511 211.408382 643.04367 346.048357 875.632259 508.010011 875.632259 508.010011L875.632259 508.010011 875.632259 508.010011ZM871.931628 109.916611C926.102565 109.916611 969.958978 152.591972 969.958978 205.188173 969.958978 257.784373 926.102565 300.459734 871.931628 300.459734 817.760691 300.459734 773.825541 257.784373 773.825541 205.188173 773.825541 152.591972 817.760691 109.916611 871.931628 109.916611L871.931628 109.916611 871.931628 109.916611ZM590.44747 689.104715C598.242416 677.845348 605.09252 666.034824 611.076519 653.830616 630.130831 617.296728 641.783881 580.290419 641.468934 544.701373 640.130408 384.156982 498.167908 254.005006 321.324993 254.005006 320.931309 254.005006 320.537625 254.005006 320.143941 254.005006 319.67152 254.005006 319.277836 254.005006 318.884152 254.005006 142.749868 254.005006 0 381.794877 0 539.504742 0 547.850846 0.393684 556.039476 1.181052 564.228106 2.125894 579.503051 5.117894 594.935469 9.92084 610.446624 18.896839 641.862618 33.699362 671.152718 53.226095 697.372081 144.009658 833.586793 321.324993 952.55814 321.324993 952.55814 321.324993 952.55814 500.057592 828.783847 590.44747 689.104715L590.44747 689.104715 590.44747 689.104715ZM316.049626 635.012514C243.847955 635.012514 185.267755 578.164525 185.267755 508.010011 185.267755 437.855498 243.847955 381.007508 316.049626 381.007508 388.330033 381.007508 446.831496 437.855498 446.831496 508.010011 446.831496 578.164525 388.330033 635.012514 316.049626 635.012514L316.049626 635.012514 316.049626 635.012514ZM1165.619995 708.316501C841.696686 648.712722 904.607412 571.471894 904.607412 571.471894L839.177108 571.471894C804.13922 773.431857 1362.619537 699.497976 1145.463367 870.514365 953.266771 1021.925285 497.065592 889.01752 497.065592 889.01752L431.714025 952.55814C1161.131996 1191.603148 1417.420369 754.692492 1165.619995 708.316501L1165.619995 708.316501 1165.619995 708.316501Z" p-id="5279"></path></svg>
\ No newline at end of file
......@@ -114,8 +114,20 @@ const AccountSelector = (props) => {
const rowChange = (keys, rows) => {
setKeys(keys);
};
const rowClick = (row) => {
setKeys([row.ID]);
if (isMultiple) {
console.log(row.ID, keys, keys.includes(row.ID))
if (keys.includes(row.ID)) {
let values = keys.filter(v => v !== row.ID)
setKeys(values)
} else {
let values = [...keys, row.ID]
setKeys(values)
}
} else {
setKeys([row.ID]);
}
};
const onOk = () => {
......@@ -202,7 +214,7 @@ const AccountSelector = (props) => {
onClick: event => {
event.stopPropagation();
rowClick(record);
}, // 点击行
},
})}
pagination={{
total: params.total,
......
import React, { useState, useEffect, useRef } from 'react'
import { Input, Button } from 'antd'
import { CompassOutlined } from '@ant-design/icons'
import IconPack from '../../IconPack'
import {
ArcGISSceneMap,
AutoCompleteSearch,
Drawtool as drawTool,
Graphic,
GraphicsLayer,
Point,
geomUtils,
SimpleLineSymbol,
SimpleFillSymbol,
} from '@wisdom-map/arcgismap/lib'
import Drag from '../../../components/Drag'
import { isJson, isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
const DrawArea = (props) => {
const { token, client } = window.globalConfig
const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue, addressSync } = schema
const [visible, setVisible] = useState(false)
const [rings, setRings] = useState({})
const viewRef = useRef(null)
const layers = useRef(null)
const createPaths = (view) => {
setTimeout(() => {
if (isJson(value)) {
let layer = new Graphic({
geometry: geomUtils.toGeometry(rings),
symbol: new SimpleFillSymbol({
}),
})
layers.current = new GraphicsLayer()
layers.current.add(layer)
view.map.add(layers.current)
}
}, 2000)
}
const getView = (viewObject) => {
viewRef.current = viewObject
createPaths(viewObject)
}
const getPoints = (view) => {
if (view) {
view.map.remove(layers.current)
drawTool.activate({
view,
action: 'polygon',
target: 'erroSendUpWidget',// 随便写
toolTip: '左键选择位置',
drawEnd: geometry => {
setRings({ rings: geometry.rings })
let layer = new Graphic({
geometry: geometry,
symbol: new SimpleFillSymbol({
}),
})
layers.current = new GraphicsLayer()
layers.current.add(layer)
view.map.add(layers.current)
},
// rightClick: () => { getPoints(view, coordGetLayer) }
})
}
}
const start = () => {
getPoints(viewRef.current)
}
const showMap = () => {
setRings(isJson(value) ? JSON.parse(value) : '')
setVisible(true)
}
const onCancel = () => {
setVisible(false)
}
const onOk = () => {
onChange(JSON.stringify(rings))
setVisible(false)
}
useEffect(() => {
if (addons) {
addons.setValueByPath(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
return (
<div>
{
!disabled ?
<Input
disabled={disabled}
placeholder={placeholder}
value={value}
addonAfter={disabled ? null : <CompassOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} onClick={showMap} />}
style={{ width: '100%' }}
onClick={showMap}
/>
:
<Button
icon={<CompassOutlined style={{ color: value ? '#0092fe' : 'rgba(0, 0, 0, 0.25)' }} />}
onClick={() => {
if (value) {
showMap()
}
}}
>
{value ? '查看位置' : '无位置信息'}
</Button>
}
<Drag
width={'80%'}
title="选取坐标"
visible={visible}
onOk={onOk}
onCancel={onCancel}
cancelText={'取消'}
okText={'确定'}
bodyStyle={{ height: 600, overflowY: "auto", position: 'relative' }}
destroyOnClose={true}
{...disabled ? { footer: null } : {}}
>
<div style={{ height: '90%' }}>
<Button
style={{ position: 'absolute', zIndex: '99', right: '10px', top: '10px' }}
type='primary'
onClick={start}
>
开始绘制
</Button>
<ArcGISSceneMap
getMapInfo={getView}
widgets={[]}
token={token}
client={token ? client : 'sandbox'}
/>
</div>
</Drag >
</div >
)
}
export default DrawArea
\ No newline at end of file
import React, { useState, useEffect } from 'react'
import { Input, Button } from 'antd'
import { CompassOutlined } from '@ant-design/icons'
import IconPack from '../../IconPack'
import {
ArcGISSceneMap,
AutoCompleteSearch,
Drawtool as drawTool,
Graphic,
GraphicsLayer,
Point,
geomUtils,
} from '@wisdom-map/arcgismap/lib'
import Drag from '../../../components/Drag'
import { isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
const DrawPartition = (props) => {
const { token, client } = window.globalConfig
const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue, addressSync } = schema
const [layersConifg, setLayersConifg] = useState(() => {
const mapConfig = window.globalConfig.mapsettings?.layers || null
return { layers: mapConfig };
});
const [visible, setVisible] = useState(false)
const [initCoordinate, setInitCoordinate] = useState([])
const [currentPointerCoordinate, setCurrentPointerCoordinate] = useState([])
const [view, setView] = useState(null)
const getView = (viewObject) => {
if (viewObject) {
setView(viewObject);
let coordGetLayer = viewObject.map.layers.find(layer => layer.id == 'coordGet');
if (coordGetLayer) {
viewObject.map.remove(coordGetLayer);
} else {
coordGetLayer = new GraphicsLayer({
id: 'coordGet',
});
}
viewObject.map.add(coordGetLayer);
if (value) {
coordGetLayer.removeAll();
const newVal = value.split(',');
const defalutGraphic = createGraphic(new Point({
x: newVal[0],
y: newVal[1],
spatialReference: {
wkid: 3857
}
}));
coordGetLayer.add(defalutGraphic);
setTimeout(() => {
viewObject.goTo({
center: geomUtils.toGeometry({ x: Number(newVal[0]), y: Number(newVal[1]) }),
scale: viewObject.scale - 1,
})
}, 2000)
}
getPoints(viewObject, coordGetLayer);
}
}
const createGraphic = (geometry) => {
return new Graphic({
geometry: geometry,
symbol: {
type: "picture-marker", // autocasts as new PictureMarkerSymbol()
url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAhCAYAAAA2/OAtAAAACXBIWXMAAArrAAAK6wGCiw1aAAAGlmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4xLWMwMDAgNzkuZWRhMmIzZiwgMjAyMS8xMS8xNC0xMjozMDo0MiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOnBob3Rvc2hvcD0iaHR0cDovL25zLmFkb2JlLmNvbS9waG90b3Nob3AvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9i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ODntA8/1yH6hMUz8LpJqo1sUkBM+MOEJnaEioArOxpfWJkL9eM0JH0ije0C1jvA8sBbZ2tp2JeiQD9Ts9iL7kxhJjLTuq/rAYhXGO9ZjI/36C5J7gBbV4sOiD1zfVBk3nUJVQAyIB1hEPLS9bbAZr/SNAa5sqLQWeZI5RY2pn7vEMRsqAFekkPEM8Osh0WOpgzzYHaoqlFRuAcdNEFkHnCup4OC+zAKlOMpzQWSdAQgiew24XFbB1gcdxMox8O06p6X1pYCvHhB9JnWAtDdVqMIccLKedVuTHgVudAsD3j6ANWBTuQ1MBZFdafhb+m8Q2SJwtqJ7p1wHVoGXmoFtkTZF/I4Hr3sdqqGmUDXm/JvZk5eb3A5widO+PJxJDVQ2vvbQIGkrcUDVmGsXnn72lYrf9i26xEf3V+5E38Dmxo0j5ehVAV+JP6qGWWR1ZnT8zG/9A1tA1w7zE/c0VTWfjU8ur/T0XUyqyzvpzIWFo2MVVU3vsG5VXUuE5vP5Nedc5aPJqatbxhSbgVvGFD+cnFpwzqWbrNc5V3LOLebz+cqulROG4T9Hxx/rGVsvyeHKRs4hCPD7gw998N3g8B9N6d4Fbs3MzJTCMFSAjuUYhuFq7ang7+nlO6dQekRk7f3jU+9WxXiqWlbVn2dnZ5fCMGzp8Xtu65Hn/7jc3fv5kXL5zFJv38K65xtUi/Pz8zf3mttRFx8dmf4+4+kbk8dey+VyI/8J1lA2m03NDfR8m81mH/lfgA29N/pwbr9j77ctd/pn419SR9UArKBoRwAAAABJRU5ErkJggg==",
width: "20px",
height: "30px"
},
});
}
const getPoints = (view, coordGetLayer) => {
drawTool.activate({
view,
action: 'point',
target: 'erroSendUpWidget',// 随便写
toolTip: '左键选择位置',
drawEnd: geometry => {
setCurrentPointerCoordinate([geometry.x, geometry.y])
coordGetLayer && coordGetLayer.removeAll()
const coordGraphic = createGraphic(geometry)
coordGetLayer.add(coordGraphic)
getPoints(view, coordGetLayer)
},
rightClick: () => { getPoints(view, coordGetLayer) }
})
}
const showMap = () => {
setVisible(true)
}
const onCancel = () => {
setCurrentPointerCoordinate(initCoordinate)
setVisible(false)
}
const onOk = async () => {
if (addressSync) {
let paths = Object.keys(addons.formData)
let targetPath = null
if (Array.isArray(paths)) {
paths.forEach(v => {
let values = addons.getValue(v)
if (isObject(values)) {
for (let key in values) {
if (key === addressSync) {
targetPath = `${v}.${key}`
}
}
}
})
}
if (targetPath) {
let LngLat = mercatorToLngLat(currentPointerCoordinate[0], currentPointerCoordinate[1])
const { code, data } = await getLocation(LngLat.join(','))
if (Array.isArray(data) && data.length) {
const { pname, adname, name, address } = data[0]
addons.setValue(targetPath, `${pname}/${adname}/${name}`)
}
}
}
setVisible(false)
onChange(currentPointerCoordinate.join(','))
}
useEffect(() => {
if (value) {
let _temp = value && value.split(',') || []
setCurrentPointerCoordinate(_temp)
setInitCoordinate(_temp)
}
}, [value])
useEffect(() => {
if (addons) {
addons.setValueByPath(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
return (
<div>
{
!disabled ?
<Input
disabled={disabled}
placeholder={placeholder}
value={value}
addonAfter={disabled ? null : <CompassOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} onClick={showMap} />}
style={{ width: '100%' }}
onClick={showMap}
/>
:
<Button
icon={<CompassOutlined style={{ color: value ? '#0092fe' : 'rgba(0, 0, 0, 0.25)' }} />}
onClick={() => {
if (value) {
showMap()
}
}}
>
{value ? '查看位置' : '无位置信息'}
</Button>
}
<Drag
width={'80%'}
title="选取坐标"
visible={visible}
onOk={onOk}
onCancel={onCancel}
cancelText={'取消'}
okText={'确定'}
bodyStyle={{ height: 600, overflowY: "auto", position: 'relative' }}
destroyOnClose={true}
{...disabled ? { footer: null } : {}}
>
<div style={{ height: '90%' }}>
<ArcGISSceneMap
getMapInfo={getView}
widgets={[]}
token={token}
client={token ? client : 'sandbox'}
/>
{/* {
view ? <div style={{ width: '400px', position: 'absolute', right: '0', top: '25px' }}>
<AutoCompleteSearch areaName={getCityName()} view={view} />
</div> : ''
} */}
</div>
</Drag>
</div>
)
}
export default DrawPartition
\ No newline at end of file
import React, { useState, useEffect, useRef } from 'react'
import { Input, Button } from 'antd'
import { CompassOutlined } from '@ant-design/icons'
import IconPack from '../../IconPack'
import {
ArcGISSceneMap,
AutoCompleteSearch,
Drawtool as drawTool,
Graphic,
GraphicsLayer,
Point,
geomUtils,
SimpleLineSymbol,
} from '@wisdom-map/arcgismap/lib'
import Drag from '../../../components/Drag'
import { isJson, isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
const DrawPath = (props) => {
const { token, client } = window.globalConfig
const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue, addressSync } = schema
const [visible, setVisible] = useState(false)
const [paths, setPaths] = useState({})
const viewRef = useRef(null)
const layers = useRef(null)
const createPaths = (view) => {
setTimeout(() => {
if (isJson(value)) {
let layer = new Graphic({
geometry: geomUtils.toGeometry(paths),
symbol: new SimpleLineSymbol({
}),
})
layers.current = new GraphicsLayer()
layers.current.add(layer)
view.map.add(layers.current)
}
}, 2000)
}
const getView = (viewObject) => {
viewRef.current = viewObject
createPaths(viewObject)
}
const getPoints = (view) => {
if (view) {
view.map.remove(layers.current)
drawTool.activate({
view,
action: 'polyline',
target: 'erroSendUpWidget',// 随便写
toolTip: '左键选择位置',
drawEnd: geometry => {
setPaths({ paths: geometry.paths })
let layer = new Graphic({
geometry: geometry,
symbol: new SimpleLineSymbol({
}),
})
layers.current = new GraphicsLayer()
layers.current.add(layer)
view.map.add(layers.current)
},
// rightClick: () => { getPoints(view, coordGetLayer) }
})
}
}
const start = () => {
getPoints(viewRef.current)
}
const showMap = () => {
setPaths(isJson(value) ? JSON.parse(value) : '')
setVisible(true)
}
const onCancel = () => {
setVisible(false)
}
const onOk = () => {
onChange(JSON.stringify(paths))
setVisible(false)
}
useEffect(() => {
if (addons) {
addons.setValueByPath(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
return (
<div>
{
!disabled ?
<Input
disabled={disabled}
placeholder={placeholder}
value={value}
addonAfter={disabled ? null : <CompassOutlined style={{ color: 'rgba(0, 0, 0, 0.25)' }} onClick={showMap} />}
style={{ width: '100%' }}
onClick={showMap}
/>
:
<Button
icon={<CompassOutlined style={{ color: value ? '#0092fe' : 'rgba(0, 0, 0, 0.25)' }} />}
onClick={() => {
if (value) {
showMap()
}
}}
>
{value ? '查看位置' : '无位置信息'}
</Button>
}
<Drag
width={'80%'}
title="选取坐标"
visible={visible}
onOk={onOk}
onCancel={onCancel}
cancelText={'取消'}
okText={'确定'}
bodyStyle={{ height: 600, overflowY: "auto", position: 'relative' }}
destroyOnClose={true}
{...disabled ? { footer: null } : {}}
>
<div style={{ height: '90%' }}>
<Button
style={{ position: 'absolute', zIndex: '99', right: '10px', top: '10px' }}
type='primary'
onClick={start}
>
开始绘制
</Button>
<ArcGISSceneMap
getMapInfo={getView}
widgets={[]}
token={token}
client={token ? client : 'sandbox'}
/>
</div>
</Drag >
</div >
)
}
export default DrawPath
\ No newline at end of file
import Coordinate from './Coordinate'
import Device from './Device'
import DrawPartition from './DrawPartition'
import DrawPath from './DrawPath'
import DrawArea from './DrawArea'
import SearchLocation from './SearchLocation'
const coord = {
Coordinate,
DrawPartition,
DrawPath,
DrawArea,
Device,
SearchLocation,
}
......
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