Commit dd14cc75 authored by 田翔's avatar 田翔

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

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