@ebiz/designer-components 0.0.58 → 0.0.59
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/README.md +29 -29
- package/dist/designer-components.css +1 -1
- package/dist/index.mjs +4822 -4822
- package/package.json +1 -1
- package/src/App.vue +26 -26
- package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
- package/src/apiService/mockDataService.js +115 -115
- package/src/apiService/simpleDataService.js +297 -297
- package/src/assets/base.css +86 -86
- package/src/assets/logo.svg +1 -1
- package/src/components/Button.vue +149 -149
- package/src/components/DataContainer.vue +40 -40
- package/src/components/EbizApproval.vue +332 -338
- package/src/components/EbizAutoForm.vue +596 -596
- package/src/components/EbizAvatar.vue +115 -115
- package/src/components/EbizCheckbox.vue +93 -93
- package/src/components/EbizCheckboxGroup.vue +69 -69
- package/src/components/EbizDepartmentSelector.vue +144 -144
- package/src/components/EbizDescriptions.vue +340 -340
- package/src/components/EbizDescriptionsItem.vue +47 -47
- package/src/components/EbizDetailBlock.vue +81 -81
- package/src/components/EbizDialog.vue +260 -260
- package/src/components/EbizDiv.vue +32 -32
- package/src/components/EbizDivider.vue +96 -96
- package/src/components/EbizEmployeeInfo.vue +138 -138
- package/src/components/EbizEmployeeSelector.vue +1093 -1086
- package/src/components/EbizFileUpload.vue +238 -238
- package/src/components/EbizMap.vue +541 -541
- package/src/components/EbizOkrTree.vue +99 -99
- package/src/components/EbizPageHeader.vue +95 -95
- package/src/components/EbizPagination.vue +162 -162
- package/src/components/EbizPopconfirm.vue +47 -47
- package/src/components/EbizRadio.vue +86 -86
- package/src/components/EbizRadioGroup.vue +83 -83
- package/src/components/EbizRemoteSelect.vue +232 -232
- package/src/components/EbizRouteBreadcrumb.vue +46 -46
- package/src/components/EbizSelect.vue +85 -85
- package/src/components/EbizSpace.vue +100 -100
- package/src/components/EbizStatistic.vue +149 -149
- package/src/components/EbizStatsCard.vue +113 -113
- package/src/components/EbizSwiper.vue +113 -113
- package/src/components/EbizSwiperItem.vue +13 -13
- package/src/components/EbizSwitch.vue +85 -85
- package/src/components/EbizTabHeader.vue +132 -132
- package/src/components/EbizTabPanel.vue +22 -22
- package/src/components/EbizTable.vue +469 -469
- package/src/components/EbizTableColumn.vue +116 -116
- package/src/components/EbizTableSort.vue +179 -179
- package/src/components/EbizTabs.vue +142 -142
- package/src/components/EbizTdesignButtonDialog.vue +332 -332
- package/src/components/EbizTdesignLoading.vue +107 -107
- package/src/components/EbizTimePicker.vue +143 -143
- package/src/components/EbizTitle.vue +91 -91
- package/src/components/EbizTree.vue +152 -152
- package/src/components/EbizTreeMergeTable.vue +1414 -1414
- package/src/components/EbizTreeSelector.vue +418 -418
- package/src/components/EbizVxeTable.vue +290 -290
- package/src/components/Form.vue +28 -28
- package/src/components/Home.vue +7 -7
- package/src/components/MyComponent.vue +39 -39
- package/src/components/Table.vue +45 -45
- package/src/components/TdesignAlert.vue +115 -115
- package/src/components/TdesignButton.vue +135 -135
- package/src/components/TdesignCalendar/index.vue +145 -145
- package/src/components/TdesignCard.vue +195 -195
- package/src/components/TdesignCol.vue +101 -101
- package/src/components/TdesignCollapse.vue +142 -142
- package/src/components/TdesignCollapsePanel.vue +79 -79
- package/src/components/TdesignDatePicker.vue +124 -124
- package/src/components/TdesignDescriptions.vue +74 -74
- package/src/components/TdesignDescriptionsItem.vue +50 -50
- package/src/components/TdesignDialog.vue +225 -225
- package/src/components/TdesignForm.vue +138 -138
- package/src/components/TdesignFormItem.vue +105 -105
- package/src/components/TdesignGrid.vue +55 -55
- package/src/components/TdesignIcon.vue +67 -67
- package/src/components/TdesignImage.vue +162 -162
- package/src/components/TdesignImageViewer.vue +200 -200
- package/src/components/TdesignInput.vue +242 -242
- package/src/components/TdesignSelect.vue +444 -444
- package/src/components/TdesignTag.vue +117 -117
- package/src/components/TdesignTextarea.vue +142 -142
- package/src/components/TdesignTimeline.vue +58 -58
- package/src/components/TdesignTimelineItem.vue +71 -71
- package/src/components/TdesignUpload.vue +388 -388
- package/src/components/TdesignWatermark.vue +107 -107
- package/src/components/ebiz-form/components/cascader.vue +61 -61
- package/src/components/ebiz-form/components/checkbox.vue +37 -37
- package/src/components/ebiz-form/components/city.vue +137 -137
- package/src/components/ebiz-form/components/date-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range.vue +56 -56
- package/src/components/ebiz-form/components/date.vue +52 -52
- package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/editor.vue +78 -78
- package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/file.vue +149 -149
- package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/images.vue +129 -129
- package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/img.vue +129 -129
- package/src/components/ebiz-form/components/number.vue +50 -50
- package/src/components/ebiz-form/components/radio.vue +28 -28
- package/src/components/ebiz-form/components/select.vue +119 -119
- package/src/components/ebiz-form/components/switch.vue +23 -23
- package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/text.vue +52 -52
- package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
- package/src/components/ebiz-form/components/textarea.vue +29 -29
- package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/video.vue +97 -97
- package/src/components/ebiz-form/index.vue +157 -157
- package/src/components/examples/PopconfirmExample.vue +149 -149
- package/src/components/icons/IconCommunity.vue +7 -7
- package/src/components/icons/IconDocumentation.vue +7 -7
- package/src/components/icons/IconEcosystem.vue +7 -7
- package/src/components/icons/IconSupport.vue +7 -7
- package/src/components/icons/IconTooling.vue +19 -19
- package/src/components/senior/EbizSData/index.vue +260 -260
- package/src/components/senior/EbizSDialog/index.vue +713 -713
- package/src/components/senior/EbizSForm/README.md +157 -157
- package/src/components/senior/EbizSForm/index.vue +668 -668
- package/src/components/senior/EbizSForm/item.vue +522 -522
- package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
- package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
- package/src/index.js +218 -218
- package/src/main.js +55 -55
- package/src/router/index.js +374 -374
- package/src/utils/formatCode.js +24 -24
- package/src/utils/generateImportStatement.js +52 -52
- package/src/utils/hasJsx.js +25 -25
- package/src/utils/index.js +166 -166
- package/src/utils/mergeOptions.js +29 -29
- package/src/utils/parseRequiredBlocks.js +18 -18
- package/src/utils/upload.ts +126 -126
- package/src/utils/vue-sfc-validator.js +155 -155
- package/src/views/Button.vue +23 -23
- package/src/views/CheckboxDemo.vue +104 -104
- package/src/views/DataContainer.vue +19 -19
- package/src/views/DialogDemo.vue +125 -125
- package/src/views/EbizApprovalDemo.vue +76 -76
- package/src/views/EbizAutoFormDemo.vue +129 -129
- package/src/views/EbizAvatar.vue +223 -223
- package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
- package/src/views/EbizDetailBlockDemo.vue +30 -30
- package/src/views/EbizEmployeeInfo.vue +249 -249
- package/src/views/EbizEmployeeSelector.vue +83 -83
- package/src/views/EbizMap.vue +201 -201
- package/src/views/EbizRadioDemo.vue +151 -151
- package/src/views/EbizSDataDemo.vue +136 -136
- package/src/views/EbizSDialogDemo.vue +301 -301
- package/src/views/EbizSForm/index.vue +359 -359
- package/src/views/EbizSFormDemo.vue +420 -420
- package/src/views/EbizSpace.vue +185 -185
- package/src/views/EbizSwiper.vue +157 -157
- package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
- package/src/views/Form.vue +19 -19
- package/src/views/GridDemo.vue +238 -238
- package/src/views/Home.vue +146 -146
- package/src/views/Mindmap.vue +17 -17
- package/src/views/MyComponent.vue +19 -19
- package/src/views/OkrTree.vue +19 -19
- package/src/views/PageHeaderDemo.vue +104 -104
- package/src/views/PaginationDemo.vue +96 -96
- package/src/views/PermissionBoxDemo.vue +85 -85
- package/src/views/PopconfirmDemo.vue +80 -80
- package/src/views/RemoteSelect.vue +350 -350
- package/src/views/StatisticDemo.vue +190 -190
- package/src/views/SwitchDemo.vue +79 -79
- package/src/views/Table.vue +19 -19
- package/src/views/TableDemo.vue +334 -334
- package/src/views/TableSortDemo.vue +143 -143
- package/src/views/TableView.vue +68 -68
- package/src/views/TabsDemo.vue +282 -282
- package/src/views/TagDemo.vue +101 -101
- package/src/views/TdesignAlert.vue +98 -98
- package/src/views/TdesignButton.vue +190 -190
- package/src/views/TdesignCalendar.vue +94 -94
- package/src/views/TdesignCard.vue +296 -296
- package/src/views/TdesignCollapse.vue +293 -293
- package/src/views/TdesignDatePicker.vue +187 -187
- package/src/views/TdesignDescriptions.vue +101 -101
- package/src/views/TdesignForm.vue +248 -248
- package/src/views/TdesignIcon.vue +203 -203
- package/src/views/TdesignImage.vue +215 -215
- package/src/views/TdesignImageViewer.vue +198 -198
- package/src/views/TdesignInput.vue +252 -252
- package/src/views/TdesignSelect.vue +473 -473
- package/src/views/TdesignSwiper.vue +157 -157
- package/src/views/TextareaDemo.vue +93 -93
- package/src/views/TimePickerDemo.vue +146 -146
- package/src/views/TimelineDemo.vue +160 -160
- package/src/views/Title.vue +19 -19
- package/src/views/TreeDemo.vue +254 -254
- package/src/views/TreeMergeTableDemo.vue +239 -239
- package/src/views/TreeSelectorDemo.vue +245 -245
- package/src/views/UploadDemo.vue +121 -121
- package/src/views/VxeTableDemo.vue +279 -279
- package/src/views/WatermarkDemo.vue +85 -85
@@ -1,421 +1,421 @@
|
|
1
|
-
<template>
|
2
|
-
<div class="ebiz-form-demo">
|
3
|
-
<t-card title="基础表单" hover-shadow>
|
4
|
-
<EbizSForm ref="basicFormRef" :data="basicFormData" :rules="basicFormRules">
|
5
|
-
<EbizSFormItem label="用户名" name="username">
|
6
|
-
<template #default>
|
7
|
-
<t-input v-model="basicFormData.username" placeholder="请输入用户名" />
|
8
|
-
</template>
|
9
|
-
</EbizSFormItem>
|
10
|
-
<EbizSFormItem label="密码" name="password">
|
11
|
-
<template #default>
|
12
|
-
<t-input type="password" v-model="basicFormData.password" placeholder="请输入密码" />
|
13
|
-
</template>
|
14
|
-
</EbizSFormItem>
|
15
|
-
</EbizSForm>
|
16
|
-
</t-card>
|
17
|
-
|
18
|
-
<t-card title="表单项类型演示" hover-shadow class="mt-20">
|
19
|
-
<EbizSForm ref="formRef" :data="formData" :rules="formRules" :api-config="apiConfig" label-align="right"
|
20
|
-
label-width="120px" reset-on-success :success-message="'提交成功!'">
|
21
|
-
<t-row :gutter="[20, 20]">
|
22
|
-
<t-col :span="12">
|
23
|
-
<EbizSFormItem label="输入框" name="input" type="input" v-model="formData.input" />
|
24
|
-
</t-col>
|
25
|
-
<t-col :span="12">
|
26
|
-
<EbizSFormItem label="数字输入框" name="number" type="number" v-model="formData.number" />
|
27
|
-
</t-col>
|
28
|
-
</t-row>
|
29
|
-
|
30
|
-
<t-row :gutter="[20, 20]">
|
31
|
-
<t-col :span="12">
|
32
|
-
<EbizSFormItem label="文本域" name="textarea" type="textarea" v-model="formData.textarea" />
|
33
|
-
</t-col>
|
34
|
-
<t-col :span="12">
|
35
|
-
<EbizSFormItem label="选择器" name="select" type="select" :options="selectOptions"
|
36
|
-
v-model="formData.select" />
|
37
|
-
</t-col>
|
38
|
-
</t-row>
|
39
|
-
|
40
|
-
<t-row :gutter="[20, 20]">
|
41
|
-
<t-col :span="12">
|
42
|
-
<EbizSFormItem label="日期选择器" name="date" type="date" v-model="formData.date" />
|
43
|
-
</t-col>
|
44
|
-
<t-col :span="12">
|
45
|
-
<EbizSFormItem label="时间选择器" name="time" type="time" v-model="formData.time" />
|
46
|
-
</t-col>
|
47
|
-
</t-row>
|
48
|
-
|
49
|
-
<t-row :gutter="[20, 20]">
|
50
|
-
<t-col :span="12">
|
51
|
-
<EbizSFormItem label="单选框组" name="radio" type="radio" :options="radioOptions"
|
52
|
-
v-model="formData.radio" />
|
53
|
-
</t-col>
|
54
|
-
<t-col :span="12">
|
55
|
-
<EbizSFormItem label="复选框组" name="checkbox" type="checkbox" :options="checkboxOptions"
|
56
|
-
v-model="formData.checkbox" />
|
57
|
-
</t-col>
|
58
|
-
</t-row>
|
59
|
-
|
60
|
-
<t-row :gutter="[20, 20]">
|
61
|
-
<t-col :span="12">
|
62
|
-
<EbizSFormItem label="开关" name="switch" type="switch" v-model="formData.switch" />
|
63
|
-
</t-col>
|
64
|
-
<t-col :span="12">
|
65
|
-
<EbizSFormItem label="滑块" name="slider" type="slider" :min="0" :max="100"
|
66
|
-
v-model="formData.slider" />
|
67
|
-
</t-col>
|
68
|
-
</t-row>
|
69
|
-
|
70
|
-
<t-row :gutter="[20, 20]">
|
71
|
-
<t-col :span="12">
|
72
|
-
<EbizSFormItem label="上传" name="upload" type="upload" upload-theme="image"
|
73
|
-
v-model="formData.upload" action="/api/upload" />
|
74
|
-
</t-col>
|
75
|
-
<t-col :span="12">
|
76
|
-
<EbizSFormItem label="级联选择器" name="cascader" type="cascader" :options="cascaderOptions"
|
77
|
-
v-model="formData.cascader" />
|
78
|
-
</t-col>
|
79
|
-
</t-row>
|
80
|
-
|
81
|
-
<t-row :gutter="[20, 20]">
|
82
|
-
<t-col :span="12">
|
83
|
-
<EbizSFormItem label="树形选择器" name="treeSelect" type="tree-select" :tree-data="treeData"
|
84
|
-
v-model="formData.treeSelect" />
|
85
|
-
</t-col>
|
86
|
-
<t-col :span="12">
|
87
|
-
<EbizSFormItem label="颜色选择器" name="color" type="color-picker" v-model="formData.color" />
|
88
|
-
</t-col>
|
89
|
-
</t-row>
|
90
|
-
</EbizSForm>
|
91
|
-
</t-card>
|
92
|
-
|
93
|
-
<t-card title="表单布局演示" hover-shadow class="mt-20">
|
94
|
-
<t-tabs>
|
95
|
-
<t-tab-panel value="vertical" label="垂直布局">
|
96
|
-
<EbizSForm layout="vertical" label-align="left">
|
97
|
-
<EbizSFormItem label="用户名" name="verticalUsername" type="input" />
|
98
|
-
<EbizSFormItem label="邮箱" name="verticalEmail" type="input" />
|
99
|
-
</EbizSForm>
|
100
|
-
</t-tab-panel>
|
101
|
-
<t-tab-panel value="inline" label="行内布局">
|
102
|
-
<EbizSForm layout="inline">
|
103
|
-
<EbizSFormItem label="用户名" name="inlineUsername" type="input" />
|
104
|
-
<EbizSFormItem label="邮箱" name="inlineEmail" type="input" />
|
105
|
-
<t-button theme="primary">查询</t-button>
|
106
|
-
</EbizSForm>
|
107
|
-
</t-tab-panel>
|
108
|
-
</t-tabs>
|
109
|
-
</t-card>
|
110
|
-
|
111
|
-
<t-card title="API调用演示" hover-shadow class="mt-20">
|
112
|
-
<EbizSForm ref="apiFormRef" :data="apiFormData" :api-config="apiConfig" show-result-message reset-on-success
|
113
|
-
success-message="API调用成功!">
|
114
|
-
<EbizSFormItem label="姓名" name="name" type="input" v-model="apiFormData.name" />
|
115
|
-
<EbizSFormItem label="年龄" name="age" type="number" v-model="apiFormData.age" />
|
116
|
-
<EbizSFormItem label="邮箱" name="email" type="input" v-model="apiFormData.email" />
|
117
|
-
</EbizSForm>
|
118
|
-
</t-card>
|
119
|
-
|
120
|
-
<t-card title="表单验证演示" hover-shadow class="mt-20">
|
121
|
-
<EbizSForm ref="validateFormRef" :data="validateFormData" :rules="validateFormRules" label-width="120px"
|
122
|
-
show-error-message status-icon>
|
123
|
-
<EbizSFormItem label="用户名" name="username" type="input" v-model="validateFormData.username" />
|
124
|
-
<EbizSFormItem label="密码" name="password" type="input" v-model="validateFormData.password" />
|
125
|
-
<EbizSFormItem label="确认密码" name="confirmPassword" type="input"
|
126
|
-
v-model="validateFormData.confirmPassword" />
|
127
|
-
<EbizSFormItem label="邮箱" name="email" type="input" v-model="validateFormData.email" />
|
128
|
-
<EbizSFormItem label="手机号" name="phone" type="input" v-model="validateFormData.phone" />
|
129
|
-
</EbizSForm>
|
130
|
-
</t-card>
|
131
|
-
|
132
|
-
<t-card title="详情加载与本地表单数据演示" hover-shadow class="mt-20">
|
133
|
-
<EbizSForm
|
134
|
-
ref="detailFormRef"
|
135
|
-
:data="detailFormData"
|
136
|
-
:api-config="submitApiConfig"
|
137
|
-
:detail-api-config="detailApiConfig"
|
138
|
-
show-result-message
|
139
|
-
@detail-loaded="handleDetailLoaded"
|
140
|
-
@detail-error="handleDetailError"
|
141
|
-
@success="handleSubmitSuccess"
|
142
|
-
@error="handleSubmitError"
|
143
|
-
>
|
144
|
-
<EbizSFormItem label="用户ID" name="id" type="input" v-model="detailFormData.id" disabled />
|
145
|
-
<EbizSFormItem label="姓名" name="name" type="input" v-model="detailFormData.name" />
|
146
|
-
<EbizSFormItem label="年龄" name="age" type="number" v-model="detailFormData.age" />
|
147
|
-
<EbizSFormItem label="邮箱" name="email" type="input" v-model="detailFormData.email" />
|
148
|
-
|
149
|
-
<template #buttons>
|
150
|
-
<t-space>
|
151
|
-
<t-button @click="loadDetailData">加载详情数据</t-button>
|
152
|
-
<t-button @click="clearFormData">清空表单</t-button>
|
153
|
-
<t-button @click="setCustomFormData">设置表单数据</t-button>
|
154
|
-
<t-button theme="default" type="reset">取消</t-button>
|
155
|
-
<t-button theme="primary" type="submit">提交</t-button>
|
156
|
-
</t-space>
|
157
|
-
</template>
|
158
|
-
</EbizSForm>
|
159
|
-
</t-card>
|
160
|
-
</div>
|
161
|
-
</template>
|
162
|
-
|
163
|
-
<script setup>
|
164
|
-
import { ref, reactive } from 'vue';
|
165
|
-
import { EbizSForm, EbizSFormItem } from '../index';
|
166
|
-
import { Card as TCard, Input as TInput, Row as TRow, Col as TCol, Button as TButton, Tabs as TTabs, TabPanel as TTabPanel, Space as TSpace, MessagePlugin } from 'tdesign-vue-next';
|
167
|
-
|
168
|
-
// 基础表单
|
169
|
-
const basicFormRef = ref(null);
|
170
|
-
const basicFormData = reactive({
|
171
|
-
username: '',
|
172
|
-
password: ''
|
173
|
-
});
|
174
|
-
const basicFormRules = {
|
175
|
-
username: [
|
176
|
-
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
177
|
-
{ min: 3, max: 20, message: '用户名长度应在3-20个字符之间', trigger: 'blur' }
|
178
|
-
],
|
179
|
-
password: [
|
180
|
-
{ required: true, message: '请输入密码', trigger: 'blur' },
|
181
|
-
{ min: 6, message: '密码长度应不少于6个字符', trigger: 'blur' }
|
182
|
-
]
|
183
|
-
};
|
184
|
-
|
185
|
-
// 表单项类型演示
|
186
|
-
const formRef = ref(null);
|
187
|
-
const formData = reactive({
|
188
|
-
input: '',
|
189
|
-
number: 0,
|
190
|
-
textarea: '',
|
191
|
-
select: '',
|
192
|
-
date: '',
|
193
|
-
time: '',
|
194
|
-
radio: '',
|
195
|
-
checkbox: [],
|
196
|
-
switch: false,
|
197
|
-
slider: 50,
|
198
|
-
upload: [],
|
199
|
-
cascader: [],
|
200
|
-
treeSelect: '',
|
201
|
-
color: '#1677FF'
|
202
|
-
});
|
203
|
-
const formRules = {};
|
204
|
-
|
205
|
-
// 选项数据
|
206
|
-
const selectOptions = [
|
207
|
-
{ label: '选项1', value: '1' },
|
208
|
-
{ label: '选项2', value: '2' },
|
209
|
-
{ label: '选项3', value: '3' }
|
210
|
-
];
|
211
|
-
|
212
|
-
const radioOptions = [
|
213
|
-
{ label: '选项1', value: '1' },
|
214
|
-
{ label: '选项2', value: '2' },
|
215
|
-
{ label: '选项3', value: '3' }
|
216
|
-
];
|
217
|
-
|
218
|
-
const checkboxOptions = [
|
219
|
-
{ label: '选项1', value: '1' },
|
220
|
-
{ label: '选项2', value: '2' },
|
221
|
-
{ label: '选项3', value: '3' }
|
222
|
-
];
|
223
|
-
|
224
|
-
const cascaderOptions = [
|
225
|
-
{
|
226
|
-
label: '北京',
|
227
|
-
value: 'beijing',
|
228
|
-
children: [
|
229
|
-
{
|
230
|
-
label: '朝阳区',
|
231
|
-
value: 'chaoyang'
|
232
|
-
},
|
233
|
-
{
|
234
|
-
label: '海淀区',
|
235
|
-
value: 'haidian'
|
236
|
-
}
|
237
|
-
]
|
238
|
-
},
|
239
|
-
{
|
240
|
-
label: '上海',
|
241
|
-
value: 'shanghai',
|
242
|
-
children: [
|
243
|
-
{
|
244
|
-
label: '浦东新区',
|
245
|
-
value: 'pudong'
|
246
|
-
},
|
247
|
-
{
|
248
|
-
label: '黄浦区',
|
249
|
-
value: 'huangpu'
|
250
|
-
}
|
251
|
-
]
|
252
|
-
}
|
253
|
-
];
|
254
|
-
|
255
|
-
const treeData = [
|
256
|
-
{
|
257
|
-
label: '总部',
|
258
|
-
value: 'headquarters',
|
259
|
-
children: [
|
260
|
-
{
|
261
|
-
label: '研发部',
|
262
|
-
value: 'rd'
|
263
|
-
},
|
264
|
-
{
|
265
|
-
label: '销售部',
|
266
|
-
value: 'sales'
|
267
|
-
}
|
268
|
-
]
|
269
|
-
},
|
270
|
-
{
|
271
|
-
label: '分公司',
|
272
|
-
value: 'branch',
|
273
|
-
children: [
|
274
|
-
{
|
275
|
-
label: '北京分公司',
|
276
|
-
value: 'beijing'
|
277
|
-
},
|
278
|
-
{
|
279
|
-
label: '上海分公司',
|
280
|
-
value: 'shanghai'
|
281
|
-
}
|
282
|
-
]
|
283
|
-
}
|
284
|
-
];
|
285
|
-
|
286
|
-
// API调用演示
|
287
|
-
const apiFormRef = ref(null);
|
288
|
-
const apiFormData = reactive({
|
289
|
-
name: '',
|
290
|
-
age: 0,
|
291
|
-
email: ''
|
292
|
-
});
|
293
|
-
|
294
|
-
const apiConfig = {
|
295
|
-
key: 'userSubmit',
|
296
|
-
apiId: 'user.submit',
|
297
|
-
apiType: '3' // 对应dataService中的DATA_INSERT
|
298
|
-
};
|
299
|
-
|
300
|
-
// 表单验证演示
|
301
|
-
const validateFormRef = ref(null);
|
302
|
-
const validateFormData = reactive({
|
303
|
-
username: '',
|
304
|
-
password: '',
|
305
|
-
confirmPassword: '',
|
306
|
-
email: '',
|
307
|
-
phone: ''
|
308
|
-
});
|
309
|
-
|
310
|
-
const validateFormRules = {
|
311
|
-
username: [
|
312
|
-
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
313
|
-
{ min: 3, max: 20, message: '用户名长度应在3-20个字符之间', trigger: 'blur' }
|
314
|
-
],
|
315
|
-
password: [
|
316
|
-
{ required: true, message: '请输入密码', trigger: 'blur' },
|
317
|
-
{ min: 6, message: '密码长度应不少于6个字符', trigger: 'blur' }
|
318
|
-
],
|
319
|
-
confirmPassword: [
|
320
|
-
{ required: true, message: '请再次输入密码', trigger: 'blur' },
|
321
|
-
{
|
322
|
-
validator: (val) => val === validateFormData.password,
|
323
|
-
message: '两次输入的密码不一致',
|
324
|
-
trigger: 'blur'
|
325
|
-
}
|
326
|
-
],
|
327
|
-
email: [
|
328
|
-
{ required: true, message: '请输入邮箱', trigger: 'blur' },
|
329
|
-
{
|
330
|
-
validator: (val) => /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(val),
|
331
|
-
message: '请输入正确的邮箱格式',
|
332
|
-
trigger: 'blur'
|
333
|
-
}
|
334
|
-
],
|
335
|
-
phone: [
|
336
|
-
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
337
|
-
{
|
338
|
-
validator: (val) => /^1[3-9]\d{9}$/.test(val),
|
339
|
-
message: '请输入正确的手机号格式',
|
340
|
-
trigger: 'blur'
|
341
|
-
}
|
342
|
-
]
|
343
|
-
};
|
344
|
-
|
345
|
-
// 详情加载与本地表单数据演示
|
346
|
-
const detailFormRef = ref(null);
|
347
|
-
const detailFormData = reactive({
|
348
|
-
id: '',
|
349
|
-
name: '',
|
350
|
-
age: 0,
|
351
|
-
email: ''
|
352
|
-
});
|
353
|
-
|
354
|
-
// 提交API配置
|
355
|
-
const submitApiConfig = {
|
356
|
-
key: 'userUpdate',
|
357
|
-
apiId: 'user.update',
|
358
|
-
apiType: '5' // 对应dataService中的DATA_MODIFY
|
359
|
-
};
|
360
|
-
|
361
|
-
// 详情API配置
|
362
|
-
const detailApiConfig = {
|
363
|
-
key: 'userDetail',
|
364
|
-
apiId: 'user.detail',
|
365
|
-
apiType: '1' // 对应dataService中的DETAILS_DATA
|
366
|
-
};
|
367
|
-
|
368
|
-
// 加载详情数据
|
369
|
-
const loadDetailData = () => {
|
370
|
-
const userId = prompt('请输入要加载的用户ID', '1001');
|
371
|
-
if (userId) {
|
372
|
-
// 使用表单组件的loadDetailData方法加载详情
|
373
|
-
detailFormRef.value.loadDetailData(userId);
|
374
|
-
}
|
375
|
-
};
|
376
|
-
|
377
|
-
// 清空表单数据
|
378
|
-
const clearFormData = () => {
|
379
|
-
detailFormRef.value.clearFormData();
|
380
|
-
};
|
381
|
-
|
382
|
-
// 设置自定义表单数据
|
383
|
-
const setCustomFormData = () => {
|
384
|
-
detailFormRef.value.setFormData({
|
385
|
-
id: '1002',
|
386
|
-
name: '张三',
|
387
|
-
age: 28,
|
388
|
-
email: 'zhangsan@example.com'
|
389
|
-
});
|
390
|
-
};
|
391
|
-
|
392
|
-
// 详情加载成功回调
|
393
|
-
const handleDetailLoaded = (data) => {
|
394
|
-
MessagePlugin.success(`详情数据加载成功: ID=${data.id}, 姓名=${data.name}`);
|
395
|
-
};
|
396
|
-
|
397
|
-
// 详情加载失败回调
|
398
|
-
const handleDetailError = (error) => {
|
399
|
-
MessagePlugin.error(`详情数据加载失败: ${error.message || '未知错误'}`);
|
400
|
-
};
|
401
|
-
|
402
|
-
// 表单提交成功回调
|
403
|
-
const handleSubmitSuccess = (_response) => {
|
404
|
-
MessagePlugin.success('表单提交成功');
|
405
|
-
};
|
406
|
-
|
407
|
-
// 表单提交失败回调
|
408
|
-
const handleSubmitError = (error) => {
|
409
|
-
MessagePlugin.error(`表单提交失败: ${error.message || '未知错误'}`);
|
410
|
-
};
|
411
|
-
</script>
|
412
|
-
|
413
|
-
<style scoped>
|
414
|
-
.ebiz-form-demo {
|
415
|
-
padding: 20px;
|
416
|
-
}
|
417
|
-
|
418
|
-
.mt-20 {
|
419
|
-
margin-top: 20px;
|
420
|
-
}
|
1
|
+
<template>
|
2
|
+
<div class="ebiz-form-demo">
|
3
|
+
<t-card title="基础表单" hover-shadow>
|
4
|
+
<EbizSForm ref="basicFormRef" :data="basicFormData" :rules="basicFormRules">
|
5
|
+
<EbizSFormItem label="用户名" name="username">
|
6
|
+
<template #default>
|
7
|
+
<t-input v-model="basicFormData.username" placeholder="请输入用户名" />
|
8
|
+
</template>
|
9
|
+
</EbizSFormItem>
|
10
|
+
<EbizSFormItem label="密码" name="password">
|
11
|
+
<template #default>
|
12
|
+
<t-input type="password" v-model="basicFormData.password" placeholder="请输入密码" />
|
13
|
+
</template>
|
14
|
+
</EbizSFormItem>
|
15
|
+
</EbizSForm>
|
16
|
+
</t-card>
|
17
|
+
|
18
|
+
<t-card title="表单项类型演示" hover-shadow class="mt-20">
|
19
|
+
<EbizSForm ref="formRef" :data="formData" :rules="formRules" :api-config="apiConfig" label-align="right"
|
20
|
+
label-width="120px" reset-on-success :success-message="'提交成功!'">
|
21
|
+
<t-row :gutter="[20, 20]">
|
22
|
+
<t-col :span="12">
|
23
|
+
<EbizSFormItem label="输入框" name="input" type="input" v-model="formData.input" />
|
24
|
+
</t-col>
|
25
|
+
<t-col :span="12">
|
26
|
+
<EbizSFormItem label="数字输入框" name="number" type="number" v-model="formData.number" />
|
27
|
+
</t-col>
|
28
|
+
</t-row>
|
29
|
+
|
30
|
+
<t-row :gutter="[20, 20]">
|
31
|
+
<t-col :span="12">
|
32
|
+
<EbizSFormItem label="文本域" name="textarea" type="textarea" v-model="formData.textarea" />
|
33
|
+
</t-col>
|
34
|
+
<t-col :span="12">
|
35
|
+
<EbizSFormItem label="选择器" name="select" type="select" :options="selectOptions"
|
36
|
+
v-model="formData.select" />
|
37
|
+
</t-col>
|
38
|
+
</t-row>
|
39
|
+
|
40
|
+
<t-row :gutter="[20, 20]">
|
41
|
+
<t-col :span="12">
|
42
|
+
<EbizSFormItem label="日期选择器" name="date" type="date" v-model="formData.date" />
|
43
|
+
</t-col>
|
44
|
+
<t-col :span="12">
|
45
|
+
<EbizSFormItem label="时间选择器" name="time" type="time" v-model="formData.time" />
|
46
|
+
</t-col>
|
47
|
+
</t-row>
|
48
|
+
|
49
|
+
<t-row :gutter="[20, 20]">
|
50
|
+
<t-col :span="12">
|
51
|
+
<EbizSFormItem label="单选框组" name="radio" type="radio" :options="radioOptions"
|
52
|
+
v-model="formData.radio" />
|
53
|
+
</t-col>
|
54
|
+
<t-col :span="12">
|
55
|
+
<EbizSFormItem label="复选框组" name="checkbox" type="checkbox" :options="checkboxOptions"
|
56
|
+
v-model="formData.checkbox" />
|
57
|
+
</t-col>
|
58
|
+
</t-row>
|
59
|
+
|
60
|
+
<t-row :gutter="[20, 20]">
|
61
|
+
<t-col :span="12">
|
62
|
+
<EbizSFormItem label="开关" name="switch" type="switch" v-model="formData.switch" />
|
63
|
+
</t-col>
|
64
|
+
<t-col :span="12">
|
65
|
+
<EbizSFormItem label="滑块" name="slider" type="slider" :min="0" :max="100"
|
66
|
+
v-model="formData.slider" />
|
67
|
+
</t-col>
|
68
|
+
</t-row>
|
69
|
+
|
70
|
+
<t-row :gutter="[20, 20]">
|
71
|
+
<t-col :span="12">
|
72
|
+
<EbizSFormItem label="上传" name="upload" type="upload" upload-theme="image"
|
73
|
+
v-model="formData.upload" action="/api/upload" />
|
74
|
+
</t-col>
|
75
|
+
<t-col :span="12">
|
76
|
+
<EbizSFormItem label="级联选择器" name="cascader" type="cascader" :options="cascaderOptions"
|
77
|
+
v-model="formData.cascader" />
|
78
|
+
</t-col>
|
79
|
+
</t-row>
|
80
|
+
|
81
|
+
<t-row :gutter="[20, 20]">
|
82
|
+
<t-col :span="12">
|
83
|
+
<EbizSFormItem label="树形选择器" name="treeSelect" type="tree-select" :tree-data="treeData"
|
84
|
+
v-model="formData.treeSelect" />
|
85
|
+
</t-col>
|
86
|
+
<t-col :span="12">
|
87
|
+
<EbizSFormItem label="颜色选择器" name="color" type="color-picker" v-model="formData.color" />
|
88
|
+
</t-col>
|
89
|
+
</t-row>
|
90
|
+
</EbizSForm>
|
91
|
+
</t-card>
|
92
|
+
|
93
|
+
<t-card title="表单布局演示" hover-shadow class="mt-20">
|
94
|
+
<t-tabs>
|
95
|
+
<t-tab-panel value="vertical" label="垂直布局">
|
96
|
+
<EbizSForm layout="vertical" label-align="left">
|
97
|
+
<EbizSFormItem label="用户名" name="verticalUsername" type="input" />
|
98
|
+
<EbizSFormItem label="邮箱" name="verticalEmail" type="input" />
|
99
|
+
</EbizSForm>
|
100
|
+
</t-tab-panel>
|
101
|
+
<t-tab-panel value="inline" label="行内布局">
|
102
|
+
<EbizSForm layout="inline">
|
103
|
+
<EbizSFormItem label="用户名" name="inlineUsername" type="input" />
|
104
|
+
<EbizSFormItem label="邮箱" name="inlineEmail" type="input" />
|
105
|
+
<t-button theme="primary">查询</t-button>
|
106
|
+
</EbizSForm>
|
107
|
+
</t-tab-panel>
|
108
|
+
</t-tabs>
|
109
|
+
</t-card>
|
110
|
+
|
111
|
+
<t-card title="API调用演示" hover-shadow class="mt-20">
|
112
|
+
<EbizSForm ref="apiFormRef" :data="apiFormData" :api-config="apiConfig" show-result-message reset-on-success
|
113
|
+
success-message="API调用成功!">
|
114
|
+
<EbizSFormItem label="姓名" name="name" type="input" v-model="apiFormData.name" />
|
115
|
+
<EbizSFormItem label="年龄" name="age" type="number" v-model="apiFormData.age" />
|
116
|
+
<EbizSFormItem label="邮箱" name="email" type="input" v-model="apiFormData.email" />
|
117
|
+
</EbizSForm>
|
118
|
+
</t-card>
|
119
|
+
|
120
|
+
<t-card title="表单验证演示" hover-shadow class="mt-20">
|
121
|
+
<EbizSForm ref="validateFormRef" :data="validateFormData" :rules="validateFormRules" label-width="120px"
|
122
|
+
show-error-message status-icon>
|
123
|
+
<EbizSFormItem label="用户名" name="username" type="input" v-model="validateFormData.username" />
|
124
|
+
<EbizSFormItem label="密码" name="password" type="input" v-model="validateFormData.password" />
|
125
|
+
<EbizSFormItem label="确认密码" name="confirmPassword" type="input"
|
126
|
+
v-model="validateFormData.confirmPassword" />
|
127
|
+
<EbizSFormItem label="邮箱" name="email" type="input" v-model="validateFormData.email" />
|
128
|
+
<EbizSFormItem label="手机号" name="phone" type="input" v-model="validateFormData.phone" />
|
129
|
+
</EbizSForm>
|
130
|
+
</t-card>
|
131
|
+
|
132
|
+
<t-card title="详情加载与本地表单数据演示" hover-shadow class="mt-20">
|
133
|
+
<EbizSForm
|
134
|
+
ref="detailFormRef"
|
135
|
+
:data="detailFormData"
|
136
|
+
:api-config="submitApiConfig"
|
137
|
+
:detail-api-config="detailApiConfig"
|
138
|
+
show-result-message
|
139
|
+
@detail-loaded="handleDetailLoaded"
|
140
|
+
@detail-error="handleDetailError"
|
141
|
+
@success="handleSubmitSuccess"
|
142
|
+
@error="handleSubmitError"
|
143
|
+
>
|
144
|
+
<EbizSFormItem label="用户ID" name="id" type="input" v-model="detailFormData.id" disabled />
|
145
|
+
<EbizSFormItem label="姓名" name="name" type="input" v-model="detailFormData.name" />
|
146
|
+
<EbizSFormItem label="年龄" name="age" type="number" v-model="detailFormData.age" />
|
147
|
+
<EbizSFormItem label="邮箱" name="email" type="input" v-model="detailFormData.email" />
|
148
|
+
|
149
|
+
<template #buttons>
|
150
|
+
<t-space>
|
151
|
+
<t-button @click="loadDetailData">加载详情数据</t-button>
|
152
|
+
<t-button @click="clearFormData">清空表单</t-button>
|
153
|
+
<t-button @click="setCustomFormData">设置表单数据</t-button>
|
154
|
+
<t-button theme="default" type="reset">取消</t-button>
|
155
|
+
<t-button theme="primary" type="submit">提交</t-button>
|
156
|
+
</t-space>
|
157
|
+
</template>
|
158
|
+
</EbizSForm>
|
159
|
+
</t-card>
|
160
|
+
</div>
|
161
|
+
</template>
|
162
|
+
|
163
|
+
<script setup>
|
164
|
+
import { ref, reactive } from 'vue';
|
165
|
+
import { EbizSForm, EbizSFormItem } from '../index';
|
166
|
+
import { Card as TCard, Input as TInput, Row as TRow, Col as TCol, Button as TButton, Tabs as TTabs, TabPanel as TTabPanel, Space as TSpace, MessagePlugin } from 'tdesign-vue-next';
|
167
|
+
|
168
|
+
// 基础表单
|
169
|
+
const basicFormRef = ref(null);
|
170
|
+
const basicFormData = reactive({
|
171
|
+
username: '',
|
172
|
+
password: ''
|
173
|
+
});
|
174
|
+
const basicFormRules = {
|
175
|
+
username: [
|
176
|
+
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
177
|
+
{ min: 3, max: 20, message: '用户名长度应在3-20个字符之间', trigger: 'blur' }
|
178
|
+
],
|
179
|
+
password: [
|
180
|
+
{ required: true, message: '请输入密码', trigger: 'blur' },
|
181
|
+
{ min: 6, message: '密码长度应不少于6个字符', trigger: 'blur' }
|
182
|
+
]
|
183
|
+
};
|
184
|
+
|
185
|
+
// 表单项类型演示
|
186
|
+
const formRef = ref(null);
|
187
|
+
const formData = reactive({
|
188
|
+
input: '',
|
189
|
+
number: 0,
|
190
|
+
textarea: '',
|
191
|
+
select: '',
|
192
|
+
date: '',
|
193
|
+
time: '',
|
194
|
+
radio: '',
|
195
|
+
checkbox: [],
|
196
|
+
switch: false,
|
197
|
+
slider: 50,
|
198
|
+
upload: [],
|
199
|
+
cascader: [],
|
200
|
+
treeSelect: '',
|
201
|
+
color: '#1677FF'
|
202
|
+
});
|
203
|
+
const formRules = {};
|
204
|
+
|
205
|
+
// 选项数据
|
206
|
+
const selectOptions = [
|
207
|
+
{ label: '选项1', value: '1' },
|
208
|
+
{ label: '选项2', value: '2' },
|
209
|
+
{ label: '选项3', value: '3' }
|
210
|
+
];
|
211
|
+
|
212
|
+
const radioOptions = [
|
213
|
+
{ label: '选项1', value: '1' },
|
214
|
+
{ label: '选项2', value: '2' },
|
215
|
+
{ label: '选项3', value: '3' }
|
216
|
+
];
|
217
|
+
|
218
|
+
const checkboxOptions = [
|
219
|
+
{ label: '选项1', value: '1' },
|
220
|
+
{ label: '选项2', value: '2' },
|
221
|
+
{ label: '选项3', value: '3' }
|
222
|
+
];
|
223
|
+
|
224
|
+
const cascaderOptions = [
|
225
|
+
{
|
226
|
+
label: '北京',
|
227
|
+
value: 'beijing',
|
228
|
+
children: [
|
229
|
+
{
|
230
|
+
label: '朝阳区',
|
231
|
+
value: 'chaoyang'
|
232
|
+
},
|
233
|
+
{
|
234
|
+
label: '海淀区',
|
235
|
+
value: 'haidian'
|
236
|
+
}
|
237
|
+
]
|
238
|
+
},
|
239
|
+
{
|
240
|
+
label: '上海',
|
241
|
+
value: 'shanghai',
|
242
|
+
children: [
|
243
|
+
{
|
244
|
+
label: '浦东新区',
|
245
|
+
value: 'pudong'
|
246
|
+
},
|
247
|
+
{
|
248
|
+
label: '黄浦区',
|
249
|
+
value: 'huangpu'
|
250
|
+
}
|
251
|
+
]
|
252
|
+
}
|
253
|
+
];
|
254
|
+
|
255
|
+
const treeData = [
|
256
|
+
{
|
257
|
+
label: '总部',
|
258
|
+
value: 'headquarters',
|
259
|
+
children: [
|
260
|
+
{
|
261
|
+
label: '研发部',
|
262
|
+
value: 'rd'
|
263
|
+
},
|
264
|
+
{
|
265
|
+
label: '销售部',
|
266
|
+
value: 'sales'
|
267
|
+
}
|
268
|
+
]
|
269
|
+
},
|
270
|
+
{
|
271
|
+
label: '分公司',
|
272
|
+
value: 'branch',
|
273
|
+
children: [
|
274
|
+
{
|
275
|
+
label: '北京分公司',
|
276
|
+
value: 'beijing'
|
277
|
+
},
|
278
|
+
{
|
279
|
+
label: '上海分公司',
|
280
|
+
value: 'shanghai'
|
281
|
+
}
|
282
|
+
]
|
283
|
+
}
|
284
|
+
];
|
285
|
+
|
286
|
+
// API调用演示
|
287
|
+
const apiFormRef = ref(null);
|
288
|
+
const apiFormData = reactive({
|
289
|
+
name: '',
|
290
|
+
age: 0,
|
291
|
+
email: ''
|
292
|
+
});
|
293
|
+
|
294
|
+
const apiConfig = {
|
295
|
+
key: 'userSubmit',
|
296
|
+
apiId: 'user.submit',
|
297
|
+
apiType: '3' // 对应dataService中的DATA_INSERT
|
298
|
+
};
|
299
|
+
|
300
|
+
// 表单验证演示
|
301
|
+
const validateFormRef = ref(null);
|
302
|
+
const validateFormData = reactive({
|
303
|
+
username: '',
|
304
|
+
password: '',
|
305
|
+
confirmPassword: '',
|
306
|
+
email: '',
|
307
|
+
phone: ''
|
308
|
+
});
|
309
|
+
|
310
|
+
const validateFormRules = {
|
311
|
+
username: [
|
312
|
+
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
313
|
+
{ min: 3, max: 20, message: '用户名长度应在3-20个字符之间', trigger: 'blur' }
|
314
|
+
],
|
315
|
+
password: [
|
316
|
+
{ required: true, message: '请输入密码', trigger: 'blur' },
|
317
|
+
{ min: 6, message: '密码长度应不少于6个字符', trigger: 'blur' }
|
318
|
+
],
|
319
|
+
confirmPassword: [
|
320
|
+
{ required: true, message: '请再次输入密码', trigger: 'blur' },
|
321
|
+
{
|
322
|
+
validator: (val) => val === validateFormData.password,
|
323
|
+
message: '两次输入的密码不一致',
|
324
|
+
trigger: 'blur'
|
325
|
+
}
|
326
|
+
],
|
327
|
+
email: [
|
328
|
+
{ required: true, message: '请输入邮箱', trigger: 'blur' },
|
329
|
+
{
|
330
|
+
validator: (val) => /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(val),
|
331
|
+
message: '请输入正确的邮箱格式',
|
332
|
+
trigger: 'blur'
|
333
|
+
}
|
334
|
+
],
|
335
|
+
phone: [
|
336
|
+
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
337
|
+
{
|
338
|
+
validator: (val) => /^1[3-9]\d{9}$/.test(val),
|
339
|
+
message: '请输入正确的手机号格式',
|
340
|
+
trigger: 'blur'
|
341
|
+
}
|
342
|
+
]
|
343
|
+
};
|
344
|
+
|
345
|
+
// 详情加载与本地表单数据演示
|
346
|
+
const detailFormRef = ref(null);
|
347
|
+
const detailFormData = reactive({
|
348
|
+
id: '',
|
349
|
+
name: '',
|
350
|
+
age: 0,
|
351
|
+
email: ''
|
352
|
+
});
|
353
|
+
|
354
|
+
// 提交API配置
|
355
|
+
const submitApiConfig = {
|
356
|
+
key: 'userUpdate',
|
357
|
+
apiId: 'user.update',
|
358
|
+
apiType: '5' // 对应dataService中的DATA_MODIFY
|
359
|
+
};
|
360
|
+
|
361
|
+
// 详情API配置
|
362
|
+
const detailApiConfig = {
|
363
|
+
key: 'userDetail',
|
364
|
+
apiId: 'user.detail',
|
365
|
+
apiType: '1' // 对应dataService中的DETAILS_DATA
|
366
|
+
};
|
367
|
+
|
368
|
+
// 加载详情数据
|
369
|
+
const loadDetailData = () => {
|
370
|
+
const userId = prompt('请输入要加载的用户ID', '1001');
|
371
|
+
if (userId) {
|
372
|
+
// 使用表单组件的loadDetailData方法加载详情
|
373
|
+
detailFormRef.value.loadDetailData(userId);
|
374
|
+
}
|
375
|
+
};
|
376
|
+
|
377
|
+
// 清空表单数据
|
378
|
+
const clearFormData = () => {
|
379
|
+
detailFormRef.value.clearFormData();
|
380
|
+
};
|
381
|
+
|
382
|
+
// 设置自定义表单数据
|
383
|
+
const setCustomFormData = () => {
|
384
|
+
detailFormRef.value.setFormData({
|
385
|
+
id: '1002',
|
386
|
+
name: '张三',
|
387
|
+
age: 28,
|
388
|
+
email: 'zhangsan@example.com'
|
389
|
+
});
|
390
|
+
};
|
391
|
+
|
392
|
+
// 详情加载成功回调
|
393
|
+
const handleDetailLoaded = (data) => {
|
394
|
+
MessagePlugin.success(`详情数据加载成功: ID=${data.id}, 姓名=${data.name}`);
|
395
|
+
};
|
396
|
+
|
397
|
+
// 详情加载失败回调
|
398
|
+
const handleDetailError = (error) => {
|
399
|
+
MessagePlugin.error(`详情数据加载失败: ${error.message || '未知错误'}`);
|
400
|
+
};
|
401
|
+
|
402
|
+
// 表单提交成功回调
|
403
|
+
const handleSubmitSuccess = (_response) => {
|
404
|
+
MessagePlugin.success('表单提交成功');
|
405
|
+
};
|
406
|
+
|
407
|
+
// 表单提交失败回调
|
408
|
+
const handleSubmitError = (error) => {
|
409
|
+
MessagePlugin.error(`表单提交失败: ${error.message || '未知错误'}`);
|
410
|
+
};
|
411
|
+
</script>
|
412
|
+
|
413
|
+
<style scoped>
|
414
|
+
.ebiz-form-demo {
|
415
|
+
padding: 20px;
|
416
|
+
}
|
417
|
+
|
418
|
+
.mt-20 {
|
419
|
+
margin-top: 20px;
|
420
|
+
}
|
421
421
|
</style>
|