Commit ca0f3eb9 authored by 田翔's avatar 田翔

fix: 搜索地址改为回车搜素

parent e7bf77e8
{
"name": "panda-xform",
"version": "6.0.13",
"description": "6.0.13 解决防止搜索已选数据失效问题",
"version": "6.0.14",
"description": "6.0.14 搜索地址改为回车搜素",
"keywords": [
"panda-xform"
],
......
......@@ -505,6 +505,39 @@ export function getLocation(location) {
})
}
//根据坐标点获取地名
export function getLocationV5(location) {
return request({
// headers: {
// 'Civ-Site': window?.globalConfig?.userInfo?.site
// },
url: `/pandagis/mapserver/Tool/PlaceAroundV5?key=6e0b74fa6de65506b360e2e801f8582f&location=${location}`,
method: 'get'
})
}
//获取分区类型
export function GetAreaSourceType() {
return request({
// headers: {
// 'Civ-Site': window?.globalConfig?.userInfo?.site
// },
url: `PandaWorkFlow/WorkFlow/PatrolInspection/GetAreaSourceType`,
method: 'get'
})
}
//根据坐标获取分区名称
export function GetAreaNameByCoordinate({ sourceType, x, y }) {
return request({
// headers: {
// 'Civ-Site': window?.globalConfig?.userInfo?.site
// },
url: `PandaWorkFlow/WorkFlow/PatrolInspection/GetAreaNameByCoordinate?sourceType=${sourceType}&x=${x}&y=${y}`,
method: 'get'
})
}
//模糊搜索地名
export function searchAdress({ keywords, region }) {
return request({
......
......@@ -2092,6 +2092,12 @@ const mapWidgets = [
default: false,
description: '只读情况下会显示缩略图'
},
areaSync: {
title: '区域同步',
type: 'string',
widget: 'AreaSync',
description: '坐标对应最小区域会同步到下方字段中',
},
required: {
title: '必填',
type: 'boolean',
......
......@@ -12,14 +12,22 @@ import {
} from '@wisdom-map/arcgismap'
import Drag from '../../../components/Drag'
import { isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
import { getLocation, getLocationV5, GetAreaNameByCoordinate } from '../../../../apis/process'
import styles from './index.less'
const Coordinate = (props) => {
const { token, client, uiwidgets } = window.globalConfig
const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue, addressSync, screenShot } = schema
const {
disabled,
presetValue,
placeholder,
addressSync,
screenShot,
areaSync,
areaSyncField,
} = schema
const [layersConifg, setLayersConifg] = useState(() => {
const mapConfig = window.globalConfig.mapsettings?.layers || null
return { layers: mapConfig };
......@@ -139,28 +147,46 @@ const Coordinate = (props) => {
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}`
}
const getTargetPath = (value) => {
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 === value) {
targetPath = `${v}.${key}`
}
}
})
}
}
})
}
return targetPath
}
const onOk = async () => {
if (addressSync) {
let targetPath = getTargetPath(addressSync)
if (targetPath) {
let LngLat = mercatorToLngLat(currentPointerCoordinate[0], currentPointerCoordinate[1])
const { code, data } = await getLocation(LngLat.join(','))
if (Array.isArray(data) && data.length) {
const { code, data } = await getLocationV5(LngLat.join(','))
if (code === '0' && Array.isArray(data) && data.length) {
const { pname, adname, name, address } = data[0]
addons.setValue(targetPath, `${pname}/${adname}/${name}`)
} else {
const { code, data } = await getLocation(LngLat.join(','))
const { pname, adname, name, address } = data[0]
addons.setValue(targetPath, `${pname}/${adname}/${name}`)
}
}
}
if (areaSync && areaSyncField) {
let targetPath = getTargetPath(areaSyncField)
if (targetPath) {
const { code, data } = await GetAreaNameByCoordinate({ sourceType: areaSync, x: Number(currentPointerCoordinate[0]), y: Number(currentPointerCoordinate[1]) })
if (code === 0 && data) {
addons.setValue(targetPath, data)
}
}
}
......@@ -168,13 +194,16 @@ const Coordinate = (props) => {
onChange(currentPointerCoordinate.join(','))
}
const getAddress = async (presetValue) => {
if (presetValue) {
let coordinate = presetValue.split(',')
let LngLat = mercatorToLngLat(coordinate[0], coordinate[1])
const { code, data } = await getLocation(LngLat.join(','))
if (Array.isArray(data) && data.length) {
const { code, data } = await getLocationV5(LngLat.join(','))
if (code === '0' && Array.isArray(data) && data.length) {
const { pname, adname, name, address } = data[0]
setText(`${pname}/${adname}/${name}`)
} else {
const { code, data } = await getLocation(LngLat.join(','))
const { pname, adname, name, address } = data[0]
setText(`${pname}/${adname}/${name}`)
}
......
......@@ -15,7 +15,6 @@ import {
} from '@wisdom-map/arcgismap'
import Drag from '../../../components/Drag'
import { isJson, isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
const DrawArea = (props) => {
......
......@@ -14,7 +14,6 @@ import {
} from '@wisdom-map/arcgismap'
import Drag from '../../../components/Drag'
import { isJson, isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
const DrawPath = (props) => {
......
import React, { useEffect, useState } from 'react'
import { Select } from 'antd'
import styles from './index.less'
import { GetAreaSourceType, ReloadTableFields } from '../../../../../apis/process'
const AreaOption = [
{ label: '管网巡检', value: '管网巡检' },
{ label: 'DMA分区', value: 'DMA分区' },
{ label: 'DMA检漏', value: 'DMA检漏' },
{ label: 'DMA报警', value: 'DMA报警' },
]
const AreaSync = (props) => {
const { value, onChange, schema, addons } = props
const { tableNameParent } = addons.formData
const [AreaOption, setAreaOption] = useState([])
const [fieldOption, setFieldOption] = useState([])
const [fieldValue, setFieldValue] = useState('')
const AreaFocus = async () => {
const { code, data } = await GetAreaSourceType()
if (code === 0) {
setAreaOption(data.map(v => ({ label: v, value: v })))
}
}
const fieldFocus = async () => {
if (!tableNameParent) {
return message.info('请选择表名!')
}
const { code, data, msg } = await ReloadTableFields({ tableName: tableNameParent })
if (code === 0) {
let result = data.root.map(v => { return { label: v.name, value: v.name } })
setFieldOption(result)
} else {
message.error(msg)
}
}
const fieldChange = (value) => {
addons.setValueByPath('areaSyncField', value)
setFieldValue(value)
}
useEffect(() => {
setFieldValue(addons?.getValue('areaSyncField') || '')
}, [])
return (
<div className={styles.AreaSync}>
<Select
style={{ width: 110, marginRight: 10 }}
onFocus={AreaFocus}
options={AreaOption}
value={value}
allowClear
placeholder='请选择区域来源'
onChange={value => onChange(value)}
/>
<Select
style={{ width: 170 }}
placeholder='请选择数据回填字段'
value={fieldValue}
onFocus={fieldFocus}
options={fieldOption}
onChange={fieldChange}
allowClear
/>
</div>
)
}
export default AreaSync
\ No newline at end of file
.AreaSync {
width: 100%;
display: flex;
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import SimpleList from './SimpleList'
import SqlFilter from './SqlFilter'
import OtherSource from './OtherSource'
import TemplateFile from './TemplateFile'
import AreaSync from './AreaSync'
const groupSource = {
Dictionary,
......@@ -31,6 +32,7 @@ const groupSource = {
FieldName,
CalculateRule,
AddressSync,
AreaSync,
CoordSync,
SimpleList,
SqlFilter,
......
......@@ -19,10 +19,13 @@ const SearchLocation = (props) => {
}
}
const doSomeThing = useCallback(debounce(getAdress), [])
// const doSomeThing = useCallback(debounce(getAdress), [])
const onSearch = async (e) => {
doSomeThing(e.target.value)
const onSearch = async (value) => {
getAdress(value)
}
const inputChange = (e) => {
onChange(e.target.value)
}
......@@ -70,11 +73,12 @@ const SearchLocation = (props) => {
return (
<div>
<Popover content={content} title="地名选择" trigger="hover" placement="topLeft">
<Input
<Input.Search
disabled={disabled}
placeholder={disabled ? (placeholder || '') : (placeholder || '请输入地址')}
placeholder={disabled ? (placeholder || '') : (placeholder || '请输入地址点击搜索或者回车')}
value={value}
onChange={onSearch}
onSearch={onSearch}
onChange={inputChange}
/>
</Popover>
</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