Commit 16a4f1b2 authored by 田翔's avatar 田翔

fix: 关联表单自动计算偶发性参数缺失问题

parent 2bb0f57a
{
"name": "panda-xform",
"version": "5.1.6",
"description": "5.1.6 关联表单优化",
"version": "5.1.7",
"description": "5.1.7 关联表单自动计算偶发性参数缺失问题",
"keywords": [
"panda-xform"
],
......
......@@ -390,6 +390,10 @@ const FormDesigner = (props, ref) => {
<FormRender
ref={formRenderRef}
schemaValues={{ formJson: schema }}
// codes={{
// 工单编号: '12421413431',
// 事件编号: 'PO230000013',
// }}
/>
</Drag>
</div>
......
......@@ -12,8 +12,6 @@ import { isObject } from '../../utils'
import { getWatch } from './watch'
import styles from '../../main.less'
let watchFns = {}
const XRender = (props, ref) => {
useImperativeHandle(ref, () => (
......@@ -91,8 +89,7 @@ const XRender = (props, ref) => {
}, [formJson, values, disabledFields, disabled])
const watch = useMemo(() => {
watchFns = getWatch({ schema: schemaForm, form, startTime, initField })
return watchFns
return getWatch({ schema: schemaForm, form, startTime, initField })
}, [schemaForm, form, startTime, initField])
const getValues = async () => {
......@@ -113,15 +110,7 @@ const XRender = (props, ref) => {
}
//初始化时存储外部传的额外数据
const onMount = () => {
setTimeout(() => {
if (isObject(watchFns)) {
for (let key in watchFns) {
watchFns?.[key]()
}
}
}, 1500)
}
const onMount = () => { }
return (
<div className={styles.pandaXform}>
......
......@@ -155,37 +155,28 @@ const RelationForm = (props) => {
let { code, data, msg } = await GetAccountConfigInfo(accountName)
if (code === 0) {
setConfig({ ...data, formJson: isJson(data.formJson) ? JSON.parse(data.formJson) : {} })
getTableData(data.addFieldGroup ? data.addFieldGroup.split(',') : [])
const queryWheres = getQueryWheres()
getTableData(queryWheres)
} else {
message.error(msg)
}
}
const getQueryWheres = (addFieldGroup) => {
const getQueryWheres = () => {
let queryWheres = []
let formDataObj = getFormDataObj(addons?.formData)
addFieldGroup.forEach(v => {
if (Array.isArray(mappedField)) {
mappedField.forEach(s => {
if (s.toField === v) {
queryWheres.push({ field: s.toField, type: '等于', value: codes ? (codes[s.fromField] || formDataObj[s.fromField]) : formDataObj[s.fromField] })
}
})
}
})
if (Array.isArray(mappedField)) {
let formDataObj = getFormDataObj(addons?.formData)
mappedField.forEach(v => {
queryWheres.push({ field: v.toField, type: '等于', value: codes[v.fromField] || formDataObj[v.fromField] })
})
}
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
relationForm?.configs.forEach(v => {
v.queryWheres = queryWheres.map(v => { return { fieldName: v.field, fieldValue: v.value } })
})
addons.setValueByPath('relationForm', { ...relationForm, configs: [...relationForm.configs, { ...schema, queryWheres }] })
return queryWheres
}
const getTableData = async (addFieldGroup) => {
const getTableData = async (queryWheres) => {
if (!addons) return
let queryWheres = getQueryWheres(addFieldGroup)
if (!queryWheres.length) {
message.info('映射字段配置错误!')
}
let params = {
user: userID,
accountName: accountName,
......@@ -430,16 +421,22 @@ const RelationForm = (props) => {
}
useEffect(() => {
if (accountName) {
getData()
}
}, [accountName])
useLayoutEffect(() => {
//初始化关联表单配置信息,初始显示隐藏
if (addons) {
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
addons.setValue('relationForm', { ...relationForm, configs: [...relationForm.configs, schema] })
getData()
// console.log('addons', addons)
// setTimeout(() => {
// let queryWheres = []
// if (Array.isArray(mappedField)) {
// let formDataObj = getFormDataObj(addons?.formData)
// mappedField.forEach(v => {
// queryWheres.push({ field: v.toField, type: '等于', value: codes[v.fromField] || formDataObj[v.fromField] })
// })
// }
// let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
// addons.setValueByPath('relationForm', { ...relationForm, configs: [...relationForm.configs, { ...schema, queryWheres }] })
// }, 0)
}
}, [])
......
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