Commit fc315212 authored by 田翔's avatar 田翔

fix: 搜索地址代码优化

parent 954473c5
{
"name": "panda-xform",
"version": "6.0.20",
"description": "6.0.20 手写签名支持电子签章",
"version": "6.0.21",
"description": "6.0.21 搜索地址代码优化",
"keywords": [
"panda-xform"
],
......
import React, { useState, useEffect, useCallback } from 'react'
import { Input, message, Popover } from 'antd'
import { Input, AutoComplete, message, Popover, Select } from 'antd'
import { searchAdress } from '../../../../apis/process'
import { debounce, lngmkt, isObject } from '../../../../utils/index'
......@@ -19,19 +19,18 @@ const SearchLocation = (props) => {
}
}
// const doSomeThing = useCallback(debounce(getAdress), [])
const onSearch = async (value) => {
getAdress(value)
}
const inputChange = (e) => {
onChange(e.target.value)
const handleSearch = (value) => {
onChange(value)
}
const selectChange = (item) => {
if (item.location) {
let array = item.location.split(',')
const onSelect = (value) => {
let location = options.find(v => v.name === value)?.location
if (location) {
let array = location.split(',')
let coord = lngmkt({ lng: array[0], lat: array[1] })
if (coordSync) {
let paths = Object.keys(addons.formData)
......@@ -53,7 +52,7 @@ const SearchLocation = (props) => {
}
}
}
onChange(item.name)
onChange(value)
}
useEffect(() => {
......@@ -62,26 +61,20 @@ const SearchLocation = (props) => {
}
}, [presetValue])
const content = (
<div>
{
(options || []).map((v, i) => <p key={i} onClick={() => selectChange(v)}><a>{v.name}</a></p>)
}
</div>
)
return (
<div>
<Popover content={content} title="地名选择" trigger="hover" placement="topLeft">
<Input.Search
disabled={disabled}
placeholder={disabled ? (placeholder || '') : (placeholder || '请输入地址点击搜索或者回车')}
value={value}
onSearch={onSearch}
onChange={inputChange}
/>
</Popover>
</div>
<AutoComplete
style={{ width: '100%' }}
options={(options || []).map(v => ({ label: v.name, value: v.name }))}
onSelect={onSelect}
onSearch={handleSearch}
>
<Input.Search
value={value}
placeholder={disabled ? (placeholder || '') : (placeholder || '请输入地址点击搜索或者回车')}
enterButton
onSearch={onSearch}
/>
</AutoComplete>
)
}
......
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