@ibiz-template/runtime 0.5.7-alpha.2 → 0.5.7-alpha.4

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 (177) hide show
  1. package/dist/index.esm.js +2384 -278
  2. package/dist/index.system.min.js +1 -1
  3. package/out/app-hub.d.ts +2 -0
  4. package/out/app-hub.d.ts.map +1 -1
  5. package/out/app-hub.js +2 -0
  6. package/out/application.d.ts +7 -0
  7. package/out/application.d.ts.map +1 -1
  8. package/out/application.js +23 -10
  9. package/out/constant/index.d.ts +1 -0
  10. package/out/constant/index.d.ts.map +1 -1
  11. package/out/constant/index.js +1 -0
  12. package/out/constant/preset-identifier.d.ts +15 -0
  13. package/out/constant/preset-identifier.d.ts.map +1 -0
  14. package/out/constant/preset-identifier.js +16 -0
  15. package/out/controller/common/editor/editor.controller.d.ts.map +1 -1
  16. package/out/controller/common/editor/editor.controller.js +4 -0
  17. package/out/controller/control/exp-bar/exp-bar.controller.d.ts.map +1 -1
  18. package/out/controller/control/exp-bar/exp-bar.controller.js +7 -0
  19. package/out/controller/control/exp-bar/tree-exp-bar.controller.d.ts +5 -0
  20. package/out/controller/control/exp-bar/tree-exp-bar.controller.d.ts.map +1 -1
  21. package/out/controller/control/exp-bar/tree-exp-bar.controller.js +16 -0
  22. package/out/controller/control/tree-grid-ex/tree-grid-ex-column/tree-grid-ex-ua-column/tree-grid-ex-ua-column.controller.d.ts +23 -1
  23. package/out/controller/control/tree-grid-ex/tree-grid-ex-column/tree-grid-ex-ua-column/tree-grid-ex-ua-column.controller.d.ts.map +1 -1
  24. package/out/controller/control/tree-grid-ex/tree-grid-ex-column/tree-grid-ex-ua-column/tree-grid-ex-ua-column.controller.js +56 -4
  25. package/out/controller/notification/async-action.controller.d.ts +64 -0
  26. package/out/controller/notification/async-action.controller.d.ts.map +1 -0
  27. package/out/controller/notification/async-action.controller.js +141 -0
  28. package/out/controller/notification/index.d.ts +2 -0
  29. package/out/controller/notification/index.d.ts.map +1 -0
  30. package/out/controller/notification/index.js +1 -0
  31. package/out/controller/notification/internal-message.controller.d.ts +23 -0
  32. package/out/controller/notification/internal-message.controller.d.ts.map +1 -0
  33. package/out/controller/notification/internal-message.controller.js +50 -0
  34. package/out/controller/notification/notice.controller.d.ts +10 -0
  35. package/out/controller/notification/notice.controller.d.ts.map +1 -0
  36. package/out/controller/notification/notice.controller.js +13 -0
  37. package/out/global/global-util/global-util.d.ts +17 -1
  38. package/out/global/global-util/global-util.d.ts.map +1 -1
  39. package/out/global/global-util/global-util.js +17 -1
  40. package/out/interface/common/i-app-hub-service/i-app-hub-service.d.ts +8 -1
  41. package/out/interface/common/i-app-hub-service/i-app-hub-service.d.ts.map +1 -1
  42. package/out/interface/common/i-app-service/i-app-service.d.ts +16 -1
  43. package/out/interface/common/i-app-service/i-app-service.d.ts.map +1 -1
  44. package/out/interface/common/i-popover-options/i-popover-options.d.ts +9 -1
  45. package/out/interface/common/i-popover-options/i-popover-options.d.ts.map +1 -1
  46. package/out/interface/controller/controller/index.d.ts +1 -0
  47. package/out/interface/controller/controller/index.d.ts.map +1 -1
  48. package/out/interface/controller/controller/index.js +1 -0
  49. package/out/interface/controller/controller/notice/i-async-action.controller.d.ts +49 -0
  50. package/out/interface/controller/controller/notice/i-async-action.controller.d.ts.map +1 -0
  51. package/out/interface/controller/controller/notice/i-async-action.controller.js +1 -0
  52. package/out/interface/controller/controller/notice/i-internal-message.controller.d.ts +68 -0
  53. package/out/interface/controller/controller/notice/i-internal-message.controller.d.ts.map +1 -0
  54. package/out/interface/controller/controller/notice/i-internal-message.controller.js +1 -0
  55. package/out/interface/controller/controller/notice/i-notice.controller.d.ts +33 -0
  56. package/out/interface/controller/controller/notice/i-notice.controller.d.ts.map +1 -0
  57. package/out/interface/controller/controller/notice/i-notice.controller.js +1 -0
  58. package/out/interface/controller/controller/notice/index.d.ts +4 -0
  59. package/out/interface/controller/controller/notice/index.d.ts.map +1 -0
  60. package/out/interface/controller/controller/notice/index.js +1 -0
  61. package/out/interface/provider/i-async-action.provider.d.ts +11 -3
  62. package/out/interface/provider/i-async-action.provider.d.ts.map +1 -1
  63. package/out/interface/provider/i-internal-message.provider.d.ts +10 -2
  64. package/out/interface/provider/i-internal-message.provider.d.ts.map +1 -1
  65. package/out/interface/util/i-animation-util/i-animation-options.d.ts +31 -0
  66. package/out/interface/util/i-animation-util/i-animation-options.d.ts.map +1 -0
  67. package/out/interface/util/i-animation-util/i-animation-options.js +1 -0
  68. package/out/interface/util/i-notice-util/i-notice-util.d.ts +34 -0
  69. package/out/interface/util/i-notice-util/i-notice-util.d.ts.map +1 -0
  70. package/out/interface/util/i-notice-util/i-notice-util.js +1 -0
  71. package/out/interface/util/i-open-view-util/i-open-view-util.d.ts +2 -2
  72. package/out/interface/util/i-open-view-util/i-open-view-util.d.ts.map +1 -1
  73. package/out/interface/util/index.d.ts +2 -0
  74. package/out/interface/util/index.d.ts.map +1 -1
  75. package/out/register/helper/async-action-register.d.ts +2 -1
  76. package/out/register/helper/async-action-register.d.ts.map +1 -1
  77. package/out/register/helper/async-action-register.js +3 -3
  78. package/out/register/helper/internal-message-register.js +2 -2
  79. package/out/service/dto/method.dto.d.ts.map +1 -1
  80. package/out/service/dto/method.dto.js +11 -0
  81. package/out/service/mqtt/mqtt.service.d.ts.map +1 -1
  82. package/out/service/mqtt/mqtt.service.js +1 -0
  83. package/out/service/service/auth/v7-auth.service.d.ts.map +1 -1
  84. package/out/service/service/auth/v7-auth.service.js +4 -0
  85. package/out/service/service/entity/method/de-action.d.ts.map +1 -1
  86. package/out/service/service/entity/method/de-action.js +4 -4
  87. package/out/service/service/internal-message/internal-message.service.d.ts +1 -1
  88. package/out/service/service/internal-message/internal-message.service.d.ts.map +1 -1
  89. package/out/service/service/internal-message/internal-message.service.js +7 -16
  90. package/out/service/utils/de-cache/de-cache.d.ts +2 -4
  91. package/out/service/utils/de-cache/de-cache.d.ts.map +1 -1
  92. package/out/service/utils/de-cache/de-cache.js +4 -8
  93. package/out/service/utils/dyna-sys-params/dyna-sys-params.d.ts +21 -0
  94. package/out/service/utils/dyna-sys-params/dyna-sys-params.d.ts.map +1 -0
  95. package/out/service/utils/dyna-sys-params/dyna-sys-params.js +48 -0
  96. package/out/service/utils/dynamic-code-list/dynamic-code-list.d.ts.map +1 -1
  97. package/out/service/utils/dynamic-code-list/dynamic-code-list.js +9 -5
  98. package/out/service/utils/index.d.ts +1 -0
  99. package/out/service/utils/index.d.ts.map +1 -1
  100. package/out/service/utils/index.js +1 -0
  101. package/out/service/vo/tree-node-data/tree-data-set-node-data.d.ts.map +1 -1
  102. package/out/service/vo/tree-node-data/tree-data-set-node-data.js +8 -0
  103. package/out/types.d.ts +8 -1
  104. package/out/types.d.ts.map +1 -1
  105. package/out/ui-action/uiaction-util.d.ts +23 -0
  106. package/out/ui-action/uiaction-util.d.ts.map +1 -1
  107. package/out/ui-action/uiaction-util.js +39 -1
  108. package/out/utils/anime/anime-element-util.d.ts +44 -0
  109. package/out/utils/anime/anime-element-util.d.ts.map +1 -0
  110. package/out/utils/anime/anime-element-util.js +108 -0
  111. package/out/utils/anime/anime-util/anime-util.d.ts +60 -0
  112. package/out/utils/anime/anime-util/anime-util.d.ts.map +1 -0
  113. package/out/utils/anime/anime-util/anime-util.js +96 -0
  114. package/out/utils/anime/anime.d.ts +27 -0
  115. package/out/utils/anime/anime.d.ts.map +1 -0
  116. package/out/utils/anime/anime.js +86 -0
  117. package/out/utils/anime/index.d.ts +2 -0
  118. package/out/utils/anime/index.d.ts.map +1 -0
  119. package/out/utils/anime/index.js +1 -0
  120. package/out/utils/file-util/file-util.d.ts +57 -0
  121. package/out/utils/file-util/file-util.d.ts.map +1 -0
  122. package/out/utils/file-util/file-util.js +113 -0
  123. package/out/utils/file-util/index.d.ts +2 -0
  124. package/out/utils/file-util/index.d.ts.map +1 -0
  125. package/out/utils/file-util/index.js +1 -0
  126. package/out/utils/index.d.ts +2 -0
  127. package/out/utils/index.d.ts.map +1 -1
  128. package/out/utils/index.js +2 -0
  129. package/package.json +9 -5
  130. package/src/app-hub.ts +3 -0
  131. package/src/application.ts +31 -16
  132. package/src/constant/index.ts +1 -0
  133. package/src/constant/preset-identifier.ts +15 -0
  134. package/src/controller/common/editor/editor.controller.ts +11 -1
  135. package/src/controller/control/exp-bar/exp-bar.controller.ts +6 -0
  136. package/src/controller/control/exp-bar/tree-exp-bar.controller.ts +17 -0
  137. package/src/controller/control/tree-grid-ex/tree-grid-ex-column/tree-grid-ex-ua-column/tree-grid-ex-ua-column.controller.ts +68 -4
  138. package/src/controller/notification/async-action.controller.ts +163 -0
  139. package/src/controller/notification/index.ts +1 -0
  140. package/src/controller/notification/internal-message.controller.ts +64 -0
  141. package/src/controller/notification/notice.controller.ts +16 -0
  142. package/src/global/global-util/global-util.ts +20 -0
  143. package/src/interface/common/i-app-hub-service/i-app-hub-service.ts +9 -1
  144. package/src/interface/common/i-app-service/i-app-service.ts +18 -0
  145. package/src/interface/common/i-popover-options/i-popover-options.ts +10 -1
  146. package/src/interface/controller/controller/index.ts +1 -0
  147. package/src/interface/controller/controller/notice/i-async-action.controller.ts +52 -0
  148. package/src/interface/controller/controller/notice/i-internal-message.controller.ts +74 -0
  149. package/src/interface/controller/controller/notice/i-notice.controller.ts +36 -0
  150. package/src/interface/controller/controller/notice/index.ts +9 -0
  151. package/src/interface/provider/i-async-action.provider.ts +14 -3
  152. package/src/interface/provider/i-internal-message.provider.ts +10 -2
  153. package/src/interface/util/i-animation-util/i-animation-options.ts +34 -0
  154. package/src/interface/util/i-notice-util/i-notice-util.ts +34 -0
  155. package/src/interface/util/i-open-view-util/i-open-view-util.ts +2 -1
  156. package/src/interface/util/index.ts +2 -0
  157. package/src/register/helper/async-action-register.ts +4 -4
  158. package/src/register/helper/internal-message-register.ts +2 -2
  159. package/src/service/dto/method.dto.ts +16 -0
  160. package/src/service/mqtt/mqtt.service.ts +1 -0
  161. package/src/service/service/auth/v7-auth.service.ts +5 -0
  162. package/src/service/service/entity/method/de-action.ts +2 -12
  163. package/src/service/service/internal-message/internal-message.service.ts +12 -18
  164. package/src/service/utils/de-cache/de-cache.ts +4 -18
  165. package/src/service/utils/dyna-sys-params/dyna-sys-params.ts +66 -0
  166. package/src/service/utils/dynamic-code-list/dynamic-code-list.ts +9 -6
  167. package/src/service/utils/index.ts +1 -0
  168. package/src/service/vo/tree-node-data/tree-data-set-node-data.ts +8 -0
  169. package/src/types.ts +9 -0
  170. package/src/ui-action/uiaction-util.ts +48 -1
  171. package/src/utils/anime/anime-element-util.ts +141 -0
  172. package/src/utils/anime/anime-util/anime-util.ts +123 -0
  173. package/src/utils/anime/anime.ts +111 -0
  174. package/src/utils/anime/index.ts +1 -0
  175. package/src/utils/file-util/file-util.ts +141 -0
  176. package/src/utils/file-util/index.ts +1 -0
  177. package/src/utils/index.ts +2 -0
@@ -115,6 +115,10 @@ export class TreeDataSetNodeData extends TreeNodeData implements ITreeNodeData {
115
115
  const dataItemKeyMap = new Map<string | symbol, string | symbol>();
116
116
  const dataItemDefaultMap = new Map<string | symbol, unknown>();
117
117
  model.detreeNodeDataItems?.forEach(dataItem => {
118
+ // 没有实体的数据项不处理,如操作列的数据项
119
+ if (!dataItem.appDEFieldId) {
120
+ return;
121
+ }
118
122
  const dataItemKey = dataItem.id!.toLowerCase();
119
123
 
120
124
  // *后台实体属性
@@ -130,6 +134,10 @@ export class TreeDataSetNodeData extends TreeNodeData implements ITreeNodeData {
130
134
  /** 表格列和数据项的映射 */
131
135
  const nodeColumnKeyMap = new Map<string | symbol, string | symbol>();
132
136
  model.detreeNodeColumns?.forEach(column => {
137
+ // 只映射属性列
138
+ if (column.columnType !== 'DEFGRIDCOLUMN') {
139
+ return;
140
+ }
133
141
  const columnKey = column.detreeColumnId!; // 不配树表格列不会有这个模型
134
142
  const dataItemKey = column.dataItemName; // 配了就一定有数据项名称
135
143
  if (!columnKey || !dataItemKey) {
package/src/types.ts CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  IAsyncActionService,
17
17
  IPlatformProvider,
18
18
  IInternalMessageService,
19
+ INoticeUtil,
19
20
  } from './interface';
20
21
  import { LogicSchedulerCenter } from './logic-scheduler';
21
22
  import { RegisterCenter } from './register/register-center';
@@ -81,6 +82,14 @@ declare module '@ibiz-template/core' {
81
82
  */
82
83
  notification: INotificationUtil;
83
84
 
85
+ /**
86
+ * 全局的消息通知类
87
+ * @author lxm
88
+ * @date 2024-01-26 05:10:37
89
+ * @type {INoticeUtil}
90
+ */
91
+ notice: INoticeUtil;
92
+
84
93
  /**
85
94
  * 多模式打开视图工具类
86
95
  *
@@ -1,5 +1,5 @@
1
1
  import { RuntimeError } from '@ibiz-template/core';
2
- import { SysUIActionTag, ViewCallTag } from '../constant';
2
+ import { PresetIdentifier, SysUIActionTag, ViewCallTag } from '../constant';
3
3
  import { IUILogicParams, IUIActionResult } from '../interface';
4
4
  import { getUIActionById } from '../model';
5
5
  import { getUIActionProvider } from '../register';
@@ -74,5 +74,52 @@ export class UIActionUtil {
74
74
  default:
75
75
  }
76
76
  }
77
+ const action = await getUIActionById(actionId, appId);
78
+ // 异步行为模型配置方式:
79
+ // 1、配置实体行为 返回值类型选择为 异步操作对象
80
+ // 2、配置界面行为 界面行为类型选择 后台调用 、配置实体行为
81
+ // 界面行为模型基于选择的实体行为的返回值类型计算异步行为(asyncAction)模型
82
+ if (action!.asyncAction && !result.cancel) {
83
+ this.handleAsyncAction(params.event);
84
+ }
85
+ }
86
+
87
+ /**
88
+ * 处理异步行为
89
+ *
90
+ * @author zk
91
+ * @date 2024-01-23 11:01:58
92
+ * @static
93
+ * @param {(Event | undefined)} event
94
+ * @return {*} {Promise<void>}
95
+ * @memberof UIActionUtil
96
+ */
97
+ private static async handleAsyncAction(
98
+ event: Event | undefined,
99
+ ): Promise<void> {
100
+ this.handleAsyncActionAnime(event);
101
+ }
102
+
103
+ /**
104
+ * 处理异步行为动画
105
+ *
106
+ * @author zk
107
+ * @date 2024-01-24 04:01:29
108
+ * @private
109
+ * @static
110
+ * @param {(Event | undefined)} event
111
+ * @return {*} {Promise<void>}
112
+ * @memberof UIActionUtil
113
+ */
114
+ private static async handleAsyncActionAnime(
115
+ event: Event | undefined,
116
+ ): Promise<void> {
117
+ if (!event || !event.target) {
118
+ return;
119
+ }
120
+ await ibiz.util.anime.moveAndResize(
121
+ event.target as HTMLElement,
122
+ `#${PresetIdentifier.MESSAGE}`,
123
+ );
77
124
  }
78
125
  }
@@ -0,0 +1,141 @@
1
+ // 基础样式
2
+ const baseStyle = {
3
+ position: 'fixed',
4
+ zIndex: '10000',
5
+ };
6
+
7
+ export function cloneElement(
8
+ clone: string | HTMLElement,
9
+ teleport: HTMLElement = document.body,
10
+ isRemoveChild: boolean = true,
11
+ ): HTMLElement {
12
+ const element = getAnimationElement(clone);
13
+ if (element == null) {
14
+ throw new Error('Cannot clone a null or undefined element.');
15
+ }
16
+ // 使用 DOM 的 cloneNode 方法深复制元素
17
+ const clonedElement = element.cloneNode(true) as HTMLElement;
18
+ if (isRemoveChild) {
19
+ while (clonedElement.firstChild) {
20
+ clonedElement.removeChild(clonedElement.firstChild);
21
+ }
22
+ }
23
+ const styles = getElementAttribute(element);
24
+ setElementStyle(clonedElement, styles);
25
+ teleport.appendChild(clonedElement);
26
+ // 返回克隆后的元素
27
+ return clonedElement;
28
+ }
29
+
30
+ /**
31
+ * 设置元素样式
32
+ *
33
+ * @author zk
34
+ * @date 2024-01-25 11:01:37
35
+ * @param {HTMLElement} element
36
+ * @param {{
37
+ * width: number;
38
+ * height: number;
39
+ * padding: number;
40
+ * boundingLeft: number;
41
+ * boundingTop: number;
42
+ * }} {
43
+ * width,
44
+ * height,
45
+ * boundingLeft,
46
+ * boundingTop,
47
+ * }
48
+ */
49
+ function setElementStyle(
50
+ element: HTMLElement,
51
+ {
52
+ width,
53
+ height,
54
+ boundingLeft,
55
+ boundingTop,
56
+ }: {
57
+ width: number;
58
+ height: number;
59
+ padding: number;
60
+ boundingLeft: number;
61
+ boundingTop: number;
62
+ },
63
+ ): void {
64
+ element.style.left = `${boundingLeft}px`;
65
+ element.style.top = `${boundingTop}px`;
66
+ element.style.width = `${width}px`;
67
+ element.style.height = `${height}px`;
68
+ Object.assign(element.style, baseStyle);
69
+ }
70
+
71
+ /**
72
+ * 获取元素属性
73
+ *
74
+ * @author zk
75
+ * @date 2024-01-25 11:01:06
76
+ * @export
77
+ * @param {HTMLElement} element
78
+ * @return {*} {{
79
+ * width: number;
80
+ * height: number;
81
+ * min: number;
82
+ * padding: number;
83
+ * boundingLeft: number;
84
+ * boundingTop: number;
85
+ * }}
86
+ */
87
+ export function getElementAttribute(element: HTMLElement): {
88
+ width: number;
89
+ height: number;
90
+ padding: number;
91
+ boundingLeft: number;
92
+ boundingTop: number;
93
+ } {
94
+ const width = element.offsetWidth;
95
+ const height = element.offsetHeight;
96
+ const styles = window.getComputedStyle(element);
97
+ const padding = parseFloat(styles.padding);
98
+ const { left: boundingLeft, top: boundingTop } = (
99
+ element as HTMLElement
100
+ ).getBoundingClientRect();
101
+ return {
102
+ width,
103
+ height,
104
+ padding,
105
+ boundingLeft,
106
+ boundingTop,
107
+ };
108
+ }
109
+
110
+ /**
111
+ * 获取事件动画元素
112
+ *
113
+ * @author zk
114
+ * @date 2024-01-23 11:01:16
115
+ * @param {string} tag
116
+ * @return {*} {(HTMLElement | undefined)}
117
+ * @memberof AnimeElementUtil
118
+ */
119
+ export function getAnimationElement(
120
+ element: string | HTMLElement,
121
+ ): HTMLElement | undefined {
122
+ if (typeof element === 'string') {
123
+ return document.querySelector(element) as HTMLElement;
124
+ }
125
+ // 参数本身是HTMLElement类型
126
+ return element;
127
+ }
128
+
129
+ /**
130
+ * 销毁事件动画元素
131
+ *
132
+ * @author zk
133
+ * @date 2024-01-23 10:01:39
134
+ * @param {HTMLElement} ele
135
+ * @memberof AnimeElementUtil
136
+ */
137
+ export function destroyElement(ele: HTMLElement): void {
138
+ if (ele) {
139
+ ele.remove();
140
+ }
141
+ }
@@ -0,0 +1,123 @@
1
+ import {
2
+ cloneElement,
3
+ destroyElement,
4
+ getAnimationElement,
5
+ getElementAttribute,
6
+ } from '../anime-element-util';
7
+ import { moveToTarget, resize } from '../anime';
8
+ import { IAnimationOptions } from '../../../interface';
9
+
10
+ type AnimeTarget = string | HTMLElement;
11
+
12
+ /**
13
+ * 动画工具类
14
+ *
15
+ * @author zk
16
+ * @date 2024-01-24 09:01:05
17
+ * @export
18
+ * @class AnimeUtil
19
+ */
20
+ export class AnimeUtil {
21
+ /**
22
+ * 元素移动到指定位置 移动点至指定元素
23
+ *
24
+ * @author zk
25
+ * @date 2024-01-24 09:01:37
26
+ * @param {Event} event
27
+ * @param {HTMLElement} toElement
28
+ * @param {anime.AnimeParams} [options={}]
29
+ * @return {*} {Promise<boolean>}
30
+ * @memberof AnimeUtil
31
+ */
32
+ public async movePoint(
33
+ element: AnimeTarget,
34
+ tElement: AnimeTarget,
35
+ options: IAnimationOptions = {},
36
+ ): Promise<boolean> {
37
+ // 获取移动终点元素
38
+ const targetElement = getAnimationElement(tElement);
39
+ if (!targetElement) {
40
+ ibiz.log.debug('终点元素不存在');
41
+ return false;
42
+ }
43
+ // 创建移动动画元素
44
+ const moveElement = cloneElement(element, document.body);
45
+ if (!moveElement) {
46
+ ibiz.log.debug('动画元素不存在');
47
+ return false;
48
+ }
49
+ const { padding, width, height } = getElementAttribute(moveElement);
50
+ // 移动点元素内置option
51
+ const option = {
52
+ borderRadius: ['0%', '50%'],
53
+ maxWidth: [width, '6px'],
54
+ maxHeight: [height, '6px'],
55
+ minWidth: [width, '6px'],
56
+ minHeight: [height, '6px'],
57
+ padding: [padding, '6px'],
58
+ duration: 700,
59
+ };
60
+ Object.assign(option, options);
61
+ const result = await moveToTarget(moveElement, targetElement, option);
62
+ destroyElement(moveElement);
63
+ return result;
64
+ }
65
+
66
+ /**
67
+ * 元素移动动画 元素a 移动到元素b
68
+ *
69
+ * @author zk
70
+ * @date 2024-01-24 06:01:35\
71
+ * @param {HTMLElement} element
72
+ * @param {HTMLElement} toElement
73
+ * @param {IAnimationOptions} [options={}]
74
+ * @return {*} {Promise<boolean>}
75
+ * @memberof AnimeUtil
76
+ */
77
+ public moveToTarget(
78
+ element: HTMLElement,
79
+ toElement: HTMLElement,
80
+ options: IAnimationOptions = {},
81
+ ): Promise<boolean> {
82
+ return moveToTarget(element, toElement, options);
83
+ }
84
+
85
+ /**
86
+ * 目标调整大小
87
+ *
88
+ * @author zk
89
+ * @date 2024-01-22 03:01:42
90
+ * @param {HTMLElement} target
91
+ * @param {anime.AnimeParams} [options={}]
92
+ * @param {IData} [builtInParams={}]
93
+ */
94
+ public resize(
95
+ targets: AnimeTarget | AnimeTarget[],
96
+ options: IAnimationOptions = {},
97
+ ): Promise<boolean> {
98
+ return resize(targets, options);
99
+ }
100
+
101
+ /**
102
+ * 目标移动和调整大小
103
+ *
104
+ * @author zk
105
+ * @date 2024-01-24 06:01:15
106
+ * @param {HTMLElement} element
107
+ * @param {HTMLElement} toElement
108
+ * @param {IAnimationOptions} [options={}]
109
+ * @return {*} {Promise<boolean>}
110
+ * @memberof AnimeUtil
111
+ */
112
+ public async moveAndResize(
113
+ element: AnimeTarget,
114
+ toElement: AnimeTarget,
115
+ options: IAnimationOptions = {},
116
+ ): Promise<boolean> {
117
+ const result = await this.movePoint(element, toElement, options);
118
+ if (result) {
119
+ await this.resize(toElement, { duration: 500 });
120
+ }
121
+ return result;
122
+ }
123
+ }
@@ -0,0 +1,111 @@
1
+ import anime from 'animejs';
2
+
3
+ type AnimeTarget = string | object | HTMLElement | SVGElement | NodeList | null;
4
+
5
+ /**
6
+ * 默认参数
7
+ *
8
+ * @author zk
9
+ * @date 2024-01-22 01:01:17
10
+ * @protected
11
+ */
12
+ const defaultOptions = {
13
+ // 动画时间
14
+ duration: 1000,
15
+ // 循环执行
16
+ loop: false,
17
+ // 运行速度曲线
18
+ easing: 'easeInOutSine',
19
+ };
20
+
21
+ /**
22
+ * 处理动画开始事件
23
+ *
24
+ * @author zk
25
+ * @date 2024-01-24 03:01:34
26
+ * @export
27
+ * @param {anime.AnimeParams} AnimeParams
28
+ * @param {anime.AnimeParams} extraOptions
29
+ * @return {*} {anime.AnimeParams}
30
+ */
31
+ function handleBefore(
32
+ AnimeParams: anime.AnimeParams,
33
+ extraOptions: anime.AnimeParams,
34
+ ): anime.AnimeParams {
35
+ const params: anime.AnimeParams = {};
36
+ // 处理动画开始事件
37
+ if (extraOptions.complete && AnimeParams.complete) {
38
+ const optionComplete = extraOptions.complete;
39
+ const animeComplete = AnimeParams.complete;
40
+ params.complete = (ins: anime.AnimeInstance): void => {
41
+ optionComplete(ins);
42
+ animeComplete(ins);
43
+ };
44
+ }
45
+ return { ...AnimeParams, ...extraOptions, ...params };
46
+ }
47
+
48
+ /**
49
+ * 元素移动动画
50
+ *
51
+ * @author zk
52
+ * @date 2024-01-24 03:01:17
53
+ * @export
54
+ * @param {HTMLElement} moveElement
55
+ * @param {HTMLElement} toElement
56
+ * @param {anime.AnimeParams} [extraOpts={}]
57
+ * @return {*} {Promise<boolean>}
58
+ */
59
+ export function moveToTarget(
60
+ moveElement: HTMLElement,
61
+ targetElement: HTMLElement,
62
+ extraOpts: anime.AnimeParams = {},
63
+ ): Promise<boolean> {
64
+ const { left: toLeft, top: toTop } = moveElement.getBoundingClientRect();
65
+ const { left: clientX, top: clientY } = targetElement.getBoundingClientRect();
66
+ const x = clientX - toLeft;
67
+ const y = clientY - toTop;
68
+ return new Promise(resolve => {
69
+ const opts = {
70
+ targets: moveElement,
71
+ translateX: x,
72
+ translateY: y,
73
+ ...defaultOptions,
74
+ // 完成回调
75
+ complete: (): void => {
76
+ resolve(true);
77
+ },
78
+ };
79
+ const options = handleBefore(opts, extraOpts);
80
+ anime(options);
81
+ });
82
+ }
83
+
84
+ /**
85
+ * 目标调整大小
86
+ *
87
+ * @author zk
88
+ * @date 2024-01-24 03:01:09
89
+ * @export
90
+ * @param {HTMLElement} targets
91
+ * @param {anime.AnimeParams} [extraOpts={}]
92
+ * @return {*} {Promise<boolean>}
93
+ */
94
+ export function resize(
95
+ targets: AnimeTarget | readonly AnimeTarget[],
96
+ extraOpts: anime.AnimeParams = {},
97
+ ): Promise<boolean> {
98
+ return new Promise(resolve => {
99
+ const opts = {
100
+ scale: [1, 0.8, 1],
101
+ targets,
102
+ ...defaultOptions,
103
+ // 完成回调
104
+ complete: (): void => {
105
+ resolve(true);
106
+ },
107
+ };
108
+ const options = handleBefore(opts, extraOpts);
109
+ anime(options);
110
+ });
111
+ }
@@ -0,0 +1 @@
1
+ export { AnimeUtil } from './anime-util/anime-util';
@@ -0,0 +1,141 @@
1
+ import { RuntimeError, downloadFileFromBlob } from '@ibiz-template/core';
2
+ import qs from 'qs';
3
+ import { convertNavData } from '../nav-params/nav-params';
4
+
5
+ export class FileUtil {
6
+ /**
7
+ * 计算OSSCat参数
8
+ *
9
+ * @author zk
10
+ * @date 2024-01-26 02:01:52
11
+ * @param {string} url
12
+ * @param {IContext} context
13
+ * @return {*} {string}
14
+ * @memberof FileUtil
15
+ */
16
+ protected calcOSSCatUrl(
17
+ url: string,
18
+ context: IContext,
19
+ OSSCatName?: string,
20
+ ): string {
21
+ let uploadUrl = `${ibiz.env.baseUrl}/${ibiz.env.appId}${url}`;
22
+ const app = ibiz.hub.getApp(context.srfappid);
23
+ const OSSCat =
24
+ OSSCatName ||
25
+ app.model.defaultOSSCat ||
26
+ app.model.userParam?.DefaultOSSCat;
27
+ uploadUrl = uploadUrl.replace('/{cat}', OSSCat ? `/${OSSCat}` : '');
28
+ return uploadUrl;
29
+ }
30
+
31
+ /**
32
+ * 计算文件的上传路径和下载路径
33
+ * 下载路径文件id用%fileId%占位,替换即可
34
+ * 配置编辑器参数uploadParams和exportParams时,会像导航参数一样动态添加对应的参数到url上
35
+ *
36
+ * @author zk
37
+ * @date 2024-01-26 02:01:15
38
+ * @param {IData} data
39
+ * @param {IContext} context
40
+ * @param {IParams} params
41
+ * @param {IParams} uploadParams
42
+ * @param {IParams} exportParams
43
+ * @return {*} {{
44
+ * uploadUrl: string;
45
+ * downloadUrl: string;
46
+ * }}
47
+ * @memberof FileUtil
48
+ */
49
+ calcFileUpDownUrl(
50
+ context: IContext,
51
+ params: IParams,
52
+ data: IData = {},
53
+ extraParams: IData = {},
54
+ ): {
55
+ uploadUrl: string;
56
+ downloadUrl: string;
57
+ } {
58
+ const { uploadParams, exportParams, osscat: OSSCatName } = extraParams;
59
+ // 计算文件上传路径
60
+ let uploadUrl = this.calcOSSCatUrl(
61
+ ibiz.env.uploadFileUrl,
62
+ context,
63
+ OSSCatName,
64
+ );
65
+ let downloadUrl = this.calcOSSCatUrl(
66
+ `${ibiz.env.downloadFileUrl}/%fileId%`,
67
+ context,
68
+ OSSCatName,
69
+ );
70
+ let _uploadParams: IParams = {};
71
+ let _exportParams: IParams = {};
72
+ if (uploadParams) {
73
+ _uploadParams = convertNavData(uploadParams, data, params, context);
74
+ }
75
+ if (exportParams) {
76
+ _exportParams = convertNavData(exportParams, data, params, context);
77
+ }
78
+ uploadUrl += qs.stringify(_uploadParams, { addQueryPrefix: true });
79
+ downloadUrl += qs.stringify(_exportParams, { addQueryPrefix: true });
80
+ return { uploadUrl, downloadUrl };
81
+ }
82
+
83
+ /**
84
+ * 请求url获取文件流,并用JS触发文件下载
85
+ *
86
+ * @author zk
87
+ * @date 2024-01-26 02:01:29
88
+ * @param {{ url: string; name: string }} file
89
+ * @memberof FileUtil
90
+ */
91
+ async fileDownload(url: string, name: string): Promise<void> {
92
+ // 发送get请求
93
+ const response = await ibiz.net.request(url, {
94
+ method: 'get',
95
+ responseType: 'blob',
96
+ baseURL: '', // 已经有baseURL了,这里无需再写
97
+ });
98
+
99
+ if (response.status !== 200) {
100
+ throw new RuntimeError('下载文件失败');
101
+ }
102
+ // 请求成功,后台返回的是一个文件流
103
+ if (!response.data) {
104
+ throw new RuntimeError('文件流数据不存在');
105
+ } else {
106
+ // 获取文件名
107
+ const fileName = name;
108
+ downloadFileFromBlob(response.data as Blob, fileName);
109
+ }
110
+ }
111
+
112
+ /**
113
+ * 文件上传
114
+ *
115
+ * @author zk
116
+ * @date 2024-01-26 05:01:35
117
+ * @param {string} uploadUrl
118
+ * @param {Blob} file
119
+ * @param {IData} headers
120
+ * @return {*} {Promise<IData>}
121
+ * @memberof FileUtil
122
+ */
123
+ async fileUpload(
124
+ uploadUrl: string,
125
+ file: Blob,
126
+ headers: IData,
127
+ ): Promise<IData> {
128
+ const formData = new FormData();
129
+ formData.append('file', file);
130
+ const res = await ibiz.net.axios({
131
+ url: uploadUrl,
132
+ method: 'post',
133
+ headers,
134
+ data: formData,
135
+ });
136
+ if (res.status !== 200) {
137
+ throw new RuntimeError('文件上传失败');
138
+ }
139
+ return res.data;
140
+ }
141
+ }
@@ -0,0 +1 @@
1
+ export { FileUtil } from './file-util';
@@ -20,3 +20,5 @@ export { UIDomainManager } from './ui-domain-manager/ui-domain-manager';
20
20
  export { RawValueUtil } from './raw-value-util/raw-value-util';
21
21
  export { ViewStack } from './view-stack/view-stack';
22
22
  export { handleAllSettled } from './promise/promise';
23
+ export { AnimeUtil } from './anime';
24
+ export { FileUtil } from './file-util';