Commit 4c871552 authored by 田翔's avatar 田翔

fix: 支持坐标与地名互相同步,附件bug

parent 48c08342
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "4.6.4", "version": "4.6.5",
"description": "4.6.4 将站点id转化为字符串", "description": "4.6.5 支持坐标与地名互相同步,附件bug'修复",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -746,6 +746,12 @@ const textWidgets = [ ...@@ -746,6 +746,12 @@ const textWidgets = [
description: '所有形态默认显示', description: '所有形态默认显示',
widget: 'HiddenCondition' widget: 'HiddenCondition'
}, },
coordSync: {
title: '坐标同步',
type: 'string',
widget: 'CoordSync',
description: '坐标信息将会同步到下方字段中'
},
required: { required: {
title: '必填', title: '必填',
type: 'boolean', type: 'boolean',
...@@ -2028,6 +2034,7 @@ const fileWidgets = [ ...@@ -2028,6 +2034,7 @@ const fileWidgets = [
type: 'string', type: 'string',
widget: 'FileUpload', widget: 'FileUpload',
width: '100%', width: '100%',
preview: true,
}, },
setting: { setting: {
widget: { widget: {
......
...@@ -61,7 +61,7 @@ const FileUpload = (props) => { ...@@ -61,7 +61,7 @@ const FileUpload = (props) => {
const { value, schema, onChange } = props const { value, schema, onChange } = props
const { disabled, fileType, presetValue, placeholder, preview, download } = schema const { disabled, fileType, presetValue, placeholder, preview, download } = schema
const [showList, setShowList] = useState('') const [showList, setShowList] = useState([])
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [showFile, setShowFile] = useState({ fileType: '', filePath: '' }) const [showFile, setShowFile] = useState({ fileType: '', filePath: '' })
...@@ -110,13 +110,13 @@ const FileUpload = (props) => { ...@@ -110,13 +110,13 @@ const FileUpload = (props) => {
message.error('上传失败!') message.error('上传失败!')
} }
if (Array.isArray(fileList)) { if (Array.isArray(fileList)) {
let list = fileList.map(v => v.sourcePath || v.value) setShowList(fileList)
onChange(list.join(','))
setShowList(JSON.stringify(fileList))
} else { } else {
onChange('')
setShowList() setShowList()
} }
if (file.status === 'done') {
onChange(fileList.map(v => v.sourcePath).join(','))
}
}, },
onPreview: (file) => { onPreview: (file) => {
if (!preview) return message.info('该附件禁止预览') if (!preview) return message.info('该附件禁止预览')
...@@ -142,16 +142,10 @@ const FileUpload = (props) => { ...@@ -142,16 +142,10 @@ const FileUpload = (props) => {
return <FileOutlined /> return <FileOutlined />
} }
useEffect(() => { const valueToList = (presetValue) => {
if (presetValue && !presetValue.includes('拍照相册')) { let fileList = []
onChange(presetValue) if (presetValue) {
} let list = presetValue ? presetValue.split(',') : []
}, [presetValue])
useEffect(() => {
if (value) {
let fileList = []
let list = value ? value.split(',') : []
list.forEach((item, index) => { list.forEach((item, index) => {
if (item) { // @Tips: 直接过滤掉名字中有异常字符的文件 if (item) { // @Tips: 直接过滤掉名字中有异常字符的文件
let uid = index + '_' + Math.random() let uid = index + '_' + Math.random()
...@@ -171,16 +165,23 @@ const FileUpload = (props) => { ...@@ -171,16 +165,23 @@ const FileUpload = (props) => {
fileList.push(_obj); fileList.push(_obj);
} }
}) })
setShowList(JSON.stringify(fileList))
} }
}, [value]) return fileList
}
useEffect(() => {
if (presetValue && !presetValue.includes('拍照相册')) {
addons?.setValueByPath(addons.dataPath, presetValue || '')
setShowList(valueToList(presetValue))
}
}, [presetValue])
return ( return (
<div className={styles.uploadBox}> <div className={styles.uploadBox}>
<Upload <Upload
disabled={disabled} disabled={disabled}
accept={accepts[fileType]} accept={accepts[fileType]}
fileList={showList ? JSON.parse(showList) : []} fileList={showList}
className="upload-list-inline" className="upload-list-inline"
iconRender={iconRender} iconRender={iconRender}
{...option} {...option}
......
import React, { useState } from 'react'
import { Select, message } from 'antd'
import { ReloadTableFields } from '../../../../../apis/process'
const CoordSync = (props) => {
const { value, onChange, schema, addons } = props
const { tableNameParent } = addons.formData
const [options, setOptions] = useState([])
const onFocus = 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 } })
setOptions(result)
} else {
message.error(msg)
}
}
const selectChange = (value) => {
onChange(value)
}
return (
<Select
style={{ width: '100%' }}
options={options}
value={value}
onFocus={onFocus}
onChange={selectChange}
>
</Select>
)
}
export default CoordSync
\ No newline at end of file
...@@ -10,6 +10,7 @@ import FieldList from './FieldList' ...@@ -10,6 +10,7 @@ import FieldList from './FieldList'
import FieldName from './FieldName' import FieldName from './FieldName'
import CalculateRule from './CalculateRule' import CalculateRule from './CalculateRule'
import AddressSync from './AddressSync' import AddressSync from './AddressSync'
import CoordSync from './CoordSync'
import SimpleList from './SimpleList' import SimpleList from './SimpleList'
import SqlFilter from './SqlFilter' import SqlFilter from './SqlFilter'
...@@ -26,6 +27,7 @@ const groupSource = { ...@@ -26,6 +27,7 @@ const groupSource = {
FieldName, FieldName,
CalculateRule, CalculateRule,
AddressSync, AddressSync,
CoordSync,
SimpleList, SimpleList,
SqlFilter, SqlFilter,
} }
......
import React, { useState, useEffect, useCallback } from 'react' import React, { useState, useEffect, useCallback } from 'react'
import { Input, message, Popover } from 'antd' import { Input, message, Popover } from 'antd'
import { searchAdress } from '../../../../apis/process' import { searchAdress } from '../../../../apis/process'
import { debounce } from '../../../../utils/index' import { debounce, lngmkt, isObject } from '../../../../utils/index'
const SearchLocation = (props) => { const SearchLocation = (props) => {
const areaName = window?.globalConfig?.mapsettings?.areasettings?.areaName || '' const areaName = window?.globalConfig?.mapsettings?.areasettings?.areaName || ''
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue } = schema const { disabled, placeholder, presetValue, coordSync } = schema
const [options, setOptions] = useState([]) const [options, setOptions] = useState([])
const getAdress = async (value) => { const getAdress = async (value) => {
...@@ -26,6 +26,34 @@ const SearchLocation = (props) => { ...@@ -26,6 +26,34 @@ const SearchLocation = (props) => {
onChange(e.target.value) onChange(e.target.value)
} }
const selectChange = (item) => {
if (item.location) {
let array = item.location.split(',')
let coord = lngmkt({ lng: array[0], lat: array[1] })
if (coordSync) {
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 === coordSync) {
targetPath = `${v}.${key}`
}
}
}
})
}
// console.log(targetPath, coord)
if (targetPath) {
addons.setValue(targetPath, `${coord.x},${coord.y}`)
}
}
}
onChange(item.name)
}
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
addons.setValue(addons.dataPath, presetValue || '') addons.setValue(addons.dataPath, presetValue || '')
...@@ -35,7 +63,7 @@ const SearchLocation = (props) => { ...@@ -35,7 +63,7 @@ const SearchLocation = (props) => {
const content = ( const content = (
<div> <div>
{ {
(options || []).map(v => <p key={v.name} onClick={() => onChange(v.name)}><a>{v.name}</a></p>) (options || []).map((v, i) => <p key={i} onClick={() => selectChange(v)}><a>{v.name}</a></p>)
} }
</div> </div>
) )
......
...@@ -85,6 +85,12 @@ export function parseSQL2JSON(str) { ...@@ -85,6 +85,12 @@ export function parseSQL2JSON(str) {
}; };
} }
/**
* @description 墨卡托转经纬度
* @param {*} x
* @param {*} y
* @returns
*/
export const mercatorToLngLat = (x, y) => { export const mercatorToLngLat = (x, y) => {
const EARTH_RAD = 6378137 const EARTH_RAD = 6378137
const radToAngle = (rad) => { const radToAngle = (rad) => {
...@@ -95,6 +101,21 @@ export const mercatorToLngLat = (x, y) => { ...@@ -95,6 +101,21 @@ export const mercatorToLngLat = (x, y) => {
return [lng, lat] return [lng, lat]
} }
/**
* @description 经纬度转墨卡托
* @param {*} x
* @param {*} y
* @returns
*/
export const lngmkt = (poi) => {
var mercator = {};
var earthRad = 6378137.0;
mercator.x = ((poi.lng * Math.PI) / 180) * earthRad;
var a = (poi.lat * Math.PI) / 180;
mercator.y = (earthRad / 2) * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a)));
return mercator; //[12727039.383734727, 3579066.6894065146
};
//判断是否为JSON字符串 //判断是否为JSON字符串
export const isJson = (json) => { export const isJson = (json) => {
if (typeof json === 'string') { if (typeof json === 'string') {
......
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