super-page-runtime 2.0.22 → 2.0.27
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/api/api-util.js +13 -5
- package/dist/es/components/runtime/utils/api/page-expose-util.js +5 -1
- package/dist/es/components/runtime/utils/assemblys-config.js +22 -7
- package/dist/es/components/runtime/utils/barcode-util.d.ts +8 -0
- package/dist/es/components/runtime/utils/barcode-util.js +36 -0
- package/dist/es/components/runtime/utils/common-util.js +1 -1
- package/dist/es/components/runtime/utils/events/event-util.d.ts +14 -0
- package/dist/es/components/runtime/utils/events/event-util.js +95 -32
- package/dist/es/components/runtime/utils/events/print-label.d.ts +5 -0
- package/dist/es/components/runtime/utils/events/print-label.js +153 -0
- package/dist/es/components/runtime/utils/events/standard-event.d.ts +3 -0
- package/dist/es/components/runtime/utils/events/standard-event.js +128 -52
- package/dist/es/components/runtime/utils/form/scan-util.js +191 -0
- package/dist/es/components/runtime/utils/page-helper-util.js +19 -2
- package/dist/es/components/runtime/utils/page-init-util.d.ts +1 -1
- package/dist/es/components/runtime/utils/page-init-util.js +21 -20
- package/dist/es/components/runtime/utils/table-utils.js +1 -10
- package/dist/es/components/runtime/views/assemblys/button/print-label/printlabel-runtime.vue.js +4 -0
- package/dist/es/components/runtime/views/assemblys/button/print-label/printlabel-runtime.vue2.js +96 -0
- package/dist/es/components/runtime/views/assemblys/container/flex/flex-runtime.vue2.js +1 -1
- package/dist/es/components/runtime/views/assemblys/data/bar-code/barcode-runtime.vue.js +4 -0
- package/dist/es/components/runtime/views/assemblys/data/bar-code/barcode-runtime.vue2.js +179 -0
- package/dist/es/components/runtime/views/assemblys/data/table/main-table-runtime.vue.js +95 -62
- package/dist/es/components/runtime/views/assemblys/data/table/sub-table-runtime.vue.js +16 -10
- package/dist/es/components/runtime/views/assemblys/data/table/table-runtime.vue2.js +3 -2
- package/dist/es/components/runtime/views/assemblys/form/date-picker/datepicker-runtime.vue2.js +25 -1
- package/dist/es/components/runtime/views/assemblys/form/file-upload/fileupload-runtime.vue2.js +77 -39
- package/dist/es/components/runtime/views/assemblys/form/input-text/inputtext-runtime.vue2.js +24 -1
- package/dist/es/components/runtime/views/assemblys/form/rich-text/richtext-runtime.vue2.js +21 -3
- package/dist/es/components/runtime/views/assemblys/object-render.vue.js +4 -1
- package/dist/es/components/runtime/views/super-page-dialog.vue.js +3 -0
- package/dist/es/components/runtime/views/super-page.vue.js +59 -38
- package/package.json +4 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSystemBackendUrl } from "agilebuilder-ui/src/utils/common-util";
|
|
2
2
|
import { getSessionCache } from "agilebuilder-ui/src/utils/auth";
|
|
3
3
|
import http from "agilebuilder-ui/src/utils/request";
|
|
4
|
-
import { getBaseUrl } from "../common-util.js";
|
|
4
|
+
import { getBaseUrl, getListCode } from "../common-util.js";
|
|
5
5
|
import { getAdditionalParamMap, dealCompleteTaskParam } from "../events/standard-event.js";
|
|
6
6
|
import { packageCustomRules, getWorkflowRules } from "../events/validator-util.js";
|
|
7
7
|
import { handleEvent } from "../events/event-util.js";
|
|
@@ -36,7 +36,7 @@ function getCommonFormData(pageContext) {
|
|
|
36
36
|
const dataId = additionalParamMap ? additionalParamMap.id : null;
|
|
37
37
|
const ids = additionalParamMap ? additionalParamMap.ids : null;
|
|
38
38
|
const taskId = additionalParamMap ? additionalParamMap.taskId : null;
|
|
39
|
-
const permissionPrefix =
|
|
39
|
+
const permissionPrefix = pageCode;
|
|
40
40
|
const backendUrl = getSystemBackendUrl(pageContext.backendUrl);
|
|
41
41
|
const param = {
|
|
42
42
|
pageCode,
|
|
@@ -45,7 +45,7 @@ function getCommonFormData(pageContext) {
|
|
|
45
45
|
formNoRuleCode: pageContext.formNoRuleCode,
|
|
46
46
|
id: dataId,
|
|
47
47
|
systemCode,
|
|
48
|
-
functionCode: permissionPrefix + ".
|
|
48
|
+
functionCode: permissionPrefix + ".gets",
|
|
49
49
|
tableNames: pageContext.tableNames
|
|
50
50
|
};
|
|
51
51
|
if (!param.id && additionalParamMap && additionalParamMap._t_ && getSessionCache(additionalParamMap._t_ + "_id")) {
|
|
@@ -66,6 +66,14 @@ function getCommonFormData(pageContext) {
|
|
|
66
66
|
if (taskId) {
|
|
67
67
|
param["taskId"] = taskId;
|
|
68
68
|
}
|
|
69
|
+
if (pageContext.tableUuids) {
|
|
70
|
+
let listCodes = [];
|
|
71
|
+
pageContext.tableUuids.forEach((tableUuid) => {
|
|
72
|
+
const listCode = getListCode(pageCode, pageVersion, tableUuid);
|
|
73
|
+
listCodes.push(listCode);
|
|
74
|
+
});
|
|
75
|
+
param["tableNames"] = listCodes;
|
|
76
|
+
}
|
|
69
77
|
const urlForView = backendUrl + "/dsc/commons/gets";
|
|
70
78
|
http.post(urlForView, param).then((commonEntity) => {
|
|
71
79
|
if (commonEntity) {
|
|
@@ -104,7 +112,7 @@ function getWorkflowFormData(pageContext) {
|
|
|
104
112
|
const dataId = additionalParamMap ? additionalParamMap.id : null;
|
|
105
113
|
const ids = additionalParamMap ? additionalParamMap.ids : null;
|
|
106
114
|
const taskId = additionalParamMap ? additionalParamMap.taskId : null;
|
|
107
|
-
const permissionPrefix =
|
|
115
|
+
const permissionPrefix = pageCode;
|
|
108
116
|
const param = {
|
|
109
117
|
pageCode,
|
|
110
118
|
pageVersion,
|
|
@@ -112,7 +120,7 @@ function getWorkflowFormData(pageContext) {
|
|
|
112
120
|
formNoRuleCode: pageContext.formNoRuleCode,
|
|
113
121
|
isWorkflowEntity: true,
|
|
114
122
|
systemCode,
|
|
115
|
-
functionCode: permissionPrefix + ".
|
|
123
|
+
functionCode: permissionPrefix + ".gets",
|
|
116
124
|
tableNames: pageContext.tableNames
|
|
117
125
|
};
|
|
118
126
|
if (ids) {
|
|
@@ -187,7 +187,11 @@ const functions = {
|
|
|
187
187
|
if (!params.taskParamMap) {
|
|
188
188
|
params.requestParams = pageContext.entity.task;
|
|
189
189
|
}
|
|
190
|
-
|
|
190
|
+
let baseUrl = pageContext.backendUrl;
|
|
191
|
+
if (!baseUrl) {
|
|
192
|
+
baseUrl = window["$vueApp"].config.globalProperties.baseURL;
|
|
193
|
+
}
|
|
194
|
+
return http.post(`${baseUrl}/dsc/service-flow/execute/${pageCode}/${flowCode}`, params);
|
|
191
195
|
},
|
|
192
196
|
openPage: function(pageContext, openParam) {
|
|
193
197
|
eventBus.$emit(pageContext.code + "_open-dialog", {
|
|
@@ -182,6 +182,12 @@ const assemblyGroups = [
|
|
|
182
182
|
runtimeComponent: defineAsyncComponent(() => {
|
|
183
183
|
return import("../views/assemblys/button/dropdown/dropdown-runtime.vue.js");
|
|
184
184
|
})
|
|
185
|
+
}, {
|
|
186
|
+
name: "print-label",
|
|
187
|
+
label: "打印标签",
|
|
188
|
+
runtimeComponent: defineAsyncComponent(() => {
|
|
189
|
+
return import("../views/assemblys/button/print-label/printlabel-runtime.vue.js");
|
|
190
|
+
})
|
|
185
191
|
}]
|
|
186
192
|
},
|
|
187
193
|
{
|
|
@@ -249,13 +255,22 @@ const assemblyGroups = [
|
|
|
249
255
|
{
|
|
250
256
|
name: "data",
|
|
251
257
|
label: "数据",
|
|
252
|
-
items: [
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
items: [
|
|
259
|
+
{
|
|
260
|
+
name: "table",
|
|
261
|
+
label: "表格",
|
|
262
|
+
runtimeComponent: defineAsyncComponent(() => {
|
|
263
|
+
return import("../views/assemblys/data/table/table-runtime.vue.js");
|
|
264
|
+
})
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: "bar-code",
|
|
268
|
+
label: "条码",
|
|
269
|
+
runtimeComponent: defineAsyncComponent(() => {
|
|
270
|
+
return import("../views/assemblys/data/bar-code/barcode-runtime.vue.js");
|
|
271
|
+
})
|
|
272
|
+
}
|
|
273
|
+
]
|
|
259
274
|
}
|
|
260
275
|
];
|
|
261
276
|
function getRuntimeComponentByName(name) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function generateCodeByRule(rules, data) {
|
|
2
|
+
let allVariablesPresent = true;
|
|
3
|
+
let value = "";
|
|
4
|
+
rules.forEach((item) => {
|
|
5
|
+
if (item.propDbName !== "-1" && item.propDbName !== -1) {
|
|
6
|
+
const filedValue = data[item.propDbName];
|
|
7
|
+
if (item.supplementaryCharacters && item.length) {
|
|
8
|
+
if (!filedValue) {
|
|
9
|
+
value += "".padEnd(item.length, item.supplementaryCharacters);
|
|
10
|
+
} else {
|
|
11
|
+
if (filedValue.length > item.length) {
|
|
12
|
+
value += filedValue.substring(0, item.supplementaryCharacters);
|
|
13
|
+
} else {
|
|
14
|
+
value += filedValue.padEnd(item.length, item.supplementaryCharacters);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
if (!filedValue) {
|
|
19
|
+
allVariablesPresent = false;
|
|
20
|
+
} else {
|
|
21
|
+
value += filedValue;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
value += item.fixedValue;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
console.log("跟据规则生成条码:" + value);
|
|
29
|
+
if (allVariablesPresent) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
generateCodeByRule
|
|
36
|
+
};
|
|
@@ -65,7 +65,7 @@ function upperFirstCase(str) {
|
|
|
65
65
|
return str.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase());
|
|
66
66
|
}
|
|
67
67
|
function getListCode(pageCode, pageVersion, tableUuid) {
|
|
68
|
-
return
|
|
68
|
+
return "V" + pageVersion + "__" + pageCode + "__" + tableUuid;
|
|
69
69
|
}
|
|
70
70
|
function deepCopy(srcObj) {
|
|
71
71
|
if (typeof srcObj !== "object" || srcObj === null) {
|
|
@@ -5,6 +5,13 @@ import { PageDesign, Component, PageContext } from '../interfaces/page-design-ty
|
|
|
5
5
|
* @param pageDesign
|
|
6
6
|
*/
|
|
7
7
|
export declare function initPageEvents(pageDesign: PageDesign, pageContext: PageContext): void;
|
|
8
|
+
/**
|
|
9
|
+
* 获取自定义方法
|
|
10
|
+
* @param pageContext
|
|
11
|
+
* @param funcName
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function getCustomFunc(pageContext: PageContext, funcName: any): any;
|
|
8
15
|
/**
|
|
9
16
|
* 页面销毁时,将window上注册的函数移除掉
|
|
10
17
|
* @param pageDesign
|
|
@@ -21,6 +28,13 @@ export declare function doAfterClickEvent(pageContext: PageContext, configure: C
|
|
|
21
28
|
* @param eventType change、click等事件类型
|
|
22
29
|
*/
|
|
23
30
|
export declare function getEventFuncByType(pageContext: PageContext, events: Array<any>, eventType: string): any;
|
|
31
|
+
/**
|
|
32
|
+
* 根据事件类型,获得事件名称
|
|
33
|
+
* @param events
|
|
34
|
+
* @param eventType
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare function getEventNameByType(events: Array<any>, eventType: string): any;
|
|
24
38
|
/**
|
|
25
39
|
* 获得事件Function对象
|
|
26
40
|
* @param events 该组件所有事件集合
|
|
@@ -1,18 +1,71 @@
|
|
|
1
1
|
import { isPromise } from "agilebuilder-ui/src/utils/common-util";
|
|
2
2
|
import { judgeDataNumber, standardEvents, getAdditionalParamMap, dealAfterOperate } from "./standard-event.js";
|
|
3
3
|
import { validateDataModelFunc } from "./validator-util.js";
|
|
4
|
-
import { getComponentRef } from "../global-refs.js";
|
|
4
|
+
import { getComponentRef, getComponentRefByCode } from "../global-refs.js";
|
|
5
5
|
import { ElMessage } from "element-plus";
|
|
6
6
|
import { analysisCondition } from "agilebuilder-ui/src/utils/util";
|
|
7
7
|
import { getListCode } from "../common-util.js";
|
|
8
8
|
import eventBus from "../eventBus.js";
|
|
9
|
-
import "
|
|
10
|
-
import "dayjs";
|
|
11
|
-
import "agilebuilder-ui/src/utils/calculator/calculator-util";
|
|
12
|
-
import "vue";
|
|
9
|
+
import { getValueFromSource } from "../page-helper-util.js";
|
|
13
10
|
function initPageEvents(pageDesign, pageContext) {
|
|
14
11
|
if (pageDesign && pageDesign.customEvents) {
|
|
15
|
-
|
|
12
|
+
const customEvents = transferToFunction(pageDesign.customEvents);
|
|
13
|
+
appendDefaultMethod(pageContext, customEvents);
|
|
14
|
+
console.log("initPage customEvents", customEvents);
|
|
15
|
+
pageContext.customEvents = customEvents;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function getCustomFunc(pageContext, funcName) {
|
|
19
|
+
if (pageContext.customEvents) {
|
|
20
|
+
return pageContext.customEvents[funcName];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function appendDefaultMethod(pageContext, customEvents) {
|
|
24
|
+
if (!customEvents) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
for (const pro in customEvents) {
|
|
28
|
+
const func = customEvents[pro];
|
|
29
|
+
func.get = function(code) {
|
|
30
|
+
if (code) {
|
|
31
|
+
return getComponentRefByCode(pageContext, code);
|
|
32
|
+
} else {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
func.getByUuid = function(uuid) {
|
|
37
|
+
if (uuid) {
|
|
38
|
+
return getComponentRef(pageContext, uuid);
|
|
39
|
+
} else {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
func.getPageContext = function() {
|
|
44
|
+
return pageContext;
|
|
45
|
+
};
|
|
46
|
+
func.getContextValue = function(fieldName) {
|
|
47
|
+
let contextData = pageContext && pageContext.entity ? pageContext.entity.context : null;
|
|
48
|
+
contextData = contextData ? contextData : {};
|
|
49
|
+
return getValueFromSource(contextData, fieldName, "context");
|
|
50
|
+
};
|
|
51
|
+
func.getContext = function() {
|
|
52
|
+
return pageContext && pageContext.entity ? pageContext.entity.context : {};
|
|
53
|
+
};
|
|
54
|
+
func.getSystem = function() {
|
|
55
|
+
return pageContext && pageContext.entity ? pageContext.entity.system : {};
|
|
56
|
+
};
|
|
57
|
+
func.getTask = function() {
|
|
58
|
+
return pageContext && pageContext.entity ? pageContext.entity.task : {};
|
|
59
|
+
};
|
|
60
|
+
func.getRequest = function() {
|
|
61
|
+
return pageContext && pageContext.entity ? pageContext.entity.request : {};
|
|
62
|
+
};
|
|
63
|
+
func.getPage = function() {
|
|
64
|
+
return pageContext && pageContext.entity ? pageContext.entity.page : {};
|
|
65
|
+
};
|
|
66
|
+
func.getCustomFunc = function(funcName) {
|
|
67
|
+
return getCustomFunc(pageContext, funcName);
|
|
68
|
+
};
|
|
16
69
|
}
|
|
17
70
|
}
|
|
18
71
|
function removeCustomFuncFromWindow(pageDesign) {
|
|
@@ -36,8 +89,6 @@ function handleEventUtil($event, pageContext, configure, eventType, isExecute, o
|
|
|
36
89
|
const pageCode = pageContext.code;
|
|
37
90
|
const pageVersion = pageContext.version;
|
|
38
91
|
const events = configure.runtime && configure.runtime.events ? configure.runtime.events : [];
|
|
39
|
-
configure.name;
|
|
40
|
-
debugger;
|
|
41
92
|
let eventFun;
|
|
42
93
|
if (eventType && eventType === "click") {
|
|
43
94
|
const tableUuid = configure.props.base.tableUuid ? configure.props.base.tableUuid : pageContext.tableUuids && pageContext.tableUuids.length > 0 ? pageContext.tableUuids[0] : null;
|
|
@@ -53,6 +104,7 @@ function handleEventUtil($event, pageContext, configure, eventType, isExecute, o
|
|
|
53
104
|
const isListButton = isListPage(pageContext);
|
|
54
105
|
if (isListButton) {
|
|
55
106
|
otherParams["selections"] = selections;
|
|
107
|
+
otherParams["id"] = selectionIds && selectionIds.length > 0 ? selectionIds[0] : null;
|
|
56
108
|
otherParams["ids"] = selectionIds;
|
|
57
109
|
}
|
|
58
110
|
const tableConfigure = gridRef.getTableConfigure();
|
|
@@ -253,35 +305,50 @@ function doClickEvent(pageContext, configure, clickEventFunObj, eventParams) {
|
|
|
253
305
|
doClickCustomEvent(pageContext, configure, clickEventFunObj, eventParams);
|
|
254
306
|
}
|
|
255
307
|
}
|
|
256
|
-
function getEventByEventName(pageContext,
|
|
308
|
+
function getEventByEventName(pageContext, eventObj) {
|
|
257
309
|
const eventsObj = pageContext.customEvents;
|
|
258
|
-
if (eventsObj &&
|
|
259
|
-
|
|
310
|
+
if (eventsObj && eventObj) {
|
|
311
|
+
let key = "";
|
|
312
|
+
if (typeof eventObj === "object") {
|
|
313
|
+
key = eventObj.componentUuid + "_" + eventObj.name;
|
|
314
|
+
} else {
|
|
315
|
+
key = eventObj;
|
|
316
|
+
}
|
|
317
|
+
return eventsObj[key];
|
|
260
318
|
}
|
|
261
319
|
}
|
|
262
320
|
function getEventFuncByType(pageContext, events, eventType) {
|
|
263
321
|
if (events && eventType) {
|
|
264
|
-
const eventArr = events.filter((item) => item.name === eventType
|
|
322
|
+
const eventArr = events.filter((item) => item.name === eventType);
|
|
265
323
|
if (eventArr && eventArr.length > 0) {
|
|
266
324
|
const event = eventArr[0];
|
|
267
325
|
if (event.isStandard) {
|
|
268
326
|
return standardEvents[event.eventName];
|
|
269
327
|
} else {
|
|
270
|
-
return getEventByEventName(pageContext, event
|
|
328
|
+
return getEventByEventName(pageContext, event);
|
|
271
329
|
}
|
|
272
330
|
}
|
|
273
331
|
}
|
|
274
332
|
}
|
|
333
|
+
function getEventNameByType(events, eventType) {
|
|
334
|
+
if (events && eventType) {
|
|
335
|
+
const eventArr = events.filter((item) => item.name === eventType);
|
|
336
|
+
if (eventArr && eventArr.length > 0) {
|
|
337
|
+
const event = eventArr[0];
|
|
338
|
+
return event.eventName;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
275
342
|
function getClickEventFuncByType(pageContext, events, eventType) {
|
|
276
343
|
if (events && eventType) {
|
|
277
|
-
const eventArr = events.filter((item) => item.name === eventType
|
|
344
|
+
const eventArr = events.filter((item) => item.name === eventType);
|
|
278
345
|
if (eventArr && eventArr.length > 0) {
|
|
279
346
|
const event = eventArr[0];
|
|
280
347
|
if (event.isStandard) {
|
|
281
348
|
return { func: standardEvents[event.eventName], isStandard: true, event };
|
|
282
349
|
} else {
|
|
283
350
|
return {
|
|
284
|
-
func: getEventByEventName(pageContext, event
|
|
351
|
+
func: getEventByEventName(pageContext, event),
|
|
285
352
|
isStandard: false,
|
|
286
353
|
event
|
|
287
354
|
};
|
|
@@ -305,19 +372,25 @@ function callItemEvent(pageContext, configureObj, eventFun, eventParams, otherPa
|
|
|
305
372
|
eventParams[key] = otherParams[key];
|
|
306
373
|
}
|
|
307
374
|
}
|
|
308
|
-
return eventFun(eventParams);
|
|
375
|
+
return eventFun.apply(eventFun, [eventParams]);
|
|
309
376
|
}
|
|
310
377
|
function transferToFunction(customEvents) {
|
|
311
378
|
const eventsObj = {};
|
|
312
379
|
customEvents.forEach((event) => {
|
|
313
|
-
if (event.jsContent) {
|
|
314
|
-
eventsObj[event.eventName] = new Function("params", event.jsContent);
|
|
380
|
+
if (!event.isStandard && event.jsContent) {
|
|
315
381
|
if (event.name === "customFunc") {
|
|
382
|
+
let newFunc = null;
|
|
316
383
|
if (event.funcParam) {
|
|
317
|
-
|
|
384
|
+
const args = event.funcParam.split(",");
|
|
385
|
+
newFunc = new Function(args, event.jsContent);
|
|
318
386
|
} else {
|
|
319
|
-
|
|
387
|
+
newFunc = new Function(event.jsContent);
|
|
320
388
|
}
|
|
389
|
+
eventsObj[event.eventName] = newFunc;
|
|
390
|
+
} else {
|
|
391
|
+
let key = event.componentUuid + "_";
|
|
392
|
+
key += event.name;
|
|
393
|
+
eventsObj[key] = new Function("params", event.jsContent);
|
|
321
394
|
}
|
|
322
395
|
}
|
|
323
396
|
});
|
|
@@ -518,27 +591,17 @@ function headerClick(pageContext, configureObj, params) {
|
|
|
518
591
|
function fileUploadBeforeUpload(params) {
|
|
519
592
|
return getHandleEvent(null, params.pageContext, params.configureObj, "before-upload", params);
|
|
520
593
|
}
|
|
521
|
-
function fileUploadUploaded(pageContext, configureObj, params) {
|
|
522
|
-
return handleEvent(null, pageContext, configureObj, "uploaded", params);
|
|
523
|
-
}
|
|
524
|
-
function fileUploadBeforeDelete(pageContext, configureObj, params) {
|
|
525
|
-
return handleEvent(null, pageContext, configureObj, "before-delete", params);
|
|
526
|
-
}
|
|
527
|
-
function fileUploadDeleted(pageContext, configureObj, params) {
|
|
528
|
-
return handleEvent(null, pageContext, configureObj, "deleted", params);
|
|
529
|
-
}
|
|
530
594
|
export {
|
|
531
595
|
canExecuteButton,
|
|
532
596
|
cellClick,
|
|
533
597
|
cellDblClick,
|
|
534
598
|
doAfterClickEvent,
|
|
535
599
|
doBeforeClickEvent,
|
|
536
|
-
fileUploadBeforeDelete,
|
|
537
600
|
fileUploadBeforeUpload,
|
|
538
|
-
fileUploadDeleted,
|
|
539
|
-
fileUploadUploaded,
|
|
540
601
|
getClickEventFuncByType,
|
|
602
|
+
getCustomFunc,
|
|
541
603
|
getEventFuncByType,
|
|
604
|
+
getEventNameByType,
|
|
542
605
|
getHandleEvent,
|
|
543
606
|
gridSelectAllRecords,
|
|
544
607
|
gridSelectRecord,
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import http from "agilebuilder-ui/src/utils/request";
|
|
2
|
+
import { hiprint } from "vue-plugin-hiprint";
|
|
3
|
+
import { generateCodeByRule } from "../barcode-util.js";
|
|
4
|
+
function printLabel(params, templateUuid) {
|
|
5
|
+
http.post(window["$vueApp"].config.globalProperties.baseAPI + "/dc/print-models/by-codes", [
|
|
6
|
+
templateUuid
|
|
7
|
+
]).then((res) => {
|
|
8
|
+
const templateJson = JSON.parse(res[0].template);
|
|
9
|
+
const barCodeOptions = [];
|
|
10
|
+
templateJson.panels.forEach((panel) => {
|
|
11
|
+
panel.printElements.forEach((element) => {
|
|
12
|
+
if (element.options.textType === "barcode" || element.options.textType === "qrcode") {
|
|
13
|
+
barCodeOptions.push(element.options);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
const printTemplate = new hiprint.PrintTemplate({
|
|
18
|
+
template: templateJson
|
|
19
|
+
});
|
|
20
|
+
const ext = {
|
|
21
|
+
callback: () => {
|
|
22
|
+
console.log("浏览器打印窗口已打开");
|
|
23
|
+
},
|
|
24
|
+
styleHandler: () => {
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const options = { leftOffset: -1, topOffset: -1 };
|
|
29
|
+
if (params.pageContext.pageType) {
|
|
30
|
+
if (params.pageContext.pageType === "list") {
|
|
31
|
+
printListData(params, barCodeOptions, printTemplate, options, ext);
|
|
32
|
+
} else if (params.pageContext.pageType === "form") {
|
|
33
|
+
printFormData(params, barCodeOptions, printTemplate, options, ext);
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
printFormData(params, barCodeOptions, printTemplate, options, ext);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function printListData(params, barCodeOptions, printTemplate, options, ext) {
|
|
41
|
+
if (barCodeOptions.length > 0) {
|
|
42
|
+
const valuePromises = [];
|
|
43
|
+
const selections = JSON.parse(JSON.stringify(params.selections));
|
|
44
|
+
barCodeOptions.forEach((barCodeOption) => {
|
|
45
|
+
valuePromises.push(resloveListData(barCodeOption, selections));
|
|
46
|
+
});
|
|
47
|
+
Promise.all(valuePromises).then((allBarValues) => {
|
|
48
|
+
allBarValues.forEach((barValues) => {
|
|
49
|
+
barValues.forEach((item) => {
|
|
50
|
+
const index = item.index;
|
|
51
|
+
const selection = selections[index];
|
|
52
|
+
if (!selection[item.type]) {
|
|
53
|
+
selection[item.type] = {};
|
|
54
|
+
}
|
|
55
|
+
selection[item.type][item.name] = item.value;
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
printTemplate.print(selections, options, ext);
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
printTemplate.print(params.selections, options, ext);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function resloveListData(barCodeOption, selections) {
|
|
65
|
+
return new Promise((reslove, reject) => {
|
|
66
|
+
const fields = barCodeOption.field.split(".");
|
|
67
|
+
const barcodeValues = [];
|
|
68
|
+
if (fields.length < 2) {
|
|
69
|
+
reslove([]);
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
getBarcodeModelsByName(fields[1]).then((res) => {
|
|
73
|
+
selections.forEach((selection, index) => {
|
|
74
|
+
const barcodeValue = {
|
|
75
|
+
type: fields[0],
|
|
76
|
+
name: fields[1],
|
|
77
|
+
value: null,
|
|
78
|
+
index
|
|
79
|
+
// 记录当前行索引
|
|
80
|
+
};
|
|
81
|
+
barcodeValue.value = generateCodeByRule(JSON.parse(res.barcodeModelItems), selection);
|
|
82
|
+
barcodeValues.push(barcodeValue);
|
|
83
|
+
});
|
|
84
|
+
reslove(barcodeValues);
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error("获取条码规则失败:", error);
|
|
88
|
+
reslove([]);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function printFormData(params, barCodeOptions, printTemplate, options, ext) {
|
|
93
|
+
if (barCodeOptions.length > 0) {
|
|
94
|
+
const valuePromises = [];
|
|
95
|
+
barCodeOptions.forEach((barCodeOption) => {
|
|
96
|
+
valuePromises.push(getFormBarCodeValue(params.pageContext, barCodeOption));
|
|
97
|
+
});
|
|
98
|
+
Promise.all(valuePromises).then((barcodeRuleValues) => {
|
|
99
|
+
const codeValue = {};
|
|
100
|
+
barcodeRuleValues.forEach((item) => {
|
|
101
|
+
if (item.type && item.name && item.value) {
|
|
102
|
+
if (!codeValue[item.type]) {
|
|
103
|
+
codeValue[item.type] = {};
|
|
104
|
+
}
|
|
105
|
+
codeValue[item.type][item.name] = item.value;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const data = {};
|
|
109
|
+
Object.assign(data, params.pageContext.entity, codeValue);
|
|
110
|
+
printTemplate.print(data, options, ext);
|
|
111
|
+
});
|
|
112
|
+
} else {
|
|
113
|
+
const data = {};
|
|
114
|
+
Object.assign(data, params.pageContext.entity);
|
|
115
|
+
printTemplate.print(data, options, ext);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function getFormBarCodeValue(pageContext, barCodeOption) {
|
|
119
|
+
return new Promise((reslove, reject) => {
|
|
120
|
+
const fields = barCodeOption.field.split(".");
|
|
121
|
+
const barcodeRule = {
|
|
122
|
+
type: null,
|
|
123
|
+
name: null,
|
|
124
|
+
value: null
|
|
125
|
+
};
|
|
126
|
+
if (fields.length < 2) {
|
|
127
|
+
reslove(barcodeRule);
|
|
128
|
+
}
|
|
129
|
+
barcodeRule.type = fields[0];
|
|
130
|
+
barcodeRule.name = fields[1];
|
|
131
|
+
try {
|
|
132
|
+
getBarcodeModelsByName(barcodeRule.name).then((res) => {
|
|
133
|
+
const rule = JSON.parse(res.barcodeModelItems);
|
|
134
|
+
barcodeRule.value = generateCodeByRule(rule, pageContext.entity.data);
|
|
135
|
+
reslove(barcodeRule);
|
|
136
|
+
});
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error("获取条码规则失败:", error);
|
|
139
|
+
reslove(barcodeRule);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function getBarcodeModelsByName(name) {
|
|
144
|
+
const encodedParam = encodeURIComponent(name);
|
|
145
|
+
return http.get(
|
|
146
|
+
window["$vueApp"].config.globalProperties.baseAPI + `/dc/setting-barcode-models/by-name?name=${encodedParam}`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
const printLabelUtil = { printLabel };
|
|
150
|
+
export {
|
|
151
|
+
printLabelUtil as default,
|
|
152
|
+
printLabel
|
|
153
|
+
};
|
|
@@ -36,8 +36,11 @@ export declare const standardEvents: {
|
|
|
36
36
|
retrieveTask: (params: any) => Promise<unknown>;
|
|
37
37
|
viewDetail: (params: any) => void;
|
|
38
38
|
lineEditCreate: (params: any) => void;
|
|
39
|
+
printLabel: (params: any) => void;
|
|
40
|
+
queryCharts: (params: any) => void;
|
|
39
41
|
};
|
|
40
42
|
export declare function exportFormReport(pageContext: any, configureObj: any, templateFile: any, isPdf: any): void;
|
|
43
|
+
export declare function getSaveFormRequestWithRow(pageContext: any, configureObj: any, url: any, isUnControlVersion: any, mainDefaultValueColumns: any, dynamicColumnInfo: any, row: any): any;
|
|
41
44
|
export declare function getSaveFormRequest(pageContext: any, configureObj: any, url: any, isUnControlVersion: any, mainDefaultValueColumns: any, dynamicColumnInfo: any): any;
|
|
42
45
|
/**
|
|
43
46
|
* 按钮执行后页面处理方式:刷新、关闭弹框等等
|