Commit bd8fd13d authored by 田翔's avatar 田翔

fix: 关联表单完善

parent dbd05bb4
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "1.5.6", "version": "1.5.7",
"description": "1.5.6: 增加地址以及设备二维码配置,台账选择器隐射字段默认设置", "description": "1.5.7: 关联表单完善",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -250,6 +250,14 @@ export function GetTableConfigJson(paramas) { ...@@ -250,6 +250,14 @@ export function GetTableConfigJson(paramas) {
}) })
} }
//获取台账的json
export function GetTableJson(accountName) {
return request({
url: `/PandaWorkFlow/WorkFlow/AccountManage/GetTableJson?accountName=${accountName}`,
method: 'get',
})
}
//保存附加表信息,支持台账6.0 //保存附加表信息,支持台账6.0
export function saveTableConfig(data) { export function saveTableConfig(data) {
return request({ return request({
......
...@@ -81,7 +81,6 @@ const layoutWidgets = [ ...@@ -81,7 +81,6 @@ const layoutWidgets = [
schema: { schema: {
title: '分组名称', title: '分组名称',
type: 'object', type: 'object',
collapsed: true,
// theme: 'collapse:pure', // theme: 'collapse:pure',
// properties: { // properties: {
// title: { // title: {
...@@ -124,8 +123,8 @@ const textWidgets = [ ...@@ -124,8 +123,8 @@ const textWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true, properties: {},
properties: {} default: null
}, },
$id: { $id: {
title: '字段名称', title: '字段名称',
...@@ -154,7 +153,6 @@ const textWidgets = [ ...@@ -154,7 +153,6 @@ const textWidgets = [
presetValue: { presetValue: {
title: '默认值', title: '默认值',
type: 'string', type: 'string',
widget: 'InputDefault',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
}, },
...@@ -669,7 +667,6 @@ const selectWidgets = [ ...@@ -669,7 +667,6 @@ const selectWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -879,7 +876,6 @@ const selectWidgets = [ ...@@ -879,7 +876,6 @@ const selectWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -1045,7 +1041,6 @@ const selectWidgets = [ ...@@ -1045,7 +1041,6 @@ const selectWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -1204,7 +1199,6 @@ const selectWidgets = [ ...@@ -1204,7 +1199,6 @@ const selectWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -1309,7 +1303,6 @@ const selectWidgets = [ ...@@ -1309,7 +1303,6 @@ const selectWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -1432,7 +1425,6 @@ const selectWidgets = [ ...@@ -1432,7 +1425,6 @@ const selectWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -1467,7 +1459,6 @@ const selectWidgets = [ ...@@ -1467,7 +1459,6 @@ const selectWidgets = [
gorupSoruce: { gorupSoruce: {
title: '数据来源', title: '数据来源',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
role: { role: {
...@@ -1560,7 +1551,6 @@ const selectWidgets = [ ...@@ -1560,7 +1551,6 @@ const selectWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -1670,7 +1660,6 @@ const selectWidgets = [ ...@@ -1670,7 +1660,6 @@ const selectWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -1705,7 +1694,6 @@ const selectWidgets = [ ...@@ -1705,7 +1694,6 @@ const selectWidgets = [
gorupSoruce: { gorupSoruce: {
title: '数据来源', title: '数据来源',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
accountName: { accountName: {
...@@ -1810,7 +1798,6 @@ const dateWidgets = [ ...@@ -1810,7 +1798,6 @@ const dateWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -1945,7 +1932,6 @@ const dateWidgets = [ ...@@ -1945,7 +1932,6 @@ const dateWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -2215,7 +2201,6 @@ const mapWidgets = [ ...@@ -2215,7 +2201,6 @@ const mapWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -2302,7 +2287,6 @@ const mapWidgets = [ ...@@ -2302,7 +2287,6 @@ const mapWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -2389,7 +2373,6 @@ const mapWidgets = [ ...@@ -2389,7 +2373,6 @@ const mapWidgets = [
groupBase: { groupBase: {
title: '基础信息', title: '基础信息',
type: 'object', type: 'object',
collapsed: true,
properties: {} properties: {}
}, },
$id: { $id: {
...@@ -2471,7 +2454,7 @@ const advancedWidgets = [ ...@@ -2471,7 +2454,7 @@ const advancedWidgets = [
text: '关联表单', text: '关联表单',
name: '关联表单', name: '关联表单',
schema: { schema: {
title: '关联表单', title: '',
name: '关联表单', name: '关联表单',
type: 'string', type: 'string',
widget: 'RelationForm', widget: 'RelationForm',
...@@ -2491,10 +2474,11 @@ const advancedWidgets = [ ...@@ -2491,10 +2474,11 @@ const advancedWidgets = [
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
}, },
title: { titleShow: {
title: '标题', title: '标题',
type: 'string', type: 'string',
widget: 'htmlInput', widget: 'htmlInput',
default: '关联表单',
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
}, },
...@@ -2550,12 +2534,13 @@ const advancedWidgets = [ ...@@ -2550,12 +2534,13 @@ const advancedWidgets = [
labelWidth: 80, labelWidth: 80,
required: true, required: true,
default: [], default: [],
dependencies: ['accountName'],
}, },
defaultShow: { defaultShow: {
title: '默认显示', title: '默认显示',
type: 'boolean', type: 'boolean',
widget: 'BooleanSwitch', widget: 'BooleanSwitch',
default: false, default: true,
displayType: 'row', displayType: 'row',
labelWidth: 80, labelWidth: 80,
}, },
...@@ -2566,7 +2551,27 @@ const advancedWidgets = [ ...@@ -2566,7 +2551,27 @@ const advancedWidgets = [
labelWidth: 80, labelWidth: 80,
widget: 'ControlShow', widget: 'ControlShow',
}, },
...groupStyle, groupStyle: {
title: '控件样式',
type: 'object',
properties: {}
},
width: {
title: '元素宽度',
type: 'string',
widget: 'percentSlider',
},
labelWidth: {
title: '标签宽度',
description: '默认值10',
default: 10,
type: 'number',
widget: 'slider',
max: 400,
props: {
hideNumber: true,
},
},
}, },
}, },
{ {
......
import React, { useRef, useEffect, useState, useContext, forwardRef, createContext, useMemo } from 'react' import React, { useRef, useEffect, useState, useContext, forwardRef, createContext, useMemo, useLayoutEffect } from 'react'
import { ConfigProvider, message, Modal, Button } from 'antd' import { ConfigProvider, message, Modal, Button } from 'antd'
import Generator from 'fr-generator' import Generator from 'fr-generator'
import { settings, baseSettings, globalSettings } from './config' import { settings, baseSettings, globalSettings } from './config'
...@@ -30,27 +30,22 @@ const FormDesigner = (props, ref) => { ...@@ -30,27 +30,22 @@ const FormDesigner = (props, ref) => {
return settingsParent return settingsParent
}, [settings, tableName]) }, [settings, tableName])
const getTableField = () => { const getTableConfig = async (tableName) => {
console.log('setSchema', settings)
}
const getTableConfig = async () => {
const { code, data, msg } = await GetTableConfigJson({ tableName }) const { code, data, msg } = await GetTableConfigJson({ tableName })
if (code === 0) { if (code === 0) {
if (typeof data === 'string') { if (data && typeof data === 'string') {
setTimeout(() => { designerRef?.current?.setValue(JSON.parse(data))
designerRef?.current?.setValue(JSON.parse(data))
// setSchema(JSON.parse(data))
}, 0)
} }
} else { } else {
message.error(msg) message.error(msg)
} }
} }
useEffect(() => { useLayoutEffect(() => {
getTableConfig() if (tableName) {
}, []) getTableConfig(tableName)
}
}, [tableName])
const extraButtons = [ const extraButtons = [
false, false,
...@@ -87,10 +82,11 @@ const FormDesigner = (props, ref) => { ...@@ -87,10 +82,11 @@ const FormDesigner = (props, ref) => {
] ]
const testSubmit = async () => { const testSubmit = async () => {
const { formValue, errors } = await formRenderRef?.current?.getValues() const { formValue, relationForm, errors } = await formRenderRef?.current?.getValues()
if (errors.length) { if (errors.length) {
return message.error('表单校验未通过!') return message.error('表单校验未通过!')
} }
console.log('获取数据', formValue, relationForm)
} }
return ( return (
......
import React, { useState, useContext, forwardRef, useImperativeHandle } from 'react' import React, { useState, useContext, forwardRef, useImperativeHandle, createContext } from 'react'
import FormRender, { useForm } from 'form-render' import FormRender, { useForm } from 'form-render'
import { ConfigProvider } from 'antd' import { ConfigProvider } from 'antd'
import widgets from '../widgets' import widgets from '../widgets'
export const GlobalStore = createContext(null)
const XRender = (props, ref) => { const XRender = (props, ref) => {
useImperativeHandle(ref, () => ( useImperativeHandle(ref, () => (
...@@ -15,22 +17,22 @@ const XRender = (props, ref) => { ...@@ -15,22 +17,22 @@ const XRender = (props, ref) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext) const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
const prefixCls = getPrefixCls('pandaXform') const prefixCls = getPrefixCls('pandaXform')
const pandaXform = getPrefixCls() const pandaXform = getPrefixCls()
const form = useForm() const form = useForm()
const getValues = async () => { const getValues = async () => {
let { data, errors } = await form.submit() let { data, errors } = await form.submit()
// console.log('form', form, errorFields)
// form.formData()
let formValue = [] let formValue = []
Object.keys(data).map((k) => { Object.keys(data).map((k) => {
Object.keys(data[k]).map((key) => { if (k !== 'relationForm') {
formValue.push({ fieldName: key, fieldValue: data[k][key] + '' }) Object.keys(data[k]).map((key) => {
}) formValue.push({ fieldName: key, fieldValue: data[k][key] })
})
}
}) })
return { return {
formValue, formValue,
errors, errors,
relationForm: data.relationForm
} }
} }
......
import React, { useMemo, forwardRef, useContext, useImperativeHandle } from 'react'
import { ConfigProvider } from 'antd'
import FormRender, { useForm } from 'form-render'
import widgets from './widgets'
const isObject = (obj) => typeof obj === 'object'
const BaseForm = (props, ref) => {
useImperativeHandle(ref, () => (
{
getValues
}
))
const { schemaForm, config, formState } = props
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
const prefixCls = getPrefixCls('pandaXform')
const pandaXform = getPrefixCls()
const form = useForm()
//表单需要显示的字段
const field = useMemo(() => {
const { fieldGroup, editFieldGroup, addFieldGroup } = config
let field = []
if (formState === '详情') {
field = fieldGroup ? fieldGroup.split(',') : []
} else if (formState === '添加') {
field = addFieldGroup ? addFieldGroup.split(',') : []
} else if (formState === '编辑') {
field = editFieldGroup ? editFieldGroup.split(',') : []
}
return field
}, [config, formState])
const schema = useMemo(() => {
const { group, values } = schemaForm
let parent = group?.properties
let parentObj = {}
if (isObject(parent)) {
for (let v in parent) {
let child = parent[v]?.properties
let childObj = {}
if (isObject(child)) {
for (let s in child) {
if (field.includes(s)) {
let value = ''
values.forEach(v => {
if (v.fieldName === s) {
value = v.fieldValue
}
})
childObj[s] = { ...child[s], presetValue: value || child[s].presetValue }
} else {
}
}
}
if (JSON.stringify(childObj) !== '{}') {
parentObj[v] = { ...parent[v], properties: childObj }
}
}
}
return { ...group, properties: parentObj }
}, [schemaForm, field, formState])
const getValues = async () => {
let { data, errors } = await form.submit()
let formValue = []
Object.keys(data).map((k) => {
Object.keys(data[k]).map((key) => {
formValue.push({ fieldName: key, fieldValue: data[k][key] + '' })
})
})
return {
formValue,
errors,
}
}
return (
<div className={prefixCls}>
<FormRender
configProvider={{ prefixCls: pandaXform }}
mapping={{
object: 'Header',
}}
form={form}
schema={schema}
widgets={widgets}
/>
</div>
)
}
export default forwardRef(BaseForm)
\ No newline at end of file
import Header from '../../../Header'
import text from '../../../text'
import date from '../../../date'
import select from '../../../select'
import file from '../../../file'
import Signature from '../../Signature'
const coord = {
Signature
}
const widgets = {
Header,
...text,
...date,
...select,
...file,
...coord,
}
export default widgets
\ No newline at end of file
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
height: 45px; height: 45px;
line-height: 45px; line-height: 45px;
position: relative; position: relative;
text-align: center;
// .account-header-title { // .account-header-title {
// width: 100%; // width: 100%;
// text-align: center; // text-align: center;
......
import React, { useState, useMemo } from 'react' import React, { useState, useMemo, useEffect } from 'react'
import { Select, message } from 'antd' import { Select, message } from 'antd'
import { GetSelectItemList, GetFieldValueFromTable, getStationListByUserID } from '../../../../apis/process' import { GetSelectItemList, GetFieldValueFromTable, getStationListByUserID } from '../../../../apis/process'
...@@ -13,13 +13,21 @@ const ComboBox = (props) => { ...@@ -13,13 +13,21 @@ const ComboBox = (props) => {
const [tableData, setTableData] = useState([]) const [tableData, setTableData] = useState([])
const [site, setSite] = useState([]) const [site, setSite] = useState([])
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
const valueShow = useMemo(() => { const valueShow = useMemo(() => {
if (isMultiple || isEdit) { if (isMultiple || isEdit) {
return (value || presetValue) ? (value || presetValue).split(',') : [] return value ? value.split(',') : []
} else { } else {
return value || presetValue || null return value || null
} }
}, [isEdit, isMultiple, presetValue, value]) }, [isEdit, isMultiple, value])
const enums = useMemo(() => { const enums = useMemo(() => {
switch (soruceType) { switch (soruceType) {
......
...@@ -188,7 +188,7 @@ const PersonSelector = (props) => { ...@@ -188,7 +188,7 @@ const PersonSelector = (props) => {
{ {
v.userList.map(s => { v.userList.map(s => {
return ( return (
<Col span={8} style={{ margin: '8px 0', display: s.noShow ? 'none' : 'block' }}> <Col span={8} key={s.userID} style={{ margin: '8px 0', display: s.noShow ? 'none' : 'block' }}>
<Checkbox <Checkbox
value={s.userName} value={s.userName}
> >
......
...@@ -5,11 +5,16 @@ import { LoadTableFields, ReloadTableFields } from '../../../../../apis/process' ...@@ -5,11 +5,16 @@ import { LoadTableFields, ReloadTableFields } from '../../../../../apis/process'
const FieldNames = (props) => { const FieldNames = (props) => {
const { value, onChange, addons } = props const { value, onChange, addons } = props
const { tableNameParent } = addons.formData const { tableNameParent, name } = addons.formData
const [fieldName, setFieldName] = useState([]) const [fieldName, setFieldName] = useState([])
const selectChange = (value) => { const selectChange = (value) => {
if (name !== '关联表单') {
addons.setValueByPath('title', value)
} else {
addons.setValueByPath('titleShow', value)
}
onChange(value) onChange(value)
} }
...@@ -21,7 +26,6 @@ const FieldNames = (props) => { ...@@ -21,7 +26,6 @@ const FieldNames = (props) => {
if (Array.isArray(data.root)) { if (Array.isArray(data.root)) {
setFieldName(data.root) setFieldName(data.root)
} }
console.log('props', props)
} }
useEffect(() => { useEffect(() => {
......
...@@ -22,10 +22,12 @@ const AccountName = (props) => { ...@@ -22,10 +22,12 @@ const AccountName = (props) => {
} }
const selectChange = (value) => { const selectChange = (value) => {
onChange(value)
if (name === '台账选择器') { if (name === '台账选择器') {
addons.setValues({ ...addons.formData, fieldshine: [] }) addons.setValueByPath('fieldshine', [])
} else if (name === '关联表单') {
addons.setValueByPath('mappedField', [])
} }
onChange(value)
} }
return ( return (
......
import React, { useState } from 'react' import React, { useEffect, useState } from 'react'
import { Form, Space, TreeSelect, Button, Input, Modal, message } from 'antd' import { Form, Space, TreeSelect, Button, Input, Modal, message } from 'antd'
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons' import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'
import styles from './index.less' import styles from './index.less'
...@@ -22,7 +22,6 @@ const MappedField = (props) => { ...@@ -22,7 +22,6 @@ const MappedField = (props) => {
const req1 = QueryFields(accountName) const req1 = QueryFields(accountName)
const req2 = ReloadTableFields({ tableName: tableNameParent }) const req2 = ReloadTableFields({ tableName: tableNameParent })
const [res1, res2] = await Promise.all([req1, req2]) const [res1, res2] = await Promise.all([req1, req2])
console.log(res1, res2)
if (res1.code === 0) { if (res1.code === 0) {
setToField(res1.data) setToField(res1.data)
} else { } else {
...@@ -33,6 +32,7 @@ const MappedField = (props) => { ...@@ -33,6 +32,7 @@ const MappedField = (props) => {
} else { } else {
message.error(res2.msg) message.error(res2.msg)
} }
form.setFieldsValue({ field: value })
setVisible(true) setVisible(true)
} }
......
import React, { useState, useEffect, useRef, useImperativeHandle, forwardRef, useMemo } from 'react' import React, { useState, useEffect, useRef, useImperativeHandle, forwardRef, useMemo, useLayoutEffect } from 'react'
import styles from './index.less' import styles from './index.less'
import { request } from '@wisdom-utils/utils' import { request } from '@wisdom-utils/utils'
import { Editor, Toolbar } from '@wangeditor/editor-for-react' import { Editor, Toolbar } from '@wangeditor/editor-for-react'
...@@ -41,7 +41,6 @@ const RichText = forwardRef(({ schema, onChange, value }, ref) => { ...@@ -41,7 +41,6 @@ const RichText = forwardRef(({ schema, onChange, value }, ref) => {
} }
}, [editor]) }, [editor])
return ( return (
<div className={styles.richText} disabled={disabled}> <div className={styles.richText} disabled={disabled}>
{ {
......
...@@ -27,14 +27,6 @@ const TextInput = (props) => { ...@@ -27,14 +27,6 @@ const TextInput = (props) => {
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName } = schema const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName } = schema
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
const style = useMemo(() => { const style = useMemo(() => {
let paths = ['【本人姓名】', '【本人部门】'] let paths = ['【本人姓名】', '【本人部门】']
if (paths.includes(value)) { if (paths.includes(value)) {
......
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