Commit dd14cc75 authored by 田翔's avatar 田翔

fix: 当一个因子影响多个的时候计算属性出现BUG

parent eab9be58
{
"name": "panda-xform",
"version": "2.4.0",
"description": "2.4.0: 解决时间控件只读问题,下拉框中的站点增加ID存储,人员选择器选择角色机构优化为选择",
"version": "2.4.1",
"description": "2.4.1: 当一个因子影响多个的时候计算属性出现BUG",
"keywords": [
"panda-xform"
],
......
......@@ -29,7 +29,7 @@ export const jsonToValues = (data, paths) => {
let values = []
if (Array.isArray(paths)) {
paths.forEach(v => {
let fieldName = v.split('.')[1]
let fieldName = v.path.split('.')[1]
let fieldValue = '0'
let item = formValue.find(s => s.fieldName === fieldName)
if (item) {
......@@ -57,7 +57,7 @@ const getRules = (json) => {
for (let s in child) {
if (child[s].widget === 'AutoCalculate') {
AutoCalculate.push({
filedName: s,
fieldName: s,
...child[s],
targetPath: `${v}.${s}`,
})
......@@ -87,13 +87,13 @@ const getPath = (json, filed) => {
}
const getFieldName = (configs, tableName) => {
let filedName = []
let path = ''
configs.forEach(v => {
if (v['台账名称'] === tableName) {
filedName.push(v.$id)
path = v.$id
}
})
return filedName
return path
}
const automaticComputation = async (params) => {
......@@ -123,14 +123,13 @@ const setValue = debounce(automaticComputation)
export const getWatch = (schema, form, startTime) => {
let watch = {}
let paths = []
let { relationForm } = form?.getValues()
const configs = relationForm?.configs || []
const AutoCalculate = getRules(schema)
// console.log('AutoCalculate', AutoCalculate)
if (Array.isArray(AutoCalculate)) {
AutoCalculate.forEach(item => {
const { filedName, rules, calculateRule } = item
let paths = []
const { fieldName, rules, calculateRule } = item
if (Array.isArray(rules)) {
rules.forEach(s => {
if (schema.tableName === s.tableName) {
......@@ -138,36 +137,37 @@ export const getWatch = (schema, form, startTime) => {
s.fields.forEach(v => {
let path = getPath(schema, v)
if (path) {
paths.push(path)
paths.push({ path: path, fieldName, formula: calculateRule })
}
})
}
} else {
paths.push(...getFieldName(configs, s.tableName))
}
})
}
if (Array.isArray(paths)) {
paths.forEach(v => {
watch[v] = () => {
let params = {
tableName: schema.tableName,
filedFormulas: [
{ fieldName: filedName, formula: calculateRule }
],
form: form,
paths: paths,
relationForm,
schema: schema,
startTime
let path = getFieldName(configs, s.tableName)
if (path) {
paths.push({ path, fieldName, formula: calculateRule })
}
setValue(params)
}
})
}
})
}
// console.log('watch', watch)
if (Array.isArray(paths)) {
paths.forEach(v => {
watch[v.path] = () => {
let params = {
tableName: schema.tableName,
filedFormulas: paths.filter(s => s.path === v.path),
form: form,
paths: paths,
relationForm,
schema: schema,
startTime
}
setValue(params)
}
})
}
console.log('paths', paths)
return watch
}
......
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