cloud-web-corejs 1.0.54-dev.202 → 1.0.54-dev.204
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/excelExport/mixins.js +1 -1
- package/src/components/xform/form-designer/designer.js +0 -1
- package/src/components/xform/form-designer/form-widget/container-widget/data-table-mixin.js +245 -1
- package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +30 -36
- package/src/components/xform/form-designer/form-widget/field-widget/number-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/select-widget.vue +1 -1
- package/src/components/xform/form-designer/setting-panel/index.vue +4 -0
- package/src/components/xform/form-designer/setting-panel/indexMixin.js +2 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +23 -4
- package/src/components/xform/form-designer/setting-panel/property-editor/formula-editor.vue +214 -129
- package/src/components/xform/form-designer/setting-panel/property-editor/multiple-editor.vue +8 -3
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +2 -0
- package/src/components/xform/form-render/container-item/data-table-item.vue +7 -4
- package/src/components/xform/form-render/container-item/data-table-mixin.js +225 -34
- package/src/components/xform/form-render/container-item/data-table-mixin2.js +2169 -0
- package/src/components/xform/form-render/indexMixin.js +65 -16
- package/src/components/xform/utils/formula-util.js +33 -12
- package/src/components/xform/utils/util.js +762 -999
- package/src/views/bd/setting/form_script/edit1.vue +8 -1
@@ -1125,25 +1125,67 @@ modules = {
|
|
1125
1125
|
n && n.setDisabled && n.setHidden(t);
|
1126
1126
|
});
|
1127
1127
|
},
|
1128
|
-
findWidgetNameInSubForm
|
1129
|
-
let
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1128
|
+
findWidgetNameInSubForm(widgetName) {
|
1129
|
+
let result = []
|
1130
|
+
let subFormName = null
|
1131
|
+
Object.keys(this.subFormRefList).forEach(sfName => {
|
1132
|
+
const fwHandler = (fw) => {
|
1133
|
+
if (fw.options.name === widgetName) {
|
1134
|
+
subFormName = sfName
|
1135
|
+
}
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
const sfRef = this.subFormRefList[sfName]
|
1139
|
+
traverseFieldWidgetsOfContainer(sfRef.widget, fwHandler, true)
|
1140
|
+
})
|
1141
|
+
|
1142
|
+
if (!!subFormName) {
|
1143
|
+
let subFormRef = this.getWidgetRef(subFormName)
|
1144
|
+
if (!!subFormRef) {
|
1145
|
+
if(subFormRef.widget.type == "data-table"){
|
1146
|
+
let rows = subFormRef.getValue();
|
1147
|
+
if(rows){
|
1148
|
+
rows.forEach(row => {
|
1149
|
+
result.push( widgetName + '_' + row._X_ROW_KEY)
|
1150
|
+
})
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
}else{
|
1154
|
+
let rowIds = subFormRef.getRowIdData()
|
1155
|
+
if (!!rowIds && (rowIds.length > 0)) {
|
1156
|
+
rowIds.forEach(rid => {
|
1157
|
+
result.push( widgetName + '@row' + rid)
|
1158
|
+
})
|
1159
|
+
}
|
1160
|
+
}
|
1161
|
+
|
1143
1162
|
}
|
1144
1163
|
}
|
1145
|
-
|
1164
|
+
|
1165
|
+
return result
|
1166
|
+
},
|
1167
|
+
|
1168
|
+
findFieldWidgetById(fieldId, staticWidgetsIncluded) {
|
1169
|
+
return getFieldWidgetById(this.formJsonObj.widgetList, fieldId, staticWidgetsIncluded)
|
1146
1170
|
},
|
1171
|
+
|
1172
|
+
getSubFormNameOfWidget(widgetName) {
|
1173
|
+
let result = []
|
1174
|
+
let subFormName = null
|
1175
|
+
Object.keys(this.subFormRefList).forEach(sfName => {
|
1176
|
+
const fwHandler = (fw) => {
|
1177
|
+
if (fw.options.name === widgetName) {
|
1178
|
+
subFormName = sfName
|
1179
|
+
}
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
const sfRef = this.subFormRefList[sfName]
|
1183
|
+
traverseFieldWidgetsOfContainer(sfRef.widget, fwHandler)
|
1184
|
+
})
|
1185
|
+
|
1186
|
+
return subFormName
|
1187
|
+
},
|
1188
|
+
|
1147
1189
|
changeLanguage: function (e) {
|
1148
1190
|
baseRefUtil.changeLocale(e);
|
1149
1191
|
},
|
@@ -2005,6 +2047,13 @@ modules = {
|
|
2005
2047
|
|
2006
2048
|
return foundWidget;
|
2007
2049
|
},
|
2050
|
+
copyNewFieldWidget(origin) {
|
2051
|
+
let newWidget = deepClone(origin);
|
2052
|
+
newWidget.type = (newWidget.targetType || newWidget.type);
|
2053
|
+
let tempId = generateId();
|
2054
|
+
newWidget.id = newWidget.type.replace(/-/g, '') + tempId;
|
2055
|
+
return newWidget
|
2056
|
+
},
|
2008
2057
|
doScriptAccess(scriptUuid, callback) {
|
2009
2058
|
if (scriptUuid) {
|
2010
2059
|
let scripts = this.formJson.formConfig.scriptList || [];
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import {evalFn, getFieldWidgetById, traverseFieldWidgetsOfContainer} from "@base/components/xform/utils/util";
|
3
3
|
import * as formulajs from '@formulajs/formulajs'
|
4
4
|
import {EditorView} from "codemirror"
|
5
|
-
import {MatchDecorator,Decoration,ViewPlugin,WidgetType} from "@codemirror/view"
|
5
|
+
import {MatchDecorator, Decoration, ViewPlugin, WidgetType} from "@codemirror/view"
|
6
6
|
import {translate} from "@base/components/xform/utils/i18n";
|
7
7
|
|
8
8
|
class PlaceholderWidget extends WidgetType {
|
@@ -44,9 +44,9 @@ export const FORMULA_REG_EXP = /\{\{(\w+\.[^.]+\.\w+)}}/g
|
|
44
44
|
const placeholderMatcher = new MatchDecorator({
|
45
45
|
regexp: /\{\{(.+?)}}/g,
|
46
46
|
decoration: (match) =>
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
Decoration.replace({
|
48
|
+
widget: new PlaceholderWidget(match[1])
|
49
|
+
})
|
50
50
|
});
|
51
51
|
|
52
52
|
|
@@ -93,7 +93,8 @@ export const baseTheme = EditorView.baseTheme({
|
|
93
93
|
});
|
94
94
|
|
95
95
|
export function calculateFormula(VFR, DSV, formulaJs, formulaFieldRef, changedFieldRef) {
|
96
|
-
if (
|
96
|
+
if (formulaFieldRef.tableParam) {
|
97
|
+
} else if (!!formulaFieldRef.subFormItemFlag && !!changedFieldRef.subFormItemFlag) {
|
97
98
|
/* 子表单字段变化,只能触发子表单同一行字段的计算公式重新计算!! */
|
98
99
|
if (changedFieldRef.subFormRowId !== formulaFieldRef.subFormRowId) {
|
99
100
|
return
|
@@ -129,7 +130,7 @@ export function calculateFormula(VFR, DSV, formulaJs, formulaFieldRef, changedFi
|
|
129
130
|
* @param formula
|
130
131
|
* @param VFR
|
131
132
|
*/
|
132
|
-
export function fieldIsUsedInFormula(fieldName, formula, VFR) {
|
133
|
+
export function fieldIsUsedInFormula(fieldName, formula, VFR, fieldTarget) {
|
133
134
|
const matchResult = formula.match(FORMULA_REG_EXP)
|
134
135
|
if (!matchResult) {
|
135
136
|
return false
|
@@ -138,14 +139,14 @@ export function fieldIsUsedInFormula(fieldName, formula, VFR) {
|
|
138
139
|
let foundResult = false
|
139
140
|
matchResult.forEach(mi => {
|
140
141
|
const thirdPart = mi.split('.')[2]
|
141
|
-
const nodeType = thirdPart.substring(0, thirdPart.length -2)
|
142
|
+
const nodeType = thirdPart.substring(0, thirdPart.length - 2)
|
142
143
|
if (nodeType === 'func') {
|
143
144
|
return
|
144
145
|
}
|
145
146
|
|
146
147
|
const firstPart = mi.split('.')[0]
|
147
148
|
const fieldId = firstPart.substring(2, firstPart.length)
|
148
|
-
|
149
|
+
let fieldSchema = getFieldWidgetById(VFR.formJsonObj.widgetList, fieldId, false)
|
149
150
|
if (!fieldSchema) {
|
150
151
|
console.error('The field used by formula not found: ', fieldId)
|
151
152
|
console.error('The formula is: ', formula)
|
@@ -175,7 +176,7 @@ export function replaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef) {
|
|
175
176
|
let quitFlag = false
|
176
177
|
matchResult.forEach(mi => {
|
177
178
|
const thirdPart = mi.split('.')[2]
|
178
|
-
const nodeType = thirdPart.substring(0, thirdPart.length -2)
|
179
|
+
const nodeType = thirdPart.substring(0, thirdPart.length - 2)
|
179
180
|
if (nodeType === 'func') {
|
180
181
|
const funcName = mi.split('.')[1]
|
181
182
|
resultFormula = resultFormula.replace(mi, funcName)
|
@@ -192,9 +193,20 @@ export function replaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef) {
|
|
192
193
|
resultFormula = resultFormula.replace(mi, fieldRef.getValue())
|
193
194
|
} else { //getWidgetRef找不到,则可能是子表单字段
|
194
195
|
const subFormNameOfField = VFR.getSubFormNameOfWidget(fieldSchema.options.name)
|
195
|
-
if (!!formulaFieldRef.subFormItemFlag) {
|
196
|
+
if (!!formulaFieldRef.subFormItemFlag || formulaFieldRef.tableParam) {
|
196
197
|
/* 如果当前计算字段是子表单字段,要判断公式中的子表单字段是否和当前计算字段是否属于同一子表单!! */
|
197
|
-
|
198
|
+
|
199
|
+
|
200
|
+
if (subFormNameOfField === formulaFieldRef?.parentWidget?.options?.name) {
|
201
|
+
let subFormRowId = formulaFieldRef.tableParam.row._X_ROW_KEY
|
202
|
+
fieldRef = VFR.getWidgetRef(fieldSchema.options.name + '_' + subFormRowId)
|
203
|
+
if (!!fieldRef) {
|
204
|
+
resultFormula = resultFormula.replaceAll(mi, fieldRef.getValue())
|
205
|
+
} else {
|
206
|
+
quitFlag = true
|
207
|
+
console.error('Field not found: ' + fieldSchema.options.label)
|
208
|
+
}
|
209
|
+
} else if (subFormNameOfField === formulaFieldRef.subFormName) {
|
198
210
|
fieldRef = VFR.getWidgetRef(fieldSchema.options.name + '@row' + formulaFieldRef.subFormRowId)
|
199
211
|
if (!!fieldRef) {
|
200
212
|
resultFormula = resultFormula.replaceAll(mi, fieldRef.getValue())
|
@@ -206,10 +218,12 @@ export function replaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef) {
|
|
206
218
|
console.error('Invalid formula!')
|
207
219
|
}
|
208
220
|
} else {
|
221
|
+
debugger
|
209
222
|
/* 在主表单字段的计算公式中使用子表单字段,应将子表单所有记录同字段的值代入!! */
|
210
223
|
const subFormValue = VFR.formDataModel[subFormNameOfField]
|
211
224
|
let allSubFieldValues = ''
|
212
|
-
const subFieldName = fieldSchema.options.name
|
225
|
+
// const subFieldName = fieldSchema.options.name
|
226
|
+
const subFieldName = fieldKeyName(fieldSchema)
|
213
227
|
subFormValue.forEach((vi, idx) => {
|
214
228
|
allSubFieldValues = (idx === 0) ? vi[subFieldName] : allSubFieldValues + ', ' + vi[subFieldName]
|
215
229
|
})
|
@@ -222,6 +236,13 @@ export function replaceFieldsAndFunctionsOfFormula(VFR, formulaFieldRef) {
|
|
222
236
|
return quitFlag ? null : resultFormula
|
223
237
|
}
|
224
238
|
|
239
|
+
function fieldKeyName(widget) {
|
240
|
+
let o = widget.options.name;
|
241
|
+
return (
|
242
|
+
(widget.options.keyNameEnabled && widget.options.keyName) || o
|
243
|
+
);
|
244
|
+
}
|
245
|
+
|
225
246
|
/**
|
226
247
|
* 获取字段值
|
227
248
|
*/
|