cloud-web-corejs 1.0.163 → 1.0.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/components/vb-tabs/x-tabs.vue +30 -13
- package/src/components/xform/form-designer/designer.js +1 -1
- package/src/components/xform/form-designer/form-widget/components/gantt/index.vue +419 -0
- package/src/components/xform/form-designer/form-widget/container-widget/data-table-mixin.js +1 -1
- package/src/components/xform/form-designer/form-widget/dialog/baseFormulaDialog copy.vue +971 -0
- package/src/components/xform/form-designer/form-widget/dialog/baseFormulaDialog.vue +971 -0
- package/src/components/xform/form-designer/form-widget/dialog/formDialog.vue +71 -50
- package/src/components/xform/form-designer/form-widget/dialog/formulaDialog.vue +799 -0
- package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin - /345/211/257/346/234/254.js" +1639 -0
- package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +102 -73
- package/src/components/xform/form-designer/form-widget/field-widget/cascader-widget.vue +19 -1
- package/src/components/xform/form-designer/form-widget/field-widget/census-widget.vue +41 -27
- package/src/components/xform/form-designer/form-widget/field-widget/checkbox-widget.vue +4 -1
- package/src/components/xform/form-designer/form-widget/field-widget/color-widget.vue +4 -1
- package/src/components/xform/form-designer/form-widget/field-widget/date-range-widget.vue +13 -2
- package/src/components/xform/form-designer/form-widget/field-widget/date-widget.vue +9 -2
- package/src/components/xform/form-designer/form-widget/field-widget/download-button-widget.vue +133 -0
- package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +2 -1
- package/src/components/xform/form-designer/form-widget/field-widget/gantt-widget.vue +962 -0
- package/src/components/xform/form-designer/form-widget/field-widget/input-widget.vue +7 -2
- package/src/components/xform/form-designer/form-widget/field-widget/multiSearch-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/number-widget.vue +7 -0
- package/src/components/xform/form-designer/form-widget/field-widget/oplog-widget.vue +1 -0
- package/src/components/xform/form-designer/form-widget/field-widget/print-button-widget.vue +44 -27
- package/src/components/xform/form-designer/form-widget/field-widget/print-detail-button-widget.vue +19 -11
- package/src/components/xform/form-designer/form-widget/field-widget/project-tag-widget.vue +19 -1
- package/src/components/xform/form-designer/form-widget/field-widget/radio-widget.vue +11 -7
- package/src/components/xform/form-designer/form-widget/field-widget/select-widget.vue +11 -8
- package/src/components/xform/form-designer/form-widget/field-widget/singerSearch-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/table-export-button-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/vabSearch-widget.vue +1 -1
- package/src/components/xform/form-designer/setting-panel/form-setting.vue +106 -76
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +13 -263
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +47 -81
- package/src/components/xform/form-designer/setting-panel/property-editor/downloadButtonFlag-editor.vue +32 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/onClick-editor.vue +14 -7
- package/src/components/xform/form-designer/setting-panel/property-editor/field-gantt/gantt-editor.vue +36 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-button-editor.vue +37 -16
- package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-detail-button-editor.vue +42 -18
- package/src/components/xform/form-designer/setting-panel/property-editor/field-vabUpload/field-vabUpload-editor.vue +2 -2
- package/src/components/xform/form-designer/setting-panel/property-editor/formScriptEnabled-editor.vue +57 -34
- package/src/components/xform/form-designer/setting-panel/property-editor/project-tag-editor.vue +84 -53
- package/src/components/xform/form-designer/setting-panel/property-editor/wfFlag-editor.vue +35 -44
- package/src/components/xform/form-designer/setting-panel/propertyRegister.js +2 -0
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +68 -3
- package/src/components/xform/form-render/container-item/containerItemMixin.js +2 -2
- package/src/components/xform/form-render/container-item/data-table-mixin.js +1 -1
- package/src/components/xform/form-render/container-item/tab-item.vue +64 -32
- package/src/components/xform/form-render/index.vue +69 -23
- package/src/components/xform/form-render/indexMixin.js +18 -17
- package/src/components/xform/lang/zh-CN.js +8 -2
- package/src/components/xform/utils/formula-util.js +306 -5
- package/src/components/xform/utils/util.js +1 -1
- package/src/components/xform/utils/vue2js-generator.js +2 -2
- package/src/utils/request.js +1 -1
- package/src/utils/vab.js +1 -1
- package/src/views/bd/setting/config_manage/list.vue +7 -0
- package/src/views/user/area/dialog.vue +223 -116
- package/src/views/user/area/list.vue +318 -0
- package/src/views/user/form/vform/render.vue +54 -36
- package/src/views/user/form/view/list.vue +103 -10
- package/src/views/user/menu/list.vue +24 -1
- package/src/views/user/role/authConfig.vue +89 -0
- package/src/views/user/role/dialog.vue +70 -48
- package/src/views/user/role/edit.vue +114 -4
|
@@ -71,8 +71,8 @@ export default {
|
|
|
71
71
|
"import_button": "导入按钮",
|
|
72
72
|
"import-button": "导入按钮",
|
|
73
73
|
"import2-button": "明细导入按钮",
|
|
74
|
-
"print-button": "
|
|
75
|
-
"print-detail-button": "
|
|
74
|
+
"print-button": "导出/打印(列表)",
|
|
75
|
+
"print-detail-button": "导出/打印(详情)",
|
|
76
76
|
"copy_button": "复制按钮",
|
|
77
77
|
"rich-editor": "富文本",
|
|
78
78
|
cascader: "级联选择",
|
|
@@ -114,6 +114,8 @@ export default {
|
|
|
114
114
|
"saleOrg-project-tag": "机构(多选)",
|
|
115
115
|
"tempStorage": "暂存按钮",
|
|
116
116
|
"oplog": "操作日志",
|
|
117
|
+
"gantt": "甘特图",
|
|
118
|
+
"download-button": "附件下载",
|
|
117
119
|
},
|
|
118
120
|
hint: {
|
|
119
121
|
formulaSetting: "公式设置",
|
|
@@ -149,6 +151,10 @@ export default {
|
|
|
149
151
|
"将数值去掉小数,举例:INT(-8.9)=-9",
|
|
150
152
|
formulaSUM:
|
|
151
153
|
"返回一组数据的和,举例:SUM(1,2,3,...)=6",
|
|
154
|
+
formulaSUMIF:
|
|
155
|
+
`根据单个条件对指定区域内的数值求和,举例:SUMIF([10, 20, 30], ">10", [80, 120, 90])=210`,
|
|
156
|
+
formulaSUMIFS:
|
|
157
|
+
`根据多个条件对指定区域内的数值求和(条件需同时满足),举例:SUMIFS([1000, 2000, 1500, 3000], [400, 600, 700, 800], '>500', [2022, 2023, 2023, 2024], 2023)=3500`,
|
|
152
158
|
formulaAVERAGE:
|
|
153
159
|
"返回一组数据的平均数,举例:AVERAGE(1,2,3,...)=2",
|
|
154
160
|
formulaMAX:
|
|
@@ -121,7 +121,294 @@ export function calculateFormula(VFR, DSV, formulaJs, formulaFieldRef, changedFi
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
const formulaValue = evalFn(formula, DSV, VFR, formulaJs)
|
|
124
|
-
formulaFieldRef.setValue(formulaValue)
|
|
124
|
+
if(formulaFieldRef)formulaFieldRef.setValue(formulaValue)
|
|
125
|
+
return formulaValue
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ... existing code ...
|
|
129
|
+
export function baseCalculateFormula(that,formulaStr, row /* VFR, DSV, formulaJs, formulaFieldRef, changedFieldRef */) {
|
|
130
|
+
if(!formulaStr)return
|
|
131
|
+
let formula = formulaStr;
|
|
132
|
+
let VFR = that.getFormRef();
|
|
133
|
+
let DSV = that.getGlobalDsv()
|
|
134
|
+
let formulaJs = formulajs
|
|
135
|
+
let formulaFieldRef = that;
|
|
136
|
+
let changedFieldRef = arguments[5];
|
|
137
|
+
|
|
138
|
+
// 增强子表单字段变化时的计算范围控制
|
|
139
|
+
if (formulaFieldRef.tableParam) {
|
|
140
|
+
} else if (!!formulaFieldRef.subFormItemFlag && !!changedFieldRef?.subFormItemFlag) {
|
|
141
|
+
/* 子表单字段变化,只能触发子表单同一行字段的计算公式重新计算 */
|
|
142
|
+
if (changedFieldRef.subFormRowId !== formulaFieldRef.subFormRowId) {
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 预处理:识别并标记聚合函数,记录它们的参数字段所属子表单
|
|
148
|
+
const aggregationFunctions = ['SUM', 'AVERAGE', 'MAX', 'MIN', 'SUMIF', 'SUMIFS'];
|
|
149
|
+
let functionCalls = [];
|
|
150
|
+
|
|
151
|
+
// 解析公式中的函数调用
|
|
152
|
+
// 方案1:先替换占位符,再解析函数调用
|
|
153
|
+
// 临时处理公式中的占位符,以便正确识别函数调用
|
|
154
|
+
let tempFormula = formulaStr;
|
|
155
|
+
const placeholders = tempFormula.match(/\{\{([^}]*)\}\}/g) || [];
|
|
156
|
+
placeholders.forEach(placeholder => {
|
|
157
|
+
// 处理函数占位符
|
|
158
|
+
if (placeholder.includes('.func')) {
|
|
159
|
+
const parts = placeholder.split('.');
|
|
160
|
+
if (parts.length >= 2) {
|
|
161
|
+
const fieldId = parts[0].substring(2); // 去掉开头的 {{
|
|
162
|
+
const funcName = parts[1];
|
|
163
|
+
// 临时替换函数占位符为函数名,便于后续解析
|
|
164
|
+
tempFormula = tempFormula.replace(placeholder, funcName);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// 解析公式中的函数调用 - 修改正则表达式,支持大小写字母
|
|
170
|
+
let functionCallMatch;
|
|
171
|
+
const functionCallRegex = /([A-Za-z]+)\s*\(([^)]*)\)/g;
|
|
172
|
+
while ((functionCallMatch = functionCallRegex.exec(tempFormula)) !== null) {
|
|
173
|
+
const funcName = functionCallMatch[1].toUpperCase();
|
|
174
|
+
const params = functionCallMatch[2];
|
|
175
|
+
|
|
176
|
+
if (aggregationFunctions.includes(funcName)) {
|
|
177
|
+
// 找出原始公式中对应的位置
|
|
178
|
+
const originalStart = formulaStr.indexOf(functionCallMatch[0].substring(0, 10));
|
|
179
|
+
|
|
180
|
+
functionCalls.push({
|
|
181
|
+
name: funcName,
|
|
182
|
+
params: params,
|
|
183
|
+
fullMatch: functionCallMatch[0],
|
|
184
|
+
start: originalStart > -1 ? originalStart : functionCallMatch.index
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// 替换字段值,增加对子表单引用子表单场景的特殊处理
|
|
190
|
+
formula = baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, formula, row, functionCalls)
|
|
191
|
+
|
|
192
|
+
if (!formula) {
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
//替换formula-js函数
|
|
197
|
+
const matchResult = formula.match(/[A-Za-z]*/g)
|
|
198
|
+
let matchedList = []
|
|
199
|
+
if (!!matchResult) {
|
|
200
|
+
matchResult.forEach(mi => {
|
|
201
|
+
if (!!mi && (findCalFunStartIndex(mi) !== -1) && !matchedList.includes(mi)) {
|
|
202
|
+
const funcName = mi.toUpperCase()
|
|
203
|
+
formula = formula.replaceAll(mi, 'formulaJs.' + funcName)
|
|
204
|
+
matchedList.push(mi)
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
const formulaValue = evalFn(formula, DSV, VFR, formulaJs)
|
|
211
|
+
return formulaValue
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error('公式计算错误:', error, '公式:', formula);
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// 优化 baseReplaceFieldsAndFunctionsOfFormula 方法,增加对聚合函数的特殊处理
|
|
219
|
+
export function baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, formula, row, functionCalls = []) {
|
|
220
|
+
// let formula = formulaFieldRef.field.options.formula
|
|
221
|
+
const matchResult = formula.match(FORMULA_REG_EXP)
|
|
222
|
+
if (!matchResult) {
|
|
223
|
+
return formula
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let resultFormula = formula
|
|
227
|
+
let quitFlag = false
|
|
228
|
+
|
|
229
|
+
// 记录所有字段引用及其所属子表单
|
|
230
|
+
let fieldReferences = [];
|
|
231
|
+
|
|
232
|
+
matchResult.forEach(mi => {
|
|
233
|
+
const thirdPart = mi.split('.')[2]
|
|
234
|
+
const nodeType = thirdPart.substring(0, thirdPart.length - 2)
|
|
235
|
+
if (nodeType === 'func') {
|
|
236
|
+
const funcName = mi.split('.')[1]
|
|
237
|
+
resultFormula = resultFormula.replace(mi, funcName)
|
|
238
|
+
return
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const firstPart = mi.split('.')[0]
|
|
242
|
+
const fieldId = firstPart.substring(2, firstPart.length)
|
|
243
|
+
const fieldSchema = getFieldWidgetById(VFR.formJsonObj.widgetList, fieldId, false)
|
|
244
|
+
if (!!fieldSchema) {
|
|
245
|
+
let fieldRef = VFR.getWidgetRef(fieldSchema.options.name)
|
|
246
|
+
if (!!fieldRef) {
|
|
247
|
+
let fieldKeyName = getFieldKeyName(fieldSchema)
|
|
248
|
+
let value = fieldRef.formModel[fieldKeyName]??null;
|
|
249
|
+
resultFormula = resultFormula.replace(mi, value)
|
|
250
|
+
} else { //getWidgetRef找不到,则可能是子表单字段
|
|
251
|
+
const subFormNameOfField = VFR.getSubFormNameOfWidget(fieldSchema.options.name)
|
|
252
|
+
|
|
253
|
+
// 记录字段引用信息
|
|
254
|
+
fieldReferences.push({
|
|
255
|
+
placeholder: mi,
|
|
256
|
+
fieldName: fieldSchema.options.name,
|
|
257
|
+
subFormName: subFormNameOfField
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
if (!!formulaFieldRef.subFormItemFlag || formulaFieldRef.tableParam || row) {
|
|
261
|
+
/* 如果当前计算字段是子表单字段,要判断公式中的子表单字段是否和当前计算字段是否属于同一子表单!! */
|
|
262
|
+
// 判断是否是同一子表单
|
|
263
|
+
const isSameSubForm = subFormNameOfField === formulaFieldRef?.parentWidget?.options?.name ||
|
|
264
|
+
subFormNameOfField === formulaFieldRef.subFormName;
|
|
265
|
+
|
|
266
|
+
// 检查该字段是否在某个聚合函数的参数中
|
|
267
|
+
let isInAggregationParam = false;
|
|
268
|
+
functionCalls.forEach(call => {
|
|
269
|
+
if (call.params.includes(mi)) {
|
|
270
|
+
isInAggregationParam = true;
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
/* if(functionCalls.length){
|
|
275
|
+
debugger
|
|
276
|
+
} */
|
|
277
|
+
|
|
278
|
+
if (isSameSubForm && !isInAggregationParam) {
|
|
279
|
+
// 同一子表单且不在聚合函数参数中,使用当前行数据
|
|
280
|
+
if(row){
|
|
281
|
+
let fieldKeyName = getFieldKeyName(fieldSchema)
|
|
282
|
+
let value = row[fieldKeyName]??null;
|
|
283
|
+
resultFormula = resultFormula.replaceAll(mi, value)
|
|
284
|
+
}else if (subFormNameOfField === formulaFieldRef?.parentWidget?.options?.name) {
|
|
285
|
+
let subFormRowId = formulaFieldRef.tableParam.row._X_ROW_KEY
|
|
286
|
+
fieldRef = VFR.getWidgetRef(fieldSchema.options.name + '_' + subFormRowId)
|
|
287
|
+
if (!!fieldRef) {
|
|
288
|
+
let value = fieldRef.currentValue??null;
|
|
289
|
+
resultFormula = resultFormula.replaceAll(mi, value)
|
|
290
|
+
} else {
|
|
291
|
+
quitFlag = true
|
|
292
|
+
console.error('Field not found: ' + fieldSchema.options.label)
|
|
293
|
+
}
|
|
294
|
+
} else if (subFormNameOfField === formulaFieldRef.subFormName) {
|
|
295
|
+
fieldRef = VFR.getWidgetRef(fieldSchema.options.name + '@row' + formulaFieldRef.subFormRowId)
|
|
296
|
+
if (!!fieldRef) {
|
|
297
|
+
resultFormula = resultFormula.replaceAll(mi, fieldRef.currentValue)
|
|
298
|
+
} else {
|
|
299
|
+
quitFlag = true
|
|
300
|
+
console.error('Field not found: ' + fieldSchema.options.label)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
// 不同子表单或在聚合函数参数中,使用全部明细行数据创建数组表达式
|
|
305
|
+
let dataTableRef = VFR.getWidgetRef(subFormNameOfField)
|
|
306
|
+
if (!dataTableRef) {
|
|
307
|
+
console.error('Subform not found: ' + subFormNameOfField);
|
|
308
|
+
quitFlag = true;
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const subFormValue = VFR.formDataModel[fieldKeyName(dataTableRef.widget)] || [];
|
|
313
|
+
const subFieldName = fieldKeyName(fieldSchema);
|
|
314
|
+
|
|
315
|
+
// 构建有效的数组表达式
|
|
316
|
+
let arrayExpr = '[';
|
|
317
|
+
subFormValue.forEach((vi, idx) => {
|
|
318
|
+
const val = vi[subFieldName] ?? null;
|
|
319
|
+
// 确保数值类型正确处理
|
|
320
|
+
if (val === null || val === undefined || val === '') {
|
|
321
|
+
arrayExpr += (idx === 0) ? '0' : ', 0';
|
|
322
|
+
} else if (typeof val === 'string' && !isNaN(Number(val))) {
|
|
323
|
+
arrayExpr += (idx === 0) ? Number(val) : ', ' + Number(val);
|
|
324
|
+
} else if (typeof val === 'number') {
|
|
325
|
+
arrayExpr += (idx === 0) ? val : ', ' + val;
|
|
326
|
+
} else {
|
|
327
|
+
arrayExpr += (idx === 0) ? '0' : ', 0';
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
arrayExpr += ']';
|
|
331
|
+
|
|
332
|
+
resultFormula = resultFormula.replaceAll(mi, arrayExpr);
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
/* 在主表单字段的计算公式中使用子表单字段,应将子表单所有记录同字段的值代入!! */
|
|
336
|
+
let dataTableRef = VFR.getWidgetRef(subFormNameOfField)
|
|
337
|
+
const subFormValue = VFR.formDataModel[fieldKeyName(dataTableRef.widget)]
|
|
338
|
+
let allSubFieldValues = ''
|
|
339
|
+
const subFieldName = fieldKeyName(fieldSchema)
|
|
340
|
+
|
|
341
|
+
// 对于聚合函数,创建数组表达式
|
|
342
|
+
let isInAggregationParam = false;
|
|
343
|
+
functionCalls.forEach(call => {
|
|
344
|
+
if (call.params.includes(mi)) {
|
|
345
|
+
isInAggregationParam = true;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
if (isInAggregationParam) {
|
|
350
|
+
let arrayExpr = '[';
|
|
351
|
+
subFormValue.forEach((vi, idx) => {
|
|
352
|
+
const val = vi[subFieldName] ?? 0;
|
|
353
|
+
arrayExpr += (idx === 0) ? val : ', ' + val;
|
|
354
|
+
});
|
|
355
|
+
arrayExpr += ']';
|
|
356
|
+
resultFormula = resultFormula.replaceAll(mi, arrayExpr);
|
|
357
|
+
} else {
|
|
358
|
+
// 非聚合函数,使用逗号分隔的字符串
|
|
359
|
+
subFormValue.forEach((vi, idx) => {
|
|
360
|
+
let val = vi[subFieldName]??null
|
|
361
|
+
allSubFieldValues = (idx === 0) ? val : allSubFieldValues + ', ' + val
|
|
362
|
+
})
|
|
363
|
+
resultFormula = resultFormula.replaceAll(mi, allSubFieldValues)
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
return quitFlag ? null : resultFormula
|
|
371
|
+
}
|
|
372
|
+
// ... existing code ...
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
function getFieldKeyName(widget) {
|
|
376
|
+
let o = widget.options.name;
|
|
377
|
+
return (widget.options.keyNameEnabled && widget.options.keyName) || o;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function funOtherHanlde(){
|
|
381
|
+
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export function calculateFormula2(formulaStr, data, that) {
|
|
385
|
+
if(!formulaStr)return
|
|
386
|
+
let formula = formulaStr;
|
|
387
|
+
let VFR = that.getFormRef();
|
|
388
|
+
let DSV = that.getGlobalDsv()
|
|
389
|
+
let formulaJs = formulajs
|
|
390
|
+
|
|
391
|
+
if(data){
|
|
392
|
+
for(let key in data){
|
|
393
|
+
formula = formula.replaceAll(`[${key}]`,(data[key] || 0))
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
//替换formula-js函数
|
|
398
|
+
const matchResult = formula.match(/[A-Za-z]*/g)
|
|
399
|
+
let matchedList = []
|
|
400
|
+
if (!!matchResult) {
|
|
401
|
+
matchResult.forEach(mi => {
|
|
402
|
+
if (!!mi && (findCalFunStartIndex(mi) !== -1) && !matchedList.includes(mi)) {
|
|
403
|
+
const funcName = mi.toUpperCase()
|
|
404
|
+
formula = formula.replaceAll(mi, 'formulaJs.' + funcName)
|
|
405
|
+
matchedList.push(mi)
|
|
406
|
+
}
|
|
407
|
+
})
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const formulaValue = evalFn(formula, DSV, VFR, formulaJs)
|
|
411
|
+
return formulaValue
|
|
125
412
|
}
|
|
126
413
|
|
|
127
414
|
/**
|
|
@@ -159,6 +446,7 @@ export function fieldIsUsedInFormula(fieldName, formula, VFR, fieldTarget) {
|
|
|
159
446
|
return foundResult
|
|
160
447
|
}
|
|
161
448
|
|
|
449
|
+
|
|
162
450
|
/**
|
|
163
451
|
* 替换计算公式中的字段值
|
|
164
452
|
* @param VFR
|
|
@@ -190,7 +478,7 @@ export function replaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef) {
|
|
|
190
478
|
let fieldRef = VFR.getWidgetRef(fieldSchema.options.name)
|
|
191
479
|
if (!!fieldRef) {
|
|
192
480
|
//是否要考虑字符串值的替换??
|
|
193
|
-
resultFormula = resultFormula.replace(mi, fieldRef.
|
|
481
|
+
resultFormula = resultFormula.replace(mi, fieldRef.currentValue)
|
|
194
482
|
} else { //getWidgetRef找不到,则可能是子表单字段
|
|
195
483
|
const subFormNameOfField = VFR.getSubFormNameOfWidget(fieldSchema.options.name)
|
|
196
484
|
if (!!formulaFieldRef.subFormItemFlag || formulaFieldRef.tableParam) {
|
|
@@ -201,7 +489,7 @@ export function replaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef) {
|
|
|
201
489
|
let subFormRowId = formulaFieldRef.tableParam.row._X_ROW_KEY
|
|
202
490
|
fieldRef = VFR.getWidgetRef(fieldSchema.options.name + '_' + subFormRowId)
|
|
203
491
|
if (!!fieldRef) {
|
|
204
|
-
resultFormula = resultFormula.replaceAll(mi, fieldRef.
|
|
492
|
+
resultFormula = resultFormula.replaceAll(mi, fieldRef.currentValue)
|
|
205
493
|
} else {
|
|
206
494
|
quitFlag = true
|
|
207
495
|
console.error('Field not found: ' + fieldSchema.options.label)
|
|
@@ -209,7 +497,7 @@ export function replaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef) {
|
|
|
209
497
|
} else if (subFormNameOfField === formulaFieldRef.subFormName) {
|
|
210
498
|
fieldRef = VFR.getWidgetRef(fieldSchema.options.name + '@row' + formulaFieldRef.subFormRowId)
|
|
211
499
|
if (!!fieldRef) {
|
|
212
|
-
resultFormula = resultFormula.replaceAll(mi, fieldRef.
|
|
500
|
+
resultFormula = resultFormula.replaceAll(mi, fieldRef.currentValue)
|
|
213
501
|
} else {
|
|
214
502
|
quitFlag = true
|
|
215
503
|
console.error('Field not found: ' + fieldSchema.options.label)
|
|
@@ -219,7 +507,10 @@ export function replaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef) {
|
|
|
219
507
|
}
|
|
220
508
|
} else {
|
|
221
509
|
/* 在主表单字段的计算公式中使用子表单字段,应将子表单所有记录同字段的值代入!! */
|
|
222
|
-
const subFormValue = VFR.formDataModel[subFormNameOfField]
|
|
510
|
+
// const subFormValue = VFR.formDataModel[subFormNameOfField]
|
|
511
|
+
let dataTableRef = VFR.getWidgetRef(subFormNameOfField)
|
|
512
|
+
const subFormValue = VFR.formDataModel[fieldKeyName(dataTableRef.widget)]
|
|
513
|
+
|
|
223
514
|
let allSubFieldValues = ''
|
|
224
515
|
// const subFieldName = fieldSchema.options.name
|
|
225
516
|
const subFieldName = fieldKeyName(fieldSchema)
|
|
@@ -484,6 +775,16 @@ export const formulas = [
|
|
|
484
775
|
fType: "designer.hint.formulaNumber",
|
|
485
776
|
fIntro: "designer.hint.formulaSUM",
|
|
486
777
|
},
|
|
778
|
+
{
|
|
779
|
+
fName: "SUMIF",
|
|
780
|
+
fType: "designer.hint.formulaNumber",
|
|
781
|
+
fIntro: "designer.hint.formulaSUMIF",
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
fName: "SUMIFS",
|
|
785
|
+
fType: "designer.hint.formulaNumber",
|
|
786
|
+
fIntro: "designer.hint.formulaSUMIFS",
|
|
787
|
+
},
|
|
487
788
|
{
|
|
488
789
|
fName: "AVERAGE",
|
|
489
790
|
fType: "designer.hint.formulaNumber",
|