af-mobile-client-vue3 1.3.11 → 1.3.13
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 +10 -0
- package/.cursorrules +60 -60
- package/.editorconfig +9 -9
- package/.env +10 -10
- package/.env.development +1 -1
- package/.env.production +1 -1
- package/.node-version +1 -1
- package/.vscode/extensions.json +12 -12
- package/.vscode/settings.json +66 -66
- package/CLAUDE.md +189 -184
- package/README.md +182 -181
- package/af-example-mobile-vue-web.iml +9 -9
- package/build/vite/index.ts +98 -98
- package/build/vite/optimize.ts +34 -34
- package/build/vite/vconsole.ts +47 -47
- package/commitlint.config.ts +32 -32
- package/compress.js +36 -36
- package/eslint.config.ts +30 -30
- package/index.html +23 -23
- package/mock/data.ts +20 -20
- package/mock/index.ts +7 -7
- package/mock/modules/prose.mock.ts +13 -13
- package/mock/modules/user.mock.ts +152 -152
- package/mock/util.ts +19 -19
- package/netlify.toml +12 -12
- package/package.json +114 -114
- package/postcss.config.ts +27 -27
- package/public/favicon.svg +4 -4
- package/public/safari-pinned-tab.svg +4 -4
- package/scripts/verifyCommit.js +19 -19
- package/src/App.vue +79 -79
- package/src/api/mock/index.ts +30 -30
- package/src/api/user/index.ts +40 -40
- package/src/assets/img/user/login/background-shadow-1.svg +20 -20
- package/src/assets/img/user/login/logo-background.svg +20 -20
- package/src/bootstrap.ts +26 -26
- package/src/components/core/BeautifulLoading/index.vue +52 -52
- package/src/components/core/ImageUploader/index.vue +244 -244
- package/src/components/core/NavBar/index.vue +53 -53
- package/src/components/core/Tabbar/index.vue +32 -32
- package/src/components/core/Uploader/index.vue +124 -124
- package/src/components/core/XGridDropOption/index.vue +154 -156
- package/src/components/core/XMultiSelect/index.vue +183 -183
- package/src/components/core/XSelect/index.vue +149 -149
- package/src/components/data/InfoDisplay/index.vue +132 -0
- package/src/components/data/UserDetail/api.ts +24 -0
- package/src/components/data/UserDetail/index.vue +539 -0
- package/src/components/data/UserDetail/recordEntries.ts +159 -0
- package/src/components/data/UserDetail/types.ts +26 -0
- package/src/components/data/XBadge/index.vue +82 -82
- package/src/components/data/XCellDetail/index.vue +105 -105
- package/src/components/data/XCellList/XCellList.md +313 -313
- package/src/components/data/XCellList/index.vue +1075 -1075
- package/src/components/data/XCellListFilter/QrScanner/index.vue +207 -207
- package/src/components/data/XCellListFilter/QrScanner/startScanAnimation.ts +53 -53
- package/src/components/data/XCellListFilter/VpnRecognition/index.vue +119 -119
- package/src/components/data/XCellListFilter/index.vue +705 -705
- package/src/components/data/XForm/index.vue +659 -659
- package/src/components/data/XFormGroup/doc/DeviceForm.vue +121 -121
- package/src/components/data/XFormGroup/doc/FormGroupDemo.vue +56 -56
- package/src/components/data/XFormGroup/doc/README.md +286 -273
- package/src/components/data/XFormGroup/doc/UserForm.vue +101 -101
- package/src/components/data/XFormGroup/index.vue +240 -240
- package/src/components/data/XFormItem/index.vue +1310 -1310
- package/src/components/data/XOlMap/README.md +227 -227
- package/src/components/data/XOlMap/XLocationPicker/index.vue +226 -225
- package/src/components/data/XOlMap/index.vue +1490 -1490
- package/src/components/data/XOlMap/types.ts +149 -149
- package/src/components/data/XOlMap/utils/wgs84ToGcj02.js +154 -154
- package/src/components/data/XReportForm/DateTimeSecondsPicker.vue +208 -208
- package/src/components/data/XReportForm/XReportFormJsonRender.vue +220 -220
- package/src/components/data/XReportForm/index.vue +1393 -1393
- package/src/components/data/XReportGrid/XAddReport/XAddReport.vue +198 -198
- package/src/components/data/XReportGrid/XAddReport/index.js +3 -3
- package/src/components/data/XReportGrid/XAddReport/index.md +53 -52
- package/src/components/data/XReportGrid/XAddReport/index.ts +10 -10
- package/src/components/data/XReportGrid/XReport.vue +960 -960
- package/src/components/data/XReportGrid/XReportDesign.vue +597 -597
- package/src/components/data/XReportGrid/XReportDrawer/XReportDrawer.vue +148 -148
- package/src/components/data/XReportGrid/XReportDrawer/index.js +3 -3
- package/src/components/data/XReportGrid/XReportDrawer/index.ts +10 -10
- package/src/components/data/XReportGrid/XReportJsonRender.vue +399 -399
- package/src/components/data/XReportGrid/XReportTrGroup.vue +592 -592
- package/src/components/data/XReportGrid/index.md +46 -42
- package/src/components/data/XSignature/index.vue +284 -285
- package/src/components/data/XTag/index.vue +10 -10
- package/src/components/layout/NormalDataLayout/index.vue +69 -69
- package/src/components/layout/TabBarLayout/index.vue +40 -40
- package/src/composables/dark.ts +5 -5
- package/src/config/routes.ts +9 -9
- package/src/constants/index.ts +2 -2
- package/src/enums/requestEnum.ts +25 -25
- package/src/expression/ExpressionRunner.ts +28 -28
- package/src/expression/TestExpression.ts +510 -510
- package/src/expression/core/Delegate.ts +116 -116
- package/src/expression/core/Expression.ts +1359 -1359
- package/src/expression/core/Program.ts +985 -985
- package/src/expression/core/Token.ts +29 -29
- package/src/expression/enums/ExpressionType.ts +81 -81
- package/src/expression/enums/TokenType.ts +11 -11
- package/src/expression/exception/BreakWayException.ts +2 -2
- package/src/expression/exception/ContinueWayException.ts +2 -2
- package/src/expression/exception/ExpressionException.ts +29 -29
- package/src/expression/exception/ReturnWayException.ts +14 -14
- package/src/expression/exception/ServiceException.ts +22 -22
- package/src/expression/instances/JSONArray.ts +52 -52
- package/src/expression/instances/JSONObject.ts +118 -118
- package/src/expression/instances/LogicConsole.ts +31 -31
- package/src/font-style/font.css +4 -4
- package/src/hooks/useBoolean.ts +26 -0
- package/src/hooks/useCommon.ts +9 -9
- package/src/hooks/useLogin.ts +97 -97
- package/src/icons/svg/check-in.svg +32 -32
- package/src/icons/svg/dark.svg +4 -4
- package/src/icons/svg/github.svg +4 -4
- package/src/icons/svg/light.svg +4 -4
- package/src/icons/svg/link.svg +4 -4
- package/src/icons/svgo.yml +22 -22
- package/src/layout/GridView/index.vue +16 -16
- package/src/layout/PageLayout.vue +9 -9
- package/src/layout/SingleLayout.vue +9 -9
- package/src/locales/en-US.json +128 -128
- package/src/locales/zh-CN.json +128 -128
- package/src/logic/LogicRunner.ts +67 -67
- package/src/logic/TestLogic.ts +13 -13
- package/src/logic/plugins/common/DateTools.ts +35 -35
- package/src/logic/plugins/common/VueTools.ts +30 -30
- package/src/logic/plugins/index.ts +7 -7
- package/src/main.ts +44 -44
- package/src/plugins/AppData.ts +38 -38
- package/src/plugins/GetLoginInfoService.ts +10 -10
- package/src/plugins/collectIcons.ts +10 -0
- package/src/plugins/index.ts +11 -11
- package/src/router/README.md +8 -8
- package/src/router/guards.ts +59 -59
- package/src/router/index.ts +35 -35
- package/src/router/invoiceRoutes.ts +33 -33
- package/src/router/routes.ts +341 -171
- package/src/router/types.ts +7 -7
- package/src/services/api/Login.ts +6 -6
- package/src/services/api/common.ts +109 -109
- package/src/services/api/index.ts +7 -7
- package/src/services/api/manage.ts +8 -8
- package/src/services/api/search.ts +16 -16
- package/src/services/api/user.ts +17 -17
- package/src/services/restTools.ts +56 -56
- package/src/services/v3Api.ts +147 -147
- package/src/stores/index.ts +11 -11
- package/src/stores/modules/counter.ts +19 -19
- package/src/stores/modules/routeCache.ts +23 -23
- package/src/stores/modules/setting.ts +76 -76
- package/src/stores/modules/user.ts +235 -235
- package/src/stores/mutation-type.ts +7 -7
- package/src/styles/app.less +36 -36
- package/src/styles/login.less +109 -109
- package/src/styles/var.less +16 -16
- package/src/types/env.d.ts +16 -16
- package/src/types/settings.ts +1 -1
- package/src/types/vue-router.d.ts +9 -9
- package/src/utils/Storage.ts +124 -124
- package/src/utils/authority-utils.ts +84 -84
- package/src/utils/common.ts +41 -41
- package/src/utils/crypto.ts +39 -39
- package/src/utils/dataUtil.ts +42 -42
- package/src/utils/dictUtil.ts +52 -52
- package/src/utils/http/index.ts +199 -199
- package/src/utils/i18n.ts +72 -72
- package/src/utils/indexedDB.ts +195 -195
- package/src/utils/inline-px-to-vw.ts +28 -28
- package/src/utils/mobileUtil.ts +34 -34
- package/src/utils/progress.ts +19 -19
- package/src/utils/queryFormDefaultRangePicker.ts +57 -57
- package/src/utils/routerUtil.ts +271 -271
- package/src/utils/runEvalFunction.ts +13 -13
- package/src/utils/secureStorage.ts +71 -71
- package/src/utils/set-page-title.ts +5 -5
- package/src/utils/validate.ts +6 -6
- package/src/utils/wechatUtil.ts +9 -9
- package/src/views/chat/index.vue +153 -153
- package/src/views/common/LoadError.vue +63 -63
- package/src/views/common/NotFound.vue +67 -67
- package/src/views/component/EvaluateRecordView/index.vue +40 -40
- package/src/views/component/IconifyView/index.vue +504 -507
- package/src/views/component/UserDetailView/UserDetailPage.vue +77 -0
- package/src/views/component/UserDetailView/index.vue +224 -0
- package/src/views/component/XCellDetailView/index.vue +217 -217
- package/src/views/component/XCellListView/index.vue +108 -147
- package/src/views/component/XFormAppraiseView/index.vue +174 -174
- package/src/views/component/XFormGroupView/index.vue +78 -91
- package/src/views/component/XFormView/index.vue +27 -107
- package/src/views/component/XOlMapView/XLocationPicker/index.vue +118 -118
- package/src/views/component/XOlMapView/index.vue +434 -434
- package/src/views/component/XOlMapView/testData.ts +64 -64
- package/src/views/component/XReportFormIframeView/index.vue +47 -47
- package/src/views/component/XReportFormView/index.vue +13 -13
- package/src/views/component/XReportGridView/index.vue +17 -17
- package/src/views/component/XRequestView/index.vue +234 -234
- package/src/views/component/XSignatureView/index.vue +50 -50
- package/src/views/component/index.vue +181 -177
- package/src/views/component/menu.vue +117 -117
- package/src/views/component/notice.vue +46 -46
- package/src/views/component/topNav.vue +36 -36
- package/src/views/invoiceShow/index.vue +61 -61
- package/src/views/user/login/ForgetPasswordForm.vue +94 -94
- package/src/views/user/login/LoginForm.vue +346 -346
- package/src/views/user/login/LoginTitle.vue +76 -76
- package/src/views/user/login/LoginWave.vue +109 -109
- package/src/views/user/login/index.vue +22 -22
- package/src/views/user/my/comm/ModifyPassword.vue +346 -346
- package/src/views/user/my/index.vue +340 -340
- package/src/views/userRecords/AbnormalAlarmRecords.vue +21 -0
- package/src/views/userRecords/CardReplacementRecords.vue +21 -0
- package/src/views/userRecords/ChangeRecords.vue +19 -0
- package/src/views/userRecords/CommandViewRecords.vue +20 -0
- package/src/views/userRecords/GasCompensationRecords.vue +20 -0
- package/src/views/userRecords/InstrumentCollectionRecords.vue +21 -0
- package/src/views/userRecords/MeterRecords.vue +20 -0
- package/src/views/userRecords/OperateRecords.vue +51 -0
- package/src/views/userRecords/OtherChargeRecords.vue +19 -0
- package/src/views/userRecords/PaymentRecords.vue +28 -0
- package/src/views/userRecords/PriceAdjustmentRecords.vue +19 -0
- package/src/views/userRecords/ReplacementRecords.vue +19 -0
- package/src/views/userRecords/SafetyRecords.vue +19 -0
- package/src/views/userRecords/TransactionRecords.vue +21 -0
- package/src/views/userRecords/TransferRecords.vue +19 -0
- package/src/views/userRecords/operateRecordDetail/index.vue +316 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/AddUserDetail.vue +124 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/AdvanceDeliveryDetail.vue +88 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/AutoAccountsCancelDetail.vue +205 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/AutoAccountsDetail.vue +192 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/BankDkDetail.vue +192 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/BankPayDetail.vue +192 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/BlacklistDetail.vue +153 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/CancellationDetail.vue +101 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/CardMeterCenterCancelDetail.vue +127 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/CardMeterCenterDetail.vue +153 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/CardOverUserDetail.vue +153 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ChangeMeterCancelDetail.vue +166 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ChangeMeterDetail.vue +205 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/DisableManageDetail.vue +127 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/EnableManageDetail.vue +114 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/FaZheChangeDetail.vue +124 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/FeeDeductionDetail.vue +153 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/GasPriceChangeDetail.vue +126 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/InputtorChangeDetail.vue +126 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/IotMeterCenterCancelDetail.vue +114 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/IotMeterCenterDetail.vue +127 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/IotOpenDetail.vue +88 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/MachineCardDetail.vue +101 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/MachineMeterCenterCancelDetail.vue +218 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/MachineMeterCenterDetail.vue +153 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/OffGasAddGasDetail.vue +140 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/OtherChargeCancelDetail.vue +127 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/OtherChargeDetail.vue +114 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/OverUserChangeDetail.vue +127 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ReBillDetail.vue +127 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/RefundDetail.vue +114 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ReplaceCardManageCancelDetail.vue +127 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ReplaceCardManageDetail.vue +114 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/SaleCardGasDetail.vue +140 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/TransferManageCancelDetail.vue +152 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/TransferManageDetail.vue +178 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/UserChangeDetail.vue +123 -0
- package/src/views/userRecords/operateRecordDetail/operateRecordDetails/WechatPayDetail.vue +192 -0
- package/src/views/userRecords/types.ts +66 -0
- package/tsconfig.json +39 -39
- package/uno.config.ts +82 -78
- package/vite.config.ts +118 -118
|
@@ -1,273 +1,286 @@
|
|
|
1
|
-
# XFormGroup 表单组组件
|
|
2
|
-
|
|
3
|
-
## 组件概述
|
|
4
|
-
|
|
5
|
-
XFormGroup 是一个基于 Vue 3 + TypeScript + Vant 4 开发的表单组组件,支持多标签页表单展示,可以通过配置实现复杂的表单组合。组件支持两种模式:普通表单模式和插槽(slot)模式。
|
|
6
|
-
|
|
7
|
-
## 功能特性
|
|
8
|
-
|
|
9
|
-
- 🏷️ **多标签页支持**:使用 Vant Tabs 组件实现标签页切换
|
|
10
|
-
- 🔧 **插槽模式**:支持通过 slot 自定义表单内容
|
|
11
|
-
- 📝 **表单验证**:支持表单数据验证和提交
|
|
12
|
-
- 🎯 **动态配置**:通过配置文件动态生成表单结构
|
|
13
|
-
- 🔄 **数据绑定**:支持表单数据的双向绑定
|
|
14
|
-
- 📱 **移动端优化**:基于 Vant 4 组件库,专为移动端设计
|
|
15
|
-
|
|
16
|
-
## 基础用法
|
|
17
|
-
|
|
18
|
-
```vue
|
|
19
|
-
// 见 FormGroupDemo.vue
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Props 参数详解
|
|
23
|
-
|
|
24
|
-
### configName
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// -
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
####
|
|
77
|
-
|
|
78
|
-
> 见 [
|
|
79
|
-
|
|
80
|
-
####
|
|
81
|
-
|
|
82
|
-
> 见 [
|
|
83
|
-
|
|
84
|
-
####
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
-
|
|
157
|
-
|
|
158
|
-
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
"
|
|
220
|
-
"
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
:
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
1
|
+
# XFormGroup 表单组组件
|
|
2
|
+
|
|
3
|
+
## 组件概述
|
|
4
|
+
|
|
5
|
+
XFormGroup 是一个基于 Vue 3 + TypeScript + Vant 4 开发的表单组组件,支持多标签页表单展示,可以通过配置实现复杂的表单组合。组件支持两种模式:普通表单模式和插槽(slot)模式。
|
|
6
|
+
|
|
7
|
+
## 功能特性
|
|
8
|
+
|
|
9
|
+
- 🏷️ **多标签页支持**:使用 Vant Tabs 组件实现标签页切换
|
|
10
|
+
- 🔧 **插槽模式**:支持通过 slot 自定义表单内容
|
|
11
|
+
- 📝 **表单验证**:支持表单数据验证和提交
|
|
12
|
+
- 🎯 **动态配置**:通过配置文件动态生成表单结构
|
|
13
|
+
- 🔄 **数据绑定**:支持表单数据的双向绑定
|
|
14
|
+
- 📱 **移动端优化**:基于 Vant 4 组件库,专为移动端设计
|
|
15
|
+
|
|
16
|
+
## 基础用法
|
|
17
|
+
|
|
18
|
+
```vue
|
|
19
|
+
// 见 FormGroupDemo.vue
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Props 参数详解
|
|
23
|
+
|
|
24
|
+
### configName
|
|
25
|
+
|
|
26
|
+
- **类型**: `string`
|
|
27
|
+
- **默认值**: `''`
|
|
28
|
+
- **说明**: 表单配置名称,用于从后端获取表单配置信息
|
|
29
|
+
- **示例**: `'appapplyuserinfoFormGroup'`
|
|
30
|
+
|
|
31
|
+
### serviceName
|
|
32
|
+
|
|
33
|
+
- **类型**: `string | undefined`
|
|
34
|
+
- **默认值**: `undefined`
|
|
35
|
+
- **说明**: 服务名称,用于指定后端服务
|
|
36
|
+
- **示例**: `'af-apply'`
|
|
37
|
+
|
|
38
|
+
### groupFormData
|
|
39
|
+
|
|
40
|
+
- **类型**: `object`
|
|
41
|
+
- **默认值**: `() => ({})`
|
|
42
|
+
- **说明**: 表单组数据,用于初始化表单数据
|
|
43
|
+
- **示例**:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
// -{
|
|
47
|
+
// - userInfo: { name: '张三', age: 25 },
|
|
48
|
+
// - deviceInfo: { deviceId: '001', status: 'active' }
|
|
49
|
+
// -}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### mode
|
|
53
|
+
|
|
54
|
+
- **类型**: `string`
|
|
55
|
+
- **默认值**: `'查询'`
|
|
56
|
+
- **说明**: `表单模式,控制表单的显示和操作模式`
|
|
57
|
+
- **可选值**: `'查询'` | `'新增'` | `'编辑'` | `'查看'`
|
|
58
|
+
|
|
59
|
+
## 插槽(Slot)使用详解
|
|
60
|
+
|
|
61
|
+
### 插槽模式配置
|
|
62
|
+
|
|
63
|
+
当配置中的 `formGroupType` 为 `'slot'` 时,组件会渲染插槽内容而不是默认的 XForm 组件。
|
|
64
|
+
|
|
65
|
+
#### 插槽参数
|
|
66
|
+
|
|
67
|
+
插槽会接收以下参数:
|
|
68
|
+
|
|
69
|
+
- **userItem/deviceItem**: 当前标签页的配置项
|
|
70
|
+
- **userFormData/deviceFormData**: 当前标签页对应的表单数据
|
|
71
|
+
- **setRef**: 注册表单实例的函数
|
|
72
|
+
- **removeRef**: 注销表单实例的函数
|
|
73
|
+
|
|
74
|
+
### 完整使用示例
|
|
75
|
+
|
|
76
|
+
#### 1. 主页面组件
|
|
77
|
+
|
|
78
|
+
> 见 [FormGroupDemo.vue](FormGroupDemo.vue)
|
|
79
|
+
|
|
80
|
+
#### 2. 用户信息表单组件
|
|
81
|
+
|
|
82
|
+
> 见 [UserForm.vue](UserForm.vue)
|
|
83
|
+
|
|
84
|
+
#### 3. 设备信息表单组件
|
|
85
|
+
|
|
86
|
+
> 见 [DeviceForm.vue](DeviceForm.vue)
|
|
87
|
+
|
|
88
|
+
#### 4. 配置结构示例
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"groups": [
|
|
93
|
+
{
|
|
94
|
+
"groupName": "userInfo",
|
|
95
|
+
"describe": "用户信息",
|
|
96
|
+
"tableName": "用户信息表",
|
|
97
|
+
"formGroupType": "slot",
|
|
98
|
+
"slotName": "user",
|
|
99
|
+
"showSubmitBtn": false
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"groupName": "deviceInfo",
|
|
103
|
+
"describe": "设备信息",
|
|
104
|
+
"tableName": "设备信息表",
|
|
105
|
+
"formGroupType": "slot",
|
|
106
|
+
"slotName": "device",
|
|
107
|
+
"showSubmitBtn": true
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"showSubmitBtn": true
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### 5. setRef 和 removeRef 工作原理
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
// XFormGroup 组件内部的实现逻辑
|
|
118
|
+
const xFormListRef = ref([])
|
|
119
|
+
|
|
120
|
+
function setRef(refValue) {
|
|
121
|
+
if (refValue && !xFormListRef.value.includes(refValue)) {
|
|
122
|
+
xFormListRef.value.push(refValue)
|
|
123
|
+
console.log('注册表单实例:', refValue.formGroupName)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function removeRef(refValue) {
|
|
128
|
+
const idx = xFormListRef.value.indexOf(refValue)
|
|
129
|
+
if (idx !== -1) {
|
|
130
|
+
xFormListRef.value.splice(idx, 1)
|
|
131
|
+
console.log('注销表单实例:', refValue.formGroupName)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function submit() {
|
|
136
|
+
const allFormData = {}
|
|
137
|
+
for (const formInstance of xFormListRef.value) {
|
|
138
|
+
try {
|
|
139
|
+
await formInstance.validate()
|
|
140
|
+
if (formInstance.formGroupName && typeof formInstance.getFormData === 'function') {
|
|
141
|
+
allFormData[formInstance.formGroupName] = formInstance.getFormData()
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
console.error('表单验证失败:', error)
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
emit('submit', allFormData)
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 关键要点
|
|
154
|
+
|
|
155
|
+
1. **必须实现的方法**:
|
|
156
|
+
- `validate()`: 表单验证方法
|
|
157
|
+
- `getFormData()`: 获取表单数据方法
|
|
158
|
+
- `formGroupName`: 表单组名称
|
|
159
|
+
2. **生命周期管理**:
|
|
160
|
+
- 在 `onMounted` 时调用 `setRef` 注册
|
|
161
|
+
- 在 `onUnmounted` 时调用 `removeRef` 注销
|
|
162
|
+
3. **数据传递**:
|
|
163
|
+
- 通过 `defineExpose` 暴露方法给父组件
|
|
164
|
+
- 通过 `props` 接收父组件传递的参数
|
|
165
|
+
4. **插槽使用**:
|
|
166
|
+
- 插槽名称必须与配置中的 `slotName` 一致
|
|
167
|
+
- 必须传递 `setRef` 和 `removeRef` 给子组件
|
|
168
|
+
|
|
169
|
+
## 事件
|
|
170
|
+
|
|
171
|
+
### submit
|
|
172
|
+
|
|
173
|
+
- **参数**: `formData: object`
|
|
174
|
+
- **说明**: 表单提交事件,当用户点击提交按钮时触发
|
|
175
|
+
- **示例**:
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
function handleSubmit(formData) {
|
|
179
|
+
console.log('表单数据:', formData)
|
|
180
|
+
// 处理表单提交逻辑
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 方法
|
|
185
|
+
|
|
186
|
+
### init(params: Form)
|
|
187
|
+
|
|
188
|
+
- **参数**: `params` - 初始化参数对象
|
|
189
|
+
- **说明**: 手动初始化组件,可以动态改变配置
|
|
190
|
+
- **示例**:
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
formGroup.value.init({
|
|
194
|
+
configName: 'newConfig',
|
|
195
|
+
serviceName: 'newService',
|
|
196
|
+
groupFormData: { ...any },
|
|
197
|
+
mode: '新增'
|
|
198
|
+
})
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### setRef(refValue)
|
|
202
|
+
|
|
203
|
+
- **参数**: `refValue` - 表单实例
|
|
204
|
+
- **说明**: 注册表单实例到组件中,用于统一管理和提交
|
|
205
|
+
|
|
206
|
+
### removeRef(refValue)
|
|
207
|
+
|
|
208
|
+
- **参数**: `refValue` - 表单实例
|
|
209
|
+
- **说明**: 从组件中注销表单实例
|
|
210
|
+
|
|
211
|
+
## 配置结构说明
|
|
212
|
+
|
|
213
|
+
### 基础配置结构
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"groups": [
|
|
218
|
+
{
|
|
219
|
+
"groupName": "userInfo",
|
|
220
|
+
"describe": "用户信息",
|
|
221
|
+
"tableName": "用户信息表",
|
|
222
|
+
"formGroupType": "form",
|
|
223
|
+
"slotName": "user",
|
|
224
|
+
"showSubmitBtn": false
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"groupName": "deviceInfo",
|
|
228
|
+
"describe": "设备信息",
|
|
229
|
+
"tableName": "设备信息表",
|
|
230
|
+
"formGroupType": "slot",
|
|
231
|
+
"slotName": "device",
|
|
232
|
+
"showSubmitBtn": true
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"showSubmitBtn": true
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 配置项说明
|
|
240
|
+
|
|
241
|
+
| 字段名 | 类型 | 说明 |
|
|
242
|
+
| ------------- | ------- | ------------------------------------------- |
|
|
243
|
+
| groupName | string | 分组名称,用于数据分组 |
|
|
244
|
+
| describe | string | 标签页显示标题 |
|
|
245
|
+
| tableName | string | 表名,当 describe 为空时作为标题 |
|
|
246
|
+
| formGroupType | string | 表单类型,'form' 为普通表单,'slot' 为插槽 |
|
|
247
|
+
| slotName | string | 插槽名称,当 formGroupType 为 'slot' 时使用 |
|
|
248
|
+
| showSubmitBtn | boolean | 是否显示提交按钮 |
|
|
249
|
+
|
|
250
|
+
## 样式定制
|
|
251
|
+
|
|
252
|
+
组件使用 Less 预处理器,可以通过以下方式定制样式:
|
|
253
|
+
|
|
254
|
+
```less
|
|
255
|
+
#x-form-group {
|
|
256
|
+
background-color: #f7f8fa;
|
|
257
|
+
padding-bottom: 10px;
|
|
258
|
+
|
|
259
|
+
.x-form-group-item {
|
|
260
|
+
margin: 20px 0;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// 自定义标签页样式
|
|
264
|
+
:deep(.van-tabs__nav) {
|
|
265
|
+
background-color: #fff;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// 自定义按钮样式
|
|
269
|
+
:deep(.van-button--primary) {
|
|
270
|
+
background-color: #1989fa;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## 注意事项
|
|
276
|
+
|
|
277
|
+
1. **插槽注册**: 使用插槽模式时,子组件必须通过 `setRef` 和 `removeRef` 注册到父组件
|
|
278
|
+
2. **数据同步**: 插槽组件需要实现 `getFormData` 方法返回表单数据
|
|
279
|
+
3. **表单验证**: 插槽组件可以实现 `validate` 方法进行表单验证
|
|
280
|
+
4. **生命周期**: 插槽组件需要在 `onMounted` 时注册,`onUnmounted` 时注销
|
|
281
|
+
5. **配置加载**: 组件会在 `onBeforeMount` 时自动加载配置,也可以通过 `init` 方法手动初始化
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## 这个文档详细介绍了 XFormGroup 组件的使用方法,特别是插槽的使用方式和各个参数的详细说明。开发者可以根据这个文档快速上手使用该组件。
|
|
286
|
+
```
|