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

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

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