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.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/src/base-client/components/common/XCollapse/XCollapse.vue +8 -14
  3. package/src/base-client/components/common/XCollapse/XCollapseDemo.vue +15 -0
  4. package/src/base-client/components/common/XReport/index.js +3 -3
  5. package/src/base-client/components/common/XReportGrid/XReportDemo.vue +44 -44
  6. package/src/base-client/components/his/XHDescriptions/XHDescriptions.vue +8 -1
  7. package/src/base-client/components/his/XList/XList.vue +131 -131
  8. package/src/base-client/components/his/XSidebar/XSidebar.vue +27 -1
  9. package/src/base-client/plugins/AppData.js +126 -126
  10. package/src/expression/ExpressionRunner.js +26 -26
  11. package/src/expression/TestExpression.js +509 -509
  12. package/src/expression/core/Delegate.js +115 -115
  13. package/src/expression/core/Expression.js +1358 -1358
  14. package/src/expression/core/Program.js +932 -932
  15. package/src/expression/core/Token.js +27 -27
  16. package/src/expression/enums/ExpressionType.js +81 -81
  17. package/src/expression/enums/TokenType.js +11 -11
  18. package/src/expression/exception/BreakWayException.js +2 -2
  19. package/src/expression/exception/ContinueWayException.js +2 -2
  20. package/src/expression/exception/ExpressionException.js +28 -28
  21. package/src/expression/exception/ReturnWayException.js +14 -14
  22. package/src/expression/exception/ServiceException.js +22 -22
  23. package/src/expression/instances/LogicConsole.js +44 -44
  24. package/src/logic/LogicRunner.js +62 -62
  25. package/src/logic/TestLogic.js +13 -13
  26. package/src/logic/plugins/common/VueTools.js +30 -30
  27. package/src/logic/ts/LogicRunner.ts +67 -67
  28. package/src/logic/ts/TestLogic.ts +13 -13
  29. package/src/pages/DynamicStatistics/FavoriteList.vue +50 -50
  30. package/src/pages/ReportGrid/index.vue +76 -76
  31. package/src/router/async/router.map.js +124 -119
  32. package/src/services/api/entity.js +18 -18
  33. package/src/utils/waterMark.js +31 -31
@@ -1,509 +1,509 @@
1
- import Program from './core/Program'
2
- import LogicConsole from './instances/LogicConsole'
3
-
4
- const logicConsole = LogicConsole.getInstance()
5
-
6
- runTest()
7
-
8
- async function runTest () {
9
- logicConsole.debug('1.========testValidate========')
10
- await testValidate()
11
- logicConsole.debug('2.========testAssert========')
12
- await testAssert()
13
- logicConsole.debug('3.========testTry========')
14
- await testTry()
15
- logicConsole.debug('4.========testPropertyType========')
16
- await testPropertyType()
17
- logicConsole.debug('5.========testJSONArrayIndex========')
18
- await testJSONArrayIndex()
19
- logicConsole.debug('6.========testArrayIndex========')
20
- await testArrayIndex()
21
- logicConsole.debug('7.========testCompare========')
22
- await testCompare()
23
- logicConsole.debug('8.========testJSONObject========')
24
- await testJSONObject()
25
- logicConsole.debug('9.========testJSONArray========')
26
- await testJSONArray()
27
- logicConsole.debug('10.========testFunctionCall========')
28
- await testFunctionCall()
29
- logicConsole.debug('11.========testMath========')
30
- await testMath()
31
- logicConsole.debug('12.========testString========')
32
- await testString()
33
- logicConsole.debug('13.========testCondition========')
34
- await testCondition()
35
- logicConsole.debug('14.========testThrow========')
36
- await testThrow()
37
- logicConsole.debug('15.========testJSONArrayLoop========')
38
- await testJSONArrayLoop()
39
- logicConsole.debug('16.========testJSONObjectLoop========')
40
- await testJSONObjectLoop()
41
- logicConsole.debug('17.========testIntLoop========')
42
- await testIntLoop()
43
- logicConsole.debug('18.========testContinueAndBreak========')
44
- await testContinueAndBreak()
45
- logicConsole.debug('19.========testComment========')
46
- await testComment()
47
- logicConsole.debug('20.========testReturn========')
48
- await testReturn()
49
- logicConsole.debug('21.========testLambda========')
50
- await testLambda()
51
- }
52
-
53
- /**
54
- * validate
55
- */
56
- async function testValidate () {
57
- const expression = `
58
- validate {
59
- model: {
60
- required: true,
61
- },
62
- visible: {
63
- default: 1 + 1,
64
- },
65
- isAep: {
66
- default: 3
67
- },
68
- testJson: {
69
- required: true,
70
- items: {
71
- userid: {
72
- required: true
73
- }
74
- }
75
- },
76
- testGroup: {
77
- mode: "atLeastOne",
78
- fields: [
79
- "test1",
80
- "test2"
81
- ]
82
- }
83
- },
84
- data.isAep == 3 :(
85
- log.info(123)
86
- ),null,
87
- log.info(data)
88
- `
89
- const data = {
90
- model: 'a',
91
- test1: 'b',
92
- isAep: null,
93
- testJson: {
94
- userid: {}
95
- }
96
- }
97
- await runExpression(expression, data)
98
- }
99
-
100
- /**
101
- * assert
102
- */
103
- async function testAssert () {
104
- const expression = `
105
- c = 1,
106
- assert c == 1,
107
- log.debug("ok"),
108
- a = 1 + c,
109
- assert a == 2,
110
- log.debug("ok2")`
111
- await runExpression(expression)
112
- }
113
-
114
- /**
115
- * try
116
- */
117
- async function testTry () {
118
- const expression = `
119
- a = 0,
120
- log.debug(a),
121
- try {
122
- assert c == 2
123
- } catch (WebException e) {
124
- log.debug(e),
125
- a = 1 + 1
126
- } catch (Exception e) {
127
- log.debug(e),
128
- a = 1 + 2
129
- },
130
- log.debug(a)
131
- `
132
- await runExpression(expression)
133
- }
134
-
135
- /**
136
- * property
137
- */
138
- async function testPropertyType () {
139
- const expression = `
140
- a = 1,
141
- b = 2.0,
142
- c = {
143
- d: 1,
144
- e: {
145
- str: "123",
146
- 你好: "中国"
147
- }
148
- },
149
- c.a = 1,
150
- log.debug(c.e.你好),
151
- log.debug(c["e"].str),
152
- e = c.d,
153
- f = "123",
154
- g = [],
155
- 名称 = "123=>",
156
- log.debug(data.testArray[0]),
157
- return 名称
158
- `
159
- const data = {
160
- testArray: 'zhang|b|c'.split('\|')
161
- }
162
- await runExpression(expression, data)
163
- }
164
-
165
- /**
166
- * JSONArray index
167
- */
168
- async function testJSONArrayIndex () {
169
- const expression = `
170
- a = [1,2,3,4,5],
171
- return a[4]
172
- `
173
- await runExpression(expression)
174
- }
175
-
176
- /**
177
- * array index
178
- */
179
- async function testArrayIndex () {
180
- const expression = `
181
- return data.a[4]
182
- `
183
- const data = {
184
- a: [1, 2, 3, 4, 5]
185
- }
186
- await runExpression(expression, data)
187
- }
188
-
189
- async function testCompare () {
190
- const expression = `
191
- a = 0,
192
- a >= 0 :(
193
- a = a + 1,
194
- b = 1,
195
- a == b :(
196
- c = 3.0,
197
- a < c :(
198
- a + 2,
199
- a <= c :(
200
- strA = $a$,
201
- strB = $b$,
202
- strC = $c$,
203
- strA < strB && strA != strC :(
204
- return $ok$
205
- ),null
206
- ),null
207
- ),null
208
- ),null
209
- ),null
210
- `
211
- await runExpression(expression)
212
- }
213
-
214
- /**
215
- * JSONObject
216
- */
217
- async function testJSONObject () {
218
- const expression = `
219
- datas = {
220
- name: "张三",
221
- 年龄: 15,
222
- },
223
- datas
224
- `
225
- await runExpression(expression)
226
- }
227
-
228
- /**
229
- * JSONArray
230
- */
231
- async function testJSONArray () {
232
- const expression = `
233
- datas = ["a","b","c"],
234
- datas
235
- `
236
- await runExpression(expression)
237
- }
238
-
239
- /**
240
- * function call
241
- */
242
- async function testFunctionCall () {
243
- const expression = `
244
- log.debug("test is ok")
245
- `
246
- await runExpression(expression)
247
- }
248
-
249
- /**
250
- * math
251
- */
252
- async function testMath () {
253
- const expression = `
254
- a = 1,
255
- b = 2,
256
- c = a + b,
257
- c = c - 1,
258
- d = 5 * 8,
259
- e = d / 10,
260
- e = e % 2,
261
- c
262
- `
263
- await runExpression(expression)
264
- }
265
-
266
- /**
267
- * string
268
- */
269
- async function testString () {
270
- const expression = `
271
- test1 = {}.toString(),
272
- log.debug(test1),
273
- a = $part1$,
274
- log.debug(a),
275
- b = "part2",
276
- log.debug(b),
277
- c = "{a}:{b}",
278
- log.debug(c),
279
- d = "{name}:张三",
280
- log.debug(d),
281
- e = "\\{name\\}:张三",
282
- log.debug(e),
283
- f = "\\"123\\"",
284
- log.debug(f),
285
- g = "\\$15.7",
286
- log.debug(g),
287
- h = $\\$15.7$,
288
- log.debug(h),
289
- i = "http:\\\\www.baidu.com",
290
- log.debug(i),
291
- j = $http://www.baidu.com$,
292
- log.debug(j)
293
- `
294
- await runExpression(expression)
295
- }
296
-
297
- /**
298
- * condition
299
- */
300
- async function testCondition () {
301
- const expression = `
302
- 1 != 1 :(
303
- throw "异常"
304
- ),null,
305
- 1 + 1 != 2 :(
306
- throw "异常"
307
- ),null,
308
- !(2 > 3) && !(3 > 2):(
309
- throw "异常"
310
- ),null,
311
- 2 > 3 :(
312
- throw "异常"
313
- ),null,
314
- !(3 > 2) :(
315
- throw "异常"
316
- ),null,
317
- y = 1 > 0,
318
- !y && 1 > 0 :(
319
- throw "异常"
320
- ),null
321
- `
322
- const data = {
323
- type: '1'
324
- }
325
- await runExpression(expression, data)
326
- }
327
-
328
- /**
329
- * throw
330
- */
331
- async function testThrow () {
332
- const expression = `
333
- data.type == 2 :(
334
- throw "error",
335
- log.debug(result)
336
- ),null
337
- `
338
- const data = {
339
- type: '1'
340
- }
341
- await runExpression(expression, data)
342
- }
343
-
344
- /**
345
- * JSONArray loop
346
- */
347
- async function testJSONArrayLoop () {
348
- const expression = `
349
- log.debug("test-JSONArray"),
350
- datas = [1,2,3,4,5],
351
- datas.each(
352
- log.debug(\${row}\$)
353
- ),
354
- log.debug("test-Set"),
355
- data.testSet.each(
356
- log.debug(\${row}\$)
357
- ),
358
- log.debug("test-Array"),
359
- data.testArray.each(
360
- log.debug(\${row}\$)
361
- )
362
- `
363
- const data = {
364
- testSet: [1, 2, 3, 4, 5],
365
- testArray: 'a|b|c'.split('\|')
366
- }
367
- await runExpression(expression, data)
368
- }
369
-
370
- /**
371
- * JSONObject loop
372
- */
373
- async function testJSONObjectLoop () {
374
- const expression = `
375
- log.debug("test-JSONObject"),
376
- datas = {name: 1, age: 2},
377
- datas.each(
378
- log.debug(\${rowKey}:{row}$)
379
- ),
380
- log.debug("test-Map"),
381
- data.testMap.each(
382
- log.debug(\${rowKey}:{row}$)
383
- )
384
- `
385
- const data = {
386
- testMap: {
387
- name: 'xxx',
388
- age: 18,
389
- gender: '男'
390
- }
391
- }
392
- await runExpression(expression, data)
393
- }
394
-
395
- /**
396
- * int loop
397
- */
398
- async function testIntLoop () {
399
- const expression = `
400
- a = 5,
401
- a.each(
402
- log.debug(row)
403
- ),
404
- (0,5).each(
405
- log.debug(row)
406
- ),
407
- null
408
- `
409
- await runExpression(expression)
410
- }
411
-
412
- /**
413
- * continue and break
414
- */
415
- async function testContinueAndBreak () {
416
- const expression = `
417
- datas = [1,2,3,4,5,6,7],
418
- datas.each(
419
- row == 3 :(
420
- continue
421
- ),row == 5:(
422
- break
423
- ),
424
- log.debug(row)
425
- )
426
- `
427
- await runExpression(expression)
428
- }
429
-
430
- /**
431
- * comment
432
- */
433
- async function testComment () {
434
- const expression = `
435
- $//排序单表查询
436
- select {items}
437
- from {tablename}
438
- where {condition}
439
- order by {orderitem}
440
- `
441
- await runExpression(expression)
442
- }
443
-
444
- /**
445
- * return
446
- */
447
- async function testReturn () {
448
- const expression = `
449
- data.type == 1 :(
450
- return "123",
451
- log.debug(123)
452
- ),(
453
- return 2
454
- ),
455
- log.debug(123)
456
- `
457
- const data = {
458
- type: 1
459
- }
460
- await runExpression(expression, data)
461
- }
462
-
463
- /**
464
- * lambda
465
- */
466
- async function testLambda () {
467
- const expression = `
468
- log.debug("进入外层逻辑,参数:{data}"),
469
- age = 13,
470
- // 声明一个lambda块
471
- lambdaObj = (data) => {
472
- index = 1,
473
- log.debug("进入lambda了"),
474
- log.debug("传入lambda块的参数:{data}"),
475
- log.debug("外层的只读参数:{age}"),
476
- return "执行lambda完成"
477
- },
478
- log.debug("age参数:{age}"),
479
- result = lambdaObj.apply({
480
- name: "江超"
481
- }),
482
- result = lambdaObj.apply({
483
- name: "大神"
484
- }),
485
- log.debug("result:{result}"),
486
- return {
487
- func: lambdaObj
488
- }
489
- `
490
- const data = {
491
- type: 1
492
- }
493
- await runExpression(expression, data)
494
- }
495
-
496
- async function runExpression (expression, data) {
497
- const program = new Program(expression)
498
- const d = program.parse()
499
- const params = {}
500
- if (data == null) {
501
- data = {}
502
- }
503
- params.data = data
504
- params.log = new LogicConsole()
505
- params.b = 5
506
- const result = await d.invoke(params)
507
- console.log(result)
508
- return result
509
- }
1
+ import Program from './core/Program'
2
+ import LogicConsole from './instances/LogicConsole'
3
+
4
+ const logicConsole = LogicConsole.getInstance()
5
+
6
+ runTest()
7
+
8
+ async function runTest () {
9
+ logicConsole.debug('1.========testValidate========')
10
+ await testValidate()
11
+ logicConsole.debug('2.========testAssert========')
12
+ await testAssert()
13
+ logicConsole.debug('3.========testTry========')
14
+ await testTry()
15
+ logicConsole.debug('4.========testPropertyType========')
16
+ await testPropertyType()
17
+ logicConsole.debug('5.========testJSONArrayIndex========')
18
+ await testJSONArrayIndex()
19
+ logicConsole.debug('6.========testArrayIndex========')
20
+ await testArrayIndex()
21
+ logicConsole.debug('7.========testCompare========')
22
+ await testCompare()
23
+ logicConsole.debug('8.========testJSONObject========')
24
+ await testJSONObject()
25
+ logicConsole.debug('9.========testJSONArray========')
26
+ await testJSONArray()
27
+ logicConsole.debug('10.========testFunctionCall========')
28
+ await testFunctionCall()
29
+ logicConsole.debug('11.========testMath========')
30
+ await testMath()
31
+ logicConsole.debug('12.========testString========')
32
+ await testString()
33
+ logicConsole.debug('13.========testCondition========')
34
+ await testCondition()
35
+ logicConsole.debug('14.========testThrow========')
36
+ await testThrow()
37
+ logicConsole.debug('15.========testJSONArrayLoop========')
38
+ await testJSONArrayLoop()
39
+ logicConsole.debug('16.========testJSONObjectLoop========')
40
+ await testJSONObjectLoop()
41
+ logicConsole.debug('17.========testIntLoop========')
42
+ await testIntLoop()
43
+ logicConsole.debug('18.========testContinueAndBreak========')
44
+ await testContinueAndBreak()
45
+ logicConsole.debug('19.========testComment========')
46
+ await testComment()
47
+ logicConsole.debug('20.========testReturn========')
48
+ await testReturn()
49
+ logicConsole.debug('21.========testLambda========')
50
+ await testLambda()
51
+ }
52
+
53
+ /**
54
+ * validate
55
+ */
56
+ async function testValidate () {
57
+ const expression = `
58
+ validate {
59
+ model: {
60
+ required: true,
61
+ },
62
+ visible: {
63
+ default: 1 + 1,
64
+ },
65
+ isAep: {
66
+ default: 3
67
+ },
68
+ testJson: {
69
+ required: true,
70
+ items: {
71
+ userid: {
72
+ required: true
73
+ }
74
+ }
75
+ },
76
+ testGroup: {
77
+ mode: "atLeastOne",
78
+ fields: [
79
+ "test1",
80
+ "test2"
81
+ ]
82
+ }
83
+ },
84
+ data.isAep == 3 :(
85
+ log.info(123)
86
+ ),null,
87
+ log.info(data)
88
+ `
89
+ const data = {
90
+ model: 'a',
91
+ test1: 'b',
92
+ isAep: null,
93
+ testJson: {
94
+ userid: {}
95
+ }
96
+ }
97
+ await runExpression(expression, data)
98
+ }
99
+
100
+ /**
101
+ * assert
102
+ */
103
+ async function testAssert () {
104
+ const expression = `
105
+ c = 1,
106
+ assert c == 1,
107
+ log.debug("ok"),
108
+ a = 1 + c,
109
+ assert a == 2,
110
+ log.debug("ok2")`
111
+ await runExpression(expression)
112
+ }
113
+
114
+ /**
115
+ * try
116
+ */
117
+ async function testTry () {
118
+ const expression = `
119
+ a = 0,
120
+ log.debug(a),
121
+ try {
122
+ assert c == 2
123
+ } catch (WebException e) {
124
+ log.debug(e),
125
+ a = 1 + 1
126
+ } catch (Exception e) {
127
+ log.debug(e),
128
+ a = 1 + 2
129
+ },
130
+ log.debug(a)
131
+ `
132
+ await runExpression(expression)
133
+ }
134
+
135
+ /**
136
+ * property
137
+ */
138
+ async function testPropertyType () {
139
+ const expression = `
140
+ a = 1,
141
+ b = 2.0,
142
+ c = {
143
+ d: 1,
144
+ e: {
145
+ str: "123",
146
+ 你好: "中国"
147
+ }
148
+ },
149
+ c.a = 1,
150
+ log.debug(c.e.你好),
151
+ log.debug(c["e"].str),
152
+ e = c.d,
153
+ f = "123",
154
+ g = [],
155
+ 名称 = "123=>",
156
+ log.debug(data.testArray[0]),
157
+ return 名称
158
+ `
159
+ const data = {
160
+ testArray: 'zhang|b|c'.split('\|')
161
+ }
162
+ await runExpression(expression, data)
163
+ }
164
+
165
+ /**
166
+ * JSONArray index
167
+ */
168
+ async function testJSONArrayIndex () {
169
+ const expression = `
170
+ a = [1,2,3,4,5],
171
+ return a[4]
172
+ `
173
+ await runExpression(expression)
174
+ }
175
+
176
+ /**
177
+ * array index
178
+ */
179
+ async function testArrayIndex () {
180
+ const expression = `
181
+ return data.a[4]
182
+ `
183
+ const data = {
184
+ a: [1, 2, 3, 4, 5]
185
+ }
186
+ await runExpression(expression, data)
187
+ }
188
+
189
+ async function testCompare () {
190
+ const expression = `
191
+ a = 0,
192
+ a >= 0 :(
193
+ a = a + 1,
194
+ b = 1,
195
+ a == b :(
196
+ c = 3.0,
197
+ a < c :(
198
+ a + 2,
199
+ a <= c :(
200
+ strA = $a$,
201
+ strB = $b$,
202
+ strC = $c$,
203
+ strA < strB && strA != strC :(
204
+ return $ok$
205
+ ),null
206
+ ),null
207
+ ),null
208
+ ),null
209
+ ),null
210
+ `
211
+ await runExpression(expression)
212
+ }
213
+
214
+ /**
215
+ * JSONObject
216
+ */
217
+ async function testJSONObject () {
218
+ const expression = `
219
+ datas = {
220
+ name: "张三",
221
+ 年龄: 15,
222
+ },
223
+ datas
224
+ `
225
+ await runExpression(expression)
226
+ }
227
+
228
+ /**
229
+ * JSONArray
230
+ */
231
+ async function testJSONArray () {
232
+ const expression = `
233
+ datas = ["a","b","c"],
234
+ datas
235
+ `
236
+ await runExpression(expression)
237
+ }
238
+
239
+ /**
240
+ * function call
241
+ */
242
+ async function testFunctionCall () {
243
+ const expression = `
244
+ log.debug("test is ok")
245
+ `
246
+ await runExpression(expression)
247
+ }
248
+
249
+ /**
250
+ * math
251
+ */
252
+ async function testMath () {
253
+ const expression = `
254
+ a = 1,
255
+ b = 2,
256
+ c = a + b,
257
+ c = c - 1,
258
+ d = 5 * 8,
259
+ e = d / 10,
260
+ e = e % 2,
261
+ c
262
+ `
263
+ await runExpression(expression)
264
+ }
265
+
266
+ /**
267
+ * string
268
+ */
269
+ async function testString () {
270
+ const expression = `
271
+ test1 = {}.toString(),
272
+ log.debug(test1),
273
+ a = $part1$,
274
+ log.debug(a),
275
+ b = "part2",
276
+ log.debug(b),
277
+ c = "{a}:{b}",
278
+ log.debug(c),
279
+ d = "{name}:张三",
280
+ log.debug(d),
281
+ e = "\\{name\\}:张三",
282
+ log.debug(e),
283
+ f = "\\"123\\"",
284
+ log.debug(f),
285
+ g = "\\$15.7",
286
+ log.debug(g),
287
+ h = $\\$15.7$,
288
+ log.debug(h),
289
+ i = "http:\\\\www.baidu.com",
290
+ log.debug(i),
291
+ j = $http://www.baidu.com$,
292
+ log.debug(j)
293
+ `
294
+ await runExpression(expression)
295
+ }
296
+
297
+ /**
298
+ * condition
299
+ */
300
+ async function testCondition () {
301
+ const expression = `
302
+ 1 != 1 :(
303
+ throw "异常"
304
+ ),null,
305
+ 1 + 1 != 2 :(
306
+ throw "异常"
307
+ ),null,
308
+ !(2 > 3) && !(3 > 2):(
309
+ throw "异常"
310
+ ),null,
311
+ 2 > 3 :(
312
+ throw "异常"
313
+ ),null,
314
+ !(3 > 2) :(
315
+ throw "异常"
316
+ ),null,
317
+ y = 1 > 0,
318
+ !y && 1 > 0 :(
319
+ throw "异常"
320
+ ),null
321
+ `
322
+ const data = {
323
+ type: '1'
324
+ }
325
+ await runExpression(expression, data)
326
+ }
327
+
328
+ /**
329
+ * throw
330
+ */
331
+ async function testThrow () {
332
+ const expression = `
333
+ data.type == 2 :(
334
+ throw "error",
335
+ log.debug(result)
336
+ ),null
337
+ `
338
+ const data = {
339
+ type: '1'
340
+ }
341
+ await runExpression(expression, data)
342
+ }
343
+
344
+ /**
345
+ * JSONArray loop
346
+ */
347
+ async function testJSONArrayLoop () {
348
+ const expression = `
349
+ log.debug("test-JSONArray"),
350
+ datas = [1,2,3,4,5],
351
+ datas.each(
352
+ log.debug(\${row}\$)
353
+ ),
354
+ log.debug("test-Set"),
355
+ data.testSet.each(
356
+ log.debug(\${row}\$)
357
+ ),
358
+ log.debug("test-Array"),
359
+ data.testArray.each(
360
+ log.debug(\${row}\$)
361
+ )
362
+ `
363
+ const data = {
364
+ testSet: [1, 2, 3, 4, 5],
365
+ testArray: 'a|b|c'.split('\|')
366
+ }
367
+ await runExpression(expression, data)
368
+ }
369
+
370
+ /**
371
+ * JSONObject loop
372
+ */
373
+ async function testJSONObjectLoop () {
374
+ const expression = `
375
+ log.debug("test-JSONObject"),
376
+ datas = {name: 1, age: 2},
377
+ datas.each(
378
+ log.debug(\${rowKey}:{row}$)
379
+ ),
380
+ log.debug("test-Map"),
381
+ data.testMap.each(
382
+ log.debug(\${rowKey}:{row}$)
383
+ )
384
+ `
385
+ const data = {
386
+ testMap: {
387
+ name: 'xxx',
388
+ age: 18,
389
+ gender: '男'
390
+ }
391
+ }
392
+ await runExpression(expression, data)
393
+ }
394
+
395
+ /**
396
+ * int loop
397
+ */
398
+ async function testIntLoop () {
399
+ const expression = `
400
+ a = 5,
401
+ a.each(
402
+ log.debug(row)
403
+ ),
404
+ (0,5).each(
405
+ log.debug(row)
406
+ ),
407
+ null
408
+ `
409
+ await runExpression(expression)
410
+ }
411
+
412
+ /**
413
+ * continue and break
414
+ */
415
+ async function testContinueAndBreak () {
416
+ const expression = `
417
+ datas = [1,2,3,4,5,6,7],
418
+ datas.each(
419
+ row == 3 :(
420
+ continue
421
+ ),row == 5:(
422
+ break
423
+ ),
424
+ log.debug(row)
425
+ )
426
+ `
427
+ await runExpression(expression)
428
+ }
429
+
430
+ /**
431
+ * comment
432
+ */
433
+ async function testComment () {
434
+ const expression = `
435
+ $//排序单表查询
436
+ select {items}
437
+ from {tablename}
438
+ where {condition}
439
+ order by {orderitem}
440
+ `
441
+ await runExpression(expression)
442
+ }
443
+
444
+ /**
445
+ * return
446
+ */
447
+ async function testReturn () {
448
+ const expression = `
449
+ data.type == 1 :(
450
+ return "123",
451
+ log.debug(123)
452
+ ),(
453
+ return 2
454
+ ),
455
+ log.debug(123)
456
+ `
457
+ const data = {
458
+ type: 1
459
+ }
460
+ await runExpression(expression, data)
461
+ }
462
+
463
+ /**
464
+ * lambda
465
+ */
466
+ async function testLambda () {
467
+ const expression = `
468
+ log.debug("进入外层逻辑,参数:{data}"),
469
+ age = 13,
470
+ // 声明一个lambda块
471
+ lambdaObj = (data) => {
472
+ index = 1,
473
+ log.debug("进入lambda了"),
474
+ log.debug("传入lambda块的参数:{data}"),
475
+ log.debug("外层的只读参数:{age}"),
476
+ return "执行lambda完成"
477
+ },
478
+ log.debug("age参数:{age}"),
479
+ result = lambdaObj.apply({
480
+ name: "江超"
481
+ }),
482
+ result = lambdaObj.apply({
483
+ name: "大神"
484
+ }),
485
+ log.debug("result:{result}"),
486
+ return {
487
+ func: lambdaObj
488
+ }
489
+ `
490
+ const data = {
491
+ type: 1
492
+ }
493
+ await runExpression(expression, data)
494
+ }
495
+
496
+ async function runExpression (expression, data) {
497
+ const program = new Program(expression)
498
+ const d = program.parse()
499
+ const params = {}
500
+ if (data == null) {
501
+ data = {}
502
+ }
503
+ params.data = data
504
+ params.log = new LogicConsole()
505
+ params.b = 5
506
+ const result = await d.invoke(params)
507
+ console.log(result)
508
+ return result
509
+ }