super-page-runtime 2.0.66 → 2.0.71
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/dist/es/components/runtime/utils/events/validator-util.js +55 -1
- package/dist/es/components/runtime/utils/page-init-util.d.ts +1 -0
- package/dist/es/components/runtime/utils/page-init-util.js +43 -19
- package/dist/es/components/runtime/views/assemblys/data/table/main-table-runtime.vue.js +2 -2
- package/dist/es/components/runtime/views/assemblys/data/table/sub-table-runtime.vue.js +2 -2
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ import { ElMessage } from "element-plus";
|
|
|
3
3
|
import { getComponentRef } from "../global-refs.js";
|
|
4
4
|
import { getI18n } from "agilebuilder-ui/src/utils/util";
|
|
5
5
|
import { getAdditionalParamMap } from "./standard-event.js";
|
|
6
|
+
import { isPromise } from "agilebuilder-ui/src/utils/common-util";
|
|
6
7
|
function setObjectPropRule(prop, rules, leafRule) {
|
|
7
8
|
const rule = {};
|
|
8
9
|
if (!rules) {
|
|
@@ -276,7 +277,18 @@ function validateCommonFormDataModel(dataModel, pageContext, rules) {
|
|
|
276
277
|
if (Object.keys(handleModels).indexOf("validateErrorField") >= 0) {
|
|
277
278
|
delete handleModels.validateErrorField;
|
|
278
279
|
}
|
|
279
|
-
|
|
280
|
+
const customRuleResult = validateCustomRuleEvents(pageContext);
|
|
281
|
+
if (customRuleResult && isPromise(customRuleResult)) {
|
|
282
|
+
customRuleResult.then((result) => {
|
|
283
|
+
if (result) {
|
|
284
|
+
resolve(handleModels);
|
|
285
|
+
} else {
|
|
286
|
+
resolve(false);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
} else {
|
|
290
|
+
resolve(handleModels);
|
|
291
|
+
}
|
|
280
292
|
} else {
|
|
281
293
|
reject(
|
|
282
294
|
new Error(
|
|
@@ -407,6 +419,48 @@ function getWorkflowRules(pageContext) {
|
|
|
407
419
|
workflowFieldPermissionRules = packageCustomRules(customRules, workflowFieldPermissionRules);
|
|
408
420
|
return workflowFieldPermissionRules;
|
|
409
421
|
}
|
|
422
|
+
function validateCustomRuleEvents(pageContext) {
|
|
423
|
+
const result = [];
|
|
424
|
+
if (pageContext.customRuleEvents && pageContext.customRuleEvents.length > 0) {
|
|
425
|
+
pageContext.customRuleEvents.forEach((event) => {
|
|
426
|
+
event.events.forEach((eventName) => {
|
|
427
|
+
const eventFun = pageContext.customEvents[eventName];
|
|
428
|
+
result.push(eventFun.apply(eventFun, [{ prop: event.prop, pageContext }]));
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
if (result && result.length > 0) {
|
|
433
|
+
return new Promise((resolve, reject) => {
|
|
434
|
+
const promiseResults = [];
|
|
435
|
+
const booleanResults = [];
|
|
436
|
+
result.forEach((validateResult) => {
|
|
437
|
+
if (isPromise(validateResult)) {
|
|
438
|
+
promiseResults.push(validateResult);
|
|
439
|
+
} else {
|
|
440
|
+
booleanResults.push(validateResult);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
if (booleanResults.includes(false)) {
|
|
444
|
+
resolve(false);
|
|
445
|
+
}
|
|
446
|
+
if (promiseResults.length > 0) {
|
|
447
|
+
Promise.all(promiseResults).then((values) => {
|
|
448
|
+
if (values.includes(false)) {
|
|
449
|
+
resolve(false);
|
|
450
|
+
} else {
|
|
451
|
+
resolve(true);
|
|
452
|
+
}
|
|
453
|
+
}).catch((error) => {
|
|
454
|
+
console.error(error);
|
|
455
|
+
resolve(false);
|
|
456
|
+
});
|
|
457
|
+
} else {
|
|
458
|
+
resolve(true);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
410
464
|
export {
|
|
411
465
|
getWorkflowRules,
|
|
412
466
|
i18nValidateRulesMessage,
|
|
@@ -24,6 +24,7 @@ export declare function getModelFields(pageContext: PageContext, formItemConfigu
|
|
|
24
24
|
* @param formItemConfigure 表单元素配置参数
|
|
25
25
|
*/
|
|
26
26
|
export declare function getFormModelFields(pageContext: PageContext, formItemConfigure: any, prop?: string): string[];
|
|
27
|
+
export declare function getDefaultValue(pageContext: PageContext, defaultValueSet: any, componentType: string, multiple: boolean): any;
|
|
27
28
|
/**
|
|
28
29
|
* 获取组件的权限编码
|
|
29
30
|
* @param configure
|
|
@@ -2,7 +2,7 @@ import http from "agilebuilder-ui/src/utils/request";
|
|
|
2
2
|
import { useRoute } from "vue-router";
|
|
3
3
|
import { getAdditionalParamMap } from "./events/standard-event.js";
|
|
4
4
|
import { PageDimensions } from "./interfaces/page-design-types.js";
|
|
5
|
-
import { formatVariableValue,
|
|
5
|
+
import { formatVariableValue, getFormPropName, setVariableValue } from "./page-helper-util.js";
|
|
6
6
|
import { getSessionCache } from "agilebuilder-ui/src/utils/auth";
|
|
7
7
|
function queryPageDesignByCode(pageCode) {
|
|
8
8
|
return http.get(
|
|
@@ -156,29 +156,43 @@ function getModelFields(pageContext, formItemConfigure, prop) {
|
|
|
156
156
|
function getFormModelFields(pageContext, formItemConfigure, prop) {
|
|
157
157
|
const fields = getModelFields(pageContext, formItemConfigure, prop);
|
|
158
158
|
const entity = pageContext.entity;
|
|
159
|
-
let propsBase;
|
|
160
|
-
if (formItemConfigure) {
|
|
161
|
-
propsBase = formItemConfigure.props.base ? formItemConfigure.props.base : {};
|
|
162
|
-
}
|
|
163
159
|
if (entity.data.ID == void 0 && entity.data.id == void 0) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
}
|
|
160
|
+
let propsBase;
|
|
161
|
+
let componentType;
|
|
162
|
+
let multiple = false;
|
|
163
|
+
if (formItemConfigure) {
|
|
164
|
+
propsBase = formItemConfigure.props.base ? formItemConfigure.props.base : {};
|
|
165
|
+
componentType = formItemConfigure.name;
|
|
166
|
+
multiple = propsBase.multiple;
|
|
167
|
+
}
|
|
168
|
+
const defaultValueSet = propsBase ? propsBase.defaultValue : null;
|
|
169
|
+
let defaultValue = getDefaultValue(pageContext, defaultValueSet, componentType, multiple);
|
|
170
|
+
if (defaultValue !== void 0 && defaultValue !== null) {
|
|
177
171
|
setVariableValue(entity, fields, defaultValue);
|
|
178
172
|
}
|
|
179
173
|
}
|
|
180
174
|
return fields;
|
|
181
175
|
}
|
|
176
|
+
function getDefaultValue(pageContext, defaultValueSet, componentType, multiple) {
|
|
177
|
+
let defaultValue;
|
|
178
|
+
console.log("pageRuntime11---getDefaultValue---defaultValueSet---", defaultValueSet, "pageContext=", pageContext);
|
|
179
|
+
if (defaultValueSet) {
|
|
180
|
+
defaultValue = formatVariableValue(pageContext, defaultValueSet);
|
|
181
|
+
console.log("pageRuntime22---getDefaultValue---defaultValue---", defaultValue);
|
|
182
|
+
if (defaultValue != null && defaultValue != void 0 && componentType) {
|
|
183
|
+
let isMultiple = false;
|
|
184
|
+
if (componentType == "checkbox") {
|
|
185
|
+
isMultiple = true;
|
|
186
|
+
} else if (componentType == "select") {
|
|
187
|
+
isMultiple = multiple;
|
|
188
|
+
}
|
|
189
|
+
if (isMultiple) {
|
|
190
|
+
defaultValue = (defaultValue + "").split(",");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return defaultValue;
|
|
195
|
+
}
|
|
182
196
|
function getPermissionCodes(configure, pageContext) {
|
|
183
197
|
if (!pageContext || !configure || pageContext.isTest) {
|
|
184
198
|
return "true";
|
|
@@ -227,7 +241,7 @@ function queryPageSuperGrids(pageDesign, pageContext, publishVersion) {
|
|
|
227
241
|
);
|
|
228
242
|
}
|
|
229
243
|
function packageFormRules(pageContext, configure) {
|
|
230
|
-
var _a;
|
|
244
|
+
var _a, _b;
|
|
231
245
|
const isWorkflow = pageContext.workflowCode ? true : false;
|
|
232
246
|
if (isWorkflow) {
|
|
233
247
|
if (configure.name !== "button-detail" && pageContext.fieldPermissionMap) {
|
|
@@ -265,10 +279,20 @@ function packageFormRules(pageContext, configure) {
|
|
|
265
279
|
}
|
|
266
280
|
}
|
|
267
281
|
}
|
|
282
|
+
if ((_b = configure.props) == null ? void 0 : _b.customRuleEvents) {
|
|
283
|
+
if (!pageContext.customRuleEvents) {
|
|
284
|
+
pageContext.customRuleEvents = [];
|
|
285
|
+
}
|
|
286
|
+
pageContext.customRuleEvents.push({
|
|
287
|
+
prop: propName,
|
|
288
|
+
events: configure.props.customRuleEvents
|
|
289
|
+
});
|
|
290
|
+
}
|
|
268
291
|
}
|
|
269
292
|
}
|
|
270
293
|
export {
|
|
271
294
|
convertToPageContext,
|
|
295
|
+
getDefaultValue,
|
|
272
296
|
getFormModelFields,
|
|
273
297
|
getModelFields,
|
|
274
298
|
getPermissionCodes,
|
|
@@ -6,7 +6,7 @@ import { getAdditionalParamMap, getSaveFormRequestWithRow, standardEvents } from
|
|
|
6
6
|
import { isPromise } from "agilebuilder-ui/src/utils/common-util";
|
|
7
7
|
import { getDataTypeMapRequest, popupToPage } from "../../../../utils/table-utils.js";
|
|
8
8
|
import eventBus from "../../../../utils/eventBus.js";
|
|
9
|
-
import { getPermissionCodes } from "../../../../utils/page-init-util.js";
|
|
9
|
+
import { getPermissionCodes, getDefaultValue } from "../../../../utils/page-init-util.js";
|
|
10
10
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
11
11
|
__name: "main-table-runtime",
|
|
12
12
|
props: {
|
|
@@ -618,7 +618,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
618
618
|
return gridRef.value.refresh();
|
|
619
619
|
}
|
|
620
620
|
function createRow() {
|
|
621
|
-
return gridRef.value.createRow(listCode);
|
|
621
|
+
return gridRef.value.createRow(listCode, {}, { getDefaultValueFunc: getDefaultValue });
|
|
622
622
|
}
|
|
623
623
|
function getSelections() {
|
|
624
624
|
return selections.value;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, ref, resolveComponent, openBlock, createElementBlock, createBlock, unref, createCommentVNode } from "vue";
|
|
2
2
|
import { setTableEvents, gridSelectRecord, gridSelectAllRecords, gridSelectionChange, cellClick, cellDblClick, rowClick, rowDblClick, headerClick } from "../../../../utils/events/event-util.js";
|
|
3
3
|
import { setVariableValue, getVariableValue } from "../../../../utils/page-helper-util.js";
|
|
4
|
-
import { getModelFields } from "../../../../utils/page-init-util.js";
|
|
4
|
+
import { getModelFields, getDefaultValue } from "../../../../utils/page-init-util.js";
|
|
5
5
|
import eventBus from "../../../../utils/eventBus.js";
|
|
6
6
|
import { popupToPage } from "../../../../utils/table-utils.js";
|
|
7
7
|
import { getListCode } from "../../../../utils/common-util.js";
|
|
@@ -278,7 +278,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
278
278
|
return canDelete;
|
|
279
279
|
}
|
|
280
280
|
function addSubTableData(originalValue, formatValue, row, column, rowIndex) {
|
|
281
|
-
gridRef.value.createRow(listCode);
|
|
281
|
+
gridRef.value.createRow(listCode, {}, { getDefaultValueFunc: getDefaultValue });
|
|
282
282
|
}
|
|
283
283
|
function removeSubTableData(originalValue, formatValue, row, column, rowIndex) {
|
|
284
284
|
gridRef.value.deleteRow(rowIndex, listCode, false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "super-page-runtime",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.71",
|
|
4
4
|
"description": "AgileBuilder super page runtime",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "dist/es/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
|
49
49
|
"@vue/eslint-config-prettier": "^8.0.0",
|
|
50
50
|
"@vue/test-utils": "^2.4.4",
|
|
51
|
-
"agilebuilder-ui": "1.0.
|
|
51
|
+
"agilebuilder-ui": "1.0.51",
|
|
52
52
|
"axios": "^1.6.8",
|
|
53
53
|
"cypress": "^13.6.6",
|
|
54
54
|
"element-plus": "^2.6.1",
|