cloud-web-corejs 1.0.54-dev.424 → 1.0.54-dev.426
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 +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/download-button-widget.vue +143 -0
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +35 -0
- package/src/components/xform/form-render/index.vue +2 -0
- package/src/components/xform/form-render/indexMixin.js +5 -0
- package/src/components/xform/lang/zh-CN.js +1 -0
- package/src/components/xform/utils/formula-util.js +178 -68
- package/src/utils/vab.js +6 -2
package/package.json
CHANGED
package/src/components/xform/form-designer/form-widget/field-widget/download-button-widget.vue
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<static-content-wrapper
|
|
3
|
+
:designer="designer"
|
|
4
|
+
:field="field"
|
|
5
|
+
:design-state="designState"
|
|
6
|
+
:display-style="field.options.displayStyle"
|
|
7
|
+
:parent-widget="parentWidget"
|
|
8
|
+
:parent-list="parentList"
|
|
9
|
+
:index-of-parent-list="indexOfParentList"
|
|
10
|
+
:sub-form-row-index="subFormRowIndex"
|
|
11
|
+
:sub-form-col-index="subFormColIndex"
|
|
12
|
+
:sub-form-row-id="subFormRowId"
|
|
13
|
+
>
|
|
14
|
+
<el-button
|
|
15
|
+
class="button-sty"
|
|
16
|
+
@click="clickHandle"
|
|
17
|
+
icon="el-icon-download"
|
|
18
|
+
:disabled="!designState && field.options.disabled"
|
|
19
|
+
>
|
|
20
|
+
{{ getI18nLabel(field.options.label) }}
|
|
21
|
+
</el-button>
|
|
22
|
+
</static-content-wrapper>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
import StaticContentWrapper from "./static-content-wrapper";
|
|
27
|
+
import emitter from "../../../utils/emitter";
|
|
28
|
+
import i18n from "../../../utils/i18n";
|
|
29
|
+
import fieldMixin from "./fieldMixin";
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
name: "download-button-widget",
|
|
33
|
+
componentName: "FieldWidget", //必须固定为FieldWidget,用于接收父级组件的broadcast事件
|
|
34
|
+
mixins: [emitter, fieldMixin, i18n],
|
|
35
|
+
props: {
|
|
36
|
+
field: Object,
|
|
37
|
+
parentWidget: Object,
|
|
38
|
+
parentList: Array,
|
|
39
|
+
indexOfParentList: Number,
|
|
40
|
+
designer: Object,
|
|
41
|
+
|
|
42
|
+
designState: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false,
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
subFormRowIndex: {
|
|
48
|
+
/* 子表单组件行索引,从0开始计数 */ type: Number,
|
|
49
|
+
default: -1,
|
|
50
|
+
},
|
|
51
|
+
subFormColIndex: {
|
|
52
|
+
/* 子表单组件列索引,从0开始计数 */ type: Number,
|
|
53
|
+
default: -1,
|
|
54
|
+
},
|
|
55
|
+
subFormRowId: {
|
|
56
|
+
/* 子表单组件行Id,唯一id且不可变 */ type: String,
|
|
57
|
+
default: "",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
components: {
|
|
61
|
+
StaticContentWrapper,
|
|
62
|
+
},
|
|
63
|
+
computed: {},
|
|
64
|
+
beforeCreate() {
|
|
65
|
+
/* 这里不能访问方法和属性!! */
|
|
66
|
+
},
|
|
67
|
+
created() {
|
|
68
|
+
/* 注意:子组件mounted在父组件created之后、父组件mounted之前触发,故子组件mounted需要用到的prop
|
|
69
|
+
需要在父组件created中初始化!! */
|
|
70
|
+
this.registerToRefList();
|
|
71
|
+
this.initEventHandler();
|
|
72
|
+
|
|
73
|
+
this.handleOnCreated();
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
mounted() {
|
|
77
|
+
this.handleOnMounted();
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
beforeDestroy() {
|
|
81
|
+
this.unregisterFromRefList();
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
methods: {
|
|
85
|
+
clickHandle() {
|
|
86
|
+
if (this.designState || this.field.options.disabled) return;
|
|
87
|
+
/* let copyData = this.$baseLodash.cloneDeep(this.formModel);
|
|
88
|
+
|
|
89
|
+
this.handleCustomEvent(this.field.options.copyDataHandle, ["copyData"], [copyData])
|
|
90
|
+
this.getFormRef().openCopyEditTab(copyData); */
|
|
91
|
+
},
|
|
92
|
+
downloadHandle() {
|
|
93
|
+
|
|
94
|
+
},
|
|
95
|
+
loadDataDefaultHandle() {
|
|
96
|
+
let reportTemplate = this.getFormRef().reportTemplate;
|
|
97
|
+
let formCode = reportTemplate.formCode;
|
|
98
|
+
let formScriptEnabled = this.field.options.formScriptEnabled || false;
|
|
99
|
+
let scriptCode = this.field.options.formScriptCode;
|
|
100
|
+
if (!scriptCode) return;
|
|
101
|
+
if (dataId) {
|
|
102
|
+
let accessParam = this.handleCustomEvent(
|
|
103
|
+
this.field.options.formScriptParam
|
|
104
|
+
);
|
|
105
|
+
return this.formHttp({
|
|
106
|
+
scriptCode: scriptCode,
|
|
107
|
+
data: {
|
|
108
|
+
formCode: formCode,
|
|
109
|
+
formVersion: reportTemplate.formVersion,
|
|
110
|
+
taBm: this.fieldKeyName,
|
|
111
|
+
data: {
|
|
112
|
+
...accessParam,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
success: (res) => {
|
|
116
|
+
let data = res.objx;
|
|
117
|
+
if(data){
|
|
118
|
+
this.$downloadByFileWhole(data, (url)=>{
|
|
119
|
+
this.openInNewTab(url)
|
|
120
|
+
})
|
|
121
|
+
}else{
|
|
122
|
+
this.$message.error(this.$t1("下载文件失败"))
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
openInNewTab(url) {
|
|
129
|
+
if (!url) return;
|
|
130
|
+
var a = document.createElement("a");
|
|
131
|
+
a.href = url;
|
|
132
|
+
a.target = "_blank";
|
|
133
|
+
document.body.appendChild(a);
|
|
134
|
+
a.click();
|
|
135
|
+
document.body.removeChild(a);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
</script>
|
|
140
|
+
|
|
141
|
+
<style lang="scss" scoped>
|
|
142
|
+
@import "~@/styles/global.scss"; //* static-content-wrapper已引入,还需要重复引入吗? *//
|
|
143
|
+
</style>
|
|
@@ -3423,6 +3423,41 @@ export const advancedFields = [
|
|
|
3423
3423
|
|
|
3424
3424
|
},
|
|
3425
3425
|
},
|
|
3426
|
+
|
|
3427
|
+
{
|
|
3428
|
+
type: "download-button",
|
|
3429
|
+
icon: "button",
|
|
3430
|
+
commonFlag: !0,
|
|
3431
|
+
columnFlag: true,
|
|
3432
|
+
formItemFlag: !1,
|
|
3433
|
+
options: {
|
|
3434
|
+
name: "",
|
|
3435
|
+
label: "附件下载",
|
|
3436
|
+
columnWidth: "200px",
|
|
3437
|
+
size: "",
|
|
3438
|
+
|
|
3439
|
+
// displayStyle: "block",
|
|
3440
|
+
disabled: !1,
|
|
3441
|
+
hidden: !1,
|
|
3442
|
+
buttonTypeFlag: 1,
|
|
3443
|
+
type: "",
|
|
3444
|
+
/*plain: !1,
|
|
3445
|
+
round: !1,
|
|
3446
|
+
circle: !1,
|
|
3447
|
+
icon: "el-icon-download",*/
|
|
3448
|
+
customClass: "",
|
|
3449
|
+
...httpConfig,
|
|
3450
|
+
|
|
3451
|
+
downloadButton: "",
|
|
3452
|
+
|
|
3453
|
+
onCreated: "",
|
|
3454
|
+
onMounted: "",
|
|
3455
|
+
...defaultWfConfig,
|
|
3456
|
+
showRuleFlag: 1,
|
|
3457
|
+
showRuleEnabled: 1,
|
|
3458
|
+
showRules: [],
|
|
3459
|
+
},
|
|
3460
|
+
},
|
|
3426
3461
|
];
|
|
3427
3462
|
|
|
3428
3463
|
export const businessFields = [
|
|
@@ -62,11 +62,13 @@
|
|
|
62
62
|
<searchFormDialog
|
|
63
63
|
v-if="showSearchDialog"
|
|
64
64
|
:visiable.sync="showSearchDialog"
|
|
65
|
+
ref="searchFormDialog"
|
|
65
66
|
:option="searchDialogOption"
|
|
66
67
|
></searchFormDialog>
|
|
67
68
|
<formDialog
|
|
68
69
|
v-if="showFormDialog"
|
|
69
70
|
:visiable.sync="showFormDialog"
|
|
71
|
+
ref="formDialog"
|
|
70
72
|
:option="formDialogOption"
|
|
71
73
|
></formDialog>
|
|
72
74
|
<importDialog
|
|
@@ -2771,6 +2771,11 @@ modules = {
|
|
|
2771
2771
|
this.formDialogOption = option;
|
|
2772
2772
|
this.showFormDialog = true;
|
|
2773
2773
|
},
|
|
2774
|
+
closeFormDialog() {
|
|
2775
|
+
if(this.showFormDialog){
|
|
2776
|
+
this.$refs.formDialog.close();
|
|
2777
|
+
}
|
|
2778
|
+
},
|
|
2774
2779
|
confirmFormDialog() {
|
|
2775
2780
|
this.formDialogOption.confirm && this.formDialogOption.confirm();
|
|
2776
2781
|
},
|
|
@@ -125,6 +125,7 @@ export function calculateFormula(VFR, DSV, formulaJs, formulaFieldRef, changedFi
|
|
|
125
125
|
return formulaValue
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
// ... existing code ...
|
|
128
129
|
export function baseCalculateFormula(that,formulaStr, row /* VFR, DSV, formulaJs, formulaFieldRef, changedFieldRef */) {
|
|
129
130
|
if(!formulaStr)return
|
|
130
131
|
let formula = formulaStr;
|
|
@@ -132,15 +133,62 @@ export function baseCalculateFormula(that,formulaStr, row /* VFR, DSV, formulaJs
|
|
|
132
133
|
let DSV = that.getGlobalDsv()
|
|
133
134
|
let formulaJs = formulajs
|
|
134
135
|
let formulaFieldRef = that;
|
|
136
|
+
let changedFieldRef = arguments[5];
|
|
137
|
+
|
|
138
|
+
// 增强子表单字段变化时的计算范围控制
|
|
135
139
|
if (formulaFieldRef.tableParam) {
|
|
136
|
-
} else if (!!formulaFieldRef.subFormItemFlag && !!changedFieldRef
|
|
137
|
-
/*
|
|
138
|
-
|
|
140
|
+
} else if (!!formulaFieldRef.subFormItemFlag && !!changedFieldRef?.subFormItemFlag) {
|
|
141
|
+
/* 子表单字段变化,只能触发子表单同一行字段的计算公式重新计算 */
|
|
142
|
+
if (changedFieldRef.subFormRowId !== formulaFieldRef.subFormRowId) {
|
|
139
143
|
return
|
|
140
|
-
}
|
|
144
|
+
}
|
|
141
145
|
}
|
|
142
146
|
|
|
143
|
-
|
|
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
|
+
|
|
144
192
|
if (!formula) {
|
|
145
193
|
return
|
|
146
194
|
}
|
|
@@ -158,26 +206,17 @@ export function baseCalculateFormula(that,formulaStr, row /* VFR, DSV, formulaJs
|
|
|
158
206
|
})
|
|
159
207
|
}
|
|
160
208
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return (widget.options.keyNameEnabled && widget.options.keyName) || o;
|
|
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
|
+
}
|
|
169
216
|
}
|
|
170
217
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* 替换计算公式中的字段值
|
|
176
|
-
* @param VFR
|
|
177
|
-
* @param formulaFieldRef
|
|
178
|
-
* @returns {*}
|
|
179
|
-
*/
|
|
180
|
-
export function baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, formula, row) {
|
|
218
|
+
// 优化 baseReplaceFieldsAndFunctionsOfFormula 方法,增加对聚合函数的特殊处理
|
|
219
|
+
export function baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, formula, row, functionCalls = []) {
|
|
181
220
|
// let formula = formulaFieldRef.field.options.formula
|
|
182
221
|
const matchResult = formula.match(FORMULA_REG_EXP)
|
|
183
222
|
if (!matchResult) {
|
|
@@ -186,16 +225,16 @@ export function baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, for
|
|
|
186
225
|
|
|
187
226
|
let resultFormula = formula
|
|
188
227
|
let quitFlag = false
|
|
228
|
+
|
|
229
|
+
// 记录所有字段引用及其所属子表单
|
|
230
|
+
let fieldReferences = [];
|
|
231
|
+
|
|
189
232
|
matchResult.forEach(mi => {
|
|
190
233
|
const thirdPart = mi.split('.')[2]
|
|
191
234
|
const nodeType = thirdPart.substring(0, thirdPart.length - 2)
|
|
192
235
|
if (nodeType === 'func') {
|
|
193
236
|
const funcName = mi.split('.')[1]
|
|
194
237
|
resultFormula = resultFormula.replace(mi, funcName)
|
|
195
|
-
|
|
196
|
-
/* if(funcName === "SUMIF" || funcName === "SUMIFS"){
|
|
197
|
-
debugger
|
|
198
|
-
} */
|
|
199
238
|
return
|
|
200
239
|
}
|
|
201
240
|
|
|
@@ -205,64 +244,124 @@ export function baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, for
|
|
|
205
244
|
if (!!fieldSchema) {
|
|
206
245
|
let fieldRef = VFR.getWidgetRef(fieldSchema.options.name)
|
|
207
246
|
if (!!fieldRef) {
|
|
208
|
-
//是否要考虑字符串值的替换??
|
|
209
|
-
// resultFormula = resultFormula.replace(mi, fieldRef.currentValue)
|
|
210
247
|
let fieldKeyName = getFieldKeyName(fieldSchema)
|
|
211
248
|
let value = fieldRef.formModel[fieldKeyName]??null;
|
|
212
249
|
resultFormula = resultFormula.replace(mi, value)
|
|
213
250
|
} else { //getWidgetRef找不到,则可能是子表单字段
|
|
214
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
|
+
|
|
215
260
|
if (!!formulaFieldRef.subFormItemFlag || formulaFieldRef.tableParam || row) {
|
|
216
261
|
/* 如果当前计算字段是子表单字段,要判断公式中的子表单字段是否和当前计算字段是否属于同一子表单!! */
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if
|
|
236
|
-
let
|
|
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;
|
|
237
283
|
resultFormula = resultFormula.replaceAll(mi, value)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
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
|
+
}
|
|
241
302
|
}
|
|
242
|
-
} else
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
quitFlag = true
|
|
248
|
-
|
|
303
|
+
} else {
|
|
304
|
+
// 不同子表单或在聚合函数参数中,使用全部明细行数据创建数组表达式
|
|
305
|
+
let dataTableRef = VFR.getWidgetRef(subFormNameOfField)
|
|
306
|
+
if (!dataTableRef) {
|
|
307
|
+
console.error('Subform not found: ' + subFormNameOfField);
|
|
308
|
+
quitFlag = true;
|
|
309
|
+
return;
|
|
249
310
|
}
|
|
250
|
-
|
|
251
|
-
|
|
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);
|
|
252
333
|
}
|
|
253
334
|
} else {
|
|
254
335
|
/* 在主表单字段的计算公式中使用子表单字段,应将子表单所有记录同字段的值代入!! */
|
|
255
|
-
// const subFormValue = VFR.formDataModel[subFormNameOfField]
|
|
256
336
|
let dataTableRef = VFR.getWidgetRef(subFormNameOfField)
|
|
257
337
|
const subFormValue = VFR.formDataModel[fieldKeyName(dataTableRef.widget)]
|
|
258
338
|
let allSubFieldValues = ''
|
|
259
|
-
// const subFieldName = fieldSchema.options.name
|
|
260
339
|
const subFieldName = fieldKeyName(fieldSchema)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
+
}
|
|
266
365
|
}
|
|
267
366
|
}
|
|
268
367
|
}
|
|
@@ -270,6 +369,17 @@ export function baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, for
|
|
|
270
369
|
|
|
271
370
|
return quitFlag ? null : resultFormula
|
|
272
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
|
+
}
|
|
273
383
|
|
|
274
384
|
export function calculateFormula2(formulaStr, data, that) {
|
|
275
385
|
if(!formulaStr)return
|
package/src/utils/vab.js
CHANGED
|
@@ -1024,7 +1024,7 @@ install = (Vue, opts = {}) => {
|
|
|
1024
1024
|
});
|
|
1025
1025
|
};
|
|
1026
1026
|
|
|
1027
|
-
Vue.prototype.$downloadByFileWhole = function (fileWhole) {
|
|
1027
|
+
Vue.prototype.$downloadByFileWhole = function (fileWhole, handler) {
|
|
1028
1028
|
let that = this;
|
|
1029
1029
|
if (!fileWhole) {
|
|
1030
1030
|
this.$baseAlert("凭证信息不存在");
|
|
@@ -1049,7 +1049,11 @@ install = (Vue, opts = {}) => {
|
|
|
1049
1049
|
isLoading: true,
|
|
1050
1050
|
success: (res) => {
|
|
1051
1051
|
// window.open(res.objx.url);
|
|
1052
|
-
|
|
1052
|
+
if(!handler){
|
|
1053
|
+
openInNewTab(res.objx.url);
|
|
1054
|
+
}else{
|
|
1055
|
+
handler(res.objx.url)
|
|
1056
|
+
}
|
|
1053
1057
|
},
|
|
1054
1058
|
});
|
|
1055
1059
|
});
|