Commit cfbce225 authored by 田翔's avatar 田翔

fix: 时间传参问题,数值校验问题

parent f7161fb7
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "2.9.3", "version": "2.9.4",
"description": "2.9.3: 地图坐标增加地址同步功能", "description": "2.9.4: 时间传参问题,数值校验问题",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -308,6 +308,13 @@ export function QueryAddFields(accountName) { ...@@ -308,6 +308,13 @@ export function QueryAddFields(accountName) {
}) })
} }
export function getLocation(location) {
return request({
url: `/pandagis/mapserver/Tool/PlaceAround?key=6e0b74fa6de65506b360e2e801f8582f&location=${location}`,
method: 'get'
})
}
//获取表字段 //获取表字段
export function LoadTableFields(paramas) { export function LoadTableFields(paramas) {
return request({ return request({
......
...@@ -404,11 +404,30 @@ const textWidgets = [ ...@@ -404,11 +404,30 @@ const textWidgets = [
description: '所有形态默认显示', description: '所有形态默认显示',
widget: 'HiddenCondition' widget: 'HiddenCondition'
}, },
rules: {
title: '正则校验',
type: 'array',
default: [
{
name: 'number',
pattern: '^[+-]?[0-9]+([.][0-9]+)?$',
message: '数值校验未通过!',
}
],
widget: 'VerifyNumberInput',
disabled: disabled,
dependencies: ['tableTypeParent', 'IsSystemField'],
},
presetValue: { presetValue: {
title: '默认值', title: '默认值',
type: 'string', type: 'string',
widget: 'NumerDefault', widget: 'NumerDefault',
}, },
calculateRule: {
title: '计算规则',
type: 'string',
widget: 'CalculateRule',
},
required: { required: {
title: '必填', title: '必填',
type: 'boolean', type: 'boolean',
...@@ -429,11 +448,6 @@ const textWidgets = [ ...@@ -429,11 +448,6 @@ const textWidgets = [
hidden: '{{Boolean(formData.calculateRule)}}', hidden: '{{Boolean(formData.calculateRule)}}',
dependencies: ['calculateRule'] dependencies: ['calculateRule']
}, },
calculateRule: {
title: '计算规则',
type: 'string',
widget: 'CalculateRule',
},
prefix: { prefix: {
title: '前缀', title: '前缀',
type: 'string', type: 'string',
......
...@@ -62,7 +62,13 @@ const XRender = (props, ref) => { ...@@ -62,7 +62,13 @@ const XRender = (props, ref) => {
if (disabledField) { if (disabledField) {
required = false required = false
} }
childObj[s] = { ...child[s], presetValue: value || child[s].presetValue, disabled: disabledField, required } childObj[s] = {
...child[s],
presetValue: value || child[s].presetValue,
textInputDefalut: child[s].presetValue,
disabled: disabledField,
required
}
} }
} }
if (JSON.stringify(childObj) !== '{}') { if (JSON.stringify(childObj) !== '{}') {
...@@ -70,7 +76,12 @@ const XRender = (props, ref) => { ...@@ -70,7 +76,12 @@ const XRender = (props, ref) => {
} }
} }
} }
return { ...schemaForm, properties: parentObj } let json = {
...schemaForm,
displayType: schemaForm.displayType === 'column' ? 'column' : 'row',//未知原因出现存储'左右'/'上下'
properties: parentObj
}
return json
}, [formJson, values, disabledFields, disabled]) }, [formJson, values, disabledFields, disabled])
const watch = useMemo(() => { const watch = useMemo(() => {
......
...@@ -11,12 +11,14 @@ import { ...@@ -11,12 +11,14 @@ import {
Point Point
} from '@wisdom-map/arcgismap' } from '@wisdom-map/arcgismap'
import Drag from '../../../components/Drag' import Drag from '../../../components/Drag'
import { isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
const Coordinate = (props) => { const Coordinate = (props) => {
const { token, client } = window.globalConfig const { token, client } = window.globalConfig
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue } = schema const { disabled, placeholder, presetValue, addressSync } = 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 };
...@@ -78,15 +80,14 @@ const Coordinate = (props) => { ...@@ -78,15 +80,14 @@ const Coordinate = (props) => {
target: 'erroSendUpWidget',// 随便写 target: 'erroSendUpWidget',// 随便写
toolTip: '左键选择位置', toolTip: '左键选择位置',
drawEnd: geometry => { drawEnd: geometry => {
setCurrentPointerCoordinate([geometry.x, geometry.y]); setCurrentPointerCoordinate([geometry.x, geometry.y])
coordGetLayer && coordGetLayer.removeAll(); coordGetLayer && coordGetLayer.removeAll()
const coordGraphic = createGraphic(geometry)
const coordGraphic = createGraphic(geometry); coordGetLayer.add(coordGraphic)
coordGetLayer.add(coordGraphic); getPoints(view, coordGetLayer)
getPoints(view, coordGetLayer);
}, },
rightClick: () => { getPoints(view, coordGetLayer); } rightClick: () => { getPoints(view, coordGetLayer) }
}); })
} }
const showMap = () => { const showMap = () => {
...@@ -95,11 +96,35 @@ const Coordinate = (props) => { ...@@ -95,11 +96,35 @@ const Coordinate = (props) => {
const onCancel = () => { const onCancel = () => {
setCurrentPointerCoordinate(initCoordinate) setCurrentPointerCoordinate(initCoordinate)
setVisible(false); setVisible(false)
} }
const onOk = () => { const onOk = async () => {
setVisible(false); 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}`
}
}
}
})
}
if (targetPath) {
let LngLat = mercatorToLngLat(currentPointerCoordinate[0], currentPointerCoordinate[1])
const { code, data } = await getLocation(LngLat.join(','))
if (Array.isArray(data) && data.length) {
const { pname, adname, name, address } = data[0]
addons.setValue(targetPath, `${pname}/${adname}/${name}`)
}
}
}
setVisible(false)
onChange(currentPointerCoordinate.join(',')) onChange(currentPointerCoordinate.join(','))
} }
......
...@@ -11,7 +11,7 @@ const DateTime = (props) => { ...@@ -11,7 +11,7 @@ const DateTime = (props) => {
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
let value = presetValue || (options === '默认为当前时间' ? moment(new Date()).format('YYYY-MM-DD HH:mm:ss') : null) let value = presetValue || (options === '默认为当前时间' ? moment(new Date()).format('YYYY-MM-DD HH:mm:ss') : '')
addons.setValue(addons.dataPath, value) addons.setValue(addons.dataPath, value)
} else { } else {
onChange(presetValue) onChange(presetValue)
...@@ -30,17 +30,19 @@ const DateTime = (props) => { ...@@ -30,17 +30,19 @@ const DateTime = (props) => {
if (date && date._d) { if (date && date._d) {
onChange(moment(date._d).format('YYYY-MM-DD HH:mm:ss')) onChange(moment(date._d).format('YYYY-MM-DD HH:mm:ss'))
} else { } else {
onChange(null) onChange('')
} }
} }
const isValid = moment(value)._isValid
return ( return (
<DatePicker <DatePicker
disabledDate={disabledDate} disabledDate={disabledDate}
picker={format} picker={format}
disabled={disabled} disabled={disabled}
placeholder={!disabled ? placeholder : ''} placeholder={!disabled ? placeholder : ''}
value={value ? moment(value) : null} value={isValid ? moment(value) : null}
onChange={dateChange} onChange={dateChange}
showNow showNow
showTime={format === 'dateTime'} showTime={format === 'dateTime'}
......
...@@ -17,24 +17,29 @@ const Time = (props) => { ...@@ -17,24 +17,29 @@ const Time = (props) => {
} }
const timeChange = (time, timeStr) => { const timeChange = (time, timeStr) => {
if (time) {
onChange(moment(time).format('YYYY-MM-DD HH:mm:ss')) onChange(moment(time).format('YYYY-MM-DD HH:mm:ss'))
} else {
onChange('')
}
} }
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
let value = presetValue || (options === '默认为当前时间' ? moment().format('YYYY-MM-DD HH:mm:ss') : null) let value = presetValue || (options === '默认为当前时间' ? moment().format('YYYY-MM-DD HH:mm:ss') : '')
console.log('value', options, value)
addons.setValue(addons.dataPath, value) addons.setValue(addons.dataPath, value)
} else { } else {
let value = presetValue || (options === '默认为当前时间' ? moment().format('YYYY-MM-DD HH:mm:ss') : null) let value = presetValue || (options === '默认为当前时间' ? moment().format('YYYY-MM-DD HH:mm:ss') : '')
onChange(value) onChange(value)
} }
}, [presetValue, options]) }, [presetValue, options])
const isValid = moment(value)._isValid
return ( return (
<TimePicker <TimePicker
style={{ width: '100%' }} style={{ width: '100%' }}
value={value ? moment(value) : null} value={isValid ? moment(value) : null}
onChange={timeChange} onChange={timeChange}
disabledDate={disabledDate} disabledDate={disabledDate}
locale={locale} locale={locale}
......
...@@ -9,9 +9,9 @@ const SwitchSelector = (props) => { ...@@ -9,9 +9,9 @@ const SwitchSelector = (props) => {
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
addons.setValue(addons.dataPath, presetValue) addons.setValue(addons.dataPath, presetValue === text[0] ? text[0]: text[1])
} else { } else {
onChange(presetValue) onChange(presetValue === text[0] ? text[0]: text[1])
} }
}, [presetValue]) }, [presetValue])
......
import React, { useMemo } from 'react'
import { Select } from 'antd'
const options = [
{
name: 'number',
label: '数值(number)',
value: '^[+-]?[0-9]+([.][0-9]+)?$',
message: '数值校验未通过!',
},
// {
// name: 'decimals',
// label: '小数(decimals)',
// value: '^[+-]?[0-9]+([.][0-9]+)?$',
// message: '小数校验未通过',
// },
{
name: 'integer',
label: '整数(integer)',
value: '^[+-]?[0-9]*$',
message: '整数校验未通过',
},
{
name: 'positiveInteger',
label: '正整数(positiveInteger)',
value: '^[1-9][0-9]*$',
message: '正整数校验未通过',
},
]
const VerifyNumberInput = (props) => {
const { value, onChange, disabled } = props
const valueShow = useMemo(() => {
return Array.isArray(value) && value.length ? value[0].pattern : null
}, [value])
const selectChange = (value) => {
if (value) {
const item = options.find(v => v.value === value)
onChange([{ name: item.name, pattern: value, message: item.message }])
} else {
onChange([])
}
}
return (
<Select
disabled={disabled}
value={valueShow}
options={options}
onChange={selectChange}
/>
)
}
export default VerifyNumberInput
\ No newline at end of file
import VerifyTextInput from './VerifyTextInput' import VerifyTextInput from './VerifyTextInput'
import VerifyNumberInput from './VerifyNumberInput'
const groupVerify = { const groupVerify = {
VerifyTextInput, VerifyTextInput,
VerifyNumberInput,
} }
export default groupVerify export default groupVerify
\ No newline at end of file
...@@ -25,7 +25,7 @@ const TextInput = (props) => { ...@@ -25,7 +25,7 @@ const TextInput = (props) => {
const userInfo = window?.globalConfig?.userInfo || { fullName: '【本人姓名】', depart: { name: '【本人部门】' } } const userInfo = window?.globalConfig?.userInfo || { fullName: '【本人姓名】', depart: { name: '【本人部门】' } }
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName, isStoreID } = schema const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName, isStoreID, textInputDefalut } = schema
const handleChange = (e) => { const handleChange = (e) => {
if (addons) { if (addons) {
...@@ -35,15 +35,15 @@ const TextInput = (props) => { ...@@ -35,15 +35,15 @@ const TextInput = (props) => {
const valueShow = useMemo(() => { const valueShow = useMemo(() => {
if (isStoreID) { if (isStoreID) {
if (presetValue === '【本人姓名】') { if (textInputDefalut === '【本人姓名】') {
return userInfo.fullName return userInfo.fullName
} }
if (presetValue === '【本人部门】') { if (textInputDefalut === '【本人部门】') {
return userInfo.depart.name return userInfo.depart.name
} }
} }
return value return value
}, [presetValue, value, isStoreID]) }, [textInputDefalut, value, isStoreID])
useEffect(() => { useEffect(() => {
let paths = ['【本人姓名】', '【本人部门】'] let paths = ['【本人姓名】', '【本人部门】']
......
...@@ -83,6 +83,16 @@ export function parseSQL2JSON(str) { ...@@ -83,6 +83,16 @@ export function parseSQL2JSON(str) {
}; };
} }
export const mercatorToLngLat = (x, y) => {
const EARTH_RAD = 6378137
const radToAngle = (rad) => {
return rad * (180 / Math.PI)
}
let lng = radToAngle(x) / EARTH_RAD
let lat = radToAngle(2 * Math.atan(Math.exp(y / EARTH_RAD)) - Math.PI / 2)
return [lng, lat]
}
//判断是否为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