Commit ca0f3eb9 authored by 田翔's avatar 田翔

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

parent e7bf77e8
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "6.0.13", "version": "6.0.14",
"description": "6.0.13 解决防止搜索已选数据失效问题", "description": "6.0.14 搜索地址改为回车搜素",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -505,6 +505,39 @@ export function getLocation(location) { ...@@ -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 }) { export function searchAdress({ keywords, region }) {
return request({ return request({
......
...@@ -2092,6 +2092,12 @@ const mapWidgets = [ ...@@ -2092,6 +2092,12 @@ const mapWidgets = [
default: false, default: false,
description: '只读情况下会显示缩略图' description: '只读情况下会显示缩略图'
}, },
areaSync: {
title: '区域同步',
type: 'string',
widget: 'AreaSync',
description: '坐标对应最小区域会同步到下方字段中',
},
required: { required: {
title: '必填', title: '必填',
type: 'boolean', type: 'boolean',
......
...@@ -12,14 +12,22 @@ import { ...@@ -12,14 +12,22 @@ import {
} from '@wisdom-map/arcgismap' } from '@wisdom-map/arcgismap'
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag'
import { isObject, mercatorToLngLat } from '../../../../utils' import { isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process' import { getLocation, getLocationV5, GetAreaNameByCoordinate } from '../../../../apis/process'
import styles from './index.less' import styles from './index.less'
const Coordinate = (props) => { const Coordinate = (props) => {
const { token, client, uiwidgets } = window.globalConfig const { token, client, uiwidgets } = window.globalConfig
const { value, onChange, schema, addons } = props 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 [layersConifg, setLayersConifg] = useState(() => {
const mapConfig = window.globalConfig.mapsettings?.layers || null const mapConfig = window.globalConfig.mapsettings?.layers || null
return { layers: mapConfig }; return { layers: mapConfig };
...@@ -139,8 +147,7 @@ const Coordinate = (props) => { ...@@ -139,8 +147,7 @@ const Coordinate = (props) => {
setVisible(false) setVisible(false)
} }
const onOk = async () => { const getTargetPath = (value) => {
if (addressSync) {
let paths = Object.keys(addons.formData) let paths = Object.keys(addons.formData)
let targetPath = null let targetPath = null
if (Array.isArray(paths)) { if (Array.isArray(paths)) {
...@@ -148,33 +155,55 @@ const Coordinate = (props) => { ...@@ -148,33 +155,55 @@ const Coordinate = (props) => {
let values = addons.getValue(v) let values = addons.getValue(v)
if (isObject(values)) { if (isObject(values)) {
for (let key in values) { for (let key in values) {
if (key === addressSync) { if (key === value) {
targetPath = `${v}.${key}` targetPath = `${v}.${key}`
} }
} }
} }
}) })
} }
return targetPath
}
const onOk = async () => {
if (addressSync) {
let targetPath = getTargetPath(addressSync)
if (targetPath) { if (targetPath) {
let LngLat = mercatorToLngLat(currentPointerCoordinate[0], currentPointerCoordinate[1]) let LngLat = mercatorToLngLat(currentPointerCoordinate[0], currentPointerCoordinate[1])
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 { code, data } = await getLocation(LngLat.join(','))
if (Array.isArray(data) && data.length) {
const { pname, adname, name, address } = data[0] const { pname, adname, name, address } = data[0]
addons.setValue(targetPath, `${pname}/${adname}/${name}`) 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)
}
}
}
setVisible(false) setVisible(false)
onChange(currentPointerCoordinate.join(',')) onChange(currentPointerCoordinate.join(','))
} }
const getAddress = async (presetValue) => { const getAddress = async (presetValue) => {
if (presetValue) { if (presetValue) {
let coordinate = presetValue.split(',') let coordinate = presetValue.split(',')
let LngLat = mercatorToLngLat(coordinate[0], coordinate[1]) let LngLat = mercatorToLngLat(coordinate[0], coordinate[1])
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 { code, data } = await getLocation(LngLat.join(','))
if (Array.isArray(data) && data.length) {
const { pname, adname, name, address } = data[0] const { pname, adname, name, address } = data[0]
setText(`${pname}/${adname}/${name}`) setText(`${pname}/${adname}/${name}`)
} }
......
...@@ -15,7 +15,6 @@ import { ...@@ -15,7 +15,6 @@ import {
} from '@wisdom-map/arcgismap' } from '@wisdom-map/arcgismap'
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag'
import { isJson, isObject, mercatorToLngLat } from '../../../../utils' import { isJson, isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
const DrawArea = (props) => { const DrawArea = (props) => {
......
...@@ -14,7 +14,6 @@ import { ...@@ -14,7 +14,6 @@ import {
} from '@wisdom-map/arcgismap' } from '@wisdom-map/arcgismap'
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag'
import { isJson, isObject, mercatorToLngLat } from '../../../../utils' import { isJson, isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
const DrawPath = (props) => { 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' ...@@ -16,6 +16,7 @@ import SimpleList from './SimpleList'
import SqlFilter from './SqlFilter' import SqlFilter from './SqlFilter'
import OtherSource from './OtherSource' import OtherSource from './OtherSource'
import TemplateFile from './TemplateFile' import TemplateFile from './TemplateFile'
import AreaSync from './AreaSync'
const groupSource = { const groupSource = {
Dictionary, Dictionary,
...@@ -31,6 +32,7 @@ const groupSource = { ...@@ -31,6 +32,7 @@ const groupSource = {
FieldName, FieldName,
CalculateRule, CalculateRule,
AddressSync, AddressSync,
AreaSync,
CoordSync, CoordSync,
SimpleList, SimpleList,
SqlFilter, SqlFilter,
......
...@@ -19,10 +19,13 @@ const SearchLocation = (props) => { ...@@ -19,10 +19,13 @@ const SearchLocation = (props) => {
} }
} }
const doSomeThing = useCallback(debounce(getAdress), []) // const doSomeThing = useCallback(debounce(getAdress), [])
const onSearch = async (e) => { const onSearch = async (value) => {
doSomeThing(e.target.value) getAdress(value)
}
const inputChange = (e) => {
onChange(e.target.value) onChange(e.target.value)
} }
...@@ -70,11 +73,12 @@ const SearchLocation = (props) => { ...@@ -70,11 +73,12 @@ const SearchLocation = (props) => {
return ( return (
<div> <div>
<Popover content={content} title="地名选择" trigger="hover" placement="topLeft"> <Popover content={content} title="地名选择" trigger="hover" placement="topLeft">
<Input <Input.Search
disabled={disabled} disabled={disabled}
placeholder={disabled ? (placeholder || '') : (placeholder || '请输入地址')} placeholder={disabled ? (placeholder || '') : (placeholder || '请输入地址点击搜索或者回车')}
value={value} value={value}
onChange={onSearch} onSearch={onSearch}
onChange={inputChange}
/> />
</Popover> </Popover>
</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