Commit bd8fd13d authored by 田翔's avatar 田翔

fix: 关联表单完善

parent dbd05bb4
{
"name": "panda-xform",
"version": "1.5.6",
"description": "1.5.6: 增加地址以及设备二维码配置,台账选择器隐射字段默认设置",
"version": "1.5.7",
"description": "1.5.7: 关联表单完善",
"keywords": [
"panda-xform"
],
......
......@@ -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
export function saveTableConfig(data) {
return request({
......
......@@ -81,7 +81,6 @@ const layoutWidgets = [
schema: {
title: '分组名称',
type: 'object',
collapsed: true,
// theme: 'collapse:pure',
// properties: {
// title: {
......@@ -124,8 +123,8 @@ const textWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
properties: {},
default: null
},
$id: {
title: '字段名称',
......@@ -154,7 +153,6 @@ const textWidgets = [
presetValue: {
title: '默认值',
type: 'string',
widget: 'InputDefault',
displayType: 'row',
labelWidth: 80,
},
......@@ -669,7 +667,6 @@ const selectWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -879,7 +876,6 @@ const selectWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -1045,7 +1041,6 @@ const selectWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -1204,7 +1199,6 @@ const selectWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -1309,7 +1303,6 @@ const selectWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -1432,7 +1425,6 @@ const selectWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -1467,7 +1459,6 @@ const selectWidgets = [
gorupSoruce: {
title: '数据来源',
type: 'object',
collapsed: true,
properties: {}
},
role: {
......@@ -1560,7 +1551,6 @@ const selectWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -1670,7 +1660,6 @@ const selectWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -1705,7 +1694,6 @@ const selectWidgets = [
gorupSoruce: {
title: '数据来源',
type: 'object',
collapsed: true,
properties: {}
},
accountName: {
......@@ -1810,7 +1798,6 @@ const dateWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -1945,7 +1932,6 @@ const dateWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -2215,7 +2201,6 @@ const mapWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -2302,7 +2287,6 @@ const mapWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -2389,7 +2373,6 @@ const mapWidgets = [
groupBase: {
title: '基础信息',
type: 'object',
collapsed: true,
properties: {}
},
$id: {
......@@ -2471,7 +2454,7 @@ const advancedWidgets = [
text: '关联表单',
name: '关联表单',
schema: {
title: '关联表单',
title: '',
name: '关联表单',
type: 'string',
widget: 'RelationForm',
......@@ -2491,10 +2474,11 @@ const advancedWidgets = [
displayType: 'row',
labelWidth: 80,
},
title: {
titleShow: {
title: '标题',
type: 'string',
widget: 'htmlInput',
default: '关联表单',
displayType: 'row',
labelWidth: 80,
},
......@@ -2550,12 +2534,13 @@ const advancedWidgets = [
labelWidth: 80,
required: true,
default: [],
dependencies: ['accountName'],
},
defaultShow: {
title: '默认显示',
type: 'boolean',
widget: 'BooleanSwitch',
default: false,
default: true,
displayType: 'row',
labelWidth: 80,
},
......@@ -2566,7 +2551,27 @@ const advancedWidgets = [
labelWidth: 80,
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 Generator from 'fr-generator'
import { settings, baseSettings, globalSettings } from './config'
......@@ -30,27 +30,22 @@ const FormDesigner = (props, ref) => {
return settingsParent
}, [settings, tableName])
const getTableField = () => {
console.log('setSchema', settings)
}
const getTableConfig = async () => {
const getTableConfig = async (tableName) => {
const { code, data, msg } = await GetTableConfigJson({ tableName })
if (code === 0) {
if (typeof data === 'string') {
setTimeout(() => {
if (data && typeof data === 'string') {
designerRef?.current?.setValue(JSON.parse(data))
// setSchema(JSON.parse(data))
}, 0)
}
} else {
message.error(msg)
}
}
useEffect(() => {
getTableConfig()
}, [])
useLayoutEffect(() => {
if (tableName) {
getTableConfig(tableName)
}
}, [tableName])
const extraButtons = [
false,
......@@ -87,10 +82,11 @@ const FormDesigner = (props, ref) => {
]
const testSubmit = async () => {
const { formValue, errors } = await formRenderRef?.current?.getValues()
const { formValue, relationForm, errors } = await formRenderRef?.current?.getValues()
if (errors.length) {
return message.error('表单校验未通过!')
}
console.log('获取数据', formValue, relationForm)
}
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 { ConfigProvider } from 'antd'
import widgets from '../widgets'
export const GlobalStore = createContext(null)
const XRender = (props, ref) => {
useImperativeHandle(ref, () => (
......@@ -15,22 +17,22 @@ const XRender = (props, ref) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext)
const prefixCls = getPrefixCls('pandaXform')
const pandaXform = getPrefixCls()
const form = useForm()
const getValues = async () => {
let { data, errors } = await form.submit()
// console.log('form', form, errorFields)
// form.formData()
let formValue = []
Object.keys(data).map((k) => {
if (k !== 'relationForm') {
Object.keys(data[k]).map((key) => {
formValue.push({ fieldName: key, fieldValue: data[k][key] + '' })
formValue.push({ fieldName: key, fieldValue: data[k][key] })
})
}
})
return {
formValue,
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
import React, { useEffect, useMemo, useState, useRef, useContext } from 'react'
import React, { useEffect, useMemo, useState, useRef, useLayoutEffect, useContext, createContext } from 'react'
import styles from './index.less'
import {
GetAccountPageList,
......@@ -9,9 +9,10 @@ import {
EditTableDataInfo,
DeleteTableDataInfo
} from '../../../../apis/process'
import { Table, Button, Modal, message, Popconfirm } from 'antd'
import { SnippetsOutlined, PlusOutlined, FormOutlined, DeleteOutlined, } from '@ant-design/icons'
import FormRender, { useForm } from 'form-render'
import { Table, Button, Modal, message, Popconfirm, ConfigProvider } from 'antd'
import { SnippetsOutlined, PlusOutlined, FormOutlined, DeleteOutlined } from '@ant-design/icons'
import { GetTableJson } from '../../../../apis/process'
import BaseForm from './BaseForm'
const icons = {
'详情': <SnippetsOutlined />,
......@@ -20,132 +21,105 @@ const icons = {
}
let formStateStr = '添加'
const getFormDataObj = (formData) => {
let formDataObj = {}
Object.keys(formData).map((k) => {
if (k !== 'relationForm') {
Object.keys(formData[k]).map((key) => {
formDataObj[key] = formData[k][key] || ''
})
}
})
return formDataObj
}
const RelationForm = (props) => {
const fieldNames = ['事件编号', '工单编号']
const { value, onChange, schema, addons } = props
const { disabled, source, accountName } = schema
const [listData, setListData] = useState([])
const { disabled, accountName, defaultShow, controlShow, titleShow, mappedField } = schema
const { codes } = parent
const form = useForm()
const [config, setConfig] = useState({ webShowFieldGroup: '', fieldGroup: '' })
const [dataSource, setDataSource] = useState([])
const [groupMeta, setGroupMeta] = useState([])
const [formData, setFormData] = useState([])
const [visible, setVisible] = useState(false)
const [formState, setFormState] = useState('详情')
const [row, setRow] = useState({})
const parseFormRef = useRef(null)
// const getMsg = () => {
// let fields = configInfo['映射字段'].map(v => v.toField)
// return `台账【${accountName}】缺少${fields.join('、')}字段`
// }
// const show = useMemo(() => {
// let str = configInfo['控制规则']
// try {
// let matchArr = str ? str.match(/\{(.+?)\}/g) : []
// matchArr?.forEach(v => {
// let value = v.replace(/{/g, '').replace(/}/g, '')
// let valueArr = value ? value.split('.') : []
// let fieldValue = parseFormData[valueArr[1]]
// str = str.replace(v, `'${fieldValue}'`)
// })
// str = str.replace(/=/g, '==')
// str = str.replace(/and/g, '&&')
// str = str.replace(/or/, '||')
// if (str && eval(str)) {
// return !configInfo['默认显示']
// }
// return configInfo['默认显示']
// } catch {
// message.error('字符串规则解析失败')
// return configInfo['默认显示']
// }
// }, [parseFormData, configInfo])
// const localForm = useMemo(() => {
// const { addFieldGroup } = config
// let array = []
// let field = addFieldGroup ? addFieldGroup.split(',') : []
// const getFieldValue = (s, parseFormData, codes) => {
// return codes ? (codes[s.fromField] || parseFormData[s.fromField]) : parseFormData[s.fromField]
// }
// field.forEach(v => {
// configInfo['映射字段'].forEach(s => {
// if (s.toField === v) {
// array.push({ fieldName: s.toField, fieldValue: getFieldValue(s, parseFormData, codes) })
// }
// })
// })
// return array
// }, [parseFormData, config, configInfo, codes, dataSource])
const localForm = []
const [schemaGroup, setSchemaGroup] = useState({})
const [schemaValues, setSchemaValues] = useState([])
const baseFormRef = useRef(null)
const tablesSchema = 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(',') : []
}
let groups = []
groupMeta.forEach(v => {
let schema = []
v.schema.forEach(s => {
if (field.includes(s.fieldName)) {
schema.push({ ...s, readOnly: fieldNames.includes(s.fieldName) ? 1 : s.readOnly })
const formDataObj = useMemo(() => {
let formDataObj = {}
if (addons) {
formDataObj = getFormDataObj(addons?.formData)
}
return formDataObj
}, [addons?.formData])
const show = useMemo(() => {
if (addons) {
let str = controlShow
try {
let matchArr = str ? str.match(/\{(.+?)\}/g) : []
matchArr?.forEach(v => {
let value = v.replace(/{/g, '').replace(/}/g, '')
let valueArr = value ? value.split('.') : []
let fieldValue = formDataObj[valueArr[1]]
str = str.replace(v, `'${fieldValue}'`)
})
if (schema.length > 0) {
groups.push({ ...v, schema, })
str = str.replace(/and/g, '&&')
str = str.replace(/or/, '||')
// console.log('str', str)
if (str && eval(str)) {
// addons.setSchemaByPath(addons.dataPath, { ...schema, hidden: !schema.hidden })
// console.log(addons)
return !defaultShow
}
return defaultShow
} catch {
// message.error('字符串规则解析失败')
return defaultShow
}
})
return {
groups,
values: formState === '添加' ? localForm : formData
}
}, [formState, localForm, groupMeta, formData, config])
return defaultShow
}, [formDataObj, defaultShow])
const groupMetaInfo = useMemo(() => {
const localForm = useMemo(() => {
const { addFieldGroup } = config
let array = []
const { webShowFieldGroup } = config
let field = webShowFieldGroup ? webShowFieldGroup.split(',') : []
let groupArr = groupMeta.length ? groupMeta.reduce((f, n) => f.concat(n.schema), []) : []
if (field.length > 0) {
let field = addFieldGroup ? addFieldGroup.split(',') : []
const getFieldValue = (s, formDataObj, codes) => {
return codes ? (codes[s.fromField] || formDataObj[s.fromField]) : formDataObj[s.fromField]
}
field.forEach(v => {
groupArr.forEach(s => {
if (s.fieldName === v) {
array.push(s)
mappedField.forEach(s => {
if (s.toField === v) {
array.push({ fieldName: s.toField, fieldValue: getFieldValue(s, formDataObj, codes) })
}
})
})
}
return array
}, [groupMeta, config])
}, [formDataObj, config, mappedField, codes, dataSource])
const columns = useMemo(() => {
let btn = ['详情']
if (!disabled) {
btn = ['详情', '编辑', '删除']
}
const { webShowFieldGroup } = config
let field = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : []
let array = []
if (groupMetaInfo.length > 0) {
if (field.length > 0) {
array.push({ title: '序号', width: 50, align: 'center', render: (_, r, i) => i + 1 })
groupMetaInfo.forEach(v => {
field.forEach(v => {
array.push({
title: v.alias,
dataIndex: v.fieldName,
key: v.fieldName,
title: v,
dataIndex: v,
key: v,
ellipsis: {
visibleTitle: false,
},
// width: 120
})
})
array.push({
......@@ -189,23 +163,16 @@ const RelationForm = (props) => {
})
}
return array
}, [disabled, groupMetaInfo, dataSource, formState])
const isReadOnly = useMemo(() => {
if (formState === '编辑' || formState == '添加') {
return false
}
return true
}, [formState])
}, [disabled, config, dataSource, formState])
const rowClick = async (v, r) => {
if (addons) {
setRow(r)
if (v === '详情') {
setFormData(getItem(r))
setSchemaValues(getItem(r))
setVisible(true)
} else if (v === '编辑') {
setFormData(getItem(r))
setSchemaValues(getItem(r))
setVisible(true)
} else if (v === '删除') {
deleteTableInfo(r)
......@@ -237,27 +204,20 @@ const RelationForm = (props) => {
const deleteTableInfo = (r) => {
let listItem = { type: 'delete', accountTable: accountName, id: r.ID, values: getItem('delete', r) }
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
if (r.ID.includes('前端ID')) {
let list = listData.filter(v => v.id !== r.ID)
setListData(list)
let list = relationForm.data.filter(v => v.id !== r.ID)
// setRelationForm({ ...relationForm, data: list })
addons.setValue('relationForm', { ...relationForm, data: list })
} else {
setListData([...listData, listItem])
// setRelationForm({ ...relationForm, data: [...relationForm, listItem] })
addons.setValue('relationForm', { ...relationForm, data: [...relationForm.data, listItem] })
}
let tableData = dataSource.filter(v => v.ID !== r.ID)
setDataSource(tableData)
onChange(`${tableData.length}`)
}
const getTableInfo = async (r) => {
const { code, data } = await GetTableDataInfo({ accountName: accountName, id: Number(r.ID) })
if (code === 0) {
setFormData(data)
setVisible(true)
} else {
message.error('数据请求失败!')
}
}
const getConfig = async () => {
let { code, data, msg } = await GetAccountConfigInfo(accountName)
if (code === 0) {
......@@ -269,9 +229,11 @@ const RelationForm = (props) => {
}
const getGroupMeta = async () => {
const { code, data, msg } = await GetTableGroupMeta(accountName)
const { code, data, msg } = await GetTableJson(accountName)
if (code === 0) {
setGroupMeta(data)
if (data && typeof data === 'string') {
setSchemaGroup(JSON.parse(data))
}
} else {
message.error(msg)
}
......@@ -279,10 +241,11 @@ const RelationForm = (props) => {
const getQueryWheres = (addFieldGroup) => {
let queryWheres = []
let formDataObj = getFormDataObj(addons?.formData)
addFieldGroup.forEach(v => {
configInfo['映射字段'].forEach(s => {
mappedField.forEach(s => {
if (s.toField === v) {
queryWheres.push({ field: s.toField, type: '等于', value: codes ? (codes[s.fromField] || parseFormData[s.fromField]) : parseFormData[s.fromField] })
queryWheres.push({ field: s.toField, type: '等于', value: codes ? (codes[s.fromField] || formDataObj[s.fromField]) : formDataObj[s.fromField] })
}
})
})
......@@ -290,19 +253,20 @@ const RelationForm = (props) => {
}
const getTableData = async (addFieldGroup) => {
// let queryWheres = getQueryWheres(addFieldGroup)
// if (!queryWheres.length) {
// onChange(`出错了,${getMsg()}`)
// }
if (!addons) return
let queryWheres = getQueryWheres(addFieldGroup)
if (!queryWheres.length) {
message.info('映射字段配置错误!')
}
let params = {
accountName: accountName,
direction: 'desc',
timeField: '录入时间',
pageIndex: 0,
pageSize: 0,
// queryWheres
queryWheres
}
// if (queryWheres.every(v => !v.value)) return
if (queryWheres.every(v => !v.value)) return
const { code, data, msg } = await GetAccountPageList(params)
if (code === 0) {
let tableData = JSON.parse(data.jsonData)
......@@ -324,14 +288,19 @@ const RelationForm = (props) => {
}
const onOk = async () => {
let formData = parseFormRef.current.getFormValues()
if (addons) {
console.log('addons', addons)
const { formValue, errors } = await baseFormRef.current.getValues()
if (errors.length) {
return message.error('请按照提示完善表单内容')
}
let type = row.ID.includes('前端ID') ? 'add' : 'edit'
let itemData = { type, accountTable: accountName, id: row.ID, values: formData }
let itemData = { type, accountTable: accountName, id: row.ID, values: formValue }
if (formStateStr !== '添加') {
let array = []
dataSource.forEach(v => {
if (v.ID === row.ID) {
array.push({ ...v, ...getItem(formData) })
array.push({ ...v, ...getItem(formValue) })
} else {
array.push({ ...v })
}
......@@ -339,39 +308,53 @@ const RelationForm = (props) => {
setDataSource(array)
onChange(`${array.length}`)
} else if (formStateStr === '添加') {
let array = [getItem(formData), ...dataSource]
let array = [getItem(formValue), ...dataSource]
setDataSource(array)
onChange(`${array.length}`)
}
let listArray = listData.filter(v => v.id !== itemData.id)
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
let listArray = relationForm.data.filter(v => v.id !== itemData.id)
listArray.push({ ...itemData })
setListData(listArray)
addons.setValue('relationForm', { ...relationForm, data: listArray })
setVisible(false)
}
}
const addClick = () => {
// if (!localForm.length) {
// return message.error(getMsg())
// }
if (!localForm.length) {
return message.error(getMsg())
}
if (addons) {
if (JSON.stringify(schemaGroup) === '{}') {
return message.info(`台账[${accountName}]未配置形态!`)
}
setRow({ ID: `前端ID${new Date().getTime()}` })
setFormState('添加')
setSchemaValues(localForm)
formStateStr = '添加'
setVisible(true)
}
}
useEffect(() => {
useLayoutEffect(() => {
if (accountName) {
getData()
}
}, [accountName])
console.log('tablesSchema', tablesSchema)
useLayoutEffect(() => {
//初始化关联表单配置信息,初始显示隐藏
if (addons) {
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
addons.setValue('relationForm', { ...relationForm, configs: [...relationForm.configs, schema] })
// addons.setSchemaByPath(addons.dataPath, { ...schema, hidden: !defaultShow })
}
}, [])
return (
<div className={styles.relationForm}>
<div className={styles.relationForm} style={{ display: show ? 'block' : 'none' }}>
<div className={styles.header}>
<span className='account-header-title'>{titleShow}</span>
{disabled ? null : <Button className={styles.headerBtn} type='primary' size='middle' icon={<PlusOutlined />} onClick={addClick}>添加</Button>}
</div>
<Table
......@@ -384,16 +367,21 @@ const RelationForm = (props) => {
/>
<Modal
title={accountName}
width='90%'
width='80%'
bodyStyle={{ height: '700px', overflow: 'auto' }}
visible={visible}
onOk={onOk}
onCancel={() => setVisible(false)}
bodyStyle={{ height: 700 }}
destroyOnClose
>
<FormRender
form={form}
schema={tablesSchema}
<BaseForm
schemaForm={{
group: schemaGroup,
values: schemaValues,
}}
formState={formState}
config={config}
ref={baseFormRef}
/>
</Modal>
</div>
......
......@@ -6,6 +6,7 @@
height: 45px;
line-height: 45px;
position: relative;
text-align: center;
// .account-header-title {
// width: 100%;
// text-align: center;
......
import React, { useState, useMemo } from 'react'
import React, { useState, useMemo, useEffect } from 'react'
import { Select, message } from 'antd'
import { GetSelectItemList, GetFieldValueFromTable, getStationListByUserID } from '../../../../apis/process'
......@@ -13,13 +13,21 @@ const ComboBox = (props) => {
const [tableData, setTableData] = useState([])
const [site, setSite] = useState([])
useEffect(() => {
if (addons) {
addons.setValue(addons.dataPath, presetValue)
} else {
onChange(presetValue)
}
}, [presetValue])
const valueShow = useMemo(() => {
if (isMultiple || isEdit) {
return (value || presetValue) ? (value || presetValue).split(',') : []
return value ? value.split(',') : []
} else {
return value || presetValue || null
return value || null
}
}, [isEdit, isMultiple, presetValue, value])
}, [isEdit, isMultiple, value])
const enums = useMemo(() => {
switch (soruceType) {
......
......@@ -188,7 +188,7 @@ const PersonSelector = (props) => {
{
v.userList.map(s => {
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
value={s.userName}
>
......
......@@ -5,11 +5,16 @@ import { LoadTableFields, ReloadTableFields } from '../../../../../apis/process'
const FieldNames = (props) => {
const { value, onChange, addons } = props
const { tableNameParent } = addons.formData
const { tableNameParent, name } = addons.formData
const [fieldName, setFieldName] = useState([])
const selectChange = (value) => {
if (name !== '关联表单') {
addons.setValueByPath('title', value)
} else {
addons.setValueByPath('titleShow', value)
}
onChange(value)
}
......@@ -21,7 +26,6 @@ const FieldNames = (props) => {
if (Array.isArray(data.root)) {
setFieldName(data.root)
}
console.log('props', props)
}
useEffect(() => {
......
......@@ -22,10 +22,12 @@ const AccountName = (props) => {
}
const selectChange = (value) => {
onChange(value)
if (name === '台账选择器') {
addons.setValues({ ...addons.formData, fieldshine: [] })
addons.setValueByPath('fieldshine', [])
} else if (name === '关联表单') {
addons.setValueByPath('mappedField', [])
}
onChange(value)
}
return (
......
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { Form, Space, TreeSelect, Button, Input, Modal, message } from 'antd'
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'
import styles from './index.less'
......@@ -22,7 +22,6 @@ const MappedField = (props) => {
const req1 = QueryFields(accountName)
const req2 = ReloadTableFields({ tableName: tableNameParent })
const [res1, res2] = await Promise.all([req1, req2])
console.log(res1, res2)
if (res1.code === 0) {
setToField(res1.data)
} else {
......@@ -33,6 +32,7 @@ const MappedField = (props) => {
} else {
message.error(res2.msg)
}
form.setFieldsValue({ field: value })
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 { request } from '@wisdom-utils/utils'
import { Editor, Toolbar } from '@wangeditor/editor-for-react'
......@@ -41,7 +41,6 @@ const RichText = forwardRef(({ schema, onChange, value }, ref) => {
}
}, [editor])
return (
<div className={styles.richText} disabled={disabled}>
{
......
......@@ -27,14 +27,6 @@ const TextInput = (props) => {
const { value, onChange, schema, addons } = props
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(() => {
let paths = ['【本人姓名】', '【本人部门】']
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