vue2-client 1.11.4 → 1.11.6-alpha
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/.babelrc +3 -0
- package/babel.config.js +18 -21
- package/jest.config.js +22 -21
- package/package.json +5 -4
- package/src/base-client/components/common/CitySelect/CitySelect.vue +366 -342
- package/src/base-client/components/common/Upload/Upload.vue +322 -322
- package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +314 -304
- package/src/base-client/components/common/XDescriptions/demo.vue +51 -50
- package/src/base-client/components/common/XFormGroup/demo.vue +39 -46
- package/src/base-client/components/common/XFormTable/demo.vue +60 -60
- package/src/components/STable/index.js +426 -426
- package/src/expression/ExpressionRunner.js +26 -0
- package/src/expression/TestExpression.js +508 -0
- package/src/expression/core/Delegate.js +113 -0
- package/src/expression/core/Expression.js +1323 -0
- package/src/expression/core/Program.js +933 -0
- package/src/expression/core/Token.js +27 -0
- package/src/expression/enums/ExpressionType.js +81 -0
- package/src/expression/enums/TokenType.js +11 -0
- package/src/expression/exception/BreakWayException.js +2 -0
- package/src/expression/exception/ContinueWayException.js +2 -0
- package/src/expression/exception/ExpressionException.js +28 -0
- package/src/expression/exception/ReturnWayException.js +14 -0
- package/src/expression/exception/ServiceException.js +22 -0
- package/src/expression/instances/JSONArray.js +48 -0
- package/src/expression/instances/JSONObject.js +122 -0
- package/src/expression/instances/LogicConsole.js +45 -0
- package/src/expression/ts/ExpressionRunner.ts +28 -0
- package/src/expression/ts/TestExpression.ts +509 -0
- package/src/expression/ts/core/Delegate.ts +114 -0
- package/src/expression/ts/core/Expression.ts +1309 -0
- package/src/expression/ts/core/Program.ts +950 -0
- package/src/expression/ts/core/Token.ts +29 -0
- package/src/expression/ts/enums/ExpressionType.ts +81 -0
- package/src/expression/ts/enums/TokenType.ts +13 -0
- package/src/expression/ts/exception/BreakWayException.ts +2 -0
- package/src/expression/ts/exception/ContinueWayException.ts +2 -0
- package/src/expression/ts/exception/ExpressionException.ts +28 -0
- package/src/expression/ts/exception/ReturnWayException.ts +14 -0
- package/src/expression/ts/exception/ServiceException.ts +22 -0
- package/src/expression/ts/instances/JSONArray.ts +48 -0
- package/src/expression/ts/instances/JSONObject.ts +109 -0
- package/src/expression/ts/instances/LogicConsole.ts +32 -0
- package/src/logic/LogicRunner.js +67 -0
- package/src/logic/TestLogic.js +13 -0
- package/src/logic/plugins/common/DateTools.js +32 -0
- package/src/logic/plugins/index.js +5 -0
- package/src/logic/ts/LogicRunner.ts +67 -0
- package/src/logic/ts/TestLogic.ts +13 -0
- package/src/pages/LogicCallExample/index.vue +30 -0
- package/src/router/async/router.map.js +4 -2
- package/src/services/user.js +2 -0
- package/src/store/mutation-types.js +1 -0
- package/src/utils/EncryptUtil.js +23 -0
- package/src/utils/indexedDB.js +234 -234
- package/src/utils/request.js +382 -362
- package/test/request.test.js +17 -0
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import JSONObject from '../instances/JSONObject'
|
|
2
|
+
|
|
3
|
+
export default class JSONArray {
|
|
4
|
+
innerList
|
|
5
|
+
|
|
6
|
+
constructor (value) {
|
|
7
|
+
if (value && typeof value === 'string') {
|
|
8
|
+
this.innerList = JSON.parse(value).map((item) => this.wrapValue(item))
|
|
9
|
+
} else if (value && Array.isArray(value)) {
|
|
10
|
+
this.innerList = value.map((item) => this.wrapValue(item))
|
|
11
|
+
} else {
|
|
12
|
+
this.innerList = []
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
wrapValue (value) {
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return new JSONArray(value)
|
|
19
|
+
} else if (value && JSONObject.isPlainObject(value)) {
|
|
20
|
+
return new JSONObject(value)
|
|
21
|
+
}
|
|
22
|
+
return value
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
length () {
|
|
26
|
+
return this.innerList.length
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
put (item) {
|
|
30
|
+
this.innerList.push(this.wrapValue(item))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get (index) {
|
|
34
|
+
return this.innerList[index]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
toString () {
|
|
38
|
+
const replacer = (key, value) => {
|
|
39
|
+
if (value instanceof JSONObject) {
|
|
40
|
+
return value.innerMap
|
|
41
|
+
} else if (value instanceof JSONArray) {
|
|
42
|
+
return value.innerList
|
|
43
|
+
}
|
|
44
|
+
return value
|
|
45
|
+
}
|
|
46
|
+
return JSON.stringify(this.innerList, replacer)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import JSONArray from '../instances/JSONArray'
|
|
2
|
+
import ServiceException from '../exception/ServiceException'
|
|
3
|
+
|
|
4
|
+
export default class JSONObject {
|
|
5
|
+
innerMap
|
|
6
|
+
|
|
7
|
+
constructor (value) {
|
|
8
|
+
let map
|
|
9
|
+
if (value && typeof value === 'string') {
|
|
10
|
+
map = JSON.parse(value)
|
|
11
|
+
} else if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
12
|
+
map = {}
|
|
13
|
+
const keySet = value instanceof JSONObject ? value.keySet() : Object.keys(value)
|
|
14
|
+
for (const key of keySet) {
|
|
15
|
+
const item = value instanceof JSONObject ? value.get(key) : value[key]
|
|
16
|
+
if (Array.isArray(item)) {
|
|
17
|
+
map[key] = new JSONArray(item)
|
|
18
|
+
} else if (JSONObject.isPlainObject(item)) {
|
|
19
|
+
map[key] = new JSONObject(item)
|
|
20
|
+
} else {
|
|
21
|
+
map[key] = item
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
map = {}
|
|
26
|
+
}
|
|
27
|
+
this.innerMap = map
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static isPlainObject (value) {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
put (key, value) {
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
this.innerMap[key] = new JSONArray(value)
|
|
37
|
+
} else if (JSONObject.isPlainObject(value)) {
|
|
38
|
+
this.innerMap[key] = new JSONObject(value)
|
|
39
|
+
} else {
|
|
40
|
+
this.innerMap[key] = value
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
putAll (object) {
|
|
45
|
+
if (object === null || object === undefined) {
|
|
46
|
+
throw new ServiceException('putAll的value不能为空')
|
|
47
|
+
}
|
|
48
|
+
if (object instanceof JSONObject) {
|
|
49
|
+
for (const key in object.keySet()) {
|
|
50
|
+
this.put(key, object.get(key))
|
|
51
|
+
}
|
|
52
|
+
} else if (typeof object === 'object') {
|
|
53
|
+
for (const key in object) {
|
|
54
|
+
this.put(key, object[key])
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
throw new ServiceException('putAll的value必须是对象或JSONObject')
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get (key) {
|
|
62
|
+
return this.innerMap[key]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
opt (key) {
|
|
66
|
+
return key == null ? null : this.innerMap[key]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
optString (key, defaultValue) {
|
|
70
|
+
const result = this.opt(key)
|
|
71
|
+
return result || defaultValue
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getBoolean (key) {
|
|
75
|
+
const object = this.get(key)
|
|
76
|
+
if (typeof object === 'boolean') {
|
|
77
|
+
return object
|
|
78
|
+
} else {
|
|
79
|
+
return Boolean(object)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
optBoolean (key, defaultValue) {
|
|
84
|
+
const val = this.opt(key)
|
|
85
|
+
if (!val) {
|
|
86
|
+
return defaultValue
|
|
87
|
+
}
|
|
88
|
+
return this.getBoolean(key)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getInt (key) {
|
|
92
|
+
return this.innerMap[key]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getJSONObject (key) {
|
|
96
|
+
return this.innerMap[key]
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getJSONArray (key) {
|
|
100
|
+
return this.innerMap[key]
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
has (key) {
|
|
104
|
+
return Object.prototype.hasOwnProperty.call(this.innerMap, key)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
keySet () {
|
|
108
|
+
return Object.keys(this.innerMap)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
toString () {
|
|
112
|
+
const replacer = (key, value) => {
|
|
113
|
+
if (value instanceof JSONObject) {
|
|
114
|
+
return value.innerMap
|
|
115
|
+
} else if (value instanceof JSONArray) {
|
|
116
|
+
return value.innerList
|
|
117
|
+
}
|
|
118
|
+
return value
|
|
119
|
+
}
|
|
120
|
+
return JSON.stringify(this.innerMap, replacer)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// 自定义 Console 类
|
|
2
|
+
export default class LogicConsole {
|
|
3
|
+
constructor () {
|
|
4
|
+
if (LogicConsole.instance) {
|
|
5
|
+
return LogicConsole.instance
|
|
6
|
+
}
|
|
7
|
+
LogicConsole.instance = this
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static getInstance () {
|
|
11
|
+
if (!LogicConsole.instance) {
|
|
12
|
+
LogicConsole.instance = new LogicConsole()
|
|
13
|
+
}
|
|
14
|
+
return LogicConsole.instance
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
debug (...args) {
|
|
18
|
+
const newArgs = this.convert(args)
|
|
19
|
+
console.debug(...newArgs)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
info (...args) {
|
|
23
|
+
const newArgs = this.convert(args)
|
|
24
|
+
console.info(...newArgs)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
warn (...args) {
|
|
28
|
+
const newArgs = this.convert(args)
|
|
29
|
+
console.warn(...newArgs)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
error (...args) {
|
|
33
|
+
const newArgs = this.convert(args)
|
|
34
|
+
console.error(...newArgs)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
convert (args) {
|
|
38
|
+
return args.map(arg => {
|
|
39
|
+
if (typeof arg === 'object' && arg !== null && typeof arg.toString === 'function') {
|
|
40
|
+
return arg.toString()
|
|
41
|
+
}
|
|
42
|
+
return arg
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Program from './core/Program'
|
|
2
|
+
import Delegate from './core/Delegate'
|
|
3
|
+
import JSONObject from "./instances/JSONObject";
|
|
4
|
+
|
|
5
|
+
export default class ExpressionRunner {
|
|
6
|
+
/**
|
|
7
|
+
* Runs an expression with parameters
|
|
8
|
+
*
|
|
9
|
+
* @param source Expression source
|
|
10
|
+
* @param params Expression parameters
|
|
11
|
+
* @returns The result of the expression
|
|
12
|
+
*/
|
|
13
|
+
public static run(source: string, params: JSONObject): any {
|
|
14
|
+
const delegate: Delegate = this.getDelegate(source);
|
|
15
|
+
return delegate.invoke(params);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Gets the delegate for the expression
|
|
20
|
+
*
|
|
21
|
+
* @param source Expression source
|
|
22
|
+
* @returns A delegate to invoke
|
|
23
|
+
*/
|
|
24
|
+
public static getDelegate(source: string): Delegate {
|
|
25
|
+
// Parse the source and return a delegate
|
|
26
|
+
return new Program(source).parse();
|
|
27
|
+
}
|
|
28
|
+
}
|