vue2-client 1.12.100 → 1.12.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/base-client/components/common/XCollapse/XCollapse.vue +8 -14
- package/src/base-client/components/common/XCollapse/XCollapseDemo.vue +15 -0
- package/src/base-client/components/common/XReport/index.js +3 -3
- package/src/base-client/components/common/XReportGrid/XReportDemo.vue +44 -44
- package/src/base-client/components/his/XHDescriptions/XHDescriptions.vue +8 -1
- package/src/base-client/components/his/XList/XList.vue +131 -131
- package/src/base-client/components/his/XSidebar/XSidebar.vue +27 -1
- package/src/base-client/plugins/AppData.js +126 -126
- package/src/expression/ExpressionRunner.js +26 -26
- package/src/expression/TestExpression.js +509 -509
- package/src/expression/core/Delegate.js +115 -115
- package/src/expression/core/Expression.js +1358 -1358
- package/src/expression/core/Program.js +932 -932
- package/src/expression/core/Token.js +27 -27
- package/src/expression/enums/ExpressionType.js +81 -81
- package/src/expression/enums/TokenType.js +11 -11
- package/src/expression/exception/BreakWayException.js +2 -2
- package/src/expression/exception/ContinueWayException.js +2 -2
- package/src/expression/exception/ExpressionException.js +28 -28
- package/src/expression/exception/ReturnWayException.js +14 -14
- package/src/expression/exception/ServiceException.js +22 -22
- package/src/expression/instances/LogicConsole.js +44 -44
- package/src/logic/LogicRunner.js +62 -62
- package/src/logic/TestLogic.js +13 -13
- package/src/logic/plugins/common/VueTools.js +30 -30
- package/src/logic/ts/LogicRunner.ts +67 -67
- package/src/logic/ts/TestLogic.ts +13 -13
- package/src/pages/DynamicStatistics/FavoriteList.vue +50 -50
- package/src/pages/ReportGrid/index.vue +76 -76
- package/src/router/async/router.map.js +124 -119
- package/src/services/api/entity.js +18 -18
- package/src/utils/waterMark.js +31 -31
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
export default class Token {
|
|
2
|
-
type
|
|
3
|
-
value
|
|
4
|
-
startPos
|
|
5
|
-
|
|
6
|
-
constructor (type, value, startPos) {
|
|
7
|
-
this.type = type
|
|
8
|
-
this.value = value
|
|
9
|
-
this.startPos = startPos
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
toString () {
|
|
13
|
-
return this.type.toString() + this.value
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getType () {
|
|
17
|
-
return this.type
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
getValue () {
|
|
21
|
-
return this.value
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
getStartPos () {
|
|
25
|
-
return this.startPos
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
export default class Token {
|
|
2
|
+
type
|
|
3
|
+
value
|
|
4
|
+
startPos
|
|
5
|
+
|
|
6
|
+
constructor (type, value, startPos) {
|
|
7
|
+
this.type = type
|
|
8
|
+
this.value = value
|
|
9
|
+
this.startPos = startPos
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
toString () {
|
|
13
|
+
return this.type.toString() + this.value
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getType () {
|
|
17
|
+
return this.type
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getValue () {
|
|
21
|
+
return this.value
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getStartPos () {
|
|
25
|
+
return this.startPos
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
const ExpressionType = {
|
|
2
|
-
// >
|
|
3
|
-
GreaterThan: 'GreaterThan',
|
|
4
|
-
// >=
|
|
5
|
-
GreaterThanOrEqual: 'GreaterThanOrEqual',
|
|
6
|
-
// <
|
|
7
|
-
LessThan: 'LessThan',
|
|
8
|
-
// <=
|
|
9
|
-
LessThanOrEqual: 'LessThanOrEqual',
|
|
10
|
-
//= =
|
|
11
|
-
Equal: 'Equal',
|
|
12
|
-
//! =
|
|
13
|
-
NotEqual: 'NotEqual',
|
|
14
|
-
// +
|
|
15
|
-
Add: 'Add',
|
|
16
|
-
// -
|
|
17
|
-
Subtract: 'Subtract',
|
|
18
|
-
//*
|
|
19
|
-
Multiply: 'Multiply',
|
|
20
|
-
// 除法
|
|
21
|
-
Divide: 'Divide',
|
|
22
|
-
// 求余
|
|
23
|
-
Modulo: 'Modulo',
|
|
24
|
-
|
|
25
|
-
// 字符串连接
|
|
26
|
-
Concat: 'Concat',
|
|
27
|
-
// 逻辑非
|
|
28
|
-
Not: 'Not',
|
|
29
|
-
// 逻辑与
|
|
30
|
-
And: 'And',
|
|
31
|
-
// 逻辑或
|
|
32
|
-
Or: 'Or',
|
|
33
|
-
|
|
34
|
-
// 常数
|
|
35
|
-
Constant: 'Constant',
|
|
36
|
-
// 标识符
|
|
37
|
-
Identity: 'Identity',
|
|
38
|
-
|
|
39
|
-
// 获取对象属性
|
|
40
|
-
Property: 'Property',
|
|
41
|
-
|
|
42
|
-
// 产生Json对象
|
|
43
|
-
Json: 'Json',
|
|
44
|
-
// 产生Json数组
|
|
45
|
-
Array: 'Array',
|
|
46
|
-
// Json对象属性值对
|
|
47
|
-
Attr: 'Attr',
|
|
48
|
-
// 数组下标,[0]
|
|
49
|
-
ArrayIndex: 'ArrayIndex',
|
|
50
|
-
// 函数调用
|
|
51
|
-
Call: 'Call',
|
|
52
|
-
// for循环
|
|
53
|
-
For: 'For',
|
|
54
|
-
// 逗号表达式
|
|
55
|
-
Comma: 'Comma',
|
|
56
|
-
// 赋值语句
|
|
57
|
-
Assign: 'Assign:',
|
|
58
|
-
// 条件语句
|
|
59
|
-
Condition: 'Condition',
|
|
60
|
-
// 参数
|
|
61
|
-
Param: 'Param',
|
|
62
|
-
// Try
|
|
63
|
-
Try: 'Try',
|
|
64
|
-
// Catch
|
|
65
|
-
Catch: 'Catch',
|
|
66
|
-
// 跳出
|
|
67
|
-
Return: 'Return',
|
|
68
|
-
// 抛出异常
|
|
69
|
-
Throw: 'Throw',
|
|
70
|
-
// 校验
|
|
71
|
-
Validate: 'Validate',
|
|
72
|
-
// 断言
|
|
73
|
-
Assert: 'Assert',
|
|
74
|
-
// 循环终止
|
|
75
|
-
Break: 'Break',
|
|
76
|
-
// 循环跳过
|
|
77
|
-
Continue: 'Continue',
|
|
78
|
-
// lambda
|
|
79
|
-
Lambda: 'Lambda'
|
|
80
|
-
}
|
|
81
|
-
export default ExpressionType
|
|
1
|
+
const ExpressionType = {
|
|
2
|
+
// >
|
|
3
|
+
GreaterThan: 'GreaterThan',
|
|
4
|
+
// >=
|
|
5
|
+
GreaterThanOrEqual: 'GreaterThanOrEqual',
|
|
6
|
+
// <
|
|
7
|
+
LessThan: 'LessThan',
|
|
8
|
+
// <=
|
|
9
|
+
LessThanOrEqual: 'LessThanOrEqual',
|
|
10
|
+
//= =
|
|
11
|
+
Equal: 'Equal',
|
|
12
|
+
//! =
|
|
13
|
+
NotEqual: 'NotEqual',
|
|
14
|
+
// +
|
|
15
|
+
Add: 'Add',
|
|
16
|
+
// -
|
|
17
|
+
Subtract: 'Subtract',
|
|
18
|
+
//*
|
|
19
|
+
Multiply: 'Multiply',
|
|
20
|
+
// 除法
|
|
21
|
+
Divide: 'Divide',
|
|
22
|
+
// 求余
|
|
23
|
+
Modulo: 'Modulo',
|
|
24
|
+
|
|
25
|
+
// 字符串连接
|
|
26
|
+
Concat: 'Concat',
|
|
27
|
+
// 逻辑非
|
|
28
|
+
Not: 'Not',
|
|
29
|
+
// 逻辑与
|
|
30
|
+
And: 'And',
|
|
31
|
+
// 逻辑或
|
|
32
|
+
Or: 'Or',
|
|
33
|
+
|
|
34
|
+
// 常数
|
|
35
|
+
Constant: 'Constant',
|
|
36
|
+
// 标识符
|
|
37
|
+
Identity: 'Identity',
|
|
38
|
+
|
|
39
|
+
// 获取对象属性
|
|
40
|
+
Property: 'Property',
|
|
41
|
+
|
|
42
|
+
// 产生Json对象
|
|
43
|
+
Json: 'Json',
|
|
44
|
+
// 产生Json数组
|
|
45
|
+
Array: 'Array',
|
|
46
|
+
// Json对象属性值对
|
|
47
|
+
Attr: 'Attr',
|
|
48
|
+
// 数组下标,[0]
|
|
49
|
+
ArrayIndex: 'ArrayIndex',
|
|
50
|
+
// 函数调用
|
|
51
|
+
Call: 'Call',
|
|
52
|
+
// for循环
|
|
53
|
+
For: 'For',
|
|
54
|
+
// 逗号表达式
|
|
55
|
+
Comma: 'Comma',
|
|
56
|
+
// 赋值语句
|
|
57
|
+
Assign: 'Assign:',
|
|
58
|
+
// 条件语句
|
|
59
|
+
Condition: 'Condition',
|
|
60
|
+
// 参数
|
|
61
|
+
Param: 'Param',
|
|
62
|
+
// Try
|
|
63
|
+
Try: 'Try',
|
|
64
|
+
// Catch
|
|
65
|
+
Catch: 'Catch',
|
|
66
|
+
// 跳出
|
|
67
|
+
Return: 'Return',
|
|
68
|
+
// 抛出异常
|
|
69
|
+
Throw: 'Throw',
|
|
70
|
+
// 校验
|
|
71
|
+
Validate: 'Validate',
|
|
72
|
+
// 断言
|
|
73
|
+
Assert: 'Assert',
|
|
74
|
+
// 循环终止
|
|
75
|
+
Break: 'Break',
|
|
76
|
+
// 循环跳过
|
|
77
|
+
Continue: 'Continue',
|
|
78
|
+
// lambda
|
|
79
|
+
Lambda: 'Lambda'
|
|
80
|
+
}
|
|
81
|
+
export default ExpressionType
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const TokenType = {
|
|
2
|
-
Int: 'Int',
|
|
3
|
-
Double: 'Double',
|
|
4
|
-
Bool: 'Bool',
|
|
5
|
-
String: 'String',
|
|
6
|
-
Identy: 'Identity',
|
|
7
|
-
Oper: 'Oper',
|
|
8
|
-
End: 'End',
|
|
9
|
-
Null: 'Null'
|
|
10
|
-
}
|
|
11
|
-
export default TokenType
|
|
1
|
+
const TokenType = {
|
|
2
|
+
Int: 'Int',
|
|
3
|
+
Double: 'Double',
|
|
4
|
+
Bool: 'Bool',
|
|
5
|
+
String: 'String',
|
|
6
|
+
Identy: 'Identity',
|
|
7
|
+
Oper: 'Oper',
|
|
8
|
+
End: 'End',
|
|
9
|
+
Null: 'Null'
|
|
10
|
+
}
|
|
11
|
+
export default TokenType
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default class BreakWayException extends Error {
|
|
2
|
-
}
|
|
1
|
+
export default class BreakWayException extends Error {
|
|
2
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default class ContinueWayException extends Error {
|
|
2
|
-
}
|
|
1
|
+
export default class ContinueWayException extends Error {
|
|
2
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 表达式执行异常,将显示执行异常的位置信息
|
|
3
|
-
*/
|
|
4
|
-
export default class ExpressionException extends Error {
|
|
5
|
-
constructor (source, pos, cause) {
|
|
6
|
-
let message
|
|
7
|
-
let beforeErrorContent = source.substring(0, pos).trim()
|
|
8
|
-
const length = beforeErrorContent.length
|
|
9
|
-
if (length > 1000) {
|
|
10
|
-
beforeErrorContent = '以上省略......\n' + beforeErrorContent.substring(length - 1000)
|
|
11
|
-
}
|
|
12
|
-
const afterErrorContent = source.substring(pos)
|
|
13
|
-
const afterErrorContentIndex = afterErrorContent.indexOf('\n')
|
|
14
|
-
if (afterErrorContentIndex === -1) {
|
|
15
|
-
message = beforeErrorContent.trim() + ' <- ' + afterErrorContent
|
|
16
|
-
} else {
|
|
17
|
-
message = beforeErrorContent.trim() + ' <- ' + afterErrorContent.substring(0, afterErrorContentIndex) + '\n后续省略......'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// 通过原生 Error 的 cause 参数传递原因
|
|
21
|
-
super(message, { cause })
|
|
22
|
-
this.name = this.constructor.name
|
|
23
|
-
|
|
24
|
-
if (Error.captureStackTrace) {
|
|
25
|
-
Error.captureStackTrace(this, this.constructor)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 表达式执行异常,将显示执行异常的位置信息
|
|
3
|
+
*/
|
|
4
|
+
export default class ExpressionException extends Error {
|
|
5
|
+
constructor (source, pos, cause) {
|
|
6
|
+
let message
|
|
7
|
+
let beforeErrorContent = source.substring(0, pos).trim()
|
|
8
|
+
const length = beforeErrorContent.length
|
|
9
|
+
if (length > 1000) {
|
|
10
|
+
beforeErrorContent = '以上省略......\n' + beforeErrorContent.substring(length - 1000)
|
|
11
|
+
}
|
|
12
|
+
const afterErrorContent = source.substring(pos)
|
|
13
|
+
const afterErrorContentIndex = afterErrorContent.indexOf('\n')
|
|
14
|
+
if (afterErrorContentIndex === -1) {
|
|
15
|
+
message = beforeErrorContent.trim() + ' <- ' + afterErrorContent
|
|
16
|
+
} else {
|
|
17
|
+
message = beforeErrorContent.trim() + ' <- ' + afterErrorContent.substring(0, afterErrorContentIndex) + '\n后续省略......'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 通过原生 Error 的 cause 参数传递原因
|
|
21
|
+
super(message, { cause })
|
|
22
|
+
this.name = this.constructor.name
|
|
23
|
+
|
|
24
|
+
if (Error.captureStackTrace) {
|
|
25
|
+
Error.captureStackTrace(this, this.constructor)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Return 方法
|
|
3
|
-
*/
|
|
4
|
-
export default class ReturnWayException extends Error {
|
|
5
|
-
returnObject
|
|
6
|
-
constructor (returnValue) {
|
|
7
|
-
super()
|
|
8
|
-
this.returnObject = returnValue
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
getReturnObject () {
|
|
12
|
-
return this.returnObject
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Return 方法
|
|
3
|
+
*/
|
|
4
|
+
export default class ReturnWayException extends Error {
|
|
5
|
+
returnObject
|
|
6
|
+
constructor (returnValue) {
|
|
7
|
+
super()
|
|
8
|
+
this.returnObject = returnValue
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
getReturnObject () {
|
|
12
|
+
return this.returnObject
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export default class ServiceException extends Error {
|
|
2
|
-
message
|
|
3
|
-
code
|
|
4
|
-
constructor (message, code) {
|
|
5
|
-
super()
|
|
6
|
-
this.message = message
|
|
7
|
-
this.code = code
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
getMessage () {
|
|
11
|
-
return this.message
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
setMessage (message) {
|
|
15
|
-
this.message = message
|
|
16
|
-
return this
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getCode () {
|
|
20
|
-
return this.code
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
export default class ServiceException extends Error {
|
|
2
|
+
message
|
|
3
|
+
code
|
|
4
|
+
constructor (message, code) {
|
|
5
|
+
super()
|
|
6
|
+
this.message = message
|
|
7
|
+
this.code = code
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getMessage () {
|
|
11
|
+
return this.message
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
setMessage (message) {
|
|
15
|
+
this.message = message
|
|
16
|
+
return this
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getCode () {
|
|
20
|
+
return this.code
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
// 自定义 Console 类
|
|
2
|
-
import Expression from '../core/Expression'
|
|
3
|
-
|
|
4
|
-
export default class LogicConsole {
|
|
5
|
-
constructor () {
|
|
6
|
-
if (LogicConsole.instance) {
|
|
7
|
-
return LogicConsole.instance
|
|
8
|
-
}
|
|
9
|
-
LogicConsole.instance = this
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static getInstance () {
|
|
13
|
-
if (!LogicConsole.instance) {
|
|
14
|
-
LogicConsole.instance = new LogicConsole()
|
|
15
|
-
}
|
|
16
|
-
return LogicConsole.instance
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
debug (...args) {
|
|
20
|
-
const newArgs = this.convert(args)
|
|
21
|
-
console.debug(...newArgs)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
info (...args) {
|
|
25
|
-
const newArgs = this.convert(args)
|
|
26
|
-
console.info(...newArgs)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
warn (...args) {
|
|
30
|
-
const newArgs = this.convert(args)
|
|
31
|
-
console.warn(...newArgs)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
error (...args) {
|
|
35
|
-
const newArgs = this.convert(args)
|
|
36
|
-
console.error(...newArgs)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
convert (args) {
|
|
40
|
-
return args.map(obj => {
|
|
41
|
-
return Expression.toJSONString(obj)
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
// 自定义 Console 类
|
|
2
|
+
import Expression from '../core/Expression'
|
|
3
|
+
|
|
4
|
+
export default class LogicConsole {
|
|
5
|
+
constructor () {
|
|
6
|
+
if (LogicConsole.instance) {
|
|
7
|
+
return LogicConsole.instance
|
|
8
|
+
}
|
|
9
|
+
LogicConsole.instance = this
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static getInstance () {
|
|
13
|
+
if (!LogicConsole.instance) {
|
|
14
|
+
LogicConsole.instance = new LogicConsole()
|
|
15
|
+
}
|
|
16
|
+
return LogicConsole.instance
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
debug (...args) {
|
|
20
|
+
const newArgs = this.convert(args)
|
|
21
|
+
console.debug(...newArgs)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
info (...args) {
|
|
25
|
+
const newArgs = this.convert(args)
|
|
26
|
+
console.info(...newArgs)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
warn (...args) {
|
|
30
|
+
const newArgs = this.convert(args)
|
|
31
|
+
console.warn(...newArgs)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
error (...args) {
|
|
35
|
+
const newArgs = this.convert(args)
|
|
36
|
+
console.error(...newArgs)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
convert (args) {
|
|
40
|
+
return args.map(obj => {
|
|
41
|
+
return Expression.toJSONString(obj)
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/logic/LogicRunner.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import ServiceException from '../expression/exception/ServiceException'
|
|
2
|
-
import LogicConsole from '../expression/instances/LogicConsole'
|
|
3
|
-
import ExpressionRunner from '../expression/ExpressionRunner'
|
|
4
|
-
import { getConfigByNameAsync } 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
|
-
/**
|
|
12
|
-
* 是否存在指定名称的Logic资源
|
|
13
|
-
*
|
|
14
|
-
* @param logicName Logic名称
|
|
15
|
-
* @return 是否存在
|
|
16
|
-
*/
|
|
17
|
-
static async has (logicName) {
|
|
18
|
-
return await LogicRunner.getLogic(logicName, false, (result) => {
|
|
19
|
-
return result != null
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 执行Logic
|
|
25
|
-
*
|
|
26
|
-
* @param logicName Logic名称
|
|
27
|
-
* @param param 参数
|
|
28
|
-
* @return 执行结果
|
|
29
|
-
*/
|
|
30
|
-
static async run (logicName, param) {
|
|
31
|
-
// 获取Logic资源
|
|
32
|
-
const result = await LogicRunner.getLogic(logicName, false)
|
|
33
|
-
if (!result || !result.source) {
|
|
34
|
-
throw new ServiceException('Logic资源' + logicName + '未找到', 400)
|
|
35
|
-
}
|
|
36
|
-
const paramStr = Expression.toJSONString(param)
|
|
37
|
-
LogicRunner.logicConsoleInstance.info(`执行Logic[${logicName}],params: ${paramStr}`)
|
|
38
|
-
// 附加用户注册的对象到业务逻辑中
|
|
39
|
-
const plugins = {}
|
|
40
|
-
plugins.data = param
|
|
41
|
-
plugins.log = LogicRunner.logicConsoleInstance
|
|
42
|
-
plugins.ENV = result.$globalProp
|
|
43
|
-
plugins.logic = this
|
|
44
|
-
Object.assign(plugins, Plugins.default)
|
|
45
|
-
return LogicRunner.runExpression(result.source, plugins)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 执行原生表达式
|
|
50
|
-
*
|
|
51
|
-
* @param source 表达式内容
|
|
52
|
-
* @param params 参数
|
|
53
|
-
* @return 执行结果
|
|
54
|
-
*/
|
|
55
|
-
static async runExpression (source, params) {
|
|
56
|
-
return await ExpressionRunner.run(source, params)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
static async getLogic (logicName, isDev) {
|
|
60
|
-
return await getConfigByNameAsync(logicName, undefined, isDev)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
import ServiceException from '../expression/exception/ServiceException'
|
|
2
|
+
import LogicConsole from '../expression/instances/LogicConsole'
|
|
3
|
+
import ExpressionRunner from '../expression/ExpressionRunner'
|
|
4
|
+
import { getConfigByNameAsync } 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
|
+
/**
|
|
12
|
+
* 是否存在指定名称的Logic资源
|
|
13
|
+
*
|
|
14
|
+
* @param logicName Logic名称
|
|
15
|
+
* @return 是否存在
|
|
16
|
+
*/
|
|
17
|
+
static async has (logicName) {
|
|
18
|
+
return await LogicRunner.getLogic(logicName, false, (result) => {
|
|
19
|
+
return result != null
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 执行Logic
|
|
25
|
+
*
|
|
26
|
+
* @param logicName Logic名称
|
|
27
|
+
* @param param 参数
|
|
28
|
+
* @return 执行结果
|
|
29
|
+
*/
|
|
30
|
+
static async run (logicName, param) {
|
|
31
|
+
// 获取Logic资源
|
|
32
|
+
const result = await LogicRunner.getLogic(logicName, false)
|
|
33
|
+
if (!result || !result.source) {
|
|
34
|
+
throw new ServiceException('Logic资源' + logicName + '未找到', 400)
|
|
35
|
+
}
|
|
36
|
+
const paramStr = Expression.toJSONString(param)
|
|
37
|
+
LogicRunner.logicConsoleInstance.info(`执行Logic[${logicName}],params: ${paramStr}`)
|
|
38
|
+
// 附加用户注册的对象到业务逻辑中
|
|
39
|
+
const plugins = {}
|
|
40
|
+
plugins.data = param
|
|
41
|
+
plugins.log = LogicRunner.logicConsoleInstance
|
|
42
|
+
plugins.ENV = result.$globalProp
|
|
43
|
+
plugins.logic = this
|
|
44
|
+
Object.assign(plugins, Plugins.default)
|
|
45
|
+
return LogicRunner.runExpression(result.source, plugins)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 执行原生表达式
|
|
50
|
+
*
|
|
51
|
+
* @param source 表达式内容
|
|
52
|
+
* @param params 参数
|
|
53
|
+
* @return 执行结果
|
|
54
|
+
*/
|
|
55
|
+
static async runExpression (source, params) {
|
|
56
|
+
return await ExpressionRunner.run(source, params)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static async getLogic (logicName, isDev) {
|
|
60
|
+
return await getConfigByNameAsync(logicName, undefined, isDev)
|
|
61
|
+
}
|
|
62
|
+
}
|
package/src/logic/TestLogic.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import LogicRunner from './LogicRunner'
|
|
2
|
-
|
|
3
|
-
testLogicCall()
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* testLogicCall
|
|
7
|
-
*/
|
|
8
|
-
function testLogicCall () {
|
|
9
|
-
const result = LogicRunner.run('testVueLogic', {
|
|
10
|
-
test: '1'
|
|
11
|
-
})
|
|
12
|
-
console.info(result)
|
|
13
|
-
}
|
|
1
|
+
import LogicRunner from './LogicRunner'
|
|
2
|
+
|
|
3
|
+
testLogicCall()
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* testLogicCall
|
|
7
|
+
*/
|
|
8
|
+
function testLogicCall () {
|
|
9
|
+
const result = LogicRunner.run('testVueLogic', {
|
|
10
|
+
test: '1'
|
|
11
|
+
})
|
|
12
|
+
console.info(result)
|
|
13
|
+
}
|