super-page-runtime 2.0.75 → 2.0.80

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 (24) hide show
  1. package/dist/es/_virtual/_plugin-vue_export-helper.js +10 -0
  2. package/dist/es/components/runtime/utils/api/api-util.d.ts +2 -2
  3. package/dist/es/components/runtime/utils/api/api-util.js +18 -14
  4. package/dist/es/components/runtime/utils/api/page-expose-util.js +136 -66
  5. package/dist/es/components/runtime/utils/events/event-util.js +43 -2
  6. package/dist/es/components/runtime/utils/events/standard-event.js +83 -41
  7. package/dist/es/components/runtime/utils/events/validator-util.d.ts +1 -0
  8. package/dist/es/components/runtime/utils/events/validator-util.js +36 -29
  9. package/dist/es/components/runtime/utils/global-refs.d.ts +6 -0
  10. package/dist/es/components/runtime/utils/global-refs.js +11 -0
  11. package/dist/es/components/runtime/utils/page-init-util.d.ts +3 -1
  12. package/dist/es/components/runtime/utils/page-init-util.js +84 -27
  13. package/dist/es/components/runtime/views/assemblys/button/button/button-runtime.vue2.js +9 -2
  14. package/dist/es/components/runtime/views/assemblys/data/table/sub-table-runtime.vue.js +2 -1
  15. package/dist/es/components/runtime/views/assemblys/form/date-picker/datepicker-runtime.vue2.js +4 -2
  16. package/dist/es/components/runtime/views/assemblys/form/file-upload/fileupload-runtime.vue2.js +5 -17
  17. package/dist/es/components/runtime/views/assemblys/form/placeholder/placeholder-runtime.vue.js +4 -1
  18. package/dist/es/components/runtime/views/assemblys/form/placeholder/placeholder-runtime.vue2.js +3 -2
  19. package/dist/es/components/runtime/views/assemblys/form/placeholder/placeholder-runtime.vue3.js +1 -0
  20. package/dist/es/components/runtime/views/assemblys/object-render.vue.js +11 -5
  21. package/dist/es/components/runtime/views/assemblys/workflow/workflow-button/workflowbutton-runtime.vue2.js +2 -2
  22. package/dist/es/components/runtime/views/super-page.vue.js +11 -4
  23. package/dist/es/style.css +3 -0
  24. package/package.json +2 -2
@@ -0,0 +1,10 @@
1
+ const _export_sfc = (sfc, props) => {
2
+ const target = sfc.__vccOpts || sfc;
3
+ for (const [key, val] of props) {
4
+ target[key] = val;
5
+ }
6
+ return target;
7
+ };
8
+ export {
9
+ _export_sfc as default
10
+ };
@@ -10,9 +10,9 @@ export declare function setCustomRules(pageContext: PageContext, customRules: an
10
10
  * 刷新页面
11
11
  * @param pageContext
12
12
  */
13
- export declare function refreshPage(pageContext: PageContext): void;
13
+ export declare function refreshPage(pageContext: PageContext, id?: any): void;
14
14
  /**
15
15
  * 获得表单数据
16
16
  * @param pageContext
17
17
  */
18
- export declare function getFormData(pageContext: PageContext): Promise<unknown>;
18
+ export declare function getFormData(pageContext: PageContext, id?: any): Promise<unknown>;
@@ -5,20 +5,21 @@ import { getAdditionalParamMap, dealCompleteTaskParam } from "../events/standard
5
5
  import { packageCustomRules, getWorkflowRules } from "../events/validator-util.js";
6
6
  import { handleEvent } from "../events/event-util.js";
7
7
  import { functions } from "./page-expose-util.js";
8
- function refreshPage(pageContext) {
9
- getFormData(pageContext).then((commonEntity) => {
8
+ function refreshPage(pageContext, id) {
9
+ getFormData(pageContext, id).then((commonEntity) => {
10
10
  pageContext.isRefresh = true;
11
11
  });
12
12
  }
13
- function getFormData(pageContext) {
13
+ function getFormData(pageContext, id) {
14
14
  const pageType = pageContext.pageType;
15
15
  if (pageType && pageType === "form") {
16
16
  console.log("获取表单数据getData--pageContext=", pageContext);
17
+ pageContext.canClick = false;
17
18
  const isWorkflow = pageContext.workflowCode ? true : false;
18
19
  if (isWorkflow) {
19
- return getWorkflowFormData(pageContext);
20
+ return getWorkflowFormData(pageContext, id);
20
21
  } else {
21
- return getCommonFormData(pageContext);
22
+ return getCommonFormData(pageContext, id);
22
23
  }
23
24
  } else {
24
25
  return new Promise((resolve, reject) => {
@@ -26,14 +27,14 @@ function getFormData(pageContext) {
26
27
  });
27
28
  }
28
29
  }
29
- function getCommonFormData(pageContext) {
30
+ function getCommonFormData(pageContext, id) {
30
31
  return new Promise((resolve, reject) => {
31
32
  const systemCode = pageContext.systemCode;
32
33
  const pageCode = pageContext.code;
33
34
  const pageVersion = pageContext.version;
34
35
  const additionalParamMap = getAdditionalParamMap(pageContext);
35
- const dataId = additionalParamMap && additionalParamMap.id ? additionalParamMap.id : null;
36
- const ids = additionalParamMap ? additionalParamMap.ids : null;
36
+ const dataId = id ? id : additionalParamMap && additionalParamMap.id ? additionalParamMap.id : null;
37
+ const ids = id ? [id] : additionalParamMap ? additionalParamMap.ids : null;
37
38
  const taskId = additionalParamMap ? additionalParamMap.taskId : null;
38
39
  const permissionPrefix = pageCode;
39
40
  console.log("getCommonFormData-----pageContext=", pageContext);
@@ -97,20 +98,22 @@ function getCommonFormData(pageContext) {
97
98
  label: ""
98
99
  };
99
100
  handleEvent(null, pageContext, pageDesign, "load");
101
+ pageContext.canClick = true;
100
102
  resolve(commonEntity);
101
103
  }).catch((error) => {
104
+ pageContext.canClick = true;
102
105
  reject(error);
103
106
  });
104
107
  });
105
108
  }
106
- function getWorkflowFormData(pageContext) {
109
+ function getWorkflowFormData(pageContext, id) {
107
110
  return new Promise((resolve, reject) => {
108
111
  const systemCode = pageContext.systemCode;
109
112
  const pageCode = pageContext.code;
110
113
  const pageVersion = pageContext.version;
111
114
  const additionalParamMap = getAdditionalParamMap(pageContext);
112
- const dataId = additionalParamMap && additionalParamMap.id ? additionalParamMap.id : null;
113
- const ids = additionalParamMap ? additionalParamMap.ids : null;
115
+ const dataId = id ? id : additionalParamMap && additionalParamMap.id ? additionalParamMap.id : null;
116
+ const ids = id ? [id] : additionalParamMap ? additionalParamMap.ids : null;
114
117
  const taskId = additionalParamMap ? additionalParamMap.taskId : null;
115
118
  const permissionPrefix = pageCode;
116
119
  const param = {
@@ -176,8 +179,10 @@ function getWorkflowFormData(pageContext) {
176
179
  };
177
180
  handleEvent(null, pageContext, pageDesign, "load");
178
181
  }
182
+ pageContext.canClick = true;
179
183
  resolve(commonEntity);
180
184
  }).catch((error) => {
185
+ pageContext.canClick = true;
181
186
  reject(error);
182
187
  });
183
188
  });
@@ -285,9 +290,8 @@ function formatAdditionalParamMapIds(ids) {
285
290
  ids = ids.split(",");
286
291
  } else if (typeof ids === "number") {
287
292
  ids = [ids];
288
- } else {
289
- console.error("ids参数类型错误");
290
- }
293
+ } else
294
+ ;
291
295
  }
292
296
  return ids;
293
297
  }
@@ -1,74 +1,91 @@
1
1
  import { setValueForVariableName } from "../page-helper-util.js";
2
- import { getComponentRefByCode } from "../global-refs.js";
2
+ import { getComponentRefByCode, getAllComponentRefs } from "../global-refs.js";
3
3
  import eventBus from "../eventBus.js";
4
4
  import http from "agilebuilder-ui/src/utils/request";
5
5
  import { getAdditionalParamMap } from "../events/standard-event.js";
6
+ import { i18nValidatePropRulesMessage } from "../events/validator-util.js";
6
7
  const functions = {
7
8
  /**
8
9
  * 展示页面中的某个组件元素
9
10
  * @param pageDesign 页面设计对象
10
11
  * @param codes 展示组件所绑定的变量或者是绑定的code值, 绑定变量时传递变量名, 如果绑定的变量为${data.xxx}则传递xxx
11
12
  */
12
- showElement: function(pageContext, codes) {
13
- codes.forEach((code) => {
14
- const ref = getComponentRefByCode(pageContext, code);
15
- if (ref) {
16
- ref.show();
17
- } else {
18
- console.error(`未找到code为${code}的组件`);
19
- }
20
- });
13
+ showElement: function(pageContext, codes, isInit) {
14
+ if (isInit) {
15
+ packageInitInfo(pageContext, "showElement", codes);
16
+ } else {
17
+ codes.forEach((code) => {
18
+ const ref = getComponentRefByCode(pageContext, code);
19
+ if (ref) {
20
+ ref.show();
21
+ } else {
22
+ console.error(`未找到code为${code}的组件`);
23
+ }
24
+ });
25
+ }
21
26
  },
22
27
  /**
23
28
  * 隐藏页面中的某个组件元素
24
29
  * @param pageDesign 页面设计对象
25
30
  * @param codes 展示组件所绑定的变量或者是绑定的code值, 绑定变量时传递变量名, 如果绑定的变量为${data.xxx}则传递xxx
26
31
  */
27
- hideElement: function(pageContext, codes) {
28
- codes.forEach((code) => {
29
- const ref = getComponentRefByCode(pageContext, code);
30
- if (ref) {
31
- ref.hide();
32
- } else {
33
- console.error(`未找到code为${code}的组件`);
34
- }
35
- });
32
+ hideElement: function(pageContext, codes, isInit) {
33
+ if (isInit) {
34
+ packageInitInfo(pageContext, "hideElement", codes);
35
+ } else {
36
+ codes.forEach((code) => {
37
+ const ref = getComponentRefByCode(pageContext, code);
38
+ if (ref) {
39
+ ref.hide();
40
+ } else {
41
+ console.error(`未找到code为${code}的组件`);
42
+ }
43
+ });
44
+ }
36
45
  },
37
46
  /**
38
47
  * 设置组件元素可用状态
39
48
  * @param pageContext
40
49
  * @param codes ['name', 'age']
41
50
  */
42
- enableElement: function(pageContext, codes) {
43
- codes.forEach((code) => {
44
- const ref = getComponentRefByCode(pageContext, code);
45
- if (ref) {
46
- const configure = ref.getConfigure();
47
- if (configure && configure.runtime.props) {
48
- configure.runtime.props.state = "enabled";
51
+ enableElement: function(pageContext, codes, isInit) {
52
+ if (isInit) {
53
+ packageInitInfo(pageContext, "enableElement", codes);
54
+ } else {
55
+ codes.forEach((code) => {
56
+ const ref = getComponentRefByCode(pageContext, code);
57
+ if (ref) {
58
+ const configure = ref.getConfigure();
59
+ if (configure && configure.runtime.props) {
60
+ configure.runtime.props.state = "enabled";
61
+ }
62
+ } else {
63
+ console.error(`未找到code为${code}的组件`);
49
64
  }
50
- } else {
51
- console.error(`未找到code为${code}的组件`);
52
- }
53
- });
65
+ });
66
+ }
54
67
  },
55
68
  /**
56
69
  * 禁用页面中的某个组件元素
57
70
  * @param pageContext
58
71
  * @param codes ['name', 'age']
59
72
  */
60
- disableElement: function(pageContext, codes) {
61
- codes.forEach((code) => {
62
- const ref = getComponentRefByCode(pageContext, code);
63
- if (ref) {
64
- const configure = ref.getConfigure();
65
- if (configure && configure.runtime.props) {
66
- configure.runtime.props.state = "disabled";
73
+ disableElement: function(pageContext, codes, isInit) {
74
+ if (isInit) {
75
+ packageInitInfo(pageContext, "disableElement", codes);
76
+ } else {
77
+ codes.forEach((code) => {
78
+ const ref = getComponentRefByCode(pageContext, code);
79
+ if (ref) {
80
+ const configure = ref.getConfigure();
81
+ if (configure && configure.runtime.props) {
82
+ configure.runtime.props.state = "disabled";
83
+ }
84
+ } else {
85
+ console.error(`未找到code为${code}的组件`);
67
86
  }
68
- } else {
69
- console.error(`未找到code为${code}的组件`);
70
- }
71
- });
87
+ });
88
+ }
72
89
  },
73
90
  /**
74
91
  * 设置值
@@ -108,14 +125,32 @@ const functions = {
108
125
  });
109
126
  },
110
127
  /**
111
- *
128
+ * 表单编辑权限动态控制
112
129
  * @param pageContext
113
130
  * @param keyValue [
131
+ {
132
+ name: '_all_fields', // _all_fields 表示所有字段
133
+ show: true,
134
+ readonly: true,
135
+ disabled: true,
136
+ required: true,
137
+ rules: [
138
+ {
139
+ required: true,
140
+ trigger: 'blur'
141
+ },
142
+ {
143
+ type: 'email',
144
+ trigger: ['blur', 'change']
145
+ }
146
+ ]
147
+ },
114
148
  {
115
149
  name: 'xxxx',
116
150
  show: true,
117
151
  readonly: true,
118
152
  disabled: true,
153
+ required: true,
119
154
  rules: [
120
155
  {
121
156
  required: true,
@@ -131,34 +166,28 @@ const functions = {
131
166
  }
132
167
  ]
133
168
  */
134
- fnProhibitToEdit: function(pageContext, settings) {
135
- if (!pageContext.customRules) {
136
- pageContext.customRules = {};
137
- }
138
- settings.forEach((item) => {
139
- if (!item.name) {
140
- return;
141
- }
142
- if (item.rules) {
143
- pageContext.customRules[item.name] = item.rules;
169
+ dynamicControlFormEdit: function(pageContext, settings, isInit) {
170
+ if (isInit) {
171
+ packageInitInfo(pageContext, "dynamicControlFormEdit", settings);
172
+ } else {
173
+ if (!pageContext.customRules) {
174
+ pageContext.customRules = {};
144
175
  }
145
- const ref = getComponentRefByCode(pageContext, item.name);
146
- if (ref) {
147
- if (item.show !== void 0) {
148
- item.show ? ref.show() : ref.hide();
149
- }
150
- const configure = ref.getConfigure();
151
- if (item.required !== void 0) {
152
- configure.runtime.props.required = item.required;
176
+ for (let i = 0; i < settings.length; i++) {
177
+ const item = settings[i];
178
+ if (!item.name) {
179
+ continue;
153
180
  }
154
- if (item.readonly !== void 0) {
155
- item.readonly ? configure.runtime.props.state = "readonly" : configure.runtime.props.state = "enabled";
156
- }
157
- if (item.disabled !== void 0) {
158
- item.disabled ? configure.runtime.props.state = "disabled" : configure.runtime.props.state = "enabled";
181
+ const allFields = "_all_fields";
182
+ if (item.name === allFields) {
183
+ packageAllFeildsRules(pageContext, item);
184
+ break;
185
+ } else {
186
+ const ref = getComponentRefByCode(pageContext, item.name);
187
+ packageOneFeildRules(pageContext, item, item.name, ref);
159
188
  }
160
189
  }
161
- });
190
+ }
162
191
  },
163
192
  /**
164
193
  * 调用服务流,
@@ -201,6 +230,47 @@ const functions = {
201
230
  });
202
231
  }
203
232
  };
233
+ function packageAllFeildsRules(pageContext, item) {
234
+ const allComponetRefs = getAllComponentRefs(pageContext);
235
+ if (allComponetRefs) {
236
+ const props = Object.keys(allComponetRefs);
237
+ props.forEach((propName) => {
238
+ const componentRef = allComponetRefs[propName];
239
+ packageOneFeildRules(pageContext, item, propName, componentRef);
240
+ });
241
+ }
242
+ }
243
+ function packageOneFeildRules(pageContext, item, propName, ref) {
244
+ if (propName) {
245
+ if (item.rules) {
246
+ i18nValidatePropRulesMessage(item.rules, false);
247
+ pageContext.customRules[propName] = item.rules;
248
+ } else {
249
+ pageContext.customRules[propName] = [];
250
+ }
251
+ }
252
+ if (ref) {
253
+ const configure = ref.getConfigure();
254
+ if (item.show !== void 0) {
255
+ item.show ? ref.show() : ref.hide();
256
+ }
257
+ if (item.required !== void 0) {
258
+ configure.runtime.props.required = item.required;
259
+ }
260
+ if (item.readonly !== void 0) {
261
+ item.readonly ? configure.runtime.props.state = "readonly" : configure.runtime.props.state = "enabled";
262
+ }
263
+ if (item.disabled !== void 0) {
264
+ item.disabled ? configure.runtime.props.state = "disabled" : configure.runtime.props.state = "enabled";
265
+ }
266
+ }
267
+ }
268
+ function packageInitInfo(pageContext, type, settings) {
269
+ if (!pageContext.initInfo) {
270
+ pageContext.initInfo = {};
271
+ }
272
+ pageContext.initInfo[type] = settings;
273
+ }
204
274
  export {
205
275
  functions
206
276
  };
@@ -102,7 +102,7 @@ function getHandleEvent($event, pageContext, configure, eventType, otherParams)
102
102
  function handleEventUtil($event, pageContext, configure, eventType, isExecute, otherParams, skipValidate) {
103
103
  const pageCode = pageContext.code;
104
104
  const pageVersion = pageContext.version;
105
- const events = configure.runtime && configure.runtime.events ? configure.runtime.events : [];
105
+ const events = configure && configure.runtime && configure.runtime.events ? configure.runtime.events : [];
106
106
  let eventFun;
107
107
  if (!skipValidate && eventType && eventType === "click") {
108
108
  const tableUuid = getTableUuid(pageContext, configure);
@@ -162,8 +162,14 @@ function buttonClickEvent(pageContext, configure, eventParams) {
162
162
  if (!judgeFlag) {
163
163
  return;
164
164
  }
165
+ if (pageContext.canClick !== void 0 && pageContext.canClick === false) {
166
+ console.log("不能重复点击");
167
+ return;
168
+ }
165
169
  canExecuteButton(eventParams).then((result) => {
166
170
  if (result["canExecute"] === true) {
171
+ pageContext.clickUuid = configure.uuid;
172
+ pageContext.canClick = false;
167
173
  const events = configure.runtime && configure.runtime.events ? configure.runtime.events : [];
168
174
  const beforeValidateFormFunc = getEventFuncByType(pageContext, events, "beforeValidateForm");
169
175
  let beforeValidateFormResult;
@@ -179,13 +185,19 @@ function buttonClickEvent(pageContext, configure, eventParams) {
179
185
  beforeValidateFormResult = true;
180
186
  }
181
187
  if (!beforeValidateFormResult) {
188
+ pageContext.canClick = true;
182
189
  return;
183
190
  }
184
191
  if (isPromise(beforeValidateFormResult)) {
185
192
  beforeValidateFormResult.then((result2) => {
186
193
  if (result2 && result2 === true) {
187
194
  doValidateForm(pageContext, configure, eventParams);
195
+ } else {
196
+ pageContext.canClick = true;
188
197
  }
198
+ }).catch((error) => {
199
+ console.log(error);
200
+ pageContext.canClick = true;
189
201
  });
190
202
  } else {
191
203
  doValidateForm(pageContext, configure, eventParams);
@@ -207,21 +219,31 @@ function doValidateForm(pageContext, configure, eventParams) {
207
219
  }
208
220
  validateDataModelFunc(pageContext, configure, isEnableRequired).then((validateReslut) => {
209
221
  if (!validateReslut) {
222
+ pageContext.canClick = true;
210
223
  return;
211
224
  }
212
225
  const beforeClickResult = doBeforeClickEvent(pageContext, configure, eventParams);
213
226
  if (!beforeClickResult) {
227
+ pageContext.canClick = true;
214
228
  return;
215
229
  }
216
230
  if (isPromise(beforeClickResult)) {
217
231
  beforeClickResult.then((result) => {
218
232
  if (result) {
219
233
  doClickEvent(pageContext, configure, clickEventFunObj, eventParams);
234
+ } else {
235
+ pageContext.canClick = true;
220
236
  }
237
+ }).catch((error) => {
238
+ console.error(error);
239
+ pageContext.canClick = true;
221
240
  });
222
241
  } else {
223
242
  doClickEvent(pageContext, configure, clickEventFunObj, eventParams);
224
243
  }
244
+ }).catch((error) => {
245
+ console.error(error);
246
+ pageContext.canClick = true;
225
247
  });
226
248
  }
227
249
  function doBeforeClickEvent(pageContext, configure, otherParams) {
@@ -258,6 +280,7 @@ function doClickCustomEvent(pageContext, configure, clickEventFuncObj, eventPara
258
280
  const clickResult = callItemEvent(pageContext, configure, eventFun, eventParams);
259
281
  const isListButton = isListPage(pageContext);
260
282
  if (isNotDoAfterClick(isStandardEvent, event)) {
283
+ pageContext.canClick = true;
261
284
  return;
262
285
  }
263
286
  if (isPromise(clickResult)) {
@@ -271,7 +294,12 @@ function doClickCustomEvent(pageContext, configure, clickEventFuncObj, eventPara
271
294
  result,
272
295
  isListButton
273
296
  );
297
+ } else {
298
+ pageContext.canClick = true;
274
299
  }
300
+ }).catch((error) => {
301
+ console.error(error);
302
+ pageContext.canClick = true;
275
303
  });
276
304
  } else {
277
305
  doAfterClickFunc(
@@ -283,6 +311,8 @@ function doClickCustomEvent(pageContext, configure, clickEventFuncObj, eventPara
283
311
  isListButton
284
312
  );
285
313
  }
314
+ } else {
315
+ pageContext.canClick = true;
286
316
  }
287
317
  }
288
318
  function isNotDoAfterClick(isStandardEvent, clickEvent) {
@@ -295,7 +325,16 @@ function doAfterClickEvent(pageContext, configure, otherParams) {
295
325
  const events = configure.runtime && configure.runtime.events ? configure.runtime.events : [];
296
326
  const afterClickFunc = getEventFuncByType(pageContext, events, "afterClick");
297
327
  if (afterClickFunc) {
298
- callItemEvent(pageContext, configure, afterClickFunc, null, otherParams);
328
+ const afterFunc = callItemEvent(pageContext, configure, afterClickFunc, null, otherParams);
329
+ if (isPromise(afterFunc)) {
330
+ afterFunc.finally(() => {
331
+ pageContext.canClick = true;
332
+ });
333
+ } else {
334
+ pageContext.canClick = true;
335
+ }
336
+ } else {
337
+ pageContext.canClick = true;
299
338
  }
300
339
  }
301
340
  function doAfterClickFunc(pageContext, configure, eventParams, isStandardEvent, result, isListButton) {
@@ -310,6 +349,7 @@ function doAfterClickFunc(pageContext, configure, eventParams, isStandardEvent,
310
349
  );
311
350
  } else {
312
351
  pageContext.result = result;
352
+ pageContext.canClick = true;
313
353
  }
314
354
  const events = configure.runtime && configure.runtime.events ? configure.runtime.events : [];
315
355
  const afterClickFunc = getEventFuncByType(pageContext, events, "afterClick");
@@ -320,6 +360,7 @@ function doAfterClickFunc(pageContext, configure, eventParams, isStandardEvent,
320
360
  function doClickEvent(pageContext, configure, clickEventFunObj, eventParams) {
321
361
  const linkPage = configure.props.linkPage;
322
362
  if (linkPage && linkPage.jumpPageUrl) {
363
+ pageContext.canClick = true;
323
364
  doClickJumpPageEvent(pageContext, configure, eventParams);
324
365
  } else {
325
366
  doClickCustomEvent(pageContext, configure, clickEventFunObj, eventParams);