Commit cfbce225 authored by 田翔's avatar 田翔

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

parent f7161fb7
{
"name": "panda-xform",
"version": "2.9.3",
"description": "2.9.3: 地图坐标增加地址同步功能",
"version": "2.9.4",
"description": "2.9.4: 时间传参问题,数值校验问题",
"keywords": [
"panda-xform"
],
......
......@@ -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) {
return request({
......
......@@ -404,11 +404,30 @@ const textWidgets = [
description: '所有形态默认显示',
widget: 'HiddenCondition'
},
rules: {
title: '正则校验',
type: 'array',
default: [
{
name: 'number',
pattern: '^[+-]?[0-9]+([.][0-9]+)?$',
message: '数值校验未通过!',
}
],
widget: 'VerifyNumberInput',
disabled: disabled,
dependencies: ['tableTypeParent', 'IsSystemField'],
},
presetValue: {
title: '默认值',
type: 'string',
widget: 'NumerDefault',
},
calculateRule: {
title: '计算规则',
type: 'string',
widget: 'CalculateRule',
},
required: {
title: '必填',
type: 'boolean',
......@@ -429,11 +448,6 @@ const textWidgets = [
hidden: '{{Boolean(formData.calculateRule)}}',
dependencies: ['calculateRule']
},
calculateRule: {
title: '计算规则',
type: 'string',
widget: 'CalculateRule',
},
prefix: {
title: '前缀',
type: 'string',
......
......@@ -62,7 +62,13 @@ const XRender = (props, ref) => {
if (disabledField) {
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) !== '{}') {
......@@ -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])
const watch = useMemo(() => {
......
......@@ -11,12 +11,14 @@ import {
Point
} from '@wisdom-map/arcgismap'
import Drag from '../../../components/Drag'
import { isObject, mercatorToLngLat } from '../../../../utils'
import { getLocation } from '../../../../apis/process'
const Coordinate = (props) => {
const { token, client } = window.globalConfig
const { value, onChange, schema, addons } = props
const { disabled, placeholder, presetValue } = schema
const { disabled, placeholder, presetValue, addressSync } = schema
const [layersConifg, setLayersConifg] = useState(() => {
const mapConfig = window.globalConfig.mapsettings?.layers || null
return { layers: mapConfig };
......@@ -78,15 +80,14 @@ const Coordinate = (props) => {
target: 'erroSendUpWidget',// 随便写
toolTip: '左键选择位置',
drawEnd: geometry => {
setCurrentPointerCoordinate([geometry.x, geometry.y]);
coordGetLayer && coordGetLayer.removeAll();
const coordGraphic = createGraphic(geometry);
coordGetLayer.add(coordGraphic);
getPoints(view, coordGetLayer);
setCurrentPointerCoordinate([geometry.x, geometry.y])
coordGetLayer && coordGetLayer.removeAll()
const coordGraphic = createGraphic(geometry)
coordGetLayer.add(coordGraphic)
getPoints(view, coordGetLayer)
},
rightClick: () => { getPoints(view, coordGetLayer); }
});
rightClick: () => { getPoints(view, coordGetLayer) }
})
}
const showMap = () => {
......@@ -95,11 +96,35 @@ const Coordinate = (props) => {
const onCancel = () => {
setCurrentPointerCoordinate(initCoordinate)
setVisible(false);
setVisible(false)
}
const onOk = () => {
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}`
}
}
}
})
}
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(','))
}
......
......@@ -11,7 +11,7 @@ const DateTime = (props) => {
useEffect(() => {
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)
} else {
onChange(presetValue)
......@@ -30,17 +30,19 @@ const DateTime = (props) => {
if (date && date._d) {
onChange(moment(date._d).format('YYYY-MM-DD HH:mm:ss'))
} else {
onChange(null)
onChange('')
}
}
const isValid = moment(value)._isValid
return (
<DatePicker
disabledDate={disabledDate}
picker={format}
disabled={disabled}
placeholder={!disabled ? placeholder : ''}
value={value ? moment(value) : null}
value={isValid ? moment(value) : null}
onChange={dateChange}
showNow
showTime={format === 'dateTime'}
......
......@@ -17,24 +17,29 @@ const Time = (props) => {
}
const timeChange = (time, timeStr) => {
onChange(moment(time).format('YYYY-MM-DD HH:mm:ss'))
if (time) {
onChange(moment(time).format('YYYY-MM-DD HH:mm:ss'))
} else {
onChange('')
}
}
useEffect(() => {
if (addons) {
let value = presetValue || (options === '默认为当前时间' ? moment().format('YYYY-MM-DD HH:mm:ss') : null)
console.log('value', options, value)
let value = presetValue || (options === '默认为当前时间' ? moment().format('YYYY-MM-DD HH:mm:ss') : '')
addons.setValue(addons.dataPath, value)
} 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)
}
}, [presetValue, options])
const isValid = moment(value)._isValid
return (
<TimePicker
style={{ width: '100%' }}
value={value ? moment(value) : null}
value={isValid ? moment(value) : null}
onChange={timeChange}
disabledDate={disabledDate}
locale={locale}
......
......@@ -9,9 +9,9 @@ const SwitchSelector = (props) => {
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
addons.setValue(addons.dataPath, presetValue === text[0] ? text[0]: text[1])
} else {
onChange(presetValue)
onChange(presetValue === text[0] ? text[0]: text[1])
}
}, [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 VerifyNumberInput from './VerifyNumberInput'
const groupVerify = {
VerifyTextInput,
VerifyNumberInput,
}
export default groupVerify
\ No newline at end of file
......@@ -25,7 +25,7 @@ const TextInput = (props) => {
const userInfo = window?.globalConfig?.userInfo || { fullName: '【本人姓名】', depart: { name: '【本人部门】' } }
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) => {
if (addons) {
......@@ -35,15 +35,15 @@ const TextInput = (props) => {
const valueShow = useMemo(() => {
if (isStoreID) {
if (presetValue === '【本人姓名】') {
if (textInputDefalut === '【本人姓名】') {
return userInfo.fullName
}
if (presetValue === '【本人部门】') {
if (textInputDefalut === '【本人部门】') {
return userInfo.depart.name
}
}
return value
}, [presetValue, value, isStoreID])
}, [textInputDefalut, value, isStoreID])
useEffect(() => {
let paths = ['【本人姓名】', '【本人部门】']
......
......@@ -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字符串
export const isJson = (json) => {
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