Commit acc3d863 authored by 田翔's avatar 田翔

fix: panda-xform

parent 506ddc6f
{
"name": "panda-xform",
"version": "2.3.4",
"description": "2.3.4: BUG修复",
"version": "2.3.5",
"description": "2.3.5: 逻辑优化",
"keywords": [
"panda-xform"
],
......
......@@ -69,24 +69,6 @@ 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)) {
......@@ -108,14 +90,15 @@ const getFieldName = (configs, tableName) => {
let filedName = []
configs.forEach(v => {
if (v['台账名称'] === tableName) {
filedName.push(v.fieldName)
filedName.push(v.$id)
}
})
return filedName
}
const automaticComputation = async (params) => {
if ((new Date().getTime() - params.startTime) < 2000) return
console.log('form.getValues()', params?.form?.getValues())
if ((new Date().getTime() - params.startTime) < 1000) return
let param = {
tableName: params.tableName,
filedFormulas: params.filedFormulas,
......@@ -142,32 +125,29 @@ 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 = RelationFormPath
let paths = []
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) }
}
if (item) {
if (Array.isArray(item.fields)) {
item.fields.forEach(v => {
if (Array.isArray(s.fields)) {
s.fields.forEach(v => {
let path = getPath(schema, v)
if (path) {
paths.push(path)
}
})
}
} else {
paths.push(...getFieldName(configs, s.tableName))
}
})
}
console.log('paths', paths)
if (Array.isArray(paths)) {
paths.forEach(v => {
watch[v] = () => {
......
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