jianghu-ui 1.0.1
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 +376 -0
- package/dist/jianghu-ui.css +2318 -0
- package/dist/jianghu-ui.js +2 -0
- package/dist/jianghu-ui.js.LICENSE.txt +1 -0
- package/package.json +56 -0
- package/src/Design.stories.mdx +195 -0
- package/src/Introduction.stories.mdx +148 -0
- package/src/components/JhAddressSelect/JhAddressSelect.md +250 -0
- package/src/components/JhAddressSelect/JhAddressSelect.stories.js +282 -0
- package/src/components/JhAddressSelect/JhAddressSelect.vue +261 -0
- package/src/components/JhCard/JhCard.md +246 -0
- package/src/components/JhCard/JhCard.stories.js +688 -0
- package/src/components/JhCard/JhCard.vue +604 -0
- package/src/components/JhCheckCard/JhCheckCard.md +245 -0
- package/src/components/JhCheckCard/JhCheckCard.stories.js +750 -0
- package/src/components/JhCheckCard/JhCheckCard.vue +476 -0
- package/src/components/JhConfirmDialog/JhConfirmDialog.md +70 -0
- package/src/components/JhConfirmDialog/JhConfirmDialog.stories.js +550 -0
- package/src/components/JhConfirmDialog/JhConfirmDialog.vue +181 -0
- package/src/components/JhDateRangePicker/JhDateRangePicker.md +56 -0
- package/src/components/JhDateRangePicker/JhDateRangePicker.stories.js +320 -0
- package/src/components/JhDateRangePicker/JhDateRangePicker.vue +307 -0
- package/src/components/JhDescriptions/JhDescriptions.md +724 -0
- package/src/components/JhDescriptions/JhDescriptions.stories.js +858 -0
- package/src/components/JhDescriptions/JhDescriptions.vue +933 -0
- package/src/components/JhDraggable/JhDraggable.md +66 -0
- package/src/components/JhDraggable/JhDraggable.stories.js +161 -0
- package/src/components/JhDraggable/JhDraggable.vue +254 -0
- package/src/components/JhDrawer/JhDrawer.md +68 -0
- package/src/components/JhDrawer/JhDrawer.stories.js +478 -0
- package/src/components/JhDrawer/JhDrawer.vue +281 -0
- package/src/components/JhDrawerForm/JhDrawerForm.md +69 -0
- package/src/components/JhDrawerForm/JhDrawerForm.stories.js +492 -0
- package/src/components/JhDrawerForm/JhDrawerForm.vue +297 -0
- package/src/components/JhEditableTable/JhEditableTable.md +507 -0
- package/src/components/JhEditableTable/JhEditableTable.stories.js +615 -0
- package/src/components/JhEditableTable/JhEditableTable.vue +685 -0
- package/src/components/JhFileInput/JhFileInput.md +56 -0
- package/src/components/JhFileInput/JhFileInput.stories.js +103 -0
- package/src/components/JhFileInput/JhFileInput.vue +253 -0
- package/src/components/JhForm/JhForm.md +676 -0
- package/src/components/JhForm/JhForm.stories.js +1375 -0
- package/src/components/JhForm/JhForm.vue +657 -0
- package/src/components/JhFormField/JhFormField.stories.js +217 -0
- package/src/components/JhFormField/JhFormField.vue +439 -0
- package/src/components/JhFormFields/JhFormFields.md +647 -0
- package/src/components/JhFormFields/JhFormFields.stories.js +922 -0
- package/src/components/JhFormFields/JhFormFields.vue +998 -0
- package/src/components/JhFormList/JhFormList.md +303 -0
- package/src/components/JhFormList/JhFormList.stories.js +661 -0
- package/src/components/JhFormList/JhFormList.vue +1127 -0
- package/src/components/JhJsonEditor/JhJsonEditor.md +54 -0
- package/src/components/JhJsonEditor/JhJsonEditor.stories.js +157 -0
- package/src/components/JhJsonEditor/JhJsonEditor.vue +178 -0
- package/src/components/JhLayout/JhLayout.md +580 -0
- package/src/components/JhLayout/JhLayout.stories.js +414 -0
- package/src/components/JhLayout/JhLayout.vue +387 -0
- package/src/components/JhList/JhList.md +441 -0
- package/src/components/JhList/JhList.stories.js +524 -0
- package/src/components/JhList/JhList.vue +571 -0
- package/src/components/JhMarkdownEditor/JhMarkdownEditor.md +56 -0
- package/src/components/JhMarkdownEditor/JhMarkdownEditor.stories.js +191 -0
- package/src/components/JhMarkdownEditor/JhMarkdownEditor.vue +188 -0
- package/src/components/JhMask/JhMask.md +62 -0
- package/src/components/JhMask/JhMask.stories.js +270 -0
- package/src/components/JhMask/JhMask.vue +123 -0
- package/src/components/JhMenu/JhMenu.md +85 -0
- package/src/components/JhMenu/JhMenu.stories.js +384 -0
- package/src/components/JhMenu/JhMenu.vue +545 -0
- package/src/components/JhModal/JhModal.md +68 -0
- package/src/components/JhModal/JhModal.stories.js +562 -0
- package/src/components/JhModal/JhModal.vue +235 -0
- package/src/components/JhModalForm/JhModalForm.md +69 -0
- package/src/components/JhModalForm/JhModalForm.stories.js +592 -0
- package/src/components/JhModalForm/JhModalForm.vue +298 -0
- package/src/components/JhPageContainer/JhPageContainer.md +409 -0
- package/src/components/JhPageContainer/JhPageContainer.stories.js +209 -0
- package/src/components/JhPageContainer/JhPageContainer.vue +72 -0
- package/src/components/JhQueryFilter/JhQueryFilter.md +77 -0
- package/src/components/JhQueryFilter/JhQueryFilter.stories.js +684 -0
- package/src/components/JhQueryFilter/JhQueryFilter.vue +429 -0
- package/src/components/JhScene/JhScene.md +64 -0
- package/src/components/JhScene/JhScene.stories.js +317 -0
- package/src/components/JhScene/JhScene.vue +376 -0
- package/src/components/JhStatisticCard/JhStatisticCard.md +363 -0
- package/src/components/JhStatisticCard/JhStatisticCard.stories.js +847 -0
- package/src/components/JhStatisticCard/JhStatisticCard.vue +459 -0
- package/src/components/JhStepsForm/JhStepsForm.md +666 -0
- package/src/components/JhStepsForm/JhStepsForm.stories.js +1224 -0
- package/src/components/JhStepsForm/JhStepsForm.vue +749 -0
- package/src/components/JhTable/JhTable.md +730 -0
- package/src/components/JhTable/JhTable.stories.js +1444 -0
- package/src/components/JhTable/JhTable.vue +2298 -0
- package/src/components/JhTableAttachment/JhTableAttachment.md +70 -0
- package/src/components/JhTableAttachment/JhTableAttachment.stories.js +198 -0
- package/src/components/JhTableAttachment/JhTableAttachment.vue +264 -0
- package/src/components/JhToast/JhToast.md +67 -0
- package/src/components/JhToast/JhToast.stories.js +386 -0
- package/src/components/JhToast/JhToast.vue +239 -0
- package/src/components/JhTreeSelect/JhTreeSelect.md +82 -0
- package/src/components/JhTreeSelect/JhTreeSelect.stories.js +391 -0
- package/src/components/JhTreeSelect/JhTreeSelect.vue +727 -0
- package/src/components/JhWaterMark/JhWaterMark.md +190 -0
- package/src/components/JhWaterMark/JhWaterMark.stories.js +675 -0
- package/src/components/JhWaterMark/JhWaterMark.vue +351 -0
- package/src/components/README.md +52 -0
- package/src/index.js +135 -0
- package/src/style/globalCSSJHV4.css +348 -0
- package/src/style/globalCSSVuetifyV4.css +637 -0
- package/src/style/storybook.css +4 -0
- package/src/tailwind.css +3 -0
- package/src/utils/vuetify.js +31 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-navigation-drawer
|
|
3
|
+
v-model="isShownInternal"
|
|
4
|
+
fixed
|
|
5
|
+
temporary
|
|
6
|
+
:right="position === 'right'"
|
|
7
|
+
:left="position === 'left'"
|
|
8
|
+
:width="width"
|
|
9
|
+
class="elevation-24"
|
|
10
|
+
>
|
|
11
|
+
<!-- 抽屉标题 -->
|
|
12
|
+
<v-row class="jh-drawer-header px-4 bg-white" no-gutters align="center">
|
|
13
|
+
<span class="text-h7 font-weight-bold py-4">{{ title }}</span>
|
|
14
|
+
<v-spacer></v-spacer>
|
|
15
|
+
|
|
16
|
+
<!-- 操作按钮组 -->
|
|
17
|
+
<div class="jh-drawer-action-btn-group">
|
|
18
|
+
<!-- 取消按钮 -->
|
|
19
|
+
<v-btn
|
|
20
|
+
class="elevation-0 grey lighten-4"
|
|
21
|
+
@click="handleCancel"
|
|
22
|
+
small
|
|
23
|
+
>
|
|
24
|
+
{{ cancelText }}
|
|
25
|
+
</v-btn>
|
|
26
|
+
|
|
27
|
+
<!-- 自定义操作按钮插槽 -->
|
|
28
|
+
<slot name="actions">
|
|
29
|
+
<!-- 默认确认按钮 -->
|
|
30
|
+
<v-btn
|
|
31
|
+
v-if="showConfirmButton"
|
|
32
|
+
color="success"
|
|
33
|
+
class="ml-2"
|
|
34
|
+
small
|
|
35
|
+
@click="handleConfirm"
|
|
36
|
+
>
|
|
37
|
+
{{ confirmText }}
|
|
38
|
+
</v-btn>
|
|
39
|
+
</slot>
|
|
40
|
+
</div>
|
|
41
|
+
</v-row>
|
|
42
|
+
|
|
43
|
+
<v-divider class="jh-divider"></v-divider>
|
|
44
|
+
|
|
45
|
+
<!-- 抽屉内容 -->
|
|
46
|
+
<div class="px-4 pb-4">
|
|
47
|
+
<!-- 支持完全自定义内容 -->
|
|
48
|
+
<slot name="content">
|
|
49
|
+
<!-- 使用 JhForm 组件渲染表单 -->
|
|
50
|
+
<jh-form
|
|
51
|
+
ref="jhForm"
|
|
52
|
+
:form-ref="formRef"
|
|
53
|
+
:fields="fields"
|
|
54
|
+
:initial-data="initialData"
|
|
55
|
+
:validation-rules="validationRules"
|
|
56
|
+
:default-cols-md="3"
|
|
57
|
+
:row-class="rowClass"
|
|
58
|
+
@field-change="handleFieldChange"
|
|
59
|
+
>
|
|
60
|
+
<!-- 传递自定义字段插槽 -->
|
|
61
|
+
<template v-for="field in slotFields" v-slot:[`field-${field.key}`]="slotProps">
|
|
62
|
+
<slot :name="`field-${field.key}`" v-bind="slotProps"></slot>
|
|
63
|
+
</template>
|
|
64
|
+
</jh-form>
|
|
65
|
+
</slot>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<!-- 抽屉关闭按钮 -->
|
|
69
|
+
<v-btn
|
|
70
|
+
elevation="0"
|
|
71
|
+
color="success"
|
|
72
|
+
fab
|
|
73
|
+
absolute
|
|
74
|
+
top
|
|
75
|
+
left
|
|
76
|
+
small
|
|
77
|
+
tile
|
|
78
|
+
class="drawer-close-float-btn"
|
|
79
|
+
@click="handleCancel"
|
|
80
|
+
>
|
|
81
|
+
<v-icon>mdi-close</v-icon>
|
|
82
|
+
</v-btn>
|
|
83
|
+
</v-navigation-drawer>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<script>
|
|
87
|
+
import JhForm from '../JhForm/JhForm.vue';
|
|
88
|
+
|
|
89
|
+
export default {
|
|
90
|
+
name: 'JhDrawerForm',
|
|
91
|
+
|
|
92
|
+
components: {
|
|
93
|
+
JhForm,
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
props: {
|
|
97
|
+
// 抽屉显示状态
|
|
98
|
+
value: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: false
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
// 抽屉标题
|
|
104
|
+
title: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: '表单'
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
// 抽屉位置
|
|
110
|
+
position: {
|
|
111
|
+
type: String,
|
|
112
|
+
default: 'right',
|
|
113
|
+
validator: (v) => ['left', 'right'].includes(v)
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
// 抽屉宽度
|
|
117
|
+
width: {
|
|
118
|
+
type: String,
|
|
119
|
+
default: '90%'
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
// 按钮配置
|
|
123
|
+
showConfirmButton: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
default: true
|
|
126
|
+
},
|
|
127
|
+
confirmText: {
|
|
128
|
+
type: String,
|
|
129
|
+
default: '确认'
|
|
130
|
+
},
|
|
131
|
+
cancelText: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: '取消'
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
// 表单引用名称
|
|
137
|
+
formRef: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: 'drawerForm'
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
// 是否在确认前验证表单
|
|
143
|
+
validateBeforeConfirm: {
|
|
144
|
+
type: Boolean,
|
|
145
|
+
default: true
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
// 表单字段配置(JSON 配置)
|
|
149
|
+
fields: {
|
|
150
|
+
type: Array,
|
|
151
|
+
default: () => []
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
// 初始表单数据
|
|
155
|
+
initialData: {
|
|
156
|
+
type: Object,
|
|
157
|
+
default: () => ({})
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
// 自定义行样式类
|
|
161
|
+
rowClass: {
|
|
162
|
+
type: String,
|
|
163
|
+
default: 'mt-0'
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
// 验证规则集合
|
|
167
|
+
validationRules: {
|
|
168
|
+
type: Object,
|
|
169
|
+
default: () => ({
|
|
170
|
+
require: [v => !!v || '必填'],
|
|
171
|
+
email: [v => !v || /.+@.+\..+/.test(v) || '邮箱格式不正确'],
|
|
172
|
+
phone: [v => !v || /^1[3-9]\d{9}$/.test(v) || '手机号格式不正确'],
|
|
173
|
+
number: [v => !v || !isNaN(v) || '请输入数字'],
|
|
174
|
+
integer: [v => !v || Number.isInteger(Number(v)) || '请输入整数']
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
data() {
|
|
180
|
+
return {
|
|
181
|
+
isShownInternal: this.value,
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
computed: {
|
|
186
|
+
// 获取所有 slot 类型的字段
|
|
187
|
+
slotFields() {
|
|
188
|
+
return this.fields.filter(field => field.type === 'slot');
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
watch: {
|
|
193
|
+
value(val) {
|
|
194
|
+
this.isShownInternal = val;
|
|
195
|
+
// 当抽屉打开时,重置表单数据和验证状态
|
|
196
|
+
if (val) {
|
|
197
|
+
this.$nextTick(() => {
|
|
198
|
+
this.resetForm();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
isShownInternal(val) {
|
|
203
|
+
if (!val) {
|
|
204
|
+
this.$emit('input', false);
|
|
205
|
+
this.$emit('close');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
methods: {
|
|
211
|
+
// 处理取消
|
|
212
|
+
handleCancel() {
|
|
213
|
+
this.$emit('cancel');
|
|
214
|
+
this.isShownInternal = false;
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
// 处理确认
|
|
218
|
+
async handleConfirm() {
|
|
219
|
+
// 如果需要验证表单
|
|
220
|
+
if (this.validateBeforeConfirm) {
|
|
221
|
+
const isValid = await this.validate();
|
|
222
|
+
if (!isValid) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
this.$emit('confirm', this.getFormData());
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
// 处理字段变化
|
|
231
|
+
handleFieldChange(event) {
|
|
232
|
+
this.$emit('field-change', event);
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
// 获取 JhForm 实例
|
|
236
|
+
getJhForm() {
|
|
237
|
+
return this.$refs.jhForm;
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
// 获取表单引用(供父组件调用)
|
|
241
|
+
getForm() {
|
|
242
|
+
const jhForm = this.getJhForm();
|
|
243
|
+
return jhForm ? jhForm.getForm() : null;
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
// 获取表单数据
|
|
247
|
+
getFormData() {
|
|
248
|
+
const jhForm = this.getJhForm();
|
|
249
|
+
return jhForm ? jhForm.getFormData() : {};
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
// 设置表单数据
|
|
253
|
+
setFieldsValue(values) {
|
|
254
|
+
const jhForm = this.getJhForm();
|
|
255
|
+
if (jhForm) {
|
|
256
|
+
jhForm.setFieldsValue(values);
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
// 设置单个字段值
|
|
261
|
+
setFieldValue(key, value) {
|
|
262
|
+
const jhForm = this.getJhForm();
|
|
263
|
+
if (jhForm) {
|
|
264
|
+
jhForm.setFieldValue(key, value);
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
// 重置表单
|
|
269
|
+
resetForm() {
|
|
270
|
+
const jhForm = this.getJhForm();
|
|
271
|
+
if (jhForm) {
|
|
272
|
+
jhForm.resetForm();
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
// 重置表单验证
|
|
277
|
+
resetValidation() {
|
|
278
|
+
const jhForm = this.getJhForm();
|
|
279
|
+
if (jhForm) {
|
|
280
|
+
jhForm.resetValidation();
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
// 验证表单
|
|
285
|
+
async validate() {
|
|
286
|
+
const jhForm = this.getJhForm();
|
|
287
|
+
if (jhForm) {
|
|
288
|
+
return await jhForm.validate();
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
</script>
|
|
295
|
+
|
|
296
|
+
<style scoped>
|
|
297
|
+
</style>
|