el-crud-page 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 tonwe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,187 @@
1
+ # el-crud-page
2
+
3
+ 一个基于 Element UI v2 的强大 CRUD 页面组件库,简化表格、表单和查询的开发。
4
+
5
+ ## 特性
6
+
7
+ - 🚀 开箱即用的 CRUD 页面组件
8
+ - 📋 灵活的表格配置
9
+ - 📝 自动表单生成
10
+ - 🔍 查询表单支持
11
+ - 🎨 完全兼容 Element UI v2
12
+ - 💪 TypeScript 支持
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ npm install el-crud-page
18
+ # 或
19
+ yarn add el-crud-page
20
+ ```
21
+
22
+ ## 依赖
23
+
24
+ 本库需要以下依赖(需要在你的项目中安装):
25
+
26
+ - Vue 2.6+
27
+ - Element UI 2.x
28
+
29
+ ## 使用
30
+
31
+ ### 完整引入
32
+
33
+ ```javascript
34
+ import Vue from 'vue';
35
+ import { Crud, CrudTabledForm, QueryForm } from 'el-crud-page';
36
+
37
+ Vue.component('Crud', Crud);
38
+ ```
39
+
40
+ ### 按需引入
41
+
42
+ ```javascript
43
+ import { Crud } from 'el-crud-page';
44
+
45
+ export default {
46
+ components: {
47
+ Crud
48
+ }
49
+ }
50
+ ```
51
+
52
+ ## 组件说明
53
+
54
+ ### Crud
55
+
56
+ 主组件,集成了表格、表单和查询功能。
57
+
58
+ ### CrudTable
59
+
60
+ 表格组件,基于 Element UI 的 Table 组件封装。
61
+
62
+ ### CrudForm
63
+
64
+ 表单组件,基于 Element UI 的 Form 组件封装。
65
+
66
+ ### QueryForm
67
+
68
+ 查询表单组件,用于数据筛选。
69
+
70
+ ## 基础示例
71
+
72
+ ```vue
73
+ <template>
74
+ <crud
75
+ ref="crud"
76
+ :columns="columns"
77
+ :query-items="queryItems"
78
+ :buttons="buttons"
79
+ @action="handleAction"
80
+ @row-action="handleRowAction"
81
+ />
82
+ </template>
83
+
84
+ ```
85
+
86
+ ## 完整示例
87
+
88
+ 更完整的示例请参考 [examples/App.vue](./examples/App.vue)
89
+
90
+ ## API 说明
91
+
92
+ ### Crud Props
93
+
94
+ | 参数 | 说明 | 类型 | 默认值 |
95
+ | --- | --- | --- | --- |
96
+ | columns | 表格列配置 | Array | [] |
97
+ | queryItems | 查询表单配置 | Array | [] |
98
+ | buttons | 顶部按钮配置,可以是数组或函数 | Array/Function | [] |
99
+ | tabPanes | 标签页配置 | Array | [] |
100
+ | queryLineClamp | 查询表单行数限制 | Number | 1 |
101
+ | queryLabelWidth | 查询表单标签宽度 | Number | 80 |
102
+ | queryInputWidth | 查询表单输入框宽度 | Number | 210 |
103
+
104
+
105
+ ### Crud Events
106
+
107
+ | 事件名 | 说明 | 回调参数 |
108
+ | --- | --- | --- |
109
+ | action | 顶部按钮点击事件 | (action, selections) |
110
+ | row-action | 行内按钮点击事件 | (action, scope) |
111
+ | tabChange | 标签页切换事件 | (tabKey) |
112
+
113
+ ### Crud Methods
114
+
115
+ | 方法名 | 说明 | 参数 |
116
+ | --- | --- | --- |
117
+ | setService | 设置服务接口 | (service) service对象包含 page/add/update/delete/info 等方法 |
118
+ | refresh | 刷新列表数据 | - |
119
+
120
+ ### 列配置 (columns)
121
+
122
+ ```javascript
123
+ {
124
+ type: 'selection', // 列类型: selection/index/expand
125
+ prop: 'name', // 字段名
126
+ label: '名称', // 列标题
127
+ width: 120, // 列宽度
128
+ fixed: 'left', // 固定列: left/right
129
+ sortable: true, // 是否可排序
130
+
131
+ }
132
+ ```
133
+
134
+ ### 查询表单配置 (queryItems)
135
+
136
+ ```javascript
137
+
138
+ ```
139
+
140
+ ### 按钮配置 (buttons)
141
+
142
+ ```javascript
143
+ // 数组形式
144
+ buttons: [
145
+ {
146
+ text: '新增',
147
+ type: 'primary',
148
+ icon: 'el-icon-plus',
149
+ action: 'add',
150
+ plain: false,
151
+ disabled: false
152
+ }
153
+ ]
154
+
155
+ // 函数形式(可根据选中数据动态配置)
156
+ buttons: (selections) => {
157
+ return [
158
+ {
159
+ text: '批量删除',
160
+ type: 'danger',
161
+ action: 'batchDelete',
162
+ disabled: selections.length === 0
163
+ }
164
+ ];
165
+ }
166
+ ```
167
+
168
+ ## 开发
169
+
170
+ ```bash
171
+ # 安装依赖
172
+ npm install
173
+
174
+ # 开发模式
175
+ npm run dev
176
+
177
+ # 构建
178
+ npm run build
179
+ ```
180
+
181
+ ## License
182
+
183
+ MIT
184
+
185
+ ## 作者
186
+
187
+ tonwe