@ebiz/designer-components 0.0.36 → 0.0.38

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.
@@ -128,13 +128,42 @@
128
128
  <EbizSFormItem label="手机号" name="phone" type="input" v-model="validateFormData.phone" />
129
129
  </EbizSForm>
130
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>
131
160
  </div>
132
161
  </template>
133
162
 
134
163
  <script setup>
135
164
  import { ref, reactive } from 'vue';
136
165
  import { EbizSForm, EbizSFormItem } from '../index';
137
- import { Card as TCard, Input as TInput, Row as TRow, Col as TCol, Button as TButton, Tabs as TTabs, TabPanel as TTabPanel } from 'tdesign-vue-next';
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';
138
167
 
139
168
  // 基础表单
140
169
  const basicFormRef = ref(null);
@@ -263,11 +292,9 @@ const apiFormData = reactive({
263
292
  });
264
293
 
265
294
  const apiConfig = {
266
- url: '/api/submit',
267
- method: 'post',
268
- headers: {
269
- 'Content-Type': 'application/json'
270
- }
295
+ key: 'userSubmit',
296
+ apiId: 'user.submit',
297
+ apiType: '3' // 对应dataService中的DATA_INSERT
271
298
  };
272
299
 
273
300
  // 表单验证演示
@@ -314,6 +341,73 @@ const validateFormRules = {
314
341
  }
315
342
  ]
316
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
+ };
317
411
  </script>
318
412
 
319
413
  <style scoped>
@@ -83,7 +83,8 @@ export default {
83
83
  { path: '/ebiz-tdesign-button-dialog', title: '弹窗按钮组件示例' },
84
84
  { path: '/ebiz-s-form', title: 'PC端表单组件示例' },
85
85
  { path: '/ebiz-map', title: '地图经纬度选择器组件示例' },
86
- { path: '/ebiz-s-data', title: 'Ebiz数据组件示例' }
86
+ { path: '/ebiz-s-data', title: 'Ebiz数据组件示例' },
87
+ { path: '/ebiz-s-dialog', title: 'Ebiz高级弹窗组件示例' }
87
88
  ]
88
89
 
89
90
  return {