Commit 702768d5 authored by 田翔's avatar 田翔

fix: 位置坐标控件未显示值问题

parent c2d67f10
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "2.4.4", "version": "2.4.5",
"description": "2.4.4: 台账选择器增加SQL报错问题", "description": "2.4.5: 位置坐标控件未显示值问题",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -12,25 +12,24 @@ import { ...@@ -12,25 +12,24 @@ import {
import { GlobalStore } from '../../../FormRender' import { GlobalStore } from '../../../FormRender'
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag'
const Coordinate = ({ value, onChange, name, schema }) => { const Coordinate = (props) => {
const { disabled, placeholder } = schema const { value, onChange, schema, addons } = props
// const { extraData, setExtraData } = useContext(GlobalStore) const { disabled, placeholder, presetValue } = schema
const [coordinate, setCoordinate] = useState('') const [coordinate, setCoordinate] = useState('')
const [layersConifg, setLayersConifg] = useState(() => { const [layersConifg, setLayersConifg] = useState(() => {
const mapConfig = window.globalConfig.mapsettings?.layers || null const mapConfig = window.globalConfig.mapsettings?.layers || null
return { layers: mapConfig }; return { layers: mapConfig };
}); });
const mapSettings = window.globalConfig?.mapsettings; const mapSettings = window.globalConfig?.mapsettings
const layers = window.globalConfig?.mapsettings?.layers; const layers = window.globalConfig?.mapsettings?.layers
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false)
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false)
const [currentPointer, setCurrentPointer] = useState([]); const [currentPointer, setCurrentPointer] = useState([])
const [initCoordinate, setInitCoordinate] = useState([]); const [initCoordinate, setInitCoordinate] = useState([])
const [currentPointerCoordinate, setCurrentPointerCoordinate] = useState([]); const [currentPointerCoordinate, setCurrentPointerCoordinate] = useState([])
const [view, setView] = useState(null); const [view, setView] = useState(null)
const [coordGetLayers, setCoordGetLayers] = useState(null); const [coordGetLayers, setCoordGetLayers] = useState(null)
let _temp = [];
const getView = (viewObject) => { const getView = (viewObject) => {
if (viewObject) { if (viewObject) {
...@@ -72,7 +71,7 @@ const Coordinate = ({ value, onChange, name, schema }) => { ...@@ -72,7 +71,7 @@ const Coordinate = ({ value, onChange, name, schema }) => {
} }
, ,
}); });
}; }
const getPoints = (view, coordGetLayer) => { const getPoints = (view, coordGetLayer) => {
drawTool.activate({ drawTool.activate({
...@@ -90,27 +89,39 @@ const Coordinate = ({ value, onChange, name, schema }) => { ...@@ -90,27 +89,39 @@ const Coordinate = ({ value, onChange, name, schema }) => {
}, },
rightClick: () => { getPoints(view, coordGetLayer); } rightClick: () => { getPoints(view, coordGetLayer); }
}); });
}; }
const showMap = () => { const showMap = () => {
if (!schema.disabled) { if (!schema.disabled) {
setVisible(true); setVisible(true);
} }
}; }
const onCancel = () => { const onCancel = () => {
setCurrentPointerCoordinate(initCoordinate); setCurrentPointerCoordinate(initCoordinate);
setVisible(false); setVisible(false);
}; }
const onOk = () => { const onOk = () => {
setVisible(false); setVisible(false);
onChange(currentPointerCoordinate.join(',')); onChange(currentPointerCoordinate.join(','))
}; }
useEffect(() => { useEffect(() => {
if (value) { if (value) {
let _temp = value && value.split(',') || []; let _temp = value && value.split(',') || []
setCurrentPointerCoordinate(_temp); setCurrentPointerCoordinate(_temp)
setInitCoordinate(_temp); setInitCoordinate(_temp)
} }
}, [value]); }, [value])
useEffect(() => {
if (addons) {
addons.setValueByPath(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
const getCityName = () => { const getCityName = () => {
let cityName = '中华人民共和国'; let cityName = '中华人民共和国';
...@@ -153,8 +164,11 @@ const Coordinate = ({ value, onChange, name, schema }) => { ...@@ -153,8 +164,11 @@ const Coordinate = ({ value, onChange, name, schema }) => {
widgets={[]} widgets={[]}
config={layersConifg} config={layersConifg}
/> />
{view ? <div style={{ width: '400px', position: 'absolute', right: '0', top: '25px' }}><AutoCompleteSearch {
areaName={getCityName()} view={view} /></div> : ''} view ? <div style={{ width: '400px', position: 'absolute', right: '0', top: '25px' }}>
<AutoCompleteSearch areaName={getCityName()} view={view} />
</div> : ''
}
</div> </div>
</Drag> </Drag>
</div> </div>
......
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