cloud-web-corejs 1.1.0-dev.42 → 1.1.0-dev.43
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/fieldMixin.js +10 -6
- package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +13 -3
- package/src/components/xform/form-render/container-item/data-table-mixin.js +6 -2
- package/src/components/xform/form-render/indexMixin.js +3 -0
- package/src/components/xform/utils/util.js +34 -0
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
isArrayValueWidgetType,
|
|
12
12
|
isAttachmentWidgetType,
|
|
13
13
|
isEmptyArrayFieldValue,
|
|
14
|
+
resolveElementFormItemProp,
|
|
14
15
|
} from "../../../../../components/xform/utils/util";
|
|
15
16
|
import FormValidators, {
|
|
16
17
|
getRegExp,
|
|
@@ -366,19 +367,22 @@ modules = {
|
|
|
366
367
|
);
|
|
367
368
|
},
|
|
368
369
|
getPropName: function () {
|
|
370
|
+
let propName;
|
|
369
371
|
if (this.formItemProp) {
|
|
370
|
-
|
|
372
|
+
propName = this.formItemProp;
|
|
371
373
|
} else {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
+
propName =
|
|
375
|
+
this.subFormItemFlag && !this.designState
|
|
376
|
+
? this.subFormName +
|
|
374
377
|
"." +
|
|
375
378
|
this.subFormRowIndex +
|
|
376
379
|
"." +
|
|
377
380
|
this.fieldKeyName
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
+
: this.getObjectFieldFlag() && !this.designState
|
|
382
|
+
? this.getObjectName() + "." + this.fieldKeyName
|
|
383
|
+
: this.fieldKeyName;
|
|
381
384
|
}
|
|
385
|
+
return resolveElementFormItemProp(this.formModel, propName);
|
|
382
386
|
},
|
|
383
387
|
initFieldModel: function (flag) {
|
|
384
388
|
let e = this;
|
|
@@ -256,6 +256,7 @@ import i18n from "../../../../../components/xform/utils/i18n";
|
|
|
256
256
|
import {
|
|
257
257
|
getSubFormNameByFieldId,
|
|
258
258
|
isVabsearchMultiWidget,
|
|
259
|
+
resolveElementFormItemProp,
|
|
259
260
|
} from "../../../../../components/xform/utils/util";
|
|
260
261
|
import compareView from "../../../../../components/xform/form-render/compareView.vue";
|
|
261
262
|
import {
|
|
@@ -307,6 +308,7 @@ export default {
|
|
|
307
308
|
},
|
|
308
309
|
inject: {
|
|
309
310
|
getFormConfig: { default: () => () => ({}) },
|
|
311
|
+
globalModel: { default: () => ({ formModel: {} }) },
|
|
310
312
|
getSubFormFieldFlag: { default: () => () => false },
|
|
311
313
|
getSubFormName: { default: () => () => "" },
|
|
312
314
|
tableParam: { default: null },
|
|
@@ -567,6 +569,12 @@ export default {
|
|
|
567
569
|
getRules() {
|
|
568
570
|
return this.rules;
|
|
569
571
|
},
|
|
572
|
+
getFormModelForProp() {
|
|
573
|
+
return (this.globalModel && this.globalModel.formModel) || null;
|
|
574
|
+
},
|
|
575
|
+
resolveFormItemProp(propName) {
|
|
576
|
+
return resolveElementFormItemProp(this.getFormModelForProp(), propName);
|
|
577
|
+
},
|
|
570
578
|
getPropName() {
|
|
571
579
|
if (this.formItemProp === "false") {
|
|
572
580
|
return null;
|
|
@@ -576,12 +584,14 @@ export default {
|
|
|
576
584
|
// }
|
|
577
585
|
if (this.tableParam && !this.tableParam.$table?.$parent?.$parent) {
|
|
578
586
|
if (this.formItemProp) {
|
|
579
|
-
return this.formItemProp;
|
|
587
|
+
return this.resolveFormItemProp(this.formItemProp);
|
|
580
588
|
}
|
|
581
589
|
return null;
|
|
582
590
|
}
|
|
583
591
|
if (this.tableParam && !!this.tableParam.$table?.$parent?.$parent) {
|
|
584
|
-
return this.
|
|
592
|
+
return this.resolveFormItemProp(
|
|
593
|
+
this.getColumnProp(this.field, this.tableParam)
|
|
594
|
+
);
|
|
585
595
|
}
|
|
586
596
|
let o = this.field.options.name;
|
|
587
597
|
let propName =
|
|
@@ -594,7 +604,7 @@ export default {
|
|
|
594
604
|
? this.getObjectName() + "." + o
|
|
595
605
|
: o);
|
|
596
606
|
|
|
597
|
-
return propName;
|
|
607
|
+
return this.resolveFormItemProp(propName);
|
|
598
608
|
},
|
|
599
609
|
getFieldKeyName(widget) {
|
|
600
610
|
let o = widget.options.name;
|
|
@@ -4234,7 +4234,11 @@ modules = {
|
|
|
4234
4234
|
let nullValue = newData.hasOwnProperty(field)
|
|
4235
4235
|
? null
|
|
4236
4236
|
: this.getColumnNullValue(widget, defaultValueEnabled);
|
|
4237
|
-
|
|
4237
|
+
// 带点 keyName 是 lookup 嵌套路径。写成字面量键后,XEUtils.get 会命中
|
|
4238
|
+
// 这个 null,不再走进 msdyn_substatus.Name 这类对象取值。
|
|
4239
|
+
if (typeof field !== "string" || field.indexOf(".") === -1) {
|
|
4240
|
+
newData[field] = nullValue;
|
|
4241
|
+
}
|
|
4238
4242
|
if (this.isSingerlSearch(widget)) {
|
|
4239
4243
|
let vabSearchName = widget.options.vabSearchName;
|
|
4240
4244
|
if (vabSearchName) newData[vabSearchName] = null;
|
|
@@ -4271,7 +4275,7 @@ modules = {
|
|
|
4271
4275
|
} else {
|
|
4272
4276
|
if (widget) {
|
|
4273
4277
|
this.handleWidgetNullValue(widget, newData, defaultValueEnabled);
|
|
4274
|
-
} else {
|
|
4278
|
+
} else if (String(item.prop).indexOf(".") === -1) {
|
|
4275
4279
|
newData[item.prop] = null;
|
|
4276
4280
|
}
|
|
4277
4281
|
}
|
|
@@ -1871,6 +1871,9 @@ modules = {
|
|
|
1871
1871
|
let e = this;
|
|
1872
1872
|
this.$off("fieldValidation"),
|
|
1873
1873
|
this.$on("fieldValidation", function (t) {
|
|
1874
|
+
// 查询区带点 keyName 不会注册到 el-form-item,getPropName 为 null。
|
|
1875
|
+
// Element validateField(null) 会 warn「please pass correct props!」
|
|
1876
|
+
if (!t || !e.$refs.renderForm) return;
|
|
1874
1877
|
e.$refs.renderForm.validateField(t);
|
|
1875
1878
|
});
|
|
1876
1879
|
},
|
|
@@ -141,6 +141,40 @@ export function isEmptyStr(str) {
|
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Element el-form-item 的 prop 按 '.' / '[]' 拆成嵌套路径,中间对象不存在会抛
|
|
146
|
+
* "please transfer a valid prop path to form item"。
|
|
147
|
+
* 本系统大量 keyName 是 Dynamics 风格字面量键(如 msdyn_reportedbycontact.fullname),
|
|
148
|
+
* 存在 model["a.b"] 上而不是 model.a.b,不能交给 el-form-item。
|
|
149
|
+
*/
|
|
150
|
+
export function isElementFormPropReachable(model, prop) {
|
|
151
|
+
if (prop == null || prop === "" || prop === false || prop === "false") {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
const path = String(prop);
|
|
155
|
+
if (path.indexOf(".") === -1 && path.indexOf("[") === -1) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
if (model == null || typeof model !== "object") {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
let tempObj = model;
|
|
162
|
+
const normalized = path.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "");
|
|
163
|
+
const keyArr = normalized.split(".");
|
|
164
|
+
for (let i = 0; i < keyArr.length - 1; i++) {
|
|
165
|
+
const key = keyArr[i];
|
|
166
|
+
if (tempObj == null || typeof tempObj !== "object" || !(key in tempObj)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
tempObj = tempObj[key];
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function resolveElementFormItemProp(model, prop) {
|
|
175
|
+
return isElementFormPropReachable(model, prop) ? prop : null;
|
|
176
|
+
}
|
|
177
|
+
|
|
144
178
|
export const generateId = function () {
|
|
145
179
|
return Math.floor(
|
|
146
180
|
Math.random() * 100000 + Math.random() * 20000 + Math.random() * 5000
|