@yetuzi/vue3-query-components 1.0.4 → 1.1.0

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 CHANGED
@@ -1,360 +1,360 @@
1
- # @yetuzi/vue3-query-components
2
-
3
- 基于 Vue 3 + Element Plus 的企业级查询页面组件库,专注于表格查询场景,开箱即用。
4
-
5
- ## ✨ 特性
6
-
7
- - 🚀 **开箱即用** - 高度封装的业务组件,减少重复开发
8
- - 🎨 **统一设计** - 基于 Element Plus 设计语言,支持全局配置
9
- - 🔧 **高度可配置** - 灵活的配置选项,满足不同业务需求
10
- - 📦 **TypeScript 支持** - 完整的类型定义,类型安全
11
- - 🌳 **Tree Shaking** - 按需引入,减小打包体积
12
- - 🔥 **热更新** - 支持开发模式热更新
13
- - 🎯 **业务导向** - 专注于查询、表单、表格等常见业务场景
14
- - 🔄 **状态管理** - 内置数据请求、分页、表单状态管理
15
- - 🎨 **插槽支持** - 灵活的插槽系统,支持自定义扩展
16
-
17
- ## 📦 安装
18
-
19
- ```bash
20
- npm install @yetuzi/vue3-query-components
21
- # 或
22
- yarn add @yetuzi/vue3-query-components
23
- # 或
24
- pnpm add @yetuzi/vue3-query-components
25
- ```
26
-
27
- ## 🚀 快速开始
28
-
29
- ### 1. 全局引入
30
-
31
- ```typescript
32
- import { createApp } from 'vue'
33
- import '@yetuzi/vue3-query-components/dist/style.css'
34
- import 'element-plus/theme-chalk/index.css' // 需要安装 Element Plus
35
-
36
- const app = createApp(App)
37
- ```
38
-
39
- ### 2. 按需引入
40
-
41
- ```typescript
42
- import {
43
- CommonQueryTable,
44
- CommonTable,
45
- CommonForm,
46
- CommonConfigProvider,
47
- } from '@yetuzi/vue3-query-components'
48
- import '@yetuzi/vue3-query-components/dist/style.css'
49
- import 'element-plus/theme-chalk/index.css' // 需要安装 Element Plus
50
- ```
51
-
52
- ### 3. 基础使用
53
-
54
- #### 完整查询表格组件(推荐)
55
-
56
- `CommonQueryTable` 是一个高度集成的组件,包含表单查询、表格展示、分页功能。
57
-
58
- ```vue
59
- <template>
60
- <CommonQueryTable :fetch="fetchData" :form="formConfig" :columns="tableColumns" />
61
- </template>
62
-
63
- <script setup>
64
- import { CommonQueryTable } from '@yetuzi/vue3-query-components'
65
-
66
- // 数据请求函数
67
- const fetchData = async (params) => {
68
- const { pageNo, pageSize, ...searchParams } = params
69
- const response = await api.getList({
70
- page: pageNo,
71
- size: pageSize,
72
- ...searchParams,
73
- })
74
- return {
75
- list: response.data.list,
76
- total: response.data.total,
77
- }
78
- }
79
-
80
- // 表单配置
81
- const formConfig = [
82
- {
83
- is: 'input', // 组件类型
84
- prop: 'name', // 字段名
85
- formItem: {
86
- label: '姓名', // 表单标签
87
- },
88
- initialValue: '', // 初始值
89
- props: {
90
- placeholder: '请输入姓名',
91
- },
92
- },
93
- {
94
- is: 'select',
95
- prop: 'status',
96
- formItem: {
97
- label: '状态',
98
- },
99
- initialValue: 'all',
100
- props: {
101
- options: [
102
- { value: 'all', label: '全部' },
103
- { value: 'active', label: '激活' },
104
- { value: 'inactive', label: '未激活' },
105
- ],
106
- },
107
- },
108
- {
109
- is: 'date-picker',
110
- prop: 'createTime',
111
- formItem: {
112
- label: '创建时间',
113
- },
114
- },
115
- ]
116
-
117
- // 表格列配置
118
- const tableColumns = [
119
- { prop: 'name', label: '姓名' },
120
- { prop: 'email', label: '邮箱' },
121
- { prop: 'status', label: '状态' },
122
- {
123
- prop: 'createTime',
124
- label: '创建时间',
125
- type: 'dateTime', // 自动格式化日期时间
126
- },
127
- ]
128
- </script>
129
- ```
130
-
131
- #### 高级配置示例
132
-
133
- ```vue
134
- <template>
135
- <CommonConfigProvider
136
- :component="{
137
- form: {
138
- submitText: '查询',
139
- resetText: '重置',
140
- formItem: {
141
- components: {
142
- width: '240px',
143
- },
144
- },
145
- },
146
- pagination: {
147
- defaultPageSize: 20,
148
- defaultPageCount: 1,
149
- },
150
- table: {
151
- headerCellStyle: {
152
- backgroundColor: '#f5f7fa',
153
- color: '#303133',
154
- },
155
- },
156
- }"
157
- >
158
- <CommonQueryTable
159
- v-bind="queryTableConfig"
160
- :layouts="['form', 'toolbar', 'table', 'pagination']"
161
- >
162
- <!-- 自定义工具栏 -->
163
- <template #toolbar>
164
- <el-button type="primary" @click="handleAdd">新增</el-button>
165
- <el-button @click="handleExport">导出</el-button>
166
- </template>
167
-
168
- <!-- 自定义表格列 -->
169
- <template #table-action="{ row }">
170
- <el-button link @click="handleEdit(row)">编辑</el-button>
171
- <el-button link type="danger" @click="handleDelete(row)">删除</el-button>
172
- </template>
173
- </CommonQueryTable>
174
- </CommonConfigProvider>
175
- </template>
176
-
177
- <script setup>
178
- import { CommonConfigProvider, CommonQueryTable } from '@yetuzi/vue3-query-components'
179
-
180
- const queryTableConfig = {
181
- fetch: fetchData,
182
- form: formConfig,
183
- columns: [
184
- { prop: 'name', label: '姓名' },
185
- { prop: 'status', label: '状态' },
186
- { label: '操作', prop: 'action', fixed: 'right', width: 150 },
187
- ],
188
- }
189
- </script>
190
- ```
191
-
192
- ## 📚 组件文档
193
-
194
- ### CommonQueryTable Props
195
-
196
- | 参数 | 说明 | 类型 | 默认值 |
197
- | ------- | ------------ | ------------------------------------------------------------------------ | --------------------------------- |
198
- | fetch | 数据请求函数 | `(params: ListParam) => Promise<{ list: T[], total: string \| number }>` | - |
199
- | form | 表单配置数组 | `CommonFormPropForm[]` | [] |
200
- | columns | 表格列配置 | `CommonTableColumn[]` | - |
201
- | layouts | 布局顺序 | `Array<'header'\|'form'\|'toolbar'\|'table'\|'pagination'\|'footer'>` | `['form', 'table', 'pagination']` |
202
-
203
- ### 表单组件类型支持
204
-
205
- 支持以下表单组件类型:
206
-
207
- - `input` - 输入框
208
- - `select` - 下拉选择
209
- - `date-picker` - 日期选择器
210
- - `radio` - 单选框组
211
- - `check-box` - 复选框组
212
- - `switch` - 开关
213
-
214
- ### 表单配置项类型
215
-
216
- ```typescript
217
- interface FormItemConfig {
218
- is: string // 组件类型
219
- prop: string // 字段名
220
- formItem: {
221
- // ElFormItem 配置
222
- label: string
223
- [key: string]: any
224
- }
225
- initialValue?: any // 初始值
226
- props?: {
227
- // 组件属性
228
- [key: string]: any
229
- }
230
- }
231
- ```
232
-
233
- ### 表格列配置类型
234
-
235
- ```typescript
236
- interface TableColumn {
237
- prop: string // 列属性名
238
- label: string // 列标题
239
- type?: 'dateTime' // 特殊类型:自动格式化日期时间
240
- width?: string \| number // 列宽度
241
- fixed?: boolean \| 'left' \| 'right' // 固定列
242
- [key: string]: any // 其他 ElTableColumn 属性
243
- }
244
- ```
245
-
246
- ## 🎨 全局配置
247
-
248
- 使用 `CommonConfigProvider` 可以全局配置组件样式和行为:
249
-
250
- ```vue
251
- <template>
252
- <CommonConfigProvider
253
- :component="{
254
- placeholder: '暂无数据', // 空值占位
255
- pagination: {
256
- defaultPageCount: 1, // 默认起始页
257
- defaultPageSize: 10, // 默认每页条数
258
- },
259
- table: {
260
- headerCellStyle: {
261
- // 表头样式
262
- backgroundColor: '#f1f6ff',
263
- color: '#000000',
264
- height: '48px',
265
- },
266
- },
267
- form: {
268
- submitText: '搜索', // 提交按钮文本
269
- resetText: '重置', // 重置按钮文本
270
- formItem: {
271
- components: {
272
- width: '200px', // 表单组件宽度
273
- },
274
- },
275
- },
276
- }"
277
- >
278
- <YourApp />
279
- </CommonConfigProvider>
280
- </template>
281
- ```
282
-
283
- ## 🛠️ 开发
284
-
285
- ### 环境要求
286
-
287
- - Node.js >= 18.0.0
288
- - Vue 3.5+
289
- - Element Plus 2.11+
290
- - TypeScript 5.9+
291
-
292
- ### 本地开发
293
-
294
- ```bash
295
- # 克隆项目
296
- git clone https://gitee.com/yetuzi/vue3-common.git
297
- cd vue3-common/vue3-query-components
298
-
299
- # 安装依赖
300
- npm install
301
-
302
- # 开发模式(构建并监听文件变化)
303
- npm run dev
304
-
305
- # 构建
306
- npm run build
307
-
308
- # 类型检查
309
- npm run type-check
310
-
311
- # 代码格式化
312
- npm run format
313
-
314
- # Lint
315
- npm run lint
316
-
317
- # 测试
318
- npm test
319
- ```
320
-
321
- ### 依赖说明
322
-
323
- ```json
324
- {
325
- "peerDependencies": {
326
- "vue": "^3.5.0", // Vue 3 - 需要宿主项目安装
327
- "element-plus": "^2.11.5" // Element Plus UI 库 - 需要宿主项目安装
328
- },
329
- "dependencies": {
330
- "dayjs": "^1.11.18", // 日期处理库
331
- "lodash-es": "^4.17.21", // 工具函数库
332
- "vue-hooks-plus": "^2.4.1" // Vue 组合式 API 工具库
333
- }
334
- }
335
- ```
336
-
337
- ## 🎯 使用场景
338
-
339
- 本组件库特别适用于:
340
-
341
- - **企业后台管理系统** - 大量数据查询、展示、分页场景
342
- - **数据报表页面** - 需要复杂查询条件的数据展示
343
- - **CRUD 操作页面** - 增删改查的标准业务页面
344
- - **列表展示页面** - 各种数据列表的展示和筛选
345
-
346
- ## 📄 许可证
347
-
348
- [MIT](./LICENSE)
349
-
350
- ## 🤝 贡献
351
-
352
- 欢迎提交 Issue 和 Pull Request!
353
-
354
- ## 📞 支持
355
-
356
- 如有问题,请提交 [Issue](https://gitee.com/yetuzi/vue3-common/issues)
357
-
358
- ## 🗺️ 更新日志
359
-
360
- 查看详细的更新日志请访问:[CHANGELOG.md](./CHANGELOG.md)
1
+ # @yetuzi/vue3-query-components
2
+
3
+ 基于 Vue 3 + Element Plus 的企业级查询页面组件库,专注于表格查询场景,开箱即用。
4
+
5
+ ## ✨ 特性
6
+
7
+ - 🚀 **开箱即用** - 高度封装的业务组件,减少重复开发
8
+ - 🎨 **统一设计** - 基于 Element Plus 设计语言,支持全局配置
9
+ - 🔧 **高度可配置** - 灵活的配置选项,满足不同业务需求
10
+ - 📦 **TypeScript 支持** - 完整的类型定义,类型安全
11
+ - 🌳 **Tree Shaking** - 按需引入,减小打包体积
12
+ - 🔥 **热更新** - 支持开发模式热更新
13
+ - 🎯 **业务导向** - 专注于查询、表单、表格等常见业务场景
14
+ - 🔄 **状态管理** - 内置数据请求、分页、表单状态管理
15
+ - 🎨 **插槽支持** - 灵活的插槽系统,支持自定义扩展
16
+
17
+ ## 📦 安装
18
+
19
+ ```bash
20
+ npm install @yetuzi/vue3-query-components
21
+ # 或
22
+ yarn add @yetuzi/vue3-query-components
23
+ # 或
24
+ pnpm add @yetuzi/vue3-query-components
25
+ ```
26
+
27
+ ## 🚀 快速开始
28
+
29
+ ### 1. 全局引入
30
+
31
+ ```typescript
32
+ import { createApp } from 'vue'
33
+ import '@yetuzi/vue3-query-components/dist/style.css'
34
+ import 'element-plus/theme-chalk/index.css' // 需要安装 Element Plus
35
+
36
+ const app = createApp(App)
37
+ ```
38
+
39
+ ### 2. 按需引入
40
+
41
+ ```typescript
42
+ import {
43
+ CommonQueryTable,
44
+ CommonTable,
45
+ CommonForm,
46
+ CommonConfigProvider,
47
+ } from '@yetuzi/vue3-query-components'
48
+ import '@yetuzi/vue3-query-components/dist/style.css'
49
+ import 'element-plus/theme-chalk/index.css' // 需要安装 Element Plus
50
+ ```
51
+
52
+ ### 3. 基础使用
53
+
54
+ #### 完整查询表格组件(推荐)
55
+
56
+ `CommonQueryTable` 是一个高度集成的组件,包含表单查询、表格展示、分页功能。
57
+
58
+ ```vue
59
+ <template>
60
+ <CommonQueryTable :fetch="fetchData" :form="formConfig" :columns="tableColumns" />
61
+ </template>
62
+
63
+ <script setup>
64
+ import { CommonQueryTable } from '@yetuzi/vue3-query-components'
65
+
66
+ // 数据请求函数
67
+ const fetchData = async (params) => {
68
+ const { pageNo, pageSize, ...searchParams } = params
69
+ const response = await api.getList({
70
+ page: pageNo,
71
+ size: pageSize,
72
+ ...searchParams,
73
+ })
74
+ return {
75
+ list: response.data.list,
76
+ total: response.data.total,
77
+ }
78
+ }
79
+
80
+ // 表单配置
81
+ const formConfig = [
82
+ {
83
+ is: 'input', // 组件类型
84
+ prop: 'name', // 字段名
85
+ formItem: {
86
+ label: '姓名', // 表单标签
87
+ },
88
+ initialValue: '', // 初始值
89
+ props: {
90
+ placeholder: '请输入姓名',
91
+ },
92
+ },
93
+ {
94
+ is: 'select',
95
+ prop: 'status',
96
+ formItem: {
97
+ label: '状态',
98
+ },
99
+ initialValue: 'all',
100
+ props: {
101
+ options: [
102
+ { value: 'all', label: '全部' },
103
+ { value: 'active', label: '激活' },
104
+ { value: 'inactive', label: '未激活' },
105
+ ],
106
+ },
107
+ },
108
+ {
109
+ is: 'date-picker',
110
+ prop: 'createTime',
111
+ formItem: {
112
+ label: '创建时间',
113
+ },
114
+ },
115
+ ]
116
+
117
+ // 表格列配置
118
+ const tableColumns = [
119
+ { prop: 'name', label: '姓名' },
120
+ { prop: 'email', label: '邮箱' },
121
+ { prop: 'status', label: '状态' },
122
+ {
123
+ prop: 'createTime',
124
+ label: '创建时间',
125
+ type: 'dateTime', // 自动格式化日期时间
126
+ },
127
+ ]
128
+ </script>
129
+ ```
130
+
131
+ #### 高级配置示例
132
+
133
+ ```vue
134
+ <template>
135
+ <CommonConfigProvider
136
+ :component="{
137
+ form: {
138
+ submitText: '查询',
139
+ resetText: '重置',
140
+ formItem: {
141
+ components: {
142
+ width: '240px',
143
+ },
144
+ },
145
+ },
146
+ pagination: {
147
+ defaultPageSize: 20,
148
+ defaultPageCount: 1,
149
+ },
150
+ table: {
151
+ headerCellStyle: {
152
+ backgroundColor: '#f5f7fa',
153
+ color: '#303133',
154
+ },
155
+ },
156
+ }"
157
+ >
158
+ <CommonQueryTable
159
+ v-bind="queryTableConfig"
160
+ :layouts="['form', 'toolbar', 'table', 'pagination']"
161
+ >
162
+ <!-- 自定义工具栏 -->
163
+ <template #toolbar>
164
+ <el-button type="primary" @click="handleAdd">新增</el-button>
165
+ <el-button @click="handleExport">导出</el-button>
166
+ </template>
167
+
168
+ <!-- 自定义表格列 -->
169
+ <template #table-action="{ row }">
170
+ <el-button link @click="handleEdit(row)">编辑</el-button>
171
+ <el-button link type="danger" @click="handleDelete(row)">删除</el-button>
172
+ </template>
173
+ </CommonQueryTable>
174
+ </CommonConfigProvider>
175
+ </template>
176
+
177
+ <script setup>
178
+ import { CommonConfigProvider, CommonQueryTable } from '@yetuzi/vue3-query-components'
179
+
180
+ const queryTableConfig = {
181
+ fetch: fetchData,
182
+ form: formConfig,
183
+ columns: [
184
+ { prop: 'name', label: '姓名' },
185
+ { prop: 'status', label: '状态' },
186
+ { label: '操作', prop: 'action', fixed: 'right', width: 150 },
187
+ ],
188
+ }
189
+ </script>
190
+ ```
191
+
192
+ ## 📚 组件文档
193
+
194
+ ### CommonQueryTable Props
195
+
196
+ | 参数 | 说明 | 类型 | 默认值 |
197
+ | ------- | ------------ | ------------------------------------------------------------------------ | --------------------------------- |
198
+ | fetch | 数据请求函数 | `(params: ListParam) => Promise<{ list: T[], total: string \| number }>` | - |
199
+ | form | 表单配置数组 | `CommonFormPropForm[]` | [] |
200
+ | columns | 表格列配置 | `CommonTableColumn[]` | - |
201
+ | layouts | 布局顺序 | `Array<'header'\|'form'\|'toolbar'\|'table'\|'pagination'\|'footer'>` | `['form', 'table', 'pagination']` |
202
+
203
+ ### 表单组件类型支持
204
+
205
+ 支持以下表单组件类型:
206
+
207
+ - `input` - 输入框
208
+ - `select` - 下拉选择
209
+ - `date-picker` - 日期选择器
210
+ - `radio` - 单选框组
211
+ - `check-box` - 复选框组
212
+ - `switch` - 开关
213
+
214
+ ### 表单配置项类型
215
+
216
+ ```typescript
217
+ interface FormItemConfig {
218
+ is: string // 组件类型
219
+ prop: string // 字段名
220
+ formItem: {
221
+ // ElFormItem 配置
222
+ label: string
223
+ [key: string]: any
224
+ }
225
+ initialValue?: any // 初始值
226
+ props?: {
227
+ // 组件属性
228
+ [key: string]: any
229
+ }
230
+ }
231
+ ```
232
+
233
+ ### 表格列配置类型
234
+
235
+ ```typescript
236
+ interface TableColumn {
237
+ prop: string // 列属性名
238
+ label: string // 列标题
239
+ type?: 'dateTime' // 特殊类型:自动格式化日期时间
240
+ width?: string \| number // 列宽度
241
+ fixed?: boolean \| 'left' \| 'right' // 固定列
242
+ [key: string]: any // 其他 ElTableColumn 属性
243
+ }
244
+ ```
245
+
246
+ ## 🎨 全局配置
247
+
248
+ 使用 `CommonConfigProvider` 可以全局配置组件样式和行为:
249
+
250
+ ```vue
251
+ <template>
252
+ <CommonConfigProvider
253
+ :component="{
254
+ placeholder: '暂无数据', // 空值占位
255
+ pagination: {
256
+ defaultPageCount: 1, // 默认起始页
257
+ defaultPageSize: 10, // 默认每页条数
258
+ },
259
+ table: {
260
+ headerCellStyle: {
261
+ // 表头样式
262
+ backgroundColor: '#f1f6ff',
263
+ color: '#000000',
264
+ height: '48px',
265
+ },
266
+ },
267
+ form: {
268
+ submitText: '搜索', // 提交按钮文本
269
+ resetText: '重置', // 重置按钮文本
270
+ formItem: {
271
+ components: {
272
+ width: '200px', // 表单组件宽度
273
+ },
274
+ },
275
+ },
276
+ }"
277
+ >
278
+ <YourApp />
279
+ </CommonConfigProvider>
280
+ </template>
281
+ ```
282
+
283
+ ## 🛠️ 开发
284
+
285
+ ### 环境要求
286
+
287
+ - Node.js >= 18.0.0
288
+ - Vue 3.5+
289
+ - Element Plus 2.11+
290
+ - TypeScript 5.9+
291
+
292
+ ### 本地开发
293
+
294
+ ```bash
295
+ # 克隆项目
296
+ git clone https://gitee.com/yetuzi/vue3-common.git
297
+ cd vue3-common/vue3-query-components
298
+
299
+ # 安装依赖
300
+ npm install
301
+
302
+ # 开发模式(构建并监听文件变化)
303
+ npm run dev
304
+
305
+ # 构建
306
+ npm run build
307
+
308
+ # 类型检查
309
+ npm run type-check
310
+
311
+ # 代码格式化
312
+ npm run format
313
+
314
+ # Lint
315
+ npm run lint
316
+
317
+ # 测试
318
+ npm test
319
+ ```
320
+
321
+ ### 依赖说明
322
+
323
+ ```json
324
+ {
325
+ "peerDependencies": {
326
+ "vue": "^3.5.0", // Vue 3 - 需要宿主项目安装
327
+ "element-plus": "^2.11.5" // Element Plus UI 库 - 需要宿主项目安装
328
+ },
329
+ "dependencies": {
330
+ "dayjs": "^1.11.18", // 日期处理库
331
+ "lodash-es": "^4.17.21", // 工具函数库
332
+ "vue-hooks-plus": "^2.4.1" // Vue 组合式 API 工具库
333
+ }
334
+ }
335
+ ```
336
+
337
+ ## 🎯 使用场景
338
+
339
+ 本组件库特别适用于:
340
+
341
+ - **企业后台管理系统** - 大量数据查询、展示、分页场景
342
+ - **数据报表页面** - 需要复杂查询条件的数据展示
343
+ - **CRUD 操作页面** - 增删改查的标准业务页面
344
+ - **列表展示页面** - 各种数据列表的展示和筛选
345
+
346
+ ## 📄 许可证
347
+
348
+ [MIT](./LICENSE)
349
+
350
+ ## 🤝 贡献
351
+
352
+ 欢迎提交 Issue 和 Pull Request!
353
+
354
+ ## 📞 支持
355
+
356
+ 如有问题,请提交 [Issue](https://gitee.com/yetuzi/vue3-common/issues)
357
+
358
+ ## 🗺️ 更新日志
359
+
360
+ 查看详细的更新日志请访问:[CHANGELOG.md](./CHANGELOG.md)