vue2-client 1.11.6 → 1.12.2

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 (58) hide show
  1. package/.babelrc +3 -0
  2. package/babel.config.js +18 -21
  3. package/jest.config.js +22 -21
  4. package/package.json +5 -4
  5. package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +314 -314
  6. package/src/base-client/components/common/XDescriptions/demo.vue +51 -51
  7. package/src/base-client/components/common/XFormGroup/demo.vue +39 -39
  8. package/src/expression/ExpressionRunner.js +26 -0
  9. package/src/expression/TestExpression.js +509 -0
  10. package/src/expression/core/Delegate.js +115 -0
  11. package/src/expression/core/Expression.js +1358 -0
  12. package/src/expression/core/Program.js +932 -0
  13. package/src/expression/core/Token.js +27 -0
  14. package/src/expression/enums/ExpressionType.js +81 -0
  15. package/src/expression/enums/TokenType.js +11 -0
  16. package/src/expression/exception/ExpressionException.js +28 -0
  17. package/src/expression/exception/ReturnWayException.js +14 -0
  18. package/src/expression/exception/ServiceException.js +22 -0
  19. package/src/expression/instances/LogicConsole.js +44 -0
  20. package/src/expression/{core → ts/core}/Expression.ts +17 -3
  21. package/src/expression/ts/exception/BreakWayException.ts +2 -0
  22. package/src/expression/ts/exception/ContinueWayException.ts +2 -0
  23. package/src/layouts/BlankView.vue +4 -2
  24. package/src/logic/LogicRunner.js +62 -0
  25. package/src/logic/TestLogic.js +13 -0
  26. package/src/logic/plugins/common/DateTools.js +32 -0
  27. package/src/logic/plugins/index.js +5 -0
  28. package/src/logic/ts/LogicRunner.ts +67 -0
  29. package/src/logic/ts/TestLogic.ts +13 -0
  30. package/src/pages/LogicCallExample/index.vue +36 -0
  31. package/src/router/async/router.map.js +1 -0
  32. package/src/services/apiService.js +2 -1
  33. package/src/services/user.js +92 -90
  34. package/src/store/mutation-types.js +1 -0
  35. package/src/utils/EncryptUtil.js +23 -0
  36. package/src/utils/request.js +381 -362
  37. package/test/Amis.spec.js +1 -0
  38. package/test/Tree.spec.js +1 -0
  39. package/test/myDialog.spec.js +1 -0
  40. package/test/request.test.js +17 -0
  41. package/test/util.test.js +1 -0
  42. package/test/v3Api.test.js +2 -1
  43. package/tests/unit/ReportTable.spec.js +1 -0
  44. /package/src/expression/exception/{BreakWayException.ts → BreakWayException.js} +0 -0
  45. /package/src/expression/exception/{ContinueWayException.ts → ContinueWayException.js} +0 -0
  46. /package/src/expression/{ExpressionRunner.ts → ts/ExpressionRunner.ts} +0 -0
  47. /package/src/expression/{TestExpression.ts → ts/TestExpression.ts} +0 -0
  48. /package/src/expression/{core → ts/core}/Delegate.ts +0 -0
  49. /package/src/expression/{core → ts/core}/Program.ts +0 -0
  50. /package/src/expression/{core → ts/core}/Token.ts +0 -0
  51. /package/src/expression/{enums → ts/enums}/ExpressionType.ts +0 -0
  52. /package/src/expression/{enums → ts/enums}/TokenType.ts +0 -0
  53. /package/src/expression/{exception → ts/exception}/ExpressionException.ts +0 -0
  54. /package/src/expression/{exception → ts/exception}/ReturnWayException.ts +0 -0
  55. /package/src/expression/{exception → ts/exception}/ServiceException.ts +0 -0
  56. /package/src/expression/{instances → ts/instances}/JSONArray.ts +0 -0
  57. /package/src/expression/{instances → ts/instances}/JSONObject.ts +0 -0
  58. /package/src/expression/{instances → ts/instances}/LogicConsole.ts +0 -0
@@ -1,51 +1,51 @@
1
- <script>
2
- import XDescriptionsGroup from '@vue2-client/base-client/components/common/XDescriptions/XDescriptionsGroup.vue'
3
-
4
- export default {
5
- name: 'Demo',
6
- components: { XDescriptionsGroup },
7
- data () {
8
- return {
9
- visible: false,
10
- userinfo: {
11
- f_userinfo_code: '143400000003',
12
- f_gasbrand: '测试表品牌',
13
- f_address: '11'
14
- }
15
- }
16
- },
17
- methods: {
18
- open () {
19
- // runLogic('querySingleUserDetail', {
20
- // f_userinfo_code: '143400000003'
21
- // }, 'af-revenue').then(res => {
22
- // this.userinfo = res
23
- // this.visible = true
24
- // })
25
- this.visible = true
26
- }
27
- }
28
- }
29
- </script>
30
-
31
- <template>
32
- <div>
33
- <a-button @click="open">
34
- 展开详情
35
- </a-button>
36
- <a-drawer
37
- title="描述列表详情"
38
- placement="right"
39
- width="65vw"
40
- :body-style="{height:'92%'}"
41
- :visible="visible"
42
- @close="()=>{visible = false}"
43
- >
44
- <x-descriptions-group config-name="测试Config" :showLeftTab="true" :data="userinfo" service-name="af-system"/>
45
- </a-drawer>
46
- </div>
47
- </template>
48
-
49
- <style scoped lang="less">
50
-
51
- </style>
1
+ <script>
2
+ import XDescriptionsGroup from '@vue2-client/base-client/components/common/XDescriptions/XDescriptionsGroup.vue'
3
+
4
+ export default {
5
+ name: 'Demo',
6
+ components: { XDescriptionsGroup },
7
+ data () {
8
+ return {
9
+ visible: false,
10
+ userinfo: {
11
+ f_userinfo_code: '143400000003',
12
+ f_gasbrand: '测试表品牌',
13
+ f_address: '11'
14
+ }
15
+ }
16
+ },
17
+ methods: {
18
+ open () {
19
+ // runLogic('querySingleUserDetail', {
20
+ // f_userinfo_code: '143400000003'
21
+ // }, 'af-revenue').then(res => {
22
+ // this.userinfo = res
23
+ // this.visible = true
24
+ // })
25
+ this.visible = true
26
+ }
27
+ }
28
+ }
29
+ </script>
30
+
31
+ <template>
32
+ <div>
33
+ <a-button @click="open">
34
+ 展开详情
35
+ </a-button>
36
+ <a-drawer
37
+ title="描述列表详情"
38
+ placement="right"
39
+ width="65vw"
40
+ :body-style="{height:'92%'}"
41
+ :visible="visible"
42
+ @close="()=>{visible = false}"
43
+ >
44
+ <x-descriptions-group config-name="测试Config" :showLeftTab="true" :data="userinfo" service-name="af-system"/>
45
+ </a-drawer>
46
+ </div>
47
+ </template>
48
+
49
+ <style scoped lang="less">
50
+
51
+ </style>
@@ -1,39 +1,39 @@
1
- <script>
2
- import XFormGroup from '@vue2-client/base-client/components/common/XFormGroup/XFormGroup.vue'
3
- import { getConfigByNameAsync } from '@vue2-client/services/api/common'
4
-
5
- export default {
6
- name: 'Demo',
7
- components: { XFormGroup },
8
- data () {
9
- return {
10
- visible: true
11
- }
12
- },
13
- created () {
14
- getConfigByNameAsync('testFormGroup', 'af-revenue').then(res => {
15
- this.$refs.xFormGroupDemo.init({
16
- ...res,
17
- serviceName: 'af-revenue',
18
- showLeftTab: true,
19
- })
20
- })
21
- },
22
- methods: {
23
- submitForm () {
24
- this.$refs.xFormGroupDemo.onSubmit().then(res => {
25
- console.log('所有表单的结果', res)
26
- })
27
- }
28
- }
29
- }
30
- </script>
31
-
32
- <template>
33
-
34
- <x-form-group ref="xFormGroupDemo"></x-form-group>
35
- </template>
36
-
37
- <style scoped lang="less">
38
-
39
- </style>
1
+ <script>
2
+ import XFormGroup from '@vue2-client/base-client/components/common/XFormGroup/XFormGroup.vue'
3
+ import { getConfigByNameAsync } from '@vue2-client/services/api/common'
4
+
5
+ export default {
6
+ name: 'Demo',
7
+ components: { XFormGroup },
8
+ data () {
9
+ return {
10
+ visible: true
11
+ }
12
+ },
13
+ created () {
14
+ getConfigByNameAsync('testFormGroup', 'af-revenue').then(res => {
15
+ this.$refs.xFormGroupDemo.init({
16
+ ...res,
17
+ serviceName: 'af-revenue',
18
+ showLeftTab: true,
19
+ })
20
+ })
21
+ },
22
+ methods: {
23
+ submitForm () {
24
+ this.$refs.xFormGroupDemo.onSubmit().then(res => {
25
+ console.log('所有表单的结果', res)
26
+ })
27
+ }
28
+ }
29
+ }
30
+ </script>
31
+
32
+ <template>
33
+
34
+ <x-form-group ref="xFormGroupDemo"></x-form-group>
35
+ </template>
36
+
37
+ <style scoped lang="less">
38
+
39
+ </style>
@@ -0,0 +1,26 @@
1
+ import Program from './core/Program'
2
+
3
+ export default class ExpressionRunner {
4
+ /**
5
+ * Runs an expression with parameters
6
+ *
7
+ * @param source Expression source
8
+ * @param params Expression parameters
9
+ * @returns The result of the expression
10
+ */
11
+ static async run (source, params) {
12
+ const delegate = this.getDelegate(source)
13
+ return await delegate.invoke(params)
14
+ }
15
+
16
+ /**
17
+ * Gets the delegate for the expression
18
+ *
19
+ * @param source Expression source
20
+ * @returns A delegate to invoke
21
+ */
22
+ static getDelegate (source) {
23
+ // Parse the source and return a delegate
24
+ return new Program(source).parse()
25
+ }
26
+ }
@@ -0,0 +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
+ }