vue2-client 1.22.21 → 1.22.22

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 (84) hide show
  1. package/.env.his +19 -19
  2. package/.idea/deployment.xml +14 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +11 -0
  4. package/.idea/misc.xml +5 -5
  5. package/package.json +1 -1
  6. package/src/base-client/components/common/HIS/HForm/HForm.vue +1186 -1186
  7. package/src/base-client/components/common/HIS/HTab/HTab.vue +790 -790
  8. package/src/base-client/components/common/XInspectionDetailDrawer/components/AiDeviceStatus.vue +25 -4
  9. package/src/base-client/components/common/XInspectionDetailDrawer/components/ImageAnnotationShow.vue +1371 -0
  10. package/src/base-client/components/common/XMarkdownViewer/demo.vue +102 -102
  11. package/src/base-client/components/his/XTransfer/index.md +327 -327
  12. package/src/utils/module-loader/VueSfcModuleCache.js +99 -99
  13. package/src/utils/module-loader/index.js +5 -5
  14. package/.history/.eslintrc_20260521171150.js +0 -74
  15. package/.history/.eslintrc_20260521171213.js +0 -74
  16. package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154443.vue +0 -726
  17. package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154700.vue +0 -478
  18. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175435.vue +0 -706
  19. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175450.vue +0 -694
  20. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260611152602.vue +0 -755
  21. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513145941.vue +0 -524
  22. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513153133.vue +0 -731
  23. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513160316.vue +0 -525
  24. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260601144150.vue +0 -1046
  25. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310142713.vue +0 -512
  26. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310145118.vue +0 -511
  27. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260311094834.vue +0 -696
  28. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260320143028.vue +0 -693
  29. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260409101450.vue +0 -677
  30. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260625173703.vue +0 -767
  31. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260626112425.vue +0 -803
  32. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140637.vue +0 -1455
  33. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140935.vue +0 -1441
  34. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513150818.vue +0 -1441
  35. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153119.vue +0 -1442
  36. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153126.vue +0 -1486
  37. package/.history/src/base-client/components/common/XForm/XFormItem_20260513140854.vue +0 -1607
  38. package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140403.vue +0 -643
  39. package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140829.vue +0 -628
  40. package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519142824.vue +0 -104
  41. package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519143155.vue +0 -102
  42. package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171231.vue +0 -1241
  43. package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171441.vue +0 -1223
  44. package/.history/src/base-client/components/his/HAi/HAi_20260612174826.vue +0 -472
  45. package/.history/src/base-client/components/his/HAi/HAi_20260612175839.vue +0 -538
  46. package/.history/src/base-client/components/his/HAi/HAi_20260615103331.vue +0 -650
  47. package/.history/src/base-client/components/his/HAi/HAi_20260618140214.vue +0 -1396
  48. package/.history/src/base-client/components/his/HAi/HAi_20260618140556.vue +0 -1396
  49. package/.history/src/base-client/components/his/XHDescriptions/XHDescriptions_20260424134504.vue +0 -1469
  50. package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171133.vue +0 -788
  51. package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171151.vue +0 -780
  52. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511170841.vue +0 -585
  53. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511171138.vue +0 -787
  54. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260512141830.vue +0 -739
  55. package/.history/src/components/STable/index_20260409155138.js +0 -806
  56. package/.history/src/components/STable/index_20260409155218.js +0 -814
  57. package/.history/src/expression/core/Expression_20260305164427.js +0 -1371
  58. package/.history/src/expression/core/Expression_20260305170258.js +0 -1358
  59. package/.history/src/expression/core/Program_20260305111830.js +0 -944
  60. package/.history/src/expression/core/Program_20260305112041.js +0 -931
  61. package/.history/src/logic/LogicRunner_20260304154306.js +0 -170
  62. package/.history/src/logic/LogicRunner_20260304155553.js +0 -112
  63. package/.history/src/logic/LogicRunner_20260305105834.js +0 -112
  64. package/.history/src/logic/LogicRunner_20260305112718.js +0 -129
  65. package/.history/src/logic/LogicRunner_20260305182436.js +0 -133
  66. package/.history/src/logic/LogicRunner_20260306151301.js +0 -213
  67. package/.history/src/logic/LogicRunner_20260306152419.js +0 -213
  68. package/.history/src/logic/plugins/common/DateTools_20260305154159.js +0 -61
  69. package/.history/src/logic/plugins/common/DateTools_20260305154217.js +0 -44
  70. package/.history/src/logic/plugins/common/DateTools_20260305161014.js +0 -44
  71. package/.history/src/logic/plugins/common/HttpTools_20260305164352.js +0 -80
  72. package/.history/src/logic/plugins/common/HttpTools_20260305170258.js +0 -75
  73. package/.history/src/logic/plugins/common/HttpTools_20260305171634.js +0 -75
  74. package/.history/src/logic/plugins/common/HttpTools_20260306152419.js +0 -72
  75. package/.history/src/services/api/restTools_20260427142149.js +0 -245
  76. package/.history/src/services/api/restTools_20260427142853.js +0 -230
  77. package/.history/src/services/api/restTools_20260519135558.js +0 -230
  78. package/.history/src/services/api/restTools_20260519140825.js +0 -230
  79. package/.history/src/services/api/restTools_20260519151223.js +0 -230
  80. package/.history/src/utils/indexedDB_20260306150918.js +0 -593
  81. package/.history/src/utils/indexedDB_20260306151301.js +0 -586
  82. package/.idea/codeStyles/Project.xml +0 -62
  83. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  84. package/preview-input-box.html +0 -180
@@ -1,213 +0,0 @@
1
- import ServiceException from '../expression/exception/ServiceException'
2
- import LogicConsole from '../expression/instances/LogicConsole'
3
- import ExpressionRunner from '../expression/ExpressionRunner'
4
- import { getLogicConfigByNameAsync } from '@vue2-client/services/api/common'
5
- import * as Plugins from './plugins/index'
6
- import Expression from '../expression/core/Expression'
7
-
8
- export default class LogicRunner {
9
- static logicConsoleInstance = new LogicConsole()
10
-
11
- // 存储正在运行的 Logic 任务,key 为 logicName,value 为 { promise, abortController, status }
12
- // status: 'running' - 运行中, 'completed' - 已完成(用于ignore模式判断)
13
- static runningTasks = new Map()
14
-
15
- // 当前正在执行的请求 ID(用于区分同一 logic 的多次调用)
16
- static currentRequestId = null
17
-
18
- // 存储请求 ID 到 abortController 的映射(用于 cancel 模式)
19
- static requestIdToAbortController = new Map()
20
-
21
- // 获取当前正在运行的任务的 abortSignal(供 HttpTools 使用)
22
- static getCurrentAbortSignal () {
23
- // 优先使用 currentRequestId 获取对应请求实例的 abortController
24
- // 这样可以确保每次请求使用自己的 abortController
25
- console.log('[LogicRunner.getCurrentAbortSignal] currentRequestId:', LogicRunner.currentRequestId)
26
- if (LogicRunner.currentRequestId) {
27
- const controller = LogicRunner.requestIdToAbortController.get(LogicRunner.currentRequestId)
28
- if (controller) {
29
- const signal = controller.signal
30
- console.log('[LogicRunner.getCurrentAbortSignal] 从 requestIdToAbortController 获取,aborted:', signal.aborted, 'requestId:', LogicRunner.currentRequestId)
31
- return signal
32
- }
33
- console.log('[LogicRunner.getCurrentAbortSignal] requestIdToAbortController 中未找到 controller')
34
- }
35
- // 降级:从 runningTasks 获取
36
- const logicName = LogicRunner.currentExecutingLogicName
37
- console.log('[LogicRunner.getCurrentAbortSignal] logicName:', logicName)
38
- if (!logicName) {
39
- return null
40
- }
41
- const task = LogicRunner.runningTasks.get(logicName)
42
- console.log('[LogicRunner.getCurrentAbortSignal] task:', task)
43
- if (task && task.status === 'running' && task.abortController) {
44
- const signal = task.abortController.signal
45
- console.log('[LogicRunner.getCurrentAbortSignal] 从 runningTasks 获取,aborted:', signal.aborted, 'logicName:', logicName)
46
- return signal
47
- }
48
- return null
49
- }
50
-
51
- // 清理请求 ID 映射
52
- static clearRequestId (requestId) {
53
- if (requestId) {
54
- LogicRunner.requestIdToAbortController.delete(requestId)
55
- }
56
- }
57
-
58
- // 任务完成后保持"已完成"状态的时间(毫秒),之后自动清理
59
- static COMPLETED_STATUS_TTL = 3000
60
-
61
- /**
62
- * 是否存在指定名称的Logic资源
63
- *
64
- * @param logicName Logic名称
65
- * @return 是否存在
66
- */
67
- static async has (logicName) {
68
- const result = await LogicRunner.getLogic(logicName, false)
69
- return result != null
70
- }
71
-
72
- /**
73
- * 执行Logic
74
- *
75
- * @param logicName Logic名称
76
- * @param param 参数
77
- * @param mode 运行模式:undefined-普通模式,'ignore'-忽略重复,'cancel'-取消前一个
78
- * @return 执行结果
79
- */
80
- static async run (logicName, param, mode) {
81
- const taskKey = logicName
82
- console.log('mode', mode)
83
- // 检查已存在的任务
84
- const existingTask = LogicRunner.runningTasks.get(taskKey)
85
-
86
- // 模式1: ignore - 如果已存在运行中的任务,直接忽略当前调用
87
- if (mode === 'ignore') {
88
- // 如果任务正在运行中,忽略本次调用
89
- if (existingTask && existingTask.status === 'running') {
90
- console.log(`[LogicRunner] ${logicName} 已在运行中,忽略本次调用`)
91
- return null
92
- }
93
- }
94
-
95
- // 模式2: cancel - 如果已存在运行中的任务,中止之前的任务
96
- let oldAbortController = null
97
- if (mode === 'cancel') {
98
- if (existingTask && existingTask.status === 'running') {
99
- console.log(`[LogicRunner] 取消 ${logicName} 的前一次运行,requestId: ${existingTask.requestId}`)
100
- oldAbortController = existingTask.abortController
101
- if (oldAbortController) {
102
- console.log(`[LogicRunner] 执行 abort,aborted:`, oldAbortController.signal.aborted, 'old requestId:', existingTask.requestId)
103
- oldAbortController.abort()
104
- }
105
- }
106
- }
107
-
108
- // 创建唯一请求 ID,用于区分同一 logic 的多次调用
109
- const requestId = `${logicName}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
110
-
111
- // 每次都创建新的 AbortController
112
- // cancel 模式下:旧的 abortController 已被 abort,用于取消前一次请求
113
- // 新的 abortController 用于当前请求
114
- const abortController = new AbortController()
115
-
116
- // 存储请求 ID 到 abortController 的映射
117
- LogicRunner.requestIdToAbortController.set(requestId, abortController)
118
-
119
- // 关键:先设置当前请求 ID 和 abortController,在调用 getLogic 之前就设置
120
- // 这样 getLogic 发起的 HTTP 请求也能使用正确的 abortSignal
121
- LogicRunner.currentExecutingLogicName = logicName
122
- LogicRunner.currentRequestId = requestId
123
-
124
- // 存储任务信息,设置状态为运行中
125
- LogicRunner.runningTasks.set(taskKey, { promise: null, abortController, status: 'running', requestId })
126
-
127
- const taskPromise = LogicRunner.executeLogic(logicName, param, abortController, requestId)
128
-
129
- // 更新 promise 引用
130
- const currentTask = LogicRunner.runningTasks.get(taskKey)
131
- if (currentTask) {
132
- currentTask.promise = taskPromise
133
- }
134
-
135
- try {
136
- const result = await taskPromise
137
- return result
138
- } finally {
139
- // 清理请求 ID 映射
140
- LogicRunner.clearRequestId(requestId)
141
-
142
- // 任务完成后更新状态为已完成,而不是直接删除
143
- const currentTask = LogicRunner.runningTasks.get(taskKey)
144
- if (currentTask && currentTask.promise === taskPromise) {
145
- currentTask.status = 'completed'
146
-
147
- // 延迟删除任务,让 ignore 模式可以检测到"刚完成"的状态
148
- setTimeout(() => {
149
- const task = LogicRunner.runningTasks.get(taskKey)
150
- if (task && task.status === 'completed') {
151
- LogicRunner.runningTasks.delete(taskKey)
152
- }
153
- }, LogicRunner.COMPLETED_STATUS_TTL)
154
- }
155
- }
156
- }
157
-
158
- /**
159
- * 实际执行 Logic 的内部方法
160
- */
161
- static async executeLogic (logicName, param, abortController, requestId) {
162
- // 设置当前正在执行的 logicName 和请求 ID
163
- // 注意:不设置 currentTaskAbortController,让 getCurrentAbortSignal 从 requestIdToAbortController 获取
164
- LogicRunner.currentExecutingLogicName = logicName
165
- LogicRunner.currentRequestId = requestId
166
-
167
- try {
168
- // 获取Logic资源(传 shouldParseConfig: false,不触发服务端解析)
169
- const result = await LogicRunner.getLogic(logicName, false)
170
- if (!result || !result.source) {
171
- throw new ServiceException('Logic资源' + logicName + '未找到', 400)
172
- }
173
- // 预处理 source:移除换行符,将换行替换为分号,避免解析器报错
174
- const source = result.source.replace(/[\r\n]+/g, '')
175
- const paramStr = Expression.toJSONString(param)
176
- const logicLog = LogicConsole.createLogger('logic.' + logicName)
177
- logicLog.info(`执行Logic[${logicName}],params: ${paramStr}`)
178
- // 附加用户注册的对象到业务逻辑中
179
- const plugins = {}
180
- plugins.data = param
181
- plugins.log = logicLog
182
- plugins.ENV = result.$globalProp
183
- plugins.logic = this
184
-
185
- // 注入 abortSignal 到 plugins,用于支持取消操作
186
- console.log('[LogicRunner.executeLogic] 设置 abortSignal:', abortController.signal)
187
- plugins.abortSignal = abortController.signal
188
-
189
- Object.assign(plugins, Plugins.default)
190
-
191
- return await LogicRunner.runExpression(source, plugins)
192
- } finally {
193
- // 不在这里清理状态,让 run() 方法的 finally 块统一管理
194
- // 这样可以确保在 cancel 模式下,第二次请求能够获取到正确的 abortSignal
195
- // 状态会在 run() 方法的 finally 中统一清理
196
- }
197
- }
198
-
199
- /**
200
- * 执行原生表达式
201
- *
202
- * @param source 表达式内容
203
- * @param params 参数
204
- * @return 执行结果
205
- */
206
- static async runExpression (source, params) {
207
- return await ExpressionRunner.run(source, params)
208
- }
209
-
210
- static async getLogic (logicName, isDev) {
211
- return await getLogicConfigByNameAsync(logicName, undefined, isDev)
212
- }
213
- }
@@ -1,213 +0,0 @@
1
- import ServiceException from '../expression/exception/ServiceException'
2
- import LogicConsole from '../expression/instances/LogicConsole'
3
- import ExpressionRunner from '../expression/ExpressionRunner'
4
- import { getLogicConfigByNameAsync } from '@vue2-client/services/api/common'
5
- import * as Plugins from './plugins/index'
6
- import Expression from '../expression/core/Expression'
7
-
8
- export default class LogicRunner {
9
- static logicConsoleInstance = new LogicConsole()
10
-
11
- // 存储正在运行的 Logic 任务,key 为 logicName,value 为 { promise, abortController, status }
12
- // status: 'running' - 运行中, 'completed' - 已完成(用于ignore模式判断)
13
- static runningTasks = new Map()
14
-
15
- // 当前正在执行的请求 ID(用于区分同一 logic 的多次调用)
16
- static currentRequestId = null
17
-
18
- // 存储请求 ID 到 abortController 的映射(用于 cancel 模式)
19
- static requestIdToAbortController = new Map()
20
-
21
- // 获取当前正在运行的任务的 abortSignal(供 HttpTools 使用)
22
- static getCurrentAbortSignal () {
23
- // 优先使用 currentRequestId 获取对应请求实例的 abortController
24
- // 这样可以确保每次请求使用自己的 abortController
25
- console.log('[LogicRunner.getCurrentAbortSignal] currentRequestId:', LogicRunner.currentRequestId)
26
- if (LogicRunner.currentRequestId) {
27
- const controller = LogicRunner.requestIdToAbortController.get(LogicRunner.currentRequestId)
28
- if (controller) {
29
- const signal = controller.signal
30
- console.log('[LogicRunner.getCurrentAbortSignal] 从 requestIdToAbortController 获取,aborted:', signal.aborted, 'requestId:', LogicRunner.currentRequestId)
31
- return signal
32
- }
33
- console.log('[LogicRunner.getCurrentAbortSignal] requestIdToAbortController 中未找到 controller')
34
- }
35
- // 降级:从 runningTasks 获取
36
- const logicName = LogicRunner.currentExecutingLogicName
37
- console.log('[LogicRunner.getCurrentAbortSignal] logicName:', logicName)
38
- if (!logicName) {
39
- return null
40
- }
41
- const task = LogicRunner.runningTasks.get(logicName)
42
- console.log('[LogicRunner.getCurrentAbortSignal] task:', task)
43
- if (task && task.status === 'running' && task.abortController) {
44
- const signal = task.abortController.signal
45
- console.log('[LogicRunner.getCurrentAbortSignal] 从 runningTasks 获取,aborted:', signal.aborted, 'logicName:', logicName)
46
- return signal
47
- }
48
- return null
49
- }
50
-
51
- // 清理请求 ID 映射
52
- static clearRequestId (requestId) {
53
- if (requestId) {
54
- LogicRunner.requestIdToAbortController.delete(requestId)
55
- }
56
- }
57
-
58
- // 任务完成后保持"已完成"状态的时间(毫秒),之后自动清理
59
- static COMPLETED_STATUS_TTL = 3000
60
-
61
- /**
62
- * 是否存在指定名称的Logic资源
63
- *
64
- * @param logicName Logic名称
65
- * @return 是否存在
66
- */
67
- static async has (logicName) {
68
- const result = await LogicRunner.getLogic(logicName, false)
69
- return result != null
70
- }
71
-
72
- /**
73
- * 执行Logic
74
- *
75
- * @param logicName Logic名称
76
- * @param param 参数
77
- * @param mode 运行模式:undefined-普通模式,'ignore'-忽略重复,'cancel'-取消前一个
78
- * @return 执行结果
79
- */
80
- static async run (logicName, param, mode) {
81
- const taskKey = logicName
82
- console.log('mode', mode)
83
- // 检查已存在的任务
84
- const existingTask = LogicRunner.runningTasks.get(taskKey)
85
-
86
- // 模式1: ignore - 如果已存在运行中的任务,直接忽略当前调用
87
- if (mode === 'ignore') {
88
- // 如果任务正在运行中,忽略本次调用
89
- if (existingTask && existingTask.status === 'running') {
90
- console.log(`[LogicRunner] ${logicName} 已在运行中,忽略本次调用`)
91
- return null
92
- }
93
- }
94
-
95
- // 模式2: cancel - 如果已存在运行中的任务,中止之前的任务
96
- let oldAbortController = null
97
- if (mode === 'cancel') {
98
- if (existingTask && existingTask.status === 'running') {
99
- console.log(`[LogicRunner] 取消 ${logicName} 的前一次运行,requestId: ${existingTask.requestId}`)
100
- oldAbortController = existingTask.abortController
101
- if (oldAbortController) {
102
- console.log(`[LogicRunner] 执行 abort,aborted:`, oldAbortController.signal.aborted, 'old requestId:', existingTask.requestId)
103
- oldAbortController.abort()
104
- }
105
- }
106
- }
107
-
108
- // 创建唯一请求 ID,用于区分同一 logic 的多次调用
109
- const requestId = `${logicName}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
110
-
111
- // 每次都创建新的 AbortController
112
- // cancel 模式下:旧的 abortController 已被 abort,用于取消前一次请求
113
- // 新的 abortController 用于当前请求
114
- const abortController = new AbortController()
115
-
116
- // 存储请求 ID 到 abortController 的映射
117
- LogicRunner.requestIdToAbortController.set(requestId, abortController)
118
-
119
- // 关键:先设置当前请求 ID 和 abortController,在调用 getLogic 之前就设置
120
- // 这样 getLogic 发起的 HTTP 请求也能使用正确的 abortSignal
121
- LogicRunner.currentExecutingLogicName = logicName
122
- LogicRunner.currentRequestId = requestId
123
-
124
- // 存储任务信息,设置状态为运行中
125
- LogicRunner.runningTasks.set(taskKey, { promise: null, abortController, status: 'running', requestId })
126
-
127
- const taskPromise = LogicRunner.executeLogic(logicName, param, abortController, requestId)
128
-
129
- // 更新 promise 引用
130
- const currentTask = LogicRunner.runningTasks.get(taskKey)
131
- if (currentTask) {
132
- currentTask.promise = taskPromise
133
- }
134
-
135
- try {
136
- const result = await taskPromise
137
- return result
138
- } finally {
139
- // 清理请求 ID 映射
140
- LogicRunner.clearRequestId(requestId)
141
-
142
- // 任务完成后更新状态为已完成,而不是直接删除
143
- const currentTask = LogicRunner.runningTasks.get(taskKey)
144
- if (currentTask && currentTask.promise === taskPromise) {
145
- currentTask.status = 'completed'
146
-
147
- // 延迟删除任务,让 ignore 模式可以检测到"刚完成"的状态
148
- setTimeout(() => {
149
- const task = LogicRunner.runningTasks.get(taskKey)
150
- if (task && task.status === 'completed') {
151
- LogicRunner.runningTasks.delete(taskKey)
152
- }
153
- }, LogicRunner.COMPLETED_STATUS_TTL)
154
- }
155
- }
156
- }
157
-
158
- /**
159
- * 实际执行 Logic 的内部方法
160
- */
161
- static async executeLogic (logicName, param, abortController, requestId) {
162
- // 设置当前正在执行的 logicName 和请求 ID
163
- // 注意:不设置 currentTaskAbortController,让 getCurrentAbortSignal 从 requestIdToAbortController 获取
164
- LogicRunner.currentExecutingLogicName = logicName
165
- LogicRunner.currentRequestId = requestId
166
-
167
- try {
168
- // 获取Logic资源(传 shouldParseConfig: false,不触发服务端解析)
169
- const result = await LogicRunner.getLogic(logicName, false)
170
- if (!result || !result.source) {
171
- throw new ServiceException('Logic资源' + logicName + '未找到', 400)
172
- }
173
- // 预处理 source:移除换行符,将换行替换为分号,避免解析器报错
174
- const source = result.source.replace(/[\r\n]+/g, '')
175
- const paramStr = Expression.toJSONString(param)
176
- const logicLog = LogicConsole.createLogger('logic.' + logicName)
177
- logicLog.info(`执行Logic[${logicName}],params: ${paramStr}`)
178
- // 附加用户注册的对象到业务逻辑中
179
- const plugins = {}
180
- plugins.data = param
181
- plugins.log = logicLog
182
- plugins.ENV = result.$globalProp
183
- plugins.logic = this
184
-
185
- // 注入 abortSignal 到 plugins,用于支持取消操作
186
- console.log('[LogicRunner.executeLogic] 设置 abortSignal:', abortController.signal)
187
- plugins.abortSignal = abortController.signal
188
-
189
- Object.assign(plugins, Plugins.default)
190
-
191
- return await LogicRunner.runExpression(source, plugins)
192
- } finally {
193
- // 不在这里清理状态,让 run() 方法的 finally 块统一管理
194
- // 这样可以确保在 cancel 模式下,第二次请求能够获取到正确的 abortSignal
195
- // 状态会在 run() 方法的 finally 中统一清理
196
- }
197
- }
198
-
199
- /**
200
- * 执行原生表达式
201
- *
202
- * @param source 表达式内容
203
- * @param params 参数
204
- * @return 执行结果
205
- */
206
- static async runExpression (source, params) {
207
- return await ExpressionRunner.run(source, params)
208
- }
209
-
210
- static async getLogic (logicName, isDev) {
211
- return await getLogicConfigByNameAsync(logicName, undefined, isDev)
212
- }
213
- }
@@ -1,61 +0,0 @@
1
- /**
2
- * 日期工具类
3
- */
4
- export default class DateTools {
5
- static instance = new DateTools()
6
- static currentAbortSignal = null
7
-
8
- constructor () {
9
- if (DateTools.instance) {
10
- return DateTools.instance
11
- }
12
- DateTools.instance = this
13
- }
14
-
15
- static getInstance () {
16
- if (!DateTools.instance) {
17
- DateTools.instance = new DateTools()
18
- }
19
- return DateTools.instance
20
- }
21
-
22
- /**
23
- * 设置当前执行的 abortSignal
24
- */
25
- static setAbortSignal (signal) {
26
- DateTools.currentAbortSignal = signal
27
- }
28
-
29
- /**
30
- * 获取当前时间
31
- * @returns {string} yyyy-MM-dd HH:mm:ss
32
- */
33
- getNow2 () {
34
- const now = new Date()
35
- const year = now.getFullYear()
36
- const month = String(now.getMonth() + 1).padStart(2, '0') // 月份从 0 开始,所以要 +1
37
- const day = String(now.getDate()).padStart(2, '0')
38
- const hours = String(now.getHours()).padStart(2, '0')
39
- const minutes = String(now.getMinutes()).padStart(2, '0')
40
- const seconds = String(now.getSeconds()).padStart(2, '0')
41
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
42
- }
43
-
44
- /**
45
- * 延迟指定毫秒(支持自动取消)
46
- * @param {number} ms 延迟毫秒数
47
- * @returns {Promise}
48
- */
49
- delay (ms) {
50
- const abortSignal = DateTools.currentAbortSignal
51
- return new Promise((resolve, reject) => {
52
- const timer = setTimeout(resolve, ms)
53
- if (abortSignal) {
54
- abortSignal.addEventListener('abort', () => {
55
- clearTimeout(timer)
56
- reject(new Error('Delay aborted'))
57
- })
58
- }
59
- })
60
- }
61
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * 日期工具类
3
- */
4
- export default class DateTools {
5
- static instance = new DateTools()
6
-
7
- constructor () {
8
- if (DateTools.instance) {
9
- return DateTools.instance
10
- }
11
- DateTools.instance = this
12
- }
13
-
14
- static getInstance () {
15
- if (!DateTools.instance) {
16
- DateTools.instance = new DateTools()
17
- }
18
- return DateTools.instance
19
- }
20
-
21
- /**
22
- * 获取当前时间
23
- * @returns {string} yyyy-MM-dd HH:mm:ss
24
- */
25
- getNow2 () {
26
- const now = new Date()
27
- const year = now.getFullYear()
28
- const month = String(now.getMonth() + 1).padStart(2, '0') // 月份从 0 开始,所以要 +1
29
- const day = String(now.getDate()).padStart(2, '0')
30
- const hours = String(now.getHours()).padStart(2, '0')
31
- const minutes = String(now.getMinutes()).padStart(2, '0')
32
- const seconds = String(now.getSeconds()).padStart(2, '0')
33
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
34
- }
35
-
36
- /**
37
- * 延迟指定毫秒
38
- * @param {number} ms 延迟毫秒数
39
- * @returns {Promise}
40
- */
41
- delay (ms) {
42
- return new Promise(resolve => setTimeout(resolve, ms))
43
- }
44
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * 日期工具类
3
- */
4
- export default class DateTools {
5
- static instance = new DateTools()
6
-
7
- constructor () {
8
- if (DateTools.instance) {
9
- return DateTools.instance
10
- }
11
- DateTools.instance = this
12
- }
13
-
14
- static getInstance () {
15
- if (!DateTools.instance) {
16
- DateTools.instance = new DateTools()
17
- }
18
- return DateTools.instance
19
- }
20
-
21
- /**
22
- * 获取当前时间
23
- * @returns {string} yyyy-MM-dd HH:mm:ss
24
- */
25
- getNow2 () {
26
- const now = new Date()
27
- const year = now.getFullYear()
28
- const month = String(now.getMonth() + 1).padStart(2, '0') // 月份从 0 开始,所以要 +1
29
- const day = String(now.getDate()).padStart(2, '0')
30
- const hours = String(now.getHours()).padStart(2, '0')
31
- const minutes = String(now.getMinutes()).padStart(2, '0')
32
- const seconds = String(now.getSeconds()).padStart(2, '0')
33
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
34
- }
35
-
36
- /**
37
- * 延迟指定毫秒
38
- * @param {number} ms 延迟毫秒数
39
- * @returns {Promise}
40
- */
41
- delay (ms) {
42
- return new Promise(resolve => setTimeout(resolve, ms))
43
- }
44
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * 前端 Logic 用 HTTP 请求插件。
3
- * 提供 post、get 方法,均返回 Promise,供表达式执行器在调用处自动等待。
4
- * 使用项目统一的 request/restTools,走 axios 拦截器与认证。
5
- */
6
- import { post as postRequest, get as getRequest } from '@vue2-client/services/api/restTools'
7
-
8
- export default class HttpTools {
9
- static instance
10
- static currentDelegate = null
11
-
12
- constructor () {
13
- if (HttpTools.instance) {
14
- return HttpTools.instance
15
- }
16
- HttpTools.instance = this
17
- }
18
-
19
- static getInstance () {
20
- if (!HttpTools.instance) {
21
- HttpTools.instance = new HttpTools()
22
- }
23
- return HttpTools.instance
24
- }
25
-
26
- /**
27
- * POST 请求,返回 Promise<响应体>(即 response.data)
28
- * @param {string} url 请求地址,如 '/hai-api/suggest-by-complaint' 或 '/api/af-his/logic/xxx'
29
- * @param {Object} body 请求体(JSON),会作为 request body 发送
30
- * @param {Object} [config] 可选,axios 配置,如 { dedupe: false }
31
- * @param {AbortSignal} [config.abortSignal] 可选的 abortSignal(从 plugins 传入)
32
- * @returns {Promise<*>} 解析为响应体(通常为 JSON 对象)
33
- */
34
- post (url, body, config) {
35
- // 从 delegate 获取 abortSignal
36
- let abortSignal = config?.abortSignal
37
- if (!abortSignal && HttpTools.currentDelegate) {
38
- abortSignal = HttpTools.currentDelegate.get('abortSignal')
39
- }
40
-
41
- console.log('[HttpTools.post] abortSignal:', abortSignal, 'aborted:', abortSignal?.aborted)
42
-
43
- // 如果已经 abort 了,直接抛出错误
44
- if (abortSignal?.aborted) {
45
- const error = new Error('请求已被取消')
46
- error.name = 'AbortError'
47
- return Promise.reject(error)
48
- }
49
-
50
- const options = { ...config }
51
- delete options.abortSignal
52
-
53
- if (abortSignal) {
54
- options.signal = abortSignal
55
- }
56
- return postRequest(url, body || {}, options)
57
- .then(res => res && res.data !== undefined ? res.data : res)
58
- }
59
-
60
- /**
61
- * GET 请求,返回 Promise<响应体>(即 response.data)
62
- * @param {string} url 请求地址
63
- * @param {Object} [params] 查询参数
64
- * @param {Object} [config] 可选,axios 配置
65
- * @param {AbortSignal} [config.abortSignal] 可选的 abortSignal(从 plugins 传入)
66
- * @returns {Promise<*>} 解析为响应体
67
- */
68
- get (url, params, config) {
69
- const options = { ...config }
70
- const abortSignal = options.abortSignal
71
-
72
- delete options.abortSignal
73
-
74
- if (abortSignal) {
75
- options.signal = abortSignal
76
- }
77
- return getRequest(url, params, options)
78
- .then(res => res && res.data !== undefined ? res.data : res)
79
- }
80
- }