vue2-client 1.19.91 → 1.19.93
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/.claude/settings.local.json +30 -30
- package/.eslintrc.js +74 -74
- package/Components.md +60 -60
- package/docs/runFrontLogic/344/275/277/347/224/250/346/214/207/345/215/227.md +220 -0
- package/index.js +31 -31
- package/jest-transform-stub.js +8 -8
- package/jest.setup.js +7 -7
- package/package.json +1 -1
- package/src/assets/img/querySlotDemo.svg +15 -15
- package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
- package/src/base-client/components/common/CitySelect/index.js +3 -3
- package/src/base-client/components/common/CitySelect/index.md +109 -109
- package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
- package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
- package/src/base-client/components/common/ImagePreviewModal/ImagePreviewModal.vue +480 -480
- package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
- package/src/base-client/components/common/PersonSetting/index.js +3 -3
- package/src/base-client/components/common/Tree/Tree.vue +149 -149
- package/src/base-client/components/common/Tree/index.js +2 -2
- package/src/base-client/components/common/Upload/index.js +3 -3
- package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
- package/src/base-client/components/common/XButtons/XButtons.vue +44 -6
- package/src/base-client/components/common/XCard/XCard.vue +64 -64
- package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
- package/src/base-client/components/common/XDataDrawer/index.js +3 -3
- package/src/base-client/components/common/XDataDrawer/index.md +41 -41
- package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +671 -671
- package/src/base-client/components/common/XDescriptions/index.js +3 -3
- package/src/base-client/components/common/XDescriptions/index.md +382 -382
- package/src/base-client/components/common/XForm/index.md +178 -178
- package/src/base-client/components/common/XFormTable/demo.vue +2 -2
- package/src/base-client/components/common/XReport/print.js +186 -186
- package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
- package/src/base-client/components/common/XStepView/index.js +3 -3
- package/src/base-client/components/common/XStepView/index.md +31 -31
- package/src/base-client/components/common/XTab/XTabDemo.vue +2 -2
- package/src/base-client/components/common/XTable/CustomFuncCel.vue +1 -1
- package/src/base-client/components/common/XTable/index.md +255 -255
- package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
- package/src/base-client/plugins/Config.js +19 -19
- package/src/base-client/plugins/FrontLogicPlugin.js +6 -1
- package/src/base-client/plugins/tabs-page-plugin.js +39 -39
- package/src/components/Charts/Bar.vue +62 -62
- package/src/components/Charts/ChartCard.vue +134 -134
- package/src/components/Charts/Liquid.vue +67 -67
- package/src/components/Charts/MiniArea.vue +39 -39
- package/src/components/Charts/MiniBar.vue +39 -39
- package/src/components/Charts/MiniProgress.vue +75 -75
- package/src/components/Charts/MiniSmoothArea.vue +40 -40
- package/src/components/Charts/Radar.vue +68 -68
- package/src/components/Charts/RankList.vue +77 -77
- package/src/components/Charts/TagCloud.vue +113 -113
- package/src/components/Charts/TransferBar.vue +64 -64
- package/src/components/Charts/Trend.vue +82 -82
- package/src/components/Charts/chart.less +12 -12
- package/src/components/Charts/smooth.area.less +13 -13
- package/src/components/NumberInfo/NumberInfo.vue +54 -54
- package/src/components/NumberInfo/index.js +3 -3
- package/src/components/NumberInfo/index.less +54 -54
- package/src/components/NumberInfo/index.md +43 -43
- package/src/components/card/ChartCard.vue +79 -79
- package/src/components/chart/Bar.vue +60 -60
- package/src/components/chart/MiniArea.vue +67 -67
- package/src/components/chart/MiniBar.vue +59 -59
- package/src/components/chart/MiniProgress.vue +57 -57
- package/src/components/chart/Radar.vue +80 -80
- package/src/components/chart/RankingList.vue +60 -60
- package/src/components/chart/Trend.vue +79 -79
- package/src/components/chart/index.less +9 -9
- package/src/components/checkbox/ColorCheckbox.vue +157 -157
- package/src/components/input/IInput.vue +66 -66
- package/src/components/menu/SideMenu.vue +75 -75
- package/src/components/menu/menu.js +273 -273
- package/src/components/tool/AStepItem.vue +60 -60
- package/src/layouts/CommonLayout.vue +56 -56
- package/src/lib.js +1 -1
- package/src/logic/LogicRunner.js +136 -4
- package/src/logic/plugins/common/DateTools.js +35 -0
- package/src/logic/plugins/common/HttpTools.js +12 -10
- package/src/mock/extend/index.js +84 -84
- package/src/mock/goods/index.js +108 -108
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandle.vue +1 -1
- package/src/pages/dashboard/workplace/WorkPlace.vue +141 -141
- package/src/pages/system/dictionary/index.vue +44 -44
- package/src/pages/system/monitor/loginInfor/index.vue +37 -37
- package/src/pages/system/monitor/operLog/index.vue +37 -37
- package/src/router/async/router.map.js +1 -1
- package/src/services/api/cas.js +79 -79
- package/src/store/modules/setting.js +119 -119
- package/src/utils/authority-utils.js +85 -85
- package/src/utils/errorCode.js +6 -6
- package/src/utils/indexedDB.js +36 -2
- package/src/utils/map-utils.js +47 -47
- package/src/utils/request.js +11 -7
- package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"WebSearch",
|
|
5
|
-
"WebFetch(domain:context7.com)",
|
|
6
|
-
"Bash(npm run lint)",
|
|
7
|
-
"mcp__context7__resolve-library-id",
|
|
8
|
-
"mcp__context7__get-library-docs",
|
|
9
|
-
"WebFetch(domain:github.com)",
|
|
10
|
-
"Bash(npm run serve:*)",
|
|
11
|
-
"mcp__serena__get_current_config",
|
|
12
|
-
"mcp__serena__activate_project",
|
|
13
|
-
"mcp__serena__get_symbols_overview",
|
|
14
|
-
"mcp__serena__list_dir",
|
|
15
|
-
"mcp__serena__find_file",
|
|
16
|
-
"mcp__serena__list_memories",
|
|
17
|
-
"mcp__serena__check_onboarding_performed",
|
|
18
|
-
"mcp__serena__read_memory",
|
|
19
|
-
"mcp__serena__think_about_collected_information",
|
|
20
|
-
"mcp__sequential-thinking__sequentialthinking",
|
|
21
|
-
"Bash(npm run lint:*)",
|
|
22
|
-
"mcp__serena__find_symbol",
|
|
23
|
-
"mcp__serena__search_for_pattern",
|
|
24
|
-
"Bash(node -c:*)"
|
|
25
|
-
],
|
|
26
|
-
"deny": [],
|
|
27
|
-
"ask": [],
|
|
28
|
-
"defaultMode": "acceptEdits"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"WebSearch",
|
|
5
|
+
"WebFetch(domain:context7.com)",
|
|
6
|
+
"Bash(npm run lint)",
|
|
7
|
+
"mcp__context7__resolve-library-id",
|
|
8
|
+
"mcp__context7__get-library-docs",
|
|
9
|
+
"WebFetch(domain:github.com)",
|
|
10
|
+
"Bash(npm run serve:*)",
|
|
11
|
+
"mcp__serena__get_current_config",
|
|
12
|
+
"mcp__serena__activate_project",
|
|
13
|
+
"mcp__serena__get_symbols_overview",
|
|
14
|
+
"mcp__serena__list_dir",
|
|
15
|
+
"mcp__serena__find_file",
|
|
16
|
+
"mcp__serena__list_memories",
|
|
17
|
+
"mcp__serena__check_onboarding_performed",
|
|
18
|
+
"mcp__serena__read_memory",
|
|
19
|
+
"mcp__serena__think_about_collected_information",
|
|
20
|
+
"mcp__sequential-thinking__sequentialthinking",
|
|
21
|
+
"Bash(npm run lint:*)",
|
|
22
|
+
"mcp__serena__find_symbol",
|
|
23
|
+
"mcp__serena__search_for_pattern",
|
|
24
|
+
"Bash(node -c:*)"
|
|
25
|
+
],
|
|
26
|
+
"deny": [],
|
|
27
|
+
"ask": [],
|
|
28
|
+
"defaultMode": "acceptEdits"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/.eslintrc.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: {
|
|
4
|
-
node: true
|
|
5
|
-
},
|
|
6
|
-
// prettier 放最后,自动关闭所有与 Prettier 冲突的格式规则
|
|
7
|
-
extends: ['plugin:vue/essential', 'plugin:vue/strongly-recommended', '@vue/standard', 'prettier'],
|
|
8
|
-
rules: {
|
|
9
|
-
camelcase: 'off',
|
|
10
|
-
'comma-dangle': 'off',
|
|
11
|
-
'no-console': 'off',
|
|
12
|
-
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
13
|
-
'generator-star-spacing': 'off',
|
|
14
|
-
'no-mixed-operators': 0,
|
|
15
|
-
'vue/max-attributes-per-line': 'off',
|
|
16
|
-
'vue/attribute-hyphenation': 0,
|
|
17
|
-
'vue/html-self-closing': 0,
|
|
18
|
-
'vue/component-name-in-template-casing': 0,
|
|
19
|
-
'vue/html-closing-bracket-spacing': 0,
|
|
20
|
-
'vue/singleline-html-element-content-newline': 0,
|
|
21
|
-
'vue/no-unused-components': 0,
|
|
22
|
-
'vue/multiline-html-element-content-newline': 0,
|
|
23
|
-
'vue/no-use-v-if-with-v-for': 0,
|
|
24
|
-
'vue/html-closing-bracket-newline': 0,
|
|
25
|
-
'vue/no-parsing-error': 0,
|
|
26
|
-
'vue/name-property-casing': 0,
|
|
27
|
-
'vue/multi-word-component-names': 0,
|
|
28
|
-
'vue/no-mutating-props': 0,
|
|
29
|
-
'no-tabs': 0,
|
|
30
|
-
'multiline-ternary': 0,
|
|
31
|
-
'object-shorthand': 0,
|
|
32
|
-
quotes: [
|
|
33
|
-
2,
|
|
34
|
-
'single',
|
|
35
|
-
{
|
|
36
|
-
avoidEscape: true,
|
|
37
|
-
allowTemplateLiterals: true
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
semi: [
|
|
41
|
-
2,
|
|
42
|
-
'never',
|
|
43
|
-
{
|
|
44
|
-
beforeStatementContinuationChars: 'never'
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
'no-delete-var': 2,
|
|
48
|
-
'prefer-const': [
|
|
49
|
-
2,
|
|
50
|
-
{
|
|
51
|
-
ignoreReadBeforeAssign: false
|
|
52
|
-
}
|
|
53
|
-
],
|
|
54
|
-
'template-curly-spacing': 'off',
|
|
55
|
-
indent: 'off',
|
|
56
|
-
// 必须使用全等: false
|
|
57
|
-
eqeqeq: 0,
|
|
58
|
-
// 可以使用!! 双重否定
|
|
59
|
-
'no-extra-boolean-cast': 'off',
|
|
60
|
-
// 关闭函数名后空格检查,跟随 Prettier 默认风格 function foo()
|
|
61
|
-
'space-before-function-paren': 'off'
|
|
62
|
-
},
|
|
63
|
-
parserOptions: {
|
|
64
|
-
parser: '@babel/eslint-parser'
|
|
65
|
-
},
|
|
66
|
-
overrides: [
|
|
67
|
-
{
|
|
68
|
-
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
|
|
69
|
-
env: {
|
|
70
|
-
jest: true
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true
|
|
5
|
+
},
|
|
6
|
+
// prettier 放最后,自动关闭所有与 Prettier 冲突的格式规则
|
|
7
|
+
extends: ['plugin:vue/essential', 'plugin:vue/strongly-recommended', '@vue/standard', 'prettier'],
|
|
8
|
+
rules: {
|
|
9
|
+
camelcase: 'off',
|
|
10
|
+
'comma-dangle': 'off',
|
|
11
|
+
'no-console': 'off',
|
|
12
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
13
|
+
'generator-star-spacing': 'off',
|
|
14
|
+
'no-mixed-operators': 0,
|
|
15
|
+
'vue/max-attributes-per-line': 'off',
|
|
16
|
+
'vue/attribute-hyphenation': 0,
|
|
17
|
+
'vue/html-self-closing': 0,
|
|
18
|
+
'vue/component-name-in-template-casing': 0,
|
|
19
|
+
'vue/html-closing-bracket-spacing': 0,
|
|
20
|
+
'vue/singleline-html-element-content-newline': 0,
|
|
21
|
+
'vue/no-unused-components': 0,
|
|
22
|
+
'vue/multiline-html-element-content-newline': 0,
|
|
23
|
+
'vue/no-use-v-if-with-v-for': 0,
|
|
24
|
+
'vue/html-closing-bracket-newline': 0,
|
|
25
|
+
'vue/no-parsing-error': 0,
|
|
26
|
+
'vue/name-property-casing': 0,
|
|
27
|
+
'vue/multi-word-component-names': 0,
|
|
28
|
+
'vue/no-mutating-props': 0,
|
|
29
|
+
'no-tabs': 0,
|
|
30
|
+
'multiline-ternary': 0,
|
|
31
|
+
'object-shorthand': 0,
|
|
32
|
+
quotes: [
|
|
33
|
+
2,
|
|
34
|
+
'single',
|
|
35
|
+
{
|
|
36
|
+
avoidEscape: true,
|
|
37
|
+
allowTemplateLiterals: true
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
semi: [
|
|
41
|
+
2,
|
|
42
|
+
'never',
|
|
43
|
+
{
|
|
44
|
+
beforeStatementContinuationChars: 'never'
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
'no-delete-var': 2,
|
|
48
|
+
'prefer-const': [
|
|
49
|
+
2,
|
|
50
|
+
{
|
|
51
|
+
ignoreReadBeforeAssign: false
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
'template-curly-spacing': 'off',
|
|
55
|
+
indent: 'off',
|
|
56
|
+
// 必须使用全等: false
|
|
57
|
+
eqeqeq: 0,
|
|
58
|
+
// 可以使用!! 双重否定
|
|
59
|
+
'no-extra-boolean-cast': 'off',
|
|
60
|
+
// 关闭函数名后空格检查,跟随 Prettier 默认风格 function foo()
|
|
61
|
+
'space-before-function-paren': 'off'
|
|
62
|
+
},
|
|
63
|
+
parserOptions: {
|
|
64
|
+
parser: '@babel/eslint-parser'
|
|
65
|
+
},
|
|
66
|
+
overrides: [
|
|
67
|
+
{
|
|
68
|
+
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
|
|
69
|
+
env: {
|
|
70
|
+
jest: true
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
package/Components.md
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
# vue2基础组件库组件介绍
|
|
2
|
-
|
|
3
|
-
## XAddForm
|
|
4
|
-
|
|
5
|
-
基于XAddNativeForm二次封装的动态表单的Modal形式
|
|
6
|
-
|
|
7
|
-
[使用文档](src/base-client/components/common/XAddForm/index.md)
|
|
8
|
-
|
|
9
|
-
## XAddNativeForm
|
|
10
|
-
|
|
11
|
-
通过JSON配置动态生成的数据保存表单
|
|
12
|
-
|
|
13
|
-
[使用文档](src/base-client/components/common/XAddNativeForm/index.md)
|
|
14
|
-
|
|
15
|
-
## XBadge
|
|
16
|
-
|
|
17
|
-
对antdv的badge组件进行重封装
|
|
18
|
-
|
|
19
|
-
[使用文档](src/base-client/components/common/XBadge/index.md)
|
|
20
|
-
|
|
21
|
-
## XCard
|
|
22
|
-
|
|
23
|
-
通用数据加载状态管理容器
|
|
24
|
-
|
|
25
|
-
提供一个可以根据数据加载状态显示不同内容的通用容器
|
|
26
|
-
当loadState为loading时,显示骨架屏(加载界面)
|
|
27
|
-
当loadState为success时,显示容器内容
|
|
28
|
-
当loadState为error时,显示点击重新加载数据的提示界面
|
|
29
|
-
|
|
30
|
-
[使用文档](src/base-client/components/common/XCard/index.md)
|
|
31
|
-
|
|
32
|
-
## XForm
|
|
33
|
-
|
|
34
|
-
通过JSON配置动态生成的数据筛选查询表单
|
|
35
|
-
|
|
36
|
-
[使用文档](src/base-client/components/common/XForm/index.md)
|
|
37
|
-
|
|
38
|
-
## XTable
|
|
39
|
-
|
|
40
|
-
通过JSON配置动态生成的数据表格
|
|
41
|
-
|
|
42
|
-
[使用文档](src/base-client/components/common/XTable/index.md)
|
|
43
|
-
|
|
44
|
-
## XFormCol
|
|
45
|
-
|
|
46
|
-
适用于动态表单的可以自适应各种分辨率设备的栅格组件封装
|
|
47
|
-
|
|
48
|
-
[使用文档](src/base-client/components/common/XFormCol/index.md)
|
|
49
|
-
|
|
50
|
-
## XFormTable
|
|
51
|
-
|
|
52
|
-
对XAddForm,XForm和XTable组件的二次封装,实现通过JSON配置动态生成一个完整的实体操作页面
|
|
53
|
-
|
|
54
|
-
[使用文档](src/base-client/components/common/XFormTable/index.md)
|
|
55
|
-
|
|
56
|
-
## XImportExcel
|
|
57
|
-
|
|
58
|
-
通用的导入excel组件
|
|
59
|
-
|
|
60
|
-
[使用文档](src/base-client/components/common/XImportExcel/index.md)
|
|
1
|
+
# vue2基础组件库组件介绍
|
|
2
|
+
|
|
3
|
+
## XAddForm
|
|
4
|
+
|
|
5
|
+
基于XAddNativeForm二次封装的动态表单的Modal形式
|
|
6
|
+
|
|
7
|
+
[使用文档](src/base-client/components/common/XAddForm/index.md)
|
|
8
|
+
|
|
9
|
+
## XAddNativeForm
|
|
10
|
+
|
|
11
|
+
通过JSON配置动态生成的数据保存表单
|
|
12
|
+
|
|
13
|
+
[使用文档](src/base-client/components/common/XAddNativeForm/index.md)
|
|
14
|
+
|
|
15
|
+
## XBadge
|
|
16
|
+
|
|
17
|
+
对antdv的badge组件进行重封装
|
|
18
|
+
|
|
19
|
+
[使用文档](src/base-client/components/common/XBadge/index.md)
|
|
20
|
+
|
|
21
|
+
## XCard
|
|
22
|
+
|
|
23
|
+
通用数据加载状态管理容器
|
|
24
|
+
|
|
25
|
+
提供一个可以根据数据加载状态显示不同内容的通用容器
|
|
26
|
+
当loadState为loading时,显示骨架屏(加载界面)
|
|
27
|
+
当loadState为success时,显示容器内容
|
|
28
|
+
当loadState为error时,显示点击重新加载数据的提示界面
|
|
29
|
+
|
|
30
|
+
[使用文档](src/base-client/components/common/XCard/index.md)
|
|
31
|
+
|
|
32
|
+
## XForm
|
|
33
|
+
|
|
34
|
+
通过JSON配置动态生成的数据筛选查询表单
|
|
35
|
+
|
|
36
|
+
[使用文档](src/base-client/components/common/XForm/index.md)
|
|
37
|
+
|
|
38
|
+
## XTable
|
|
39
|
+
|
|
40
|
+
通过JSON配置动态生成的数据表格
|
|
41
|
+
|
|
42
|
+
[使用文档](src/base-client/components/common/XTable/index.md)
|
|
43
|
+
|
|
44
|
+
## XFormCol
|
|
45
|
+
|
|
46
|
+
适用于动态表单的可以自适应各种分辨率设备的栅格组件封装
|
|
47
|
+
|
|
48
|
+
[使用文档](src/base-client/components/common/XFormCol/index.md)
|
|
49
|
+
|
|
50
|
+
## XFormTable
|
|
51
|
+
|
|
52
|
+
对XAddForm,XForm和XTable组件的二次封装,实现通过JSON配置动态生成一个完整的实体操作页面
|
|
53
|
+
|
|
54
|
+
[使用文档](src/base-client/components/common/XFormTable/index.md)
|
|
55
|
+
|
|
56
|
+
## XImportExcel
|
|
57
|
+
|
|
58
|
+
通用的导入excel组件
|
|
59
|
+
|
|
60
|
+
[使用文档](src/base-client/components/common/XImportExcel/index.md)
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# $runFrontLogic 使用指南
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
`$runFrontLogic` 是前端业务逻辑的统一调用入口,由 `FrontLogicPlugin` 注册为 Vue 全局方法。它从配置中心按名称拉取 Logic 脚本,在浏览器中执行,支持操作界面组件、发起 HTTP 请求等操作。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 函数签名
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
this.$runFrontLogic(logicName, param, mode?)
|
|
13
|
+
// 等价于
|
|
14
|
+
LogicRunner.run(logicName, param, mode?)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
18
|
+
|------|------|------|------|
|
|
19
|
+
| `logicName` | `string` | ✅ | Logic 配置名称 |
|
|
20
|
+
| `param` | `object` | ✅ | 传入 Logic 脚本的参数,脚本中通过 `data.xxx` 访问 |
|
|
21
|
+
| `mode` | `string` | ❌ | 并发控制模式,见下方说明 |
|
|
22
|
+
|
|
23
|
+
**返回值**:`Promise`,resolve 值为 Logic 脚本最后一条表达式的结果。
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 运行模式(mode)
|
|
28
|
+
|
|
29
|
+
### 普通模式(默认)
|
|
30
|
+
|
|
31
|
+
不传 `mode` 参数,每次调用都独立执行,互不干扰。
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
// 适用场景:普通按钮点击、页面初始化加载
|
|
35
|
+
await this.$runFrontLogic('loadPatientInfo', { patientId: 123 })
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### ignore 模式
|
|
41
|
+
|
|
42
|
+
若同名 Logic **已在运行中**,忽略本次调用,直接返回 `null`。
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
// 适用场景:防止重复提交、防止重复初始化
|
|
46
|
+
this.$runFrontLogic('submitForm', { form: formData }, 'ignore')
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**行为**:
|
|
50
|
+
- 第一次调用:正常执行
|
|
51
|
+
- 第一次未结束时触发第二次:直接返回 `null`,不执行
|
|
52
|
+
- 第一次结束后触发第二次:正常执行
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
用户第1次点击 → 执行中...
|
|
56
|
+
用户第2次点击(第1次未结束)→ 忽略,返回 null
|
|
57
|
+
用户第3次点击(第1次已结束)→ 正常执行
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### cancel 模式
|
|
63
|
+
|
|
64
|
+
若同名 Logic **已在运行中**,中止前一次的 HTTP 请求,立即执行本次调用。
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
// 适用场景:搜索框输入联想、筛选条件变化后重新查询
|
|
68
|
+
this.$runFrontLogic('searchGroupLogic', { keyword: value }, 'cancel')
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**行为**:
|
|
72
|
+
- 第一次调用:正常执行
|
|
73
|
+
- 第一次未结束时触发第二次:**中止第一次的 HTTP 请求**,同时启动第二次执行
|
|
74
|
+
- 第二次正常完成,第一次中途抛出 `AbortError`
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
用户第1次触发 → 执行中(delay + http.post)...
|
|
78
|
+
用户第2次触发 → abort 第1次的 http 请求,同时开始第2次执行
|
|
79
|
+
第1次:http.post 抛出 AbortError,Logic 中止
|
|
80
|
+
第2次:正常完成,返回结果
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
> **注意**:cancel 只能中止**未完成的 HTTP 请求**,不能撤回已执行的 JS 代码。
|
|
84
|
+
> 若 Logic 脚本中 `http.post` 之前有 `log.info("结束")` 等语句,这些语句仍会执行。
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Logic 脚本内可用的插件
|
|
89
|
+
|
|
90
|
+
通过 `LogicRunner.run` 执行时,脚本内自动注入以下对象:
|
|
91
|
+
|
|
92
|
+
| 名称 | 说明 | 示例 |
|
|
93
|
+
|------|------|------|
|
|
94
|
+
| `data` | 本次调用的 `param` 参数 | `data.proxy`、`data.form` |
|
|
95
|
+
| `log` | 日志工具 | `log.info("消息")`、`log.debug(value)` |
|
|
96
|
+
| `ENV` | 全局环境变量(来自配置的 `$globalProp`) | `ENV.baseUrl` |
|
|
97
|
+
| `logic` | LogicRunner 自身,可嵌套调用其他 Logic | `logic.run('otherLogic', data)` |
|
|
98
|
+
| `dateTools` | 日期工具 | `dateTools.getNow2()`、`dateTools.delay(1000)` |
|
|
99
|
+
| `vueTools` | Vue 组件工具 | `vueTools.getComponent(data.proxy, 'refName')` |
|
|
100
|
+
| `http` | HTTP 请求(自动绑定 abortSignal) | `http.post(url, body)`、`http.get(url, params)` |
|
|
101
|
+
| `abortSignal` | 当前执行实例的取消信号 | `abortSignal.aborted` |
|
|
102
|
+
|
|
103
|
+
### http 插件说明
|
|
104
|
+
|
|
105
|
+
`http.post` / `http.get` 返回 `Promise`,表达式执行器会自动等待结果,可直接赋值:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
// Logic 脚本语法(表达式,逗号分隔)
|
|
109
|
+
res = http.post("/api/his/logic/searchResult", { form: data.form }),
|
|
110
|
+
log.info("result={res}")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- **自动携带认证 Token**(走统一的 axios 拦截器)
|
|
114
|
+
- **cancel 模式下自动绑定 abortSignal**,中止时 http 请求会立即取消
|
|
115
|
+
- **禁用请求去重**(Logic 中的请求是有意发起的,不应被去重拦截)
|
|
116
|
+
|
|
117
|
+
### dateTools.delay 说明
|
|
118
|
+
|
|
119
|
+
`dateTools.delay(ms)` 支持 cancel 模式中断:
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
// Logic 脚本:delay 期间如果被 cancel,会立即抛出 AbortError
|
|
123
|
+
log.info("开始"),
|
|
124
|
+
dateTools.delay(3000), // cancel 时这里会中断
|
|
125
|
+
http.post("/api/xxx", {}),
|
|
126
|
+
log.info("完成")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 调用方式
|
|
132
|
+
|
|
133
|
+
### 方式一:Vue 组件内(推荐)
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
// 组件方法或配置脚本中
|
|
137
|
+
await this.$runFrontLogic('logicName', { proxy: this })
|
|
138
|
+
|
|
139
|
+
// 带模式
|
|
140
|
+
this.$runFrontLogic('searchLogic', { keyword: val }, 'cancel')
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 方式二:XButtons 按钮配置
|
|
144
|
+
|
|
145
|
+
在按钮配置 JSON 中指定 `frontLogicName` 和 `frontLogicMode`,XButtons 组件会自动调用:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"key": "search",
|
|
150
|
+
"title": "搜索",
|
|
151
|
+
"frontLogicName": "searchGroupLogic",
|
|
152
|
+
"frontLogicMode": "cancel"
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
XButtons 会将当前组件实例(`proxy`)作为参数传入:
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
// XButtons 内部等价于:
|
|
160
|
+
await this.$runFrontLogic(item.frontLogicName, { proxy: this }, item.frontLogicMode)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**XButtons 的错误处理**:
|
|
164
|
+
- abort/cancel 导致的取消错误:**静默忽略**,不弹出提示
|
|
165
|
+
- 其他业务错误:弹出 `$message.error` 提示
|
|
166
|
+
|
|
167
|
+
### 方式三:直接使用 LogicRunner
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
import LogicRunner from '@vue2-client/logic/LogicRunner'
|
|
171
|
+
|
|
172
|
+
const result = await LogicRunner.run('logicName', { param1: value }, 'cancel')
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 错误处理
|
|
178
|
+
|
|
179
|
+
```javascript
|
|
180
|
+
try {
|
|
181
|
+
const result = await this.$runFrontLogic('logicName', params)
|
|
182
|
+
// 处理结果
|
|
183
|
+
} catch (e) {
|
|
184
|
+
// cancel 模式下被中止时,e.cause 为 AbortError / CanceledError
|
|
185
|
+
const cause = e?.cause || e
|
|
186
|
+
if (cause?.name === 'AbortError' || cause?.name === 'CanceledError' || cause?.code === 'ERR_CANCELED') {
|
|
187
|
+
// 被取消,可忽略
|
|
188
|
+
return
|
|
189
|
+
}
|
|
190
|
+
// 其他业务错误
|
|
191
|
+
this.$message.error('执行失败:' + e.message)
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
> 通过 XButtons 触发时,cancel 取消错误由 XButtons 自动静默处理,业务代码无需关心。
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 各模式对比
|
|
200
|
+
|
|
201
|
+
| 场景 | 推荐模式 | 原因 |
|
|
202
|
+
|------|----------|------|
|
|
203
|
+
| 普通按钮触发、页面初始化 | 默认(不传) | 每次独立执行 |
|
|
204
|
+
| 表单提交、防止重复操作 | `'ignore'` | 执行中时忽略重复点击 |
|
|
205
|
+
| 搜索框、筛选条件实时查询 | `'cancel'` | 新条件触发时取消旧请求 |
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 相关文件
|
|
210
|
+
|
|
211
|
+
| 文件 | 说明 |
|
|
212
|
+
|------|------|
|
|
213
|
+
| `src/base-client/plugins/FrontLogicPlugin.js` | 注册 `$runFrontLogic` 全局方法 |
|
|
214
|
+
| `src/logic/LogicRunner.js` | 核心运行器,实现三种模式 |
|
|
215
|
+
| `src/logic/plugins/index.js` | 插件注册(dateTools、vueTools、http) |
|
|
216
|
+
| `src/logic/plugins/common/HttpTools.js` | HTTP 插件(兜底单例) |
|
|
217
|
+
| `src/logic/plugins/common/DateTools.js` | 日期工具,delay 支持 abort |
|
|
218
|
+
| `src/logic/plugins/common/VueTools.js` | Vue 组件工具 |
|
|
219
|
+
| `src/base-client/components/common/XButtons/XButtons.vue` | 按钮配置驱动调用 |
|
|
220
|
+
| `docs/前端业务逻辑使用说明.md` | 表达式语法与插件详细说明 |
|
package/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
|
-
import { initRouter } from '@vue2-client/router/index.js'
|
|
3
|
-
import { initI18n } from '@vue2-client/utils/i18n'
|
|
4
|
-
import bootstrap from '@vue2-client/bootstrap'
|
|
5
|
-
import { modules } from '@vue2-client/store'
|
|
6
|
-
import '@vue2-client/theme/index.less'
|
|
7
|
-
import '@vue2-client/utils/filter'
|
|
8
|
-
import 'animate.css/source/animate.css'
|
|
9
|
-
import 'moment/locale/zh-cn'
|
|
10
|
-
import Antd from 'ant-design-vue'
|
|
11
|
-
import Viser from 'viser-vue'
|
|
12
|
-
// 插件
|
|
13
|
-
import Plugins from '@vue2-client/base-client/plugins'
|
|
14
|
-
|
|
15
|
-
const routerOptions = initRouter()
|
|
16
|
-
const i18n = initI18n('CN', 'US')
|
|
17
|
-
|
|
18
|
-
Vue.use(Antd)
|
|
19
|
-
Vue.use(Viser)
|
|
20
|
-
Vue.use(Plugins)
|
|
21
|
-
|
|
22
|
-
Vue.config.productionTip = false
|
|
23
|
-
const message = Vue.prototype.$message
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
routerOptions,
|
|
27
|
-
modules,
|
|
28
|
-
i18n,
|
|
29
|
-
message,
|
|
30
|
-
bootstrap
|
|
31
|
-
}
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import { initRouter } from '@vue2-client/router/index.js'
|
|
3
|
+
import { initI18n } from '@vue2-client/utils/i18n'
|
|
4
|
+
import bootstrap from '@vue2-client/bootstrap'
|
|
5
|
+
import { modules } from '@vue2-client/store'
|
|
6
|
+
import '@vue2-client/theme/index.less'
|
|
7
|
+
import '@vue2-client/utils/filter'
|
|
8
|
+
import 'animate.css/source/animate.css'
|
|
9
|
+
import 'moment/locale/zh-cn'
|
|
10
|
+
import Antd from 'ant-design-vue'
|
|
11
|
+
import Viser from 'viser-vue'
|
|
12
|
+
// 插件
|
|
13
|
+
import Plugins from '@vue2-client/base-client/plugins'
|
|
14
|
+
|
|
15
|
+
const routerOptions = initRouter()
|
|
16
|
+
const i18n = initI18n('CN', 'US')
|
|
17
|
+
|
|
18
|
+
Vue.use(Antd)
|
|
19
|
+
Vue.use(Viser)
|
|
20
|
+
Vue.use(Plugins)
|
|
21
|
+
|
|
22
|
+
Vue.config.productionTip = false
|
|
23
|
+
const message = Vue.prototype.$message
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
routerOptions,
|
|
27
|
+
modules,
|
|
28
|
+
i18n,
|
|
29
|
+
message,
|
|
30
|
+
bootstrap
|
|
31
|
+
}
|
package/jest-transform-stub.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
process () {
|
|
3
|
-
return 'module.exports = {};'
|
|
4
|
-
},
|
|
5
|
-
getCacheKey () {
|
|
6
|
-
return 'lessTransform'
|
|
7
|
-
},
|
|
8
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
process () {
|
|
3
|
+
return 'module.exports = {};'
|
|
4
|
+
},
|
|
5
|
+
getCacheKey () {
|
|
6
|
+
return 'lessTransform'
|
|
7
|
+
},
|
|
8
|
+
}
|
package/jest.setup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
global.matchMedia = global.matchMedia || function () {
|
|
2
|
-
return {
|
|
3
|
-
matches: false,
|
|
4
|
-
addListener: function () {},
|
|
5
|
-
removeListener: function () {}
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
global.matchMedia = global.matchMedia || function () {
|
|
2
|
+
return {
|
|
3
|
+
matches: false,
|
|
4
|
+
addListener: function () {},
|
|
5
|
+
removeListener: function () {}
|
|
6
|
+
}
|
|
7
|
+
}
|