Commit 3c941206 authored by 田翔's avatar 田翔

fix: 强行增加分组,分组套分组解析成一个分组

parent 00eb6093
{
"name": "panda-xform",
"version": "4.3.3",
"description": "4.3.3 时间日期格式增加确定按钮",
"version": "4.3.4",
"description": "4.3.4 强行增加分组,分组套分组解析成一个分组",
"keywords": [
"panda-xform"
],
......
......@@ -12,8 +12,8 @@
cursor: col-resize;
z-index: 1;
&:hover {
width: 10px;
right: -5px;
width: 20px;
right: -10px;
background: #0e98ed;
z-index: 999;
}
......
......@@ -420,7 +420,7 @@ const TablePack = (props, ref) => {
style={{ display: 'inline-block' }}
>
<Tag
color='volcano'
color='blue'
closable
onClose={(e) => closeTag(e, v)}
>
......
......@@ -72,9 +72,6 @@ const FormDesigner = (props, ref) => {
child[s].tableNameParent = tableName
child[s].tableTypeParent = json.tableType
child[s].IsSystemField = IsSystemField
// if (v === '(未分组)') {
// ungroupedChild[s] = child[s]
// }
}
}
} else {
......@@ -149,21 +146,19 @@ const FormDesigner = (props, ref) => {
}
const preview = () => {
let json = getJSON(designerRef.current.getValue(), fieldName)
let json = designerRef.current.getValue()
let verify = getVerify(json)
if (verify === true) {
setTextShow(false)
setVisible(true)
setSchema(json)
designerRef.current.setValue(json)
}
}
const submit = async () => {
let json = getJSON(designerRef.current.getValue(), fieldName)
let json = designerRef.current.getValue()
let verify = getVerify(json)
if (verify === true) {
designerRef.current.setValue(json)
const { code, data, msg } = await saveTableConfig(json)
if (code === 0) {
message.info('保存成功')
......@@ -174,7 +169,7 @@ const FormDesigner = (props, ref) => {
}
const initLayout = () => {
let json = getJSON(designerRef.current.getValue(), fieldName)
let json = designerRef.current.getValue()
let verify = getVerify(json)
if (verify === true) {
Modal.confirm({
......@@ -224,23 +219,69 @@ const FormDesigner = (props, ref) => {
const getFields = (schema) => {
let array = []
let paths = []
let inError = false
let outError = false
let parent = schema?.properties
let parentObj = {}
if (isObject(parent)) {
for (let v in parent) {
if (parent[v].type === 'object') {
paths.push(v)
parentObj[v] = parent[v]
let child = parent[v]?.properties
if (isObject(child)) {
let childObj = {}
for (let s in child) {
if (child[s].type !== 'object') {
array.push({ ...child[s], fieldName: s })
childObj[s] = child[s]
} else {
inError = true
let sun = child[s]?.properties
if (isObject(sun)) {
for (let k in sun) {
array.push({ ...sun[k], fieldName: k })
childObj[k] = sun[k]
}
}
}
}
parentObj[v].properties = childObj
}
} else {
outError = true
let nanoid = getNanoid()
paths.push(nanoid)
parentObj[nanoid] = {
title: '(未分组)',
type: 'object',
collapsed: false,
properties: {
[v]: parent[v]
}
}
}
}
}
return array
return {
inError,
outError,
fields: array,
newSchema: {
...schema,
paths,
properties: parentObj
}
}
}
const onSchemaChange = (schema) => {
let fields = getFields(schema)
let { inError, outError, fields, newSchema } = getFields(schema)
window.designer = fields
if (inError || outError) {
designerRef.current.setValue(newSchema)
}
}
const testSubmit = async () => {
......
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