@bscjc/webui 0.0.2

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 ADDED
@@ -0,0 +1,476 @@
1
+ # @bscjc/webui
2
+
3
+ 一个 Vue3 组件库,使用 Vite,Element Plus 和 TypeScript 构建
4
+
5
+ # webui 组件库文档
6
+
7
+ ## 目录
8
+
9
+ - [组件目录介绍](#组件目录介绍)
10
+ - [安装使用说明](#安装使用说明)
11
+ - [组件文档](#组件文档)
12
+ - [JcSelectQuery](#JcSelectQuery)
13
+ - [JcDatePicker](#JcDatePicker)
14
+ - [JcInputSwitch](#JcInputSwitch)
15
+ - [JcInputComplex](#JcInputComplex)
16
+ - [JcTagQuery](#JcTagQuery)
17
+ - [JcMoreQueryContain](#JcMoreQueryContain)
18
+ - [配套 Hooks 使用说明](#配套Hooks使用说明)
19
+
20
+ ## 组件目录介绍
21
+
22
+ @bscjc/webui 是一个基于 Element Plus 的 Vue3 组件库,包含以下组件:
23
+
24
+ | 组件名 | 说明 |
25
+ | ------------------ | --------------------------------------------- |
26
+ | JcSelectQuery | 下拉选择器组件,支持多选、shi、搜索和全选功能 |
27
+ | JcDatePicker | 日期选择器组件,支持日期范围和月份范围选择 |
28
+ | JcInputSwitch | 输入切换组件,支持多字段切换输入 |
29
+ | JcInputComplex | 复杂输入切换组件,支持单行和多行文本输入 |
30
+ | JcTagQuery | 标签查询组件,用于展示和管理查询标签 |
31
+ | JcMoreQueryContain | 查询容器,用于包裹更多查询条件 |
32
+
33
+ ## 安装使用说明
34
+
35
+ ### 安装
36
+
37
+ ```shell
38
+ npm i @bscjc/webui
39
+ ```
40
+
41
+ ### 完整导入
42
+
43
+ ```typescript
44
+ // src/main.ts
45
+ import { createApp } from "vue";
46
+ import App from "./App.vue";
47
+ import JcWebui from "@bscjc/webui";
48
+ import "@bscjc/webui/dist/style.css";
49
+
50
+ const app = createApp(App);
51
+ app.use(JcWebui);
52
+ app.mount("#app");
53
+ ```
54
+
55
+ ### 按需导入
56
+
57
+ ```vue
58
+ <template>
59
+ <jc-select-query
60
+ ref="selectRef"
61
+ field="selectList"
62
+ :options="options"
63
+ @change="(val:any) => console.log(val)"
64
+ >
65
+ </jc-select-query>
66
+ </template>
67
+
68
+ <script setup>
69
+ import { JcSelectQuery } from "@bscjc/webui";
70
+ </script>
71
+ ```
72
+
73
+ ## 组件文档
74
+
75
+ ### JcSelectQuery
76
+
77
+ #### 概述
78
+
79
+ 基于 Element Plus 的`el-select`组件封装,支持多选、搜索、全选和虚拟滚动等高级功能。
80
+
81
+ #### 基本使用
82
+
83
+ ```vue
84
+ <template>
85
+ <jc-select-query :options="options" field="selectedList" />
86
+ </template>
87
+
88
+ <script setup lang="ts">
89
+ import { ref } from "vue";
90
+ import { JcSelectQuery } from "@bscjc/webui";
91
+ const options = ref([
92
+ { label: "选项1", value: "1" },
93
+ { label: "选项2", value: "2" },
94
+ { label: "选项3", value: "3" },
95
+ ]);
96
+ </script>
97
+ ```
98
+
99
+ #### 核心功能
100
+
101
+ 1. 支持多选和全选操作
102
+ 2. 内置搜索功能,支持模糊匹配
103
+ 3. 支持虚拟滚动,优化大数据量渲染
104
+ 4. 支持创建新选项
105
+ 5. 支持按住 Shift 键快速多选
106
+
107
+ #### Props
108
+
109
+ | 参数 | 类型 | 默认值 | 说明 |
110
+ | --------------- | ------------------------------------- | ------------------ | -------------------- |
111
+ | field | string | - | 绑定的字段名,必填 |
112
+ | options | Array<{label: string, value: string}> | [] | 选项数据,必填 |
113
+ | allowCreate | boolean | true | 是否允许创建新选项 |
114
+ | keyField | Array<string> | ['label', 'value'] | 选项的键名配置 |
115
+ | width | string | '160px' | 组件宽度 |
116
+ | size | 'small' \| 'default' \| 'large' | 'default' | 组件尺寸 |
117
+ | footerBtnName | string | '搜索' | 底部按钮文本 |
118
+ | maxScrollHeight | string | '240px' | 下拉框最大高度 |
119
+ | isNeedFooter | boolean | true | 是否显示底部按钮区域 |
120
+
121
+ #### Events
122
+
123
+ | 事件名 | 参数 | 说明 |
124
+ | -------------- | ---------------- | --------------------- |
125
+ | change | value: string[] | 选中值变化时触发 |
126
+ | remove-tag | tag: any | 移除标签时触发 |
127
+ | visible-change | visible: boolean | 下拉框显示/隐藏时触发 |
128
+
129
+ #### 方法
130
+
131
+ | 方法名 | 说明 |
132
+ | ------ | ---------- |
133
+ | focus | 获取焦点 |
134
+ | blur | 失去焦点 |
135
+ | clear | 清空选中值 |
136
+
137
+ #### 原组件 API
138
+
139
+ 继承自 Element Plus 的`el-select`组件,支持其所有 Props 和 Events。
140
+
141
+ ### JcDatePicker
142
+
143
+ #### 概述
144
+
145
+ 基于 Element Plus 的`el-date-picker`组件封装,支持多字段切换的日期选择功能。
146
+
147
+ #### 基本使用
148
+
149
+ ```vue
150
+ <template>
151
+ <jc-date-picker :field-list="fieldList" />
152
+ </template>
153
+
154
+ <script setup lang="ts">
155
+ import { ref } from "vue";
156
+ import { JcDatePicker } from "@bscjc/webui";
157
+
158
+ const fieldList = ref([
159
+ { label: "创建时间", value: "createTimeList" },
160
+ { label: "更新时间", value: "updateTimeList" },
161
+ ]);
162
+ </script>
163
+ ```
164
+
165
+ #### 核心功能
166
+
167
+ 1. 支持多字段切换选择
168
+ 2. 支持日期范围和月份范围选择
169
+ 3. 自动集成查询表单状态管理
170
+
171
+ #### Props
172
+
173
+ | 参数 | 类型 | 默认值 | 说明 |
174
+ | --------- | ------------------------------------- | ----------- | -------------- |
175
+ | fieldList | Array<{label: string, value: string}> | [] | 字段列表,必填 |
176
+ | type | 'daterange' \| 'monthrange' | 'daterange' | 日期选择类型 |
177
+ | size | 'small' \| 'default' \| 'large' | 'default' | 组件尺寸 |
178
+ | width | string | '320px' | 日期选择器宽度 |
179
+
180
+ #### Events
181
+
182
+ | 事件名 | 参数 | 说明 |
183
+ | ----------- | ----------- | ---------------- |
184
+ | fieldChange | val: string | 字段切换时触发 |
185
+ | change | val: any | 日期值变化时触发 |
186
+
187
+ #### 方法
188
+
189
+ | 方法名 | 说明 |
190
+ | ----------- | ---------------- |
191
+ | focus | 获取焦点 |
192
+ | blur | 失去焦点 |
193
+ | handleOpen | 打开日期选择面板 |
194
+ | handleClose | 关闭日期选择面板 |
195
+
196
+ #### 原组件 API
197
+
198
+ 继承自 Element Plus 的`el-date-picker`组件,支持其所有 Props 和 Events。
199
+
200
+ ### JcInputSwitch
201
+
202
+ #### 概述
203
+
204
+ 基于 Element Plus 的`el-input`组件封装,支持多字段切换的输入组件。
205
+
206
+ #### 基本使用
207
+
208
+ ```vue
209
+ <template>
210
+ <jc-input-switch :field-list="fieldList" />
211
+ </template>
212
+
213
+ <script setup lang="ts">
214
+ import { ref } from "vue";
215
+ import { JcInputSwitch } from "@bscjc/webui";
216
+
217
+ const fieldList = ref([
218
+ { label: "名称", value: "name" },
219
+ { label: "ID", value: "id" },
220
+ ]);
221
+ </script>
222
+ ```
223
+
224
+ #### 核心功能
225
+
226
+ 1. 支持多字段切换输入
227
+ 2. 内置清除和搜索功能
228
+ 3. 自动集成查询表单状态管理
229
+
230
+ #### Props
231
+
232
+ | 参数 | 类型 | 默认值 | 说明 |
233
+ | --------- | ------------------------------------- | --------- | -------------- |
234
+ | fieldList | Array<{label: string, value: string}> | [] | 字段列表,必填 |
235
+ | size | 'small' \| 'default' \| 'large' | 'default' | 组件尺寸 |
236
+ | width | string | '320px' | 组件宽度 |
237
+
238
+ #### Events
239
+
240
+ | 事件名 | 参数 | 说明 |
241
+ | ----------- | ----------- | ---------------- |
242
+ | fieldChange | val: string | 字段切换时触发 |
243
+ | input | val: string | 输入值变化时触发 |
244
+
245
+ #### 方法
246
+
247
+ | 方法名 | 说明 |
248
+ | ------ | ---------- |
249
+ | focus | 获取焦点 |
250
+ | blur | 失去焦点 |
251
+ | clear | 清空输入值 |
252
+
253
+ #### 原组件 API
254
+
255
+ 继承自 Element Plus 的`el-input`组件,支持其所有 Props 和 Events。
256
+
257
+ ### JcInputComplex
258
+
259
+ #### 概述
260
+
261
+ 基于 Element Plus 的`el-input`组件封装,支持单行和多行文本输入的复杂输入组件。
262
+
263
+ #### 基本使用
264
+
265
+ ```vue
266
+ <template>
267
+ <jc-input-complex :field-list="fieldList" />
268
+ </template>
269
+
270
+ <script setup lang="ts">
271
+ import { ref } from "vue";
272
+ import { JcInputComplex } from "@bscjc/webui";
273
+
274
+ const fieldList = ref([
275
+ { label: "关键词", value: "keyword" },
276
+ { label: "描述", value: "description" },
277
+ ]);
278
+ </script>
279
+ ```
280
+
281
+ #### 核心功能
282
+
283
+ 1. 支持多字段切换输入
284
+ 2. 支持单行和多行文本输入切换
285
+ 3. 内置清除和搜索功能
286
+ 4. 自动集成查询表单状态管理
287
+
288
+ #### Props
289
+
290
+ | 参数 | 类型 | 默认值 | 说明 |
291
+ | --------- | ------------------------------------- | --------- | -------------- |
292
+ | fieldList | Array<{label: string, value: string}> | [] | 字段列表,必填 |
293
+ | size | 'small' \| 'default' \| 'large' | 'default' | 组件尺寸 |
294
+ | width | string | '320px' | 组件宽度 |
295
+
296
+ #### Events
297
+
298
+ | 事件名 | 参数 | 说明 |
299
+ | ----------- | ----------- | ---------------- |
300
+ | fieldChange | val: string | 字段切换时触发 |
301
+ | input | val: string | 输入值变化时触发 |
302
+
303
+ #### 方法
304
+
305
+ | 方法名 | 说明 |
306
+ | ------ | ---------- |
307
+ | focus | 获取焦点 |
308
+ | blur | 失去焦点 |
309
+ | clear | 清空输入值 |
310
+
311
+ #### 原组件 API
312
+
313
+ 继承自 Element Plus 的`el-input`组件,支持其所有 Props 和 Events。
314
+
315
+ ### JcTagQuery
316
+
317
+ #### 概述
318
+
319
+ 基于 Element Plus 的`el-tag`组件封装,用于展示和管理查询标签的组件。
320
+
321
+ #### 基本使用
322
+
323
+ ```vue
324
+ <template>
325
+ <jc-tag-query />
326
+ </template>
327
+
328
+ <script setup lang="ts">
329
+ import { JcTagQuery } from "@bscjc/webui";
330
+ </script>
331
+ ```
332
+
333
+ #### 核心功能
334
+
335
+ 1. 展示当前查询条件标签
336
+ 2. 支持单个标签删除
337
+ 3. 支持全部标签清除
338
+
339
+ #### Props
340
+
341
+ | 参数 | 类型 | 默认值 | 说明 |
342
+ | -------- | ------- | ------- | ---------- |
343
+ | closable | boolean | true | 是否可关闭 |
344
+ | type | string | 'info' | 标签类型 |
345
+ | effect | string | 'light' | 标签主题 |
346
+
347
+ #### Events
348
+
349
+ | 事件名 | 参数 | 说明 |
350
+ | ------ | -------------------------- | -------------- |
351
+ | close | tag: object, index: number | 标签关闭时触发 |
352
+ | click | tag: object, index: number | 点击标签时触发 |
353
+
354
+ #### 原组件 API
355
+
356
+ 继承自 Element Plus 的`el-tag`组件,支持其所有 Props 和 Events。
357
+
358
+ ### JcMoreQueryContain
359
+
360
+ #### 概述
361
+
362
+ 基于 Element Plus 的`el-popover`组件封装,用于包裹更多查询条件的高级查询容器。
363
+
364
+ #### 基本使用
365
+
366
+ ```vue
367
+ <template>
368
+ <jc-more-query-contain :field-list="fieldList" :width="500" :size="'small'">
369
+ <!-- 高级查询条件内容 -->
370
+ <el-form-item label="状态">
371
+ <el-select v-model="moreQueryForm.status" placeholder="请选择状态">
372
+ <el-option label="启用" value="1"></el-option>
373
+ <el-option label="禁用" value="0"></el-option>
374
+ </el-select>
375
+ </el-form-item>
376
+ </jc-more-query-contain>
377
+ </template>
378
+
379
+ <script setup lang="ts">
380
+ import { ref } from "vue";
381
+ import { JcMoreQueryContain } from "@bscjc/webui";
382
+ const fieldList = ref([
383
+ { label: "状态", value: "status" },
384
+ { label: "类型", value: "type" },
385
+ ]);
386
+ const moreQueryForm = ref({ status: "", type: "" });
387
+ </script>
388
+ ```
389
+
390
+ #### 核心功能
391
+
392
+ 1. 弹出式高级查询面板
393
+ 2. 支持多字段复杂查询
394
+ 3. 内置清空和搜索功能
395
+ 4. 自动集成查询表单状态管理
396
+
397
+ #### Props
398
+
399
+ | 参数 | 类型 | 默认值 | 说明 |
400
+ | ------------ | ------------------------------------- | --------- | -------------- |
401
+ | fieldList | Array<{label: string, value: string}> | [] | 字段列表,必填 |
402
+ | customTagObj | { [key: string]: string } | {} | 自定义标签对象 |
403
+ | width | number | 400 | 弹窗宽度 |
404
+ | size | 'small' \| 'default' \| 'large' | 'default' | 组件尺寸 |
405
+
406
+ #### Events
407
+
408
+ | 事件名 | 参数 | 说明 |
409
+ | ------ | ---- | ------------------ |
410
+ | clear | - | 清空按钮点击时触发 |
411
+ | search | - | 搜索按钮点击时触发 |
412
+
413
+ #### 方法
414
+
415
+ | 方法名 | 说明 |
416
+ | ------ | ------------ |
417
+ | hide | 隐藏 popover |
418
+
419
+ #### 原组件 API
420
+
421
+ 继承自 Element Plus 的`el-popover`组件,支持其所有 Props 和 Events。
422
+
423
+ ## 配套 Hooks 使用说明
424
+
425
+ ### useQuery.ts
426
+
427
+ #### 概述
428
+
429
+ `useQuery`是 QueryFormComponents 组件库的配套 Hooks,提供查询表单状态管理功能。
430
+
431
+ #### 基本使用
432
+
433
+ ```typescript
434
+ import { reactiveQuery } from from "@bscjc/webui"
435
+ const { queryForm, setQuery, addTag, reduceTag, reduceAllTag, clearQuery } = reactiveQuery()
436
+
437
+ // 设置查询条件
438
+ setQuery('name', 'test')
439
+
440
+ // 添加标签
441
+ addTag({ label: 'name', value: '名称:test' })
442
+
443
+ // 移除标签
444
+ reduceTag({ label: 'name', value: '名称:test' })
445
+
446
+ // 移除所有标签
447
+ reduceAllTag()
448
+
449
+ // 清空查询条件
450
+ clearQuery()
451
+ ```
452
+
453
+ #### 方法
454
+
455
+ | 方法名 | 参数 | 说明 |
456
+ | ------------ | ------------------------------------- | ---------------- |
457
+ | setQuery | key: string, value: any | 设置查询条件 |
458
+ | addTag | tag: { label: string, value: string } | 添加查询标签 |
459
+ | reduceTag | tag: { label: string, value: string } | 移除指定标签 |
460
+ | reduceAllTag | - | 移除所有标签 |
461
+ | clearQuery | - | 清空所有查询条件 |
462
+
463
+ #### 返回值
464
+
465
+ | 名称 | 类型 | 说明 |
466
+ | ------------ | -------- | ------------------ |
467
+ | queryForm | object | 响应式查询表单对象 |
468
+ | setQuery | Function | 设置查询条件的方法 |
469
+ | addTag | Function | 添加标签的方法 |
470
+ | reduceTag | Function | 移除标签的方法 |
471
+ | reduceAllTag | Function | 移除所有标签的方法 |
472
+ | clearQuery | Function | 清空查询条件的方法 |
473
+
474
+ ## License
475
+
476
+ MIT