super-page-runtime 2.0.22 → 2.0.25

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.
Files changed (20) hide show
  1. package/dist/es/components/runtime/utils/api/api-util.js +4 -4
  2. package/dist/es/components/runtime/utils/api/page-expose-util.js +5 -1
  3. package/dist/es/components/runtime/utils/assemblys-config.js +16 -7
  4. package/dist/es/components/runtime/utils/common-util.js +1 -1
  5. package/dist/es/components/runtime/utils/events/event-util.d.ts +14 -0
  6. package/dist/es/components/runtime/utils/events/event-util.js +94 -20
  7. package/dist/es/components/runtime/utils/events/standard-event.d.ts +1 -0
  8. package/dist/es/components/runtime/utils/events/standard-event.js +69 -27
  9. package/dist/es/components/runtime/utils/form/scan-util.js +191 -0
  10. package/dist/es/components/runtime/utils/page-helper-util.js +18 -2
  11. package/dist/es/components/runtime/utils/page-init-util.js +5 -13
  12. package/dist/es/components/runtime/views/assemblys/data/bar-code/barcode-runtime.vue.js +4 -0
  13. package/dist/es/components/runtime/views/assemblys/data/bar-code/barcode-runtime.vue2.js +207 -0
  14. package/dist/es/components/runtime/views/assemblys/data/table/main-table-runtime.vue.js +91 -59
  15. package/dist/es/components/runtime/views/assemblys/data/table/sub-table-runtime.vue.js +1 -1
  16. package/dist/es/components/runtime/views/assemblys/form/input-text/inputtext-runtime.vue2.js +24 -1
  17. package/dist/es/components/runtime/views/assemblys/form/rich-text/richtext-runtime.vue2.js +21 -3
  18. package/dist/es/components/runtime/views/assemblys/object-render.vue.js +3 -0
  19. package/dist/es/components/runtime/views/super-page.vue.js +16 -5
  20. package/package.json +2 -2
@@ -0,0 +1,191 @@
1
+ import http from "agilebuilder-ui/src/utils/request";
2
+ import { setValueForVariableName } from "../page-helper-util.js";
3
+ function formatScanRuleSets(ruleList) {
4
+ const scanRuleSets2 = {};
5
+ ruleList.forEach((ruleSet) => {
6
+ if (ruleSet.type === "group") {
7
+ ruleSet.outs.forEach((valueSet) => {
8
+ if (!scanRuleSets2[valueSet.ruleCode]) {
9
+ scanRuleSets2[valueSet.ruleCode] = { outs: [], adaptations: [] };
10
+ }
11
+ scanRuleSets2[valueSet.ruleCode].outs.push(valueSet);
12
+ });
13
+ } else {
14
+ scanRuleSets2[ruleSet.code] = { outs: ruleSet.outs, adaptations: [] };
15
+ }
16
+ });
17
+ return packageScanRuleSets(scanRuleSets2);
18
+ }
19
+ function packageScanRuleSets(scanRuleSets2) {
20
+ return new Promise((resolve, reject) => {
21
+ if (Object.keys(scanRuleSets2).length > 0) {
22
+ http.post("/dc/setting-barcode-analysis/by-codes", Object.keys(scanRuleSets2)).then((res2) => {
23
+ res2.forEach((rule) => {
24
+ const ruleOuts = JSON.parse(rule.barcodeAnalysisOuts);
25
+ const needOutsFields = /* @__PURE__ */ new Set();
26
+ const outsFiledsSet = {};
27
+ scanRuleSets2[rule.code].outs.forEach((valueSet) => {
28
+ needOutsFields.add(valueSet.returnedValue);
29
+ outsFiledsSet[valueSet.returnedValue] = valueSet.pageVariable;
30
+ });
31
+ const filteredOutsField = [];
32
+ ruleOuts.forEach((outFiled) => {
33
+ if (needOutsFields.has(outFiled.code)) {
34
+ outFiled.pageVariable = outsFiledsSet[outFiled.code];
35
+ filteredOutsField.push(outFiled);
36
+ }
37
+ });
38
+ scanRuleSets2[rule.code].outs = filteredOutsField;
39
+ scanRuleSets2[rule.code].adaptations = JSON.parse(rule.barcodeAnalysisAdaptations);
40
+ resolve(scanRuleSets2);
41
+ });
42
+ });
43
+ } else {
44
+ resolve(null);
45
+ }
46
+ });
47
+ }
48
+ function analysisScanValue(scanValue, scanRuleSets) {
49
+ if (!scanValue) {
50
+ return null;
51
+ }
52
+ const scanSets = Object.values(scanRuleSets);
53
+ for (let i = 0; i < scanSets.length; i++) {
54
+ const scanSet = scanSets[i];
55
+ const adaptations = scanSet.adaptations;
56
+ let validStr = "";
57
+ for (let k = 0; k < adaptations.length; k++) {
58
+ const adap = adaptations[k];
59
+ const indexs = _getScanIndexs(scanValue, adap.startIndex, adap.endIndex);
60
+ const startIndex = indexs[0];
61
+ const endIndex = indexs[1];
62
+ let paramValue = scanValue.substring(startIndex, endIndex);
63
+ let compareValue = adap.value;
64
+ let operate = adap.operate;
65
+ if (operate == "times") {
66
+ const realValue = paramValue.split(compareValue == void 0 ? "" : compareValue).length - 1;
67
+ compareValue = realValue;
68
+ paramValue = adap.times;
69
+ operate = "=";
70
+ }
71
+ if (isNaN(paramValue) || isNaN(compareValue)) {
72
+ paramValue = "'" + paramValue + "'";
73
+ compareValue = "'" + compareValue + "'";
74
+ }
75
+ if (adap.leftBracket) {
76
+ validStr += adap.leftBracket;
77
+ }
78
+ if (operate == "<>") {
79
+ operate = "!=";
80
+ } else if (operate == "=") {
81
+ operate = "==";
82
+ }
83
+ if (operate == "include" || operate == "notinclude") {
84
+ validStr += paramValue + ".indexOf(" + compareValue + ")";
85
+ if (operate == "include") {
86
+ validStr += ">-1";
87
+ } else {
88
+ validStr += "<0";
89
+ }
90
+ } else {
91
+ validStr += paramValue + operate + compareValue;
92
+ }
93
+ if (adap.rightBracket) {
94
+ validStr += adap.rightBracket;
95
+ }
96
+ if (adap.joinStr && k + 1 < adaptations.length) {
97
+ const joinStr = adap.joinStr == "and" ? "&&" : "||";
98
+ validStr += joinStr;
99
+ }
100
+ }
101
+ let res = false;
102
+ if (validStr) {
103
+ try {
104
+ console.log("validStr", validStr);
105
+ res = eval("(" + validStr + ")");
106
+ console.log("res", res);
107
+ } catch (e) {
108
+ console.log(e);
109
+ }
110
+ } else {
111
+ res = true;
112
+ }
113
+ if (res) {
114
+ return executeAnalysisForScan(scanValue, scanSet);
115
+ }
116
+ }
117
+ return null;
118
+ }
119
+ function executeAnalysisForScan(scanValue2, scanSet2) {
120
+ if (!scanSet2 || !scanValue2) {
121
+ return;
122
+ }
123
+ const outs = scanSet2.outs;
124
+ const params = {};
125
+ outs.forEach((outJson) => {
126
+ const fieldName = outJson.fieldName;
127
+ if (outJson.fixedValue != void 0) {
128
+ params[fieldName] = outJson.fixedValue;
129
+ } else {
130
+ let pValue = scanValue2;
131
+ if (outJson.splitChar && outJson.splitNum) {
132
+ const splitChar = outJson.splitChar == "|" ? outJson.splitChar : outJson.splitChar;
133
+ const strs = scanValue2.split(splitChar);
134
+ const splitNum = outJson.splitNum < 1 ? 1 : outJson.splitNum;
135
+ console.log(pValue, splitChar, strs, splitNum);
136
+ if (splitNum <= strs.length) {
137
+ pValue = strs[splitNum - 1];
138
+ } else {
139
+ pValue = "";
140
+ }
141
+ }
142
+ if (outJson.splitChar2 && outJson.splitNum2) {
143
+ const splitChar2 = outJson.splitChar2 == "|" ? outJson.splitChar2 : outJson.splitChar2;
144
+ const strs = pValue.split(splitChar2);
145
+ const splitNum2 = outJson.splitNum2 < 1 ? 1 : outJson.splitNum2;
146
+ console.log(pValue, splitChar2, strs, splitNum2);
147
+ if (splitNum2 <= strs.length) {
148
+ pValue = strs[splitNum2 - 1];
149
+ } else {
150
+ pValue = "";
151
+ }
152
+ }
153
+ if (pValue.length > 0) {
154
+ const indexs = _getScanIndexs(pValue, outJson.startIndex, outJson.endIndex);
155
+ const startIndex = indexs[0];
156
+ const endIndex = indexs[1];
157
+ pValue = pValue.substring(startIndex, endIndex);
158
+ }
159
+ params[fieldName] = pValue;
160
+ }
161
+ });
162
+ return { value: scanValue2, params, scanSet: scanSet2 };
163
+ }
164
+ function _getScanIndexs(value, startIndex, endIndex) {
165
+ startIndex = startIndex == void 0 ? 0 : startIndex - 1;
166
+ startIndex = startIndex < 0 ? 0 : startIndex;
167
+ startIndex = startIndex > value.length - 1 ? value.length - 1 : startIndex;
168
+ endIndex = endIndex == void 0 ? value.length : endIndex;
169
+ endIndex = endIndex > value.length ? value.length : endIndex;
170
+ endIndex = endIndex < 1 ? 1 : endIndex;
171
+ if (endIndex < startIndex) {
172
+ endIndex = startIndex;
173
+ }
174
+ return [startIndex, endIndex];
175
+ }
176
+ function setScanAnalysisValue(pageContext, scanSet2, params) {
177
+ if (!scanSet2) {
178
+ return;
179
+ }
180
+ const outs = scanSet2.outs;
181
+ outs.forEach((outField) => {
182
+ const fieldName = outField.fieldName;
183
+ const value = params[fieldName];
184
+ setValueForVariableName(pageContext.entity, outField.pageVariable, value);
185
+ });
186
+ }
187
+ export {
188
+ analysisScanValue,
189
+ formatScanRuleSets,
190
+ setScanAnalysisValue
191
+ };
@@ -156,7 +156,11 @@ function updateChartDatasources(pageContext2, dataSourceConfs, appendParams) {
156
156
  systemCode: pageContext2.systemCode,
157
157
  pageCode: pageContext2.code
158
158
  };
159
- const url = window["$vueApp"].config.globalProperties.baseURL + "/common/common-data/find-chart-datas";
159
+ let baseUrl = pageContext2.backendUrl;
160
+ if (!baseUrl) {
161
+ baseUrl = window["$vueApp"].config.globalProperties.baseURL;
162
+ }
163
+ const url = baseUrl + "/common/common-data/find-chart-datas";
160
164
  http.post(url, param).then((result) => {
161
165
  if (!pageContext2.chartDataSourceMap) {
162
166
  pageContext2.chartDataSourceMap = {};
@@ -198,7 +202,11 @@ function updateOptionDatasources(pageContext2, dataSourceConfs, query) {
198
202
  systemCode: pageContext2.systemCode,
199
203
  query
200
204
  };
201
- const url = window["$vueApp"].config.globalProperties.baseURL + "/common/common-data/find-datas";
205
+ let baseUrl = pageContext2.backendUrl;
206
+ if (!baseUrl) {
207
+ baseUrl = window["$vueApp"].config.globalProperties.baseURL;
208
+ }
209
+ const url = baseUrl + "/common/common-data/find-datas";
202
210
  http.post(url, param).then((result) => {
203
211
  if (!pageContext2.optionSourceMap) {
204
212
  pageContext2.optionSourceMap = {};
@@ -611,6 +619,13 @@ function getMonitorFieldValues(monitorFieldInfos, entity) {
611
619
  }
612
620
  return values;
613
621
  }
622
+ function getFormPropName(prop) {
623
+ if (prop && prop.indexOf("${") >= 0) {
624
+ return prop.substring(prop.indexOf(".") + 1, prop.lastIndexOf("}"));
625
+ } else {
626
+ return prop;
627
+ }
628
+ }
614
629
  export {
615
630
  autoSetAfterSelect,
616
631
  caculateShowCondition,
@@ -618,6 +633,7 @@ export {
618
633
  formatVariableValue,
619
634
  getChartDatasFromPage,
620
635
  getComponentOptionConfigs,
636
+ getFormPropName,
621
637
  getOptionDatasFromPage,
622
638
  getValueFromSource,
623
639
  getVariableValue,
@@ -2,9 +2,9 @@ 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, setVariableValue } from "./page-helper-util.js";
5
+ import { formatVariableValue, setVariableValue, getFormPropName } from "./page-helper-util.js";
6
6
  function queryPageDesignByCode(pageCode) {
7
- return http.get("/component/super-page-design/runtime/" + pageCode);
7
+ return http.get(window["$vueApp"].config.globalProperties.baseAPI + "/component/super-page-design/runtime/" + pageCode);
8
8
  }
9
9
  function convertToPageContext(pageDesign, pageRequest) {
10
10
  if (pageDesign == null) {
@@ -128,7 +128,6 @@ function getFormModelFields(pageContext, formItemConfigure) {
128
128
  fields = [formItemConfigure.uuid];
129
129
  }
130
130
  }
131
- debugger;
132
131
  if (entity.data.ID == void 0 && entity.data.ID == void 0) {
133
132
  if (propsBase.defaultValue) {
134
133
  let defaultValue = formatVariableValue(pageContext, propsBase.defaultValue);
@@ -149,7 +148,7 @@ function getFormModelFields(pageContext, formItemConfigure) {
149
148
  return fields;
150
149
  }
151
150
  function getPermissionCodes(configure, pageContext) {
152
- if (!pageContext || pageContext.isTest || !configure) {
151
+ if (!pageContext || !configure) {
153
152
  return "true";
154
153
  }
155
154
  const codes = [];
@@ -182,10 +181,10 @@ function queryPageSuperGrids(pageDesign, pageContext, publishVersion) {
182
181
  const additionalParamMap = getAdditionalParamMap(pageContext);
183
182
  let additionalParamMapJson;
184
183
  const pageCode = pageContext.code;
185
- if (additionalParamMap) {
184
+ if (additionalParamMap && Object.keys(additionalParamMap) > 0) {
186
185
  additionalParamMapJson = JSON.stringify(additionalParamMap);
187
186
  }
188
- return http.post("/component/super-page-design/super-grids", {
187
+ return http.post(window["$vueApp"].config.globalProperties.baseAPI + "/component/super-page-design/super-grids", {
189
188
  tableRuntimes,
190
189
  additionalParamMapJson,
191
190
  pageCode,
@@ -211,13 +210,6 @@ function packageFormRules(pageContext, configure) {
211
210
  pageContext.rules[propName] = configure.props.rules;
212
211
  }
213
212
  }
214
- function getFormPropName(prop) {
215
- if (prop && prop.indexOf("${") >= 0) {
216
- return prop.substring(prop.indexOf(".") + 1, prop.lastIndexOf("}"));
217
- } else {
218
- return prop;
219
- }
220
- }
221
213
  export {
222
214
  convertToPageContext,
223
215
  getFormModelFields,
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./barcode-runtime.vue2.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,207 @@
1
+ import { defineComponent, computed, ref, onMounted, watch, resolveComponent, openBlock, createBlock, normalizeClass, unref, normalizeStyle, withCtx, createElementBlock, toDisplayString, createCommentVNode } from "vue";
2
+ import qrcode from "qrcode";
3
+ import JsBarcode from "jsbarcode";
4
+ import { getFormModelFields } from "../../../../utils/page-init-util.js";
5
+ import { getVariableValue, setVariableValue } from "../../../../utils/page-helper-util.js";
6
+ import { handleEvent } from "../../../../utils/events/event-util.js";
7
+ import "agilebuilder-ui/src/utils/request";
8
+ const _hoisted_1 = ["src"];
9
+ const _sfc_main = /* @__PURE__ */ defineComponent({
10
+ __name: "barcode-runtime",
11
+ props: {
12
+ pageContext: {},
13
+ configure: {}
14
+ },
15
+ setup(__props, { expose: __expose }) {
16
+ const props = __props;
17
+ const entity = props.pageContext.entity ? props.pageContext.entity : {};
18
+ let dynamicFields = getFormModelFields(props.pageContext, props.configure);
19
+ const dynamicModelMethod = computed({
20
+ get() {
21
+ return getVariableValue(entity, dynamicFields);
22
+ },
23
+ set(value) {
24
+ setVariableValue(entity, dynamicFields, value);
25
+ }
26
+ });
27
+ const runtimeInfo = props.configure.runtime ? props.configure.runtime : {};
28
+ const designProperty = ref(runtimeInfo.props ? runtimeInfo.props : {});
29
+ const runtimeStyle = runtimeInfo.style;
30
+ const runtimeClass = runtimeInfo.class;
31
+ const headerStyle = runtimeInfo.headerStyle;
32
+ const qrUrl = ref("");
33
+ const barcode = ref(null);
34
+ const barcodeFormat = ref(designProperty.value.brCodeFormat ?? "CODE128");
35
+ const watchVariableNames = ref([]);
36
+ onMounted(() => {
37
+ if (designProperty.value.generateRule) {
38
+ if (designProperty.value.generateRuleType === "fixed") {
39
+ handleFixedFormat();
40
+ } else {
41
+ handleSelectedRule();
42
+ }
43
+ }
44
+ if (dynamicModelMethod.value) {
45
+ createCode(dynamicModelMethod.value);
46
+ }
47
+ });
48
+ function getValue() {
49
+ return getVariableValue(entity, dynamicFields);
50
+ }
51
+ function setValue(value) {
52
+ return setVariableValue(entity, dynamicFields, value);
53
+ }
54
+ function handleFixedFormat() {
55
+ watchVariableNames.value = Array.from(
56
+ designProperty.value.generateRule.matchAll(/\$\{(\w+)\}/g),
57
+ (m) => m[1]
58
+ );
59
+ watchVariableNames.value.forEach((name) => {
60
+ watch(
61
+ () => props.pageContext.entity.data[name],
62
+ (newValue, oldValue) => {
63
+ if (newValue !== void 0 && newValue !== null) {
64
+ generateFixedFormatCode();
65
+ }
66
+ }
67
+ );
68
+ });
69
+ }
70
+ function handleSelectedRule() {
71
+ const rule = JSON.parse(
72
+ '[{"fieldName":"-1","fixedValue":"|"},{"fixedValue":"","fieldLength":"10","suppliement":"x","fieldName":"passenger"},{"fixedValue":"","fieldLength":"","suppliement":"","fieldName":"passengerNumber"},{"fixedValue":"AAA","fieldLength":"","suppliement":"","fieldName":"-1"}]'
73
+ );
74
+ rule.forEach((item) => {
75
+ if (item.fieldName !== "-1" && item.fieldName !== -1) {
76
+ watchVariableNames.value.push(item.fieldName);
77
+ watch(
78
+ () => props.pageContext.entity.data[item.fieldName],
79
+ (newValue, oldValue) => {
80
+ if (newValue !== void 0 && newValue !== null) {
81
+ generateCodeByRule(rule);
82
+ }
83
+ }
84
+ );
85
+ }
86
+ });
87
+ }
88
+ function generateFixedFormatCode() {
89
+ let allVariablesPresent = true;
90
+ watchVariableNames.value.forEach((name) => {
91
+ if (!props.pageContext.entity.data[name]) {
92
+ allVariablesPresent = false;
93
+ return;
94
+ }
95
+ });
96
+ if (allVariablesPresent) {
97
+ let barCodeValue = replaceVariables(
98
+ designProperty.value.generateRule,
99
+ props.pageContext.entity.data
100
+ );
101
+ generateCode(barCodeValue);
102
+ }
103
+ }
104
+ function generateCodeByRule(rule) {
105
+ let allVariablesPresent = true;
106
+ let value = "";
107
+ rule.forEach((item) => {
108
+ if (item.fieldName !== "-1" && item.fieldName !== -1) {
109
+ const filedValue = props.pageContext.entity.data[item.fieldName];
110
+ if (item.suppliement && item.fieldLength) {
111
+ if (!filedValue) {
112
+ value += "".padEnd(item.fieldLength, item.suppliement);
113
+ } else {
114
+ if (filedValue.length > item.fieldLength) {
115
+ value += filedValue.substring(0, item.fieldLength);
116
+ } else {
117
+ value += filedValue.padEnd(item.fieldLength, item.suppliement);
118
+ }
119
+ }
120
+ } else {
121
+ if (!filedValue) {
122
+ allVariablesPresent = false;
123
+ } else {
124
+ value += filedValue;
125
+ }
126
+ }
127
+ } else {
128
+ value += item.fixedValue;
129
+ }
130
+ });
131
+ console.log(value);
132
+ if (allVariablesPresent) {
133
+ generateCode(value);
134
+ }
135
+ }
136
+ function generateCode(value) {
137
+ createCode(value);
138
+ setValue(value);
139
+ handleEvent(value, props.pageContext, props.configure, "change", {
140
+ entity
141
+ });
142
+ }
143
+ function createCode(value) {
144
+ if (designProperty.value.type === "QR-code") {
145
+ createQrCode(value);
146
+ } else {
147
+ createBarCode(value);
148
+ }
149
+ }
150
+ function createBarCode(codeValue) {
151
+ try {
152
+ JsBarcode(barcode.value, codeValue, { format: barcodeFormat.value });
153
+ } catch (error) {
154
+ console.error("生成条形码时发生错误:", error);
155
+ }
156
+ }
157
+ function createQrCode(codeValue) {
158
+ qrcode.toDataURL(codeValue, (err, url) => {
159
+ if (err) {
160
+ console.error(err);
161
+ } else {
162
+ qrUrl.value = url;
163
+ }
164
+ });
165
+ }
166
+ function replaceVariables(template, variables) {
167
+ const regex = /\$\{(\w+)\}/g;
168
+ return template.replace(regex, (match, keyword) => {
169
+ return variables.hasOwnProperty(keyword) ? variables[keyword] : match;
170
+ });
171
+ }
172
+ __expose({
173
+ getValue,
174
+ setValue
175
+ });
176
+ return (_ctx, _cache) => {
177
+ const _component_el_form_item = resolveComponent("el-form-item");
178
+ return openBlock(), createBlock(_component_el_form_item, {
179
+ required: designProperty.value.required ? true : false,
180
+ class: normalizeClass(unref(runtimeClass)),
181
+ "label-width": designProperty.value.labelWidth,
182
+ style: normalizeStyle(unref(runtimeStyle))
183
+ }, {
184
+ label: withCtx(() => [
185
+ designProperty.value.tittleShow ? (openBlock(), createElementBlock("div", {
186
+ key: 0,
187
+ style: normalizeStyle({ ...unref(headerStyle) })
188
+ }, toDisplayString(designProperty.value.title), 5)) : createCommentVNode("", true)
189
+ ]),
190
+ default: withCtx(() => [
191
+ designProperty.value.type === "QR-code" ? (openBlock(), createElementBlock("img", {
192
+ key: 0,
193
+ src: qrUrl.value
194
+ }, null, 8, _hoisted_1)) : (openBlock(), createElementBlock("canvas", {
195
+ key: 1,
196
+ ref_key: "barcode",
197
+ ref: barcode
198
+ }, null, 512))
199
+ ]),
200
+ _: 1
201
+ }, 8, ["required", "class", "label-width", "style"]);
202
+ };
203
+ }
204
+ });
205
+ export {
206
+ _sfc_main as default
207
+ };