cloud-web-corejs 1.0.54-dev.390 → 1.0.54-dev.392
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/dialog/baseFormulaDialog.vue +30 -31
- package/src/components/xform/form-designer/form-widget/field-widget/gantt-widget.vue +0 -1
- package/src/components/xform/mixins/defaultHandle.js +2 -2
- package/src/components/xform/utils/formula-util.js +27 -9
- package/src/components/xform/utils/util.js +1451 -1
package/package.json
CHANGED
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
:data="fieldTreeData"
|
|
63
63
|
:filter-node-method="filterNode"
|
|
64
64
|
@node-click="insertField"
|
|
65
|
+
default-expand-all
|
|
65
66
|
>
|
|
66
67
|
<template #default="{ node, data }">
|
|
67
68
|
<span class="custom-tree-node">
|
|
@@ -292,15 +293,6 @@ export default {
|
|
|
292
293
|
handleTableConfigData(widget, callback) {
|
|
293
294
|
callback(widget);
|
|
294
295
|
},
|
|
295
|
-
initFields() {
|
|
296
|
-
let option = this.option;
|
|
297
|
-
let formCode = option.formCode;
|
|
298
|
-
if (formCode) {
|
|
299
|
-
this.getReportTemplate(formCode, () => {
|
|
300
|
-
this.loadFieldListToTree();
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
296
|
initHandleFields() {
|
|
305
297
|
let option = this.option;
|
|
306
298
|
let formWidgetNames = option.formWidgetNames || [];
|
|
@@ -353,11 +345,11 @@ export default {
|
|
|
353
345
|
}
|
|
354
346
|
});
|
|
355
347
|
},
|
|
356
|
-
|
|
348
|
+
getReportTemplate(formCode, callback) {
|
|
357
349
|
let url, data;
|
|
358
350
|
url = USER_PREFIX + `/formTemplate/getByFormCode`;
|
|
359
351
|
data = { stringOne: formCode };
|
|
360
|
-
|
|
352
|
+
return this.$http({
|
|
361
353
|
// aes: true,
|
|
362
354
|
url: url,
|
|
363
355
|
method: `post`,
|
|
@@ -365,7 +357,7 @@ export default {
|
|
|
365
357
|
isLoading: true,
|
|
366
358
|
// loadingTarget: document.body,
|
|
367
359
|
// modalStrictly: true,
|
|
368
|
-
success:
|
|
360
|
+
success: (res) => {
|
|
369
361
|
let formTemplate = res.objx || {};
|
|
370
362
|
this.targetFormTemplate = formTemplate;
|
|
371
363
|
this.targetFormJson = formTemplate.formViewContent
|
|
@@ -616,30 +608,37 @@ export default {
|
|
|
616
608
|
|
|
617
609
|
// 打开编辑公式弹窗
|
|
618
610
|
editFormula() {
|
|
611
|
+
this.formula = this.option.formula ?? null;
|
|
619
612
|
this.fieldTreeData.length = 0;
|
|
620
613
|
// 初始化字段树
|
|
621
614
|
|
|
622
615
|
// this.loadFieldListToTree();
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
616
|
+
|
|
617
|
+
let option = this.option;
|
|
618
|
+
let formCode = option.formCode;
|
|
619
|
+
if (formCode) {
|
|
620
|
+
this.getReportTemplate(formCode, () => {
|
|
621
|
+
this.loadFieldListToTree();
|
|
622
|
+
console.log("设计器字段===>", this.fieldTreeData);
|
|
623
|
+
|
|
624
|
+
// 加载当前字段计算公式tags
|
|
625
|
+
this.refreshFormula();
|
|
626
|
+
const code = this.formula;
|
|
627
|
+
this.formulaDialogVisible = true;
|
|
628
|
+
|
|
629
|
+
//==== codeMirror 挂载视图 ====
|
|
630
|
+
this.$nextTick(() => {
|
|
631
|
+
this.codeMirror = new EditorView({
|
|
632
|
+
state: EditorState.create({
|
|
633
|
+
doc: code,
|
|
634
|
+
extensions: [basicSetup, javascript(), [baseTheme, [], placeholders]],
|
|
635
|
+
}),
|
|
636
|
+
parent: this.$refs.cmRef,
|
|
637
|
+
});
|
|
638
|
+
console.log("编辑器实例==>", this.codeMirror);
|
|
639
|
+
});
|
|
640
640
|
});
|
|
641
|
-
|
|
642
|
-
});
|
|
641
|
+
}
|
|
643
642
|
},
|
|
644
643
|
|
|
645
644
|
// 保存计算公式
|
|
@@ -335,8 +335,8 @@ modules = {
|
|
|
335
335
|
calculateFormula(formula,data){
|
|
336
336
|
return calculateFormula2(formula, data, this)
|
|
337
337
|
},
|
|
338
|
-
baseCalculateFormula(formula){
|
|
339
|
-
return baseCalculateFormula(formula,
|
|
338
|
+
baseCalculateFormula(formula, row){
|
|
339
|
+
return baseCalculateFormula(this,formula, row)
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
}
|
|
@@ -125,8 +125,7 @@ export function calculateFormula(VFR, DSV, formulaJs, formulaFieldRef, changedFi
|
|
|
125
125
|
return formulaValue
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
export function baseCalculateFormula(formulaStr,
|
|
129
|
-
|
|
128
|
+
export function baseCalculateFormula(that,formulaStr, row /* VFR, DSV, formulaJs, formulaFieldRef, changedFieldRef */) {
|
|
130
129
|
if(!formulaStr)return
|
|
131
130
|
let formula = formulaStr;
|
|
132
131
|
let VFR = that.getFormRef();
|
|
@@ -141,7 +140,7 @@ export function baseCalculateFormula(formulaStr, data, that /* VFR, DSV, formula
|
|
|
141
140
|
} */
|
|
142
141
|
}
|
|
143
142
|
|
|
144
|
-
formula = baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef,formula) //替换字段值
|
|
143
|
+
formula = baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef,formula,row) //替换字段值
|
|
145
144
|
if (!formula) {
|
|
146
145
|
return
|
|
147
146
|
}
|
|
@@ -163,13 +162,18 @@ export function baseCalculateFormula(formulaStr, data, that /* VFR, DSV, formula
|
|
|
163
162
|
return formulaValue
|
|
164
163
|
}
|
|
165
164
|
|
|
165
|
+
|
|
166
|
+
function getFieldKeyName(widget) {
|
|
167
|
+
let o = widget.options.name;
|
|
168
|
+
return (widget.options.keyNameEnabled && widget.options.keyName) || o;
|
|
169
|
+
}
|
|
166
170
|
/**
|
|
167
171
|
* 替换计算公式中的字段值
|
|
168
172
|
* @param VFR
|
|
169
173
|
* @param formulaFieldRef
|
|
170
174
|
* @returns {*}
|
|
171
175
|
*/
|
|
172
|
-
export function baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, formula) {
|
|
176
|
+
export function baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, formula, row) {
|
|
173
177
|
// let formula = formulaFieldRef.field.options.formula
|
|
174
178
|
const matchResult = formula.match(FORMULA_REG_EXP)
|
|
175
179
|
if (!matchResult) {
|
|
@@ -197,15 +201,29 @@ export function baseReplaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef, for
|
|
|
197
201
|
resultFormula = resultFormula.replace(mi, fieldRef.getValue())
|
|
198
202
|
} else { //getWidgetRef找不到,则可能是子表单字段
|
|
199
203
|
const subFormNameOfField = VFR.getSubFormNameOfWidget(fieldSchema.options.name)
|
|
200
|
-
if (!!formulaFieldRef.subFormItemFlag || formulaFieldRef.tableParam) {
|
|
204
|
+
if (!!formulaFieldRef.subFormItemFlag || formulaFieldRef.tableParam || row) {
|
|
201
205
|
/* 如果当前计算字段是子表单字段,要判断公式中的子表单字段是否和当前计算字段是否属于同一子表单!! */
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
206
|
+
if(row){
|
|
207
|
+
let fieldKeyName = getFieldKeyName(fieldSchema)
|
|
208
|
+
let value = row[fieldKeyName];
|
|
209
|
+
resultFormula = resultFormula.replaceAll(mi, value)
|
|
210
|
+
/*
|
|
211
|
+
let subFormRowId = row._X_ROW_KEY
|
|
212
|
+
fieldRef = VFR.getWidgetRef(fieldSchema.options.name + '_' + subFormRowId)
|
|
213
|
+
if (!!fieldRef) {
|
|
214
|
+
let value = fieldRef.getValue();
|
|
215
|
+
resultFormula = resultFormula.replaceAll(mi, value)
|
|
216
|
+
} else {
|
|
217
|
+
de
|
|
218
|
+
quitFlag = true
|
|
219
|
+
console.error('Field not found: ' + fieldSchema.options.label)
|
|
220
|
+
} */
|
|
221
|
+
}else if (subFormNameOfField === formulaFieldRef?.parentWidget?.options?.name) {
|
|
205
222
|
let subFormRowId = formulaFieldRef.tableParam.row._X_ROW_KEY
|
|
206
223
|
fieldRef = VFR.getWidgetRef(fieldSchema.options.name + '_' + subFormRowId)
|
|
207
224
|
if (!!fieldRef) {
|
|
208
|
-
|
|
225
|
+
let value = fieldRef.getValue();
|
|
226
|
+
resultFormula = resultFormula.replaceAll(mi, value)
|
|
209
227
|
} else {
|
|
210
228
|
quitFlag = true
|
|
211
229
|
console.error('Field not found: ' + fieldSchema.options.label)
|