jianghu-ui 1.0.7 → 1.0.8
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/dist/jianghu-ui.css +76 -84
- package/dist/jianghu-ui.js +1 -1
- package/package.json +1 -1
- package/src/components/JhDrawer/JhDrawer.vue +7 -1
- package/src/components/JhDrawerForm/JhDrawerForm.stories.js +161 -0
- package/src/components/JhForm/JhForm.vue +837 -273
- package/src/components/JhFormFields/JhFormFields.vue +9 -2
package/package.json
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
<v-divider class="jh-divider"></v-divider>
|
|
50
50
|
|
|
51
51
|
<!-- 抽屉内容 -->
|
|
52
|
-
<div class="
|
|
52
|
+
<div :class="drawerContentClass">
|
|
53
53
|
<!-- 完全自定义内容插槽 -->
|
|
54
54
|
<slot></slot>
|
|
55
55
|
</div>
|
|
@@ -131,6 +131,12 @@ export default {
|
|
|
131
131
|
type: String,
|
|
132
132
|
default: '取消'
|
|
133
133
|
},
|
|
134
|
+
|
|
135
|
+
// 抽屉内容class
|
|
136
|
+
drawerContentClass: {
|
|
137
|
+
type: String,
|
|
138
|
+
default: 'pa-4',
|
|
139
|
+
},
|
|
134
140
|
},
|
|
135
141
|
|
|
136
142
|
data() {
|
|
@@ -490,3 +490,164 @@ export const 自定义验证 = {
|
|
|
490
490
|
},
|
|
491
491
|
}),
|
|
492
492
|
};
|
|
493
|
+
|
|
494
|
+
// 初始化表单数据
|
|
495
|
+
export const 初始化表单数据 = {
|
|
496
|
+
render: () => ({
|
|
497
|
+
components: { JhDrawerForm },
|
|
498
|
+
data() {
|
|
499
|
+
return {
|
|
500
|
+
visible: false,
|
|
501
|
+
fields: [
|
|
502
|
+
{
|
|
503
|
+
key: 'username',
|
|
504
|
+
label: '用户名',
|
|
505
|
+
type: 'text',
|
|
506
|
+
rules: 'require',
|
|
507
|
+
placeholder: '请输入用户名',
|
|
508
|
+
cols: 12,
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
key: 'email',
|
|
512
|
+
label: '邮箱',
|
|
513
|
+
type: 'text',
|
|
514
|
+
rules: 'require|email',
|
|
515
|
+
placeholder: '请输入邮箱',
|
|
516
|
+
cols: 12,
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
key: 'phone',
|
|
520
|
+
label: '手机号',
|
|
521
|
+
type: 'text',
|
|
522
|
+
rules: 'phone',
|
|
523
|
+
placeholder: '请输入手机号',
|
|
524
|
+
cols: 12,
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
key: 'role',
|
|
528
|
+
label: '角色',
|
|
529
|
+
type: 'select',
|
|
530
|
+
rules: 'require',
|
|
531
|
+
options: [
|
|
532
|
+
{ text: '管理员', value: 'admin' },
|
|
533
|
+
{ text: '普通用户', value: 'user' },
|
|
534
|
+
{ text: '访客', value: 'guest' },
|
|
535
|
+
],
|
|
536
|
+
cols: 12,
|
|
537
|
+
},
|
|
538
|
+
],
|
|
539
|
+
initialData: {
|
|
540
|
+
username: '默认用户名',
|
|
541
|
+
email: 'default@example.com',
|
|
542
|
+
phone: '13800138000',
|
|
543
|
+
role: 'user',
|
|
544
|
+
},
|
|
545
|
+
};
|
|
546
|
+
},
|
|
547
|
+
template: `
|
|
548
|
+
<div>
|
|
549
|
+
<v-btn color="primary" @click="visible = true">
|
|
550
|
+
打开表单(带初始数据)
|
|
551
|
+
</v-btn>
|
|
552
|
+
<jh-drawer-form
|
|
553
|
+
v-model="visible"
|
|
554
|
+
title="用户信息"
|
|
555
|
+
:fields="fields"
|
|
556
|
+
:initial-data="initialData"
|
|
557
|
+
@confirm="handleConfirm"
|
|
558
|
+
/>
|
|
559
|
+
</div>
|
|
560
|
+
`,
|
|
561
|
+
methods: {
|
|
562
|
+
handleConfirm(data) {
|
|
563
|
+
console.log('表单数据:', data);
|
|
564
|
+
alert('提交成功!\n' + JSON.stringify(data, null, 2));
|
|
565
|
+
this.visible = false;
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
}),
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
// 异步填充数据
|
|
572
|
+
export const 异步填充数据 = {
|
|
573
|
+
render: () => ({
|
|
574
|
+
components: { JhDrawerForm },
|
|
575
|
+
data() {
|
|
576
|
+
return {
|
|
577
|
+
visible: false,
|
|
578
|
+
fields: [
|
|
579
|
+
{
|
|
580
|
+
key: 'userId',
|
|
581
|
+
label: '用户ID',
|
|
582
|
+
type: 'text',
|
|
583
|
+
rules: 'require',
|
|
584
|
+
placeholder: '请输入用户ID',
|
|
585
|
+
cols: 12,
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
key: 'username',
|
|
589
|
+
label: '用户名',
|
|
590
|
+
type: 'text',
|
|
591
|
+
rules: 'require',
|
|
592
|
+
placeholder: '请输入用户名',
|
|
593
|
+
cols: 12,
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
key: 'email',
|
|
597
|
+
label: '邮箱',
|
|
598
|
+
type: 'text',
|
|
599
|
+
rules: 'require|email',
|
|
600
|
+
placeholder: '请输入邮箱',
|
|
601
|
+
cols: 12,
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
key: 'phone',
|
|
605
|
+
label: '手机号',
|
|
606
|
+
type: 'text',
|
|
607
|
+
rules: 'phone',
|
|
608
|
+
placeholder: '请输入手机号',
|
|
609
|
+
cols: 12,
|
|
610
|
+
},
|
|
611
|
+
],
|
|
612
|
+
};
|
|
613
|
+
},
|
|
614
|
+
template: `
|
|
615
|
+
<div>
|
|
616
|
+
<v-btn color="primary" @click="openDrawer">
|
|
617
|
+
打开表单(异步填充数据)
|
|
618
|
+
</v-btn>
|
|
619
|
+
<jh-drawer-form
|
|
620
|
+
ref="drawerForm"
|
|
621
|
+
v-model="visible"
|
|
622
|
+
title="用户信息"
|
|
623
|
+
:fields="fields"
|
|
624
|
+
@confirm="handleConfirm"
|
|
625
|
+
/>
|
|
626
|
+
</div>
|
|
627
|
+
`,
|
|
628
|
+
methods: {
|
|
629
|
+
// 打开抽屉并异步填充数据
|
|
630
|
+
openDrawer() {
|
|
631
|
+
this.visible = true;
|
|
632
|
+
|
|
633
|
+
// 模拟异步请求获取数据
|
|
634
|
+
setTimeout(() => {
|
|
635
|
+
// 等待抽屉完全打开后设置数据
|
|
636
|
+
this.$nextTick(() => {
|
|
637
|
+
this.$refs.drawerForm.setFieldsValue({
|
|
638
|
+
userId: '1001',
|
|
639
|
+
username: '异步获取的用户名',
|
|
640
|
+
email: 'async@example.com',
|
|
641
|
+
phone: '13900139000',
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
}, 1000); // 模拟1秒的网络延迟
|
|
645
|
+
},
|
|
646
|
+
handleConfirm(data) {
|
|
647
|
+
console.log('表单数据:', data);
|
|
648
|
+
alert('提交成功!\n' + JSON.stringify(data, null, 2));
|
|
649
|
+
this.visible = false;
|
|
650
|
+
},
|
|
651
|
+
},
|
|
652
|
+
}),
|
|
653
|
+
};
|