Commit 7f20709b authored by 田翔's avatar 田翔

fix: 监听所有关联表单

parent bc8b1051
{
"name": "panda-xform",
"version": "2.3.1",
"description": "2.3.1: bug修复",
"version": "2.3.2",
"description": "2.3.2: 监听所有关联表单",
"keywords": [
"panda-xform"
],
......
......@@ -69,6 +69,24 @@ const getRules = (json) => {
return AutoCalculate
}
const getRelationFormPath = (json) => {
let RelationFormPath = []
let parent = json?.properties
if (isObject(parent)) {
for (let v in parent) {
let child = parent[v]?.properties
if (isObject(child)) {
for (let s in child) {
if (child[s].widget === 'RelationForm') {
RelationFormPath.push(`${v}.${s}`)
}
}
}
}
}
return RelationFormPath
}
const getPath = (json, filed) => {
let parent = json?.properties
if (isObject(parent)) {
......@@ -97,7 +115,6 @@ const getFieldName = (configs, tableName) => {
}
const automaticComputation = async (params) => {
console.log('form.getValues()', params?.form?.getValues())
if ((new Date().getTime() - params.startTime) < 1000) return
let param = {
tableName: params.tableName,
......@@ -125,20 +142,21 @@ const setValue = debounce(automaticComputation)
export const getWatch = (schema, form, startTime) => {
let watch = {}
let { relationForm } = form?.getValues()
const configs = relationForm?.configs || []
const AutoCalculate = getRules(schema)
const RelationFormPath = getRelationFormPath(schema)
if (Array.isArray(AutoCalculate)) {
AutoCalculate.forEach(item => {
const { filedName, rules, calculateRule } = item
let paths = []
let paths = RelationFormPath
if (Array.isArray(rules)) {
rules.forEach(s => {
let item = { tableName: null, fields: [] }
if (schema.tableName === s.tableName) {
item = s
} else {
item = { fields: getFieldName(configs, s.tableName) }
// item = { fields: getFieldName(configs, s.tableName) }
}
console.log('item', item)
if (item) {
if (Array.isArray(item.fields)) {
item.fields.forEach(v => {
......@@ -169,6 +187,7 @@ export const getWatch = (schema, form, startTime) => {
}
})
}
console.log('watch', watch)
return watch
}
......
......@@ -308,11 +308,16 @@ const RelationForm = (props) => {
}
})
setDataSource(array)
onChange(`${array.length}`)
setTimeout(() => {
onChange(`${array.length}`)
}, 0)
} else if (formStateStr === '添加') {
let array = [getItem(formValue), ...dataSource]
setDataSource(array)
onChange(`${array.length}`)
setTimeout(() => {
onChange(`${array.length}`)
}, 0)
}
let relationForm = addons.getValue('relationForm') || { configs: [], data: [] }
let listArray = relationForm.data.filter(v => v.id !== itemData.id)
......
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