Commit 23b36a54 authored by 田翔's avatar 田翔

fix: 向字段生成分组名称数据

parent 16c6ea91
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "1.6.5", "version": "1.6.7",
"description": "1.6.5: 防止出现重新取字段名问题", "description": "1.6.7: 向字段生成分组名称数据",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -681,12 +681,12 @@ const textWidgets = [ ...@@ -681,12 +681,12 @@ const textWidgets = [
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
}, },
presetValue: { // presetValue: {
title: '默认值', // title: '默认值',
type: 'string', // type: 'string',
displayType: 'row', // displayType: 'row',
labelWidth: 80, // labelWidth: 80,
}, // },
groupSetting: { groupSetting: {
title: '控件设置', title: '控件设置',
type: 'object', type: 'object',
...@@ -703,13 +703,13 @@ const textWidgets = [ ...@@ -703,13 +703,13 @@ const textWidgets = [
} }
} }
}, },
disabled: { // disabled: {
title: '只读', // title: '只读',
type: 'boolean', // type: 'boolean',
widget: 'checkbox', // widget: 'checkbox',
default: true, // default: true,
width: '30%', // width: '30%',
}, // },
hidden: { hidden: {
title: '隐藏', title: '隐藏',
type: 'boolean', type: 'boolean',
...@@ -717,11 +717,28 @@ const textWidgets = [ ...@@ -717,11 +717,28 @@ const textWidgets = [
default: false, default: false,
width: '30%', width: '30%',
}, },
prefixion: {
title: '前缀',
type: 'string',
displayType: 'row',
labelWidth: 90,
},
codingType: {
title: '编码方式',
type: 'string',
displayType: 'row',
labelWidth: 90,
widget: 'select',
enum: ['1', '2', '3'],
default: '3',
enumNames: ['前缀-年份-六位编码', '前缀-年份月份-六位编码', '前缀 -八位编码'],
description: '{{rootValue.codingType === "1" ?"示例:XJ-2019-000001" : (rootValue.codingType === "2" ? "示例: XJ-201909-000001" : "示例: XJ00000001")}}'
},
description: { description: {
title: '说明', title: '说明',
type: 'string', type: 'string',
displayType: 'row', displayType: 'row',
labelWidth: 55, labelWidth: 90,
}, },
groupStyle: { groupStyle: {
title: '控件样式', title: '控件样式',
......
...@@ -25,7 +25,7 @@ const FormDesigner = (props, ref) => { ...@@ -25,7 +25,7 @@ const FormDesigner = (props, ref) => {
let settingsParent = [] let settingsParent = []
settings.forEach(v => { settings.forEach(v => {
v.widgets.forEach(s => { v.widgets.forEach(s => {
s.schema = { ...s.schema, tableNameParent: tableName } s.schema.parent = { tableName }
}) })
settingsParent.push(v) settingsParent.push(v)
}) })
...@@ -35,11 +35,13 @@ const FormDesigner = (props, ref) => { ...@@ -35,11 +35,13 @@ const FormDesigner = (props, ref) => {
const getJSON = (json, tableName) => { const getJSON = (json, tableName) => {
let parent = json?.properties let parent = json?.properties
if (isObject(parent)) { if (isObject(parent)) {
let paths = []
for (let v in parent) { for (let v in parent) {
paths.push(v)
let child = parent[v]?.properties let child = parent[v]?.properties
if (isObject(child)) { if (isObject(child)) {
for (let s in child) { for (let s in child) {
child[s].tableNameParent = tableName child[s].parent = { tableName, paths }
} }
} }
} }
...@@ -100,14 +102,15 @@ const FormDesigner = (props, ref) => { ...@@ -100,14 +102,15 @@ const FormDesigner = (props, ref) => {
text: '预览', text: '预览',
onClick: (e) => { onClick: (e) => {
setVisible(true) setVisible(true)
setSchema(designerRef.current.getValue()) let json = getJSON(designerRef.current.getValue(), tableName)
setSchema(json)
} }
}, },
{ {
text: '提交', text: '提交',
onClick: async (value) => { onClick: async (value) => {
const errors = designerRef.current.getErrorFields() const errors = designerRef.current.getErrorFields()
const json = designerRef.current.getValue() let json = getJSON(designerRef.current.getValue(), tableName)
if (errors.length) { if (errors.length) {
return message.error('请按照提示完善表单内容') return message.error('请按照提示完善表单内容')
} }
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
Graphic Graphic
} from '@wisdom-map/arcgismap' } from '@wisdom-map/arcgismap'
import point from './img/point.png' import point from './img/point.png'
import { isObject } from '../../../../utils'
let geometrystr = '' let geometrystr = ''
let gisInfo = {} let gisInfo = {}
...@@ -188,11 +189,11 @@ const initMapConfig = [ ...@@ -188,11 +189,11 @@ const initMapConfig = [
} }
] ]
const Device = ({ addons, value, onChange, schema }) => { const Device = (props) => {
const mapConfig = window.globalConfig?.mapsettings?.layers || initMapConfig const mapConfig = window.globalConfig?.mapsettings?.layers || initMapConfig
const { addons, value, onChange, schema } = props
const { placeholder, disabled } = schema const { placeholder, disabled, parent } = schema
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const layersConifg = { layers: mapConfig } const layersConifg = { layers: mapConfig }
let clickref = useRef(null) let clickref = useRef(null)
...@@ -259,17 +260,22 @@ const Device = ({ addons, value, onChange, schema }) => { ...@@ -259,17 +260,22 @@ const Device = ({ addons, value, onChange, schema }) => {
} }
const onOk = () => { const onOk = () => {
onChange(geometrystr) const { paths } = parent
// if (Array.isArray(paths)) { if (Array.isArray(paths)) {
// paths.forEach(v => { paths.forEach(v => {
// if (v.fileName === 'GIS编码' && gisInfo.layerName) { let values = addons.getValue(v)
// addons.setValue(v.path, gisInfo.gisCode) if (isObject(values)) {
// } for (let key in values) {
// if (v.fileName === 'GIS图层' && gisInfo.layerName) { if (key === 'GIS编码' && gisInfo.gisCode) {
// addons.setValue(v.path, gisInfo.layerName) addons.setValue(`${v}.${key}`, gisInfo.gisCode)
// } }
// }) if (key === 'GIS图层' && gisInfo.layerName) {
// } addons.setValue(`${v}.${key}`, gisInfo.layerName)
}
}
}
})
}
setVisible(false) setVisible(false)
} }
......
...@@ -7,7 +7,7 @@ const FieldNames = (props) => { ...@@ -7,7 +7,7 @@ const FieldNames = (props) => {
let fieldsStr = window.sessionStorage.getItem('designerRef') || '' let fieldsStr = window.sessionStorage.getItem('designerRef') || ''
let fields = fieldsStr.split(',') || [] let fields = fieldsStr.split(',') || []
const { value, onChange, addons } = props const { value, onChange, addons } = props
const { tableNameParent, name } = addons.formData const { parent, name } = addons.formData
const [fieldName, setFieldName] = useState([]) const [fieldName, setFieldName] = useState([])
const options = useMemo(() => { const options = useMemo(() => {
...@@ -27,10 +27,10 @@ const FieldNames = (props) => { ...@@ -27,10 +27,10 @@ const FieldNames = (props) => {
} }
const onFocus = async () => { const onFocus = async () => {
if (!tableNameParent) { if (!parent.tableName) {
return message.info('缺少表名!') return message.info('缺少表名!')
} }
const { data } = await ReloadTableFields({ tableName: tableNameParent }) const { data } = await ReloadTableFields({ tableName: parent.tableName })
if (Array.isArray(data.root)) { if (Array.isArray(data.root)) {
setFieldName(data.root) setFieldName(data.root)
} }
......
...@@ -9,7 +9,7 @@ const { TreeNode } = TreeSelect ...@@ -9,7 +9,7 @@ const { TreeNode } = TreeSelect
const Fieldshine = (props) => { const Fieldshine = (props) => {
const { addons, onChange, value } = props const { addons, onChange, value } = props
const { $id, accountName, tableNameParent } = addons.formData const { $id, accountName, parent } = addons.formData
const [form] = Form.useForm() const [form] = Form.useForm()
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
...@@ -40,7 +40,7 @@ const Fieldshine = (props) => { ...@@ -40,7 +40,7 @@ const Fieldshine = (props) => {
return message.info('请选择台账名称') return message.info('请选择台账名称')
} }
const req1 = QueryFields(accountName) const req1 = QueryFields(accountName)
const req2 = ReloadTableFields({ tableName: tableNameParent }) const req2 = ReloadTableFields({ tableName: parent.tableName })
const [res1, res2] = await Promise.all([req1, req2]) const [res1, res2] = await Promise.all([req1, req2])
if (res1.code === 0) { if (res1.code === 0) {
if (Array.isArray(res1.data)) { if (Array.isArray(res1.data)) {
......
...@@ -9,7 +9,7 @@ const { TreeNode } = TreeSelect ...@@ -9,7 +9,7 @@ const { TreeNode } = TreeSelect
const MappedField = (props) => { const MappedField = (props) => {
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { accountName, tableNameParent } = addons.formData const { accountName, parent } = addons.formData
const [form] = Form.useForm() const [form] = Form.useForm()
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [fromField, setFromField] = useState([]) const [fromField, setFromField] = useState([])
...@@ -20,7 +20,7 @@ const MappedField = (props) => { ...@@ -20,7 +20,7 @@ const MappedField = (props) => {
message.info('请选择台账名称') message.info('请选择台账名称')
} }
const req1 = QueryFields(accountName) const req1 = QueryFields(accountName)
const req2 = ReloadTableFields({ tableName: tableNameParent }) const req2 = ReloadTableFields({ tableName: parent.tableName })
const [res1, res2] = await Promise.all([req1, req2]) const [res1, res2] = await Promise.all([req1, req2])
if (res1.code === 0) { if (res1.code === 0) {
setToField(res1.data) setToField(res1.data)
......
...@@ -3,19 +3,46 @@ import { Input, Popover, ConfigProvider } from 'antd' ...@@ -3,19 +3,46 @@ import { Input, Popover, ConfigProvider } from 'antd'
import { QrcodeOutlined } from '@ant-design/icons' import { QrcodeOutlined } from '@ant-design/icons'
import QRcode from 'qrcode.react' import QRcode from 'qrcode.react'
import './index.less' import './index.less'
import moment from 'moment'
function toUtf8(str) {
let out = ''
for (let i = 0; i < str.length; i++) {
let c = str.charCodeAt(i)
if (c >= 0x0001 && c <= 0x007f) {
out += str.charAt(i);
} else if (c > 0x07ff) {
out += String.fromCharCode(0xe0 | ((c >> 12) & 0x0f));
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3f));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f));
} else {
out += String.fromCharCode(0xc0 | ((c >> 6) & 0x1f));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f));
}
}
console.log('out', out)
return out;
}
const Coding = (props) => { const Coding = (props) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext) const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
const prefixCls = getPrefixCls('pandaXform') const prefixCls = getPrefixCls('pandaXform')
const { value, onChange, schema, addons } = props const { value, onChange, schema } = props
const { disabled } = schema const { disabled, prefixion, codingType } = schema
const inputChange = (e) => { // useEffect(() => {
if (addons) { // let date = ''
onChange(e.target.value) // if (codingType === '1') {
} // date = moment().format('YYYY')
} // } else if (codingType === '2') {
// date = moment().format('YYYYMM')
// }
// let code = toUtf8(tableNameParent)
// let codeValue = `${prefixion ? `${prefixion}-` : ''}${date ? `${date}-` : date}${code}`
// console.log('value', value, code)
// onChange(codeValue)
// }, [prefixion, codingType])
const content = ( const content = (
<div> <div>
...@@ -26,7 +53,8 @@ const Coding = (props) => { ...@@ -26,7 +53,8 @@ const Coding = (props) => {
return ( return (
<div className={`${prefixCls}-input`} isdisabled={JSON.stringify(disabled)}> <div className={`${prefixCls}-input`} isdisabled={JSON.stringify(disabled)}>
<Input <Input
onChange={inputChange} // onChange={inputChange}
value={value}
disabled={disabled} disabled={disabled}
addonAfter={ addonAfter={
<Popover content={content}> <Popover content={content}>
......
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