py-test-components 1.0.0 → 1.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/CLAUDE.md +8 -0
- package/DEVELOPER.md +541 -0
- package/README.md +60 -214
- package/dist/py-component.esm.js +1 -1
- package/dist/py-component.esm.js.LICENSE.txt +0 -6
- package/dist/py-component.js +1 -1
- package/dist/py-component.js.LICENSE.txt +0 -6
- package/package.json +29 -42
- package/src/components/PyTable.vue +40 -280
- package/src/components/PyWeather.vue +48 -387
- package/src/index.js +20 -51
- package/src/react/index.js +60 -156
- package/src/store/index.js +17 -66
- package/src/utils/api.js +13 -101
- package/src/utils/request.js +10 -113
- package/src/vue/index.js +25 -32
- package/webpack.config.js +48 -0
- package//350/246/201/346/261/202.txt +17 -0
package/package.json
CHANGED
|
@@ -1,42 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "py-test-components",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "dist/py-component.js",
|
|
6
|
-
"module": "dist/py-component.esm.js",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"element
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"webpack": "^5.89.0",
|
|
31
|
-
"webpack-cli": "^5.1.4"
|
|
32
|
-
},
|
|
33
|
-
"keywords": [
|
|
34
|
-
"vue",
|
|
35
|
-
"react",
|
|
36
|
-
"web-components",
|
|
37
|
-
"component-library",
|
|
38
|
-
"element-ui"
|
|
39
|
-
],
|
|
40
|
-
"author": "",
|
|
41
|
-
"license": "MIT"
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "py-test-components",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Vue2 + ElementUI component library for Vue and React",
|
|
5
|
+
"main": "dist/py-component.js",
|
|
6
|
+
"module": "dist/py-component.esm.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "webpack --mode development --watch",
|
|
9
|
+
"build": "webpack --mode production"
|
|
10
|
+
},
|
|
11
|
+
"keywords": ["vue", "elementui", "component", "library"],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"vue": "^2.7.0",
|
|
16
|
+
"element-ui": "^2.15.0",
|
|
17
|
+
"vue-custom-element": "^3.3.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"webpack": "^5.0.0",
|
|
21
|
+
"webpack-cli": "^5.0.0",
|
|
22
|
+
"vue-loader": "^15.10.0",
|
|
23
|
+
"vue-template-compiler": "^2.7.0",
|
|
24
|
+
"css-loader": "^6.0.0",
|
|
25
|
+
"style-loader": "^3.0.0",
|
|
26
|
+
"file-loader": "^6.0.0",
|
|
27
|
+
"url-loader": "^4.0.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,280 +1,40 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="py-table">
|
|
3
|
-
<el-
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<!-- 动态列 -->
|
|
42
|
-
<el-table-column
|
|
43
|
-
v-for="column in columns"
|
|
44
|
-
:key="column.prop"
|
|
45
|
-
:prop="column.prop"
|
|
46
|
-
:label="column.label"
|
|
47
|
-
:width="column.width"
|
|
48
|
-
:min-width="column.minWidth"
|
|
49
|
-
:sortable="column.sortable"
|
|
50
|
-
>
|
|
51
|
-
<template slot-scope="scope">
|
|
52
|
-
<!-- 自定义渲染 -->
|
|
53
|
-
<span v-if="column.formatter">
|
|
54
|
-
{{ column.formatter(scope.row[column.prop], scope.row) }}
|
|
55
|
-
</span>
|
|
56
|
-
<span v-else-if="column.type === 'date'">
|
|
57
|
-
{{ formatDate(scope.row[column.prop]) }}
|
|
58
|
-
</span>
|
|
59
|
-
<span v-else-if="column.type === 'status'">
|
|
60
|
-
<el-tag :type="getStatusType(scope.row[column.prop])">
|
|
61
|
-
{{ scope.row[column.prop] }}
|
|
62
|
-
</el-tag>
|
|
63
|
-
</span>
|
|
64
|
-
<span v-else>
|
|
65
|
-
{{ scope.row[column.prop] }}
|
|
66
|
-
</span>
|
|
67
|
-
</template>
|
|
68
|
-
</el-table-column>
|
|
69
|
-
|
|
70
|
-
<!-- 操作列 -->
|
|
71
|
-
<el-table-column
|
|
72
|
-
v-if="config.showActions !== false"
|
|
73
|
-
label="操作"
|
|
74
|
-
width="150"
|
|
75
|
-
fixed="right"
|
|
76
|
-
>
|
|
77
|
-
<template slot-scope="scope">
|
|
78
|
-
<el-button
|
|
79
|
-
type="text"
|
|
80
|
-
size="small"
|
|
81
|
-
@click="handleEdit(scope.row)"
|
|
82
|
-
>
|
|
83
|
-
编辑
|
|
84
|
-
</el-button>
|
|
85
|
-
<el-button
|
|
86
|
-
type="text"
|
|
87
|
-
size="small"
|
|
88
|
-
@click="handleDelete(scope.row)"
|
|
89
|
-
>
|
|
90
|
-
删除
|
|
91
|
-
</el-button>
|
|
92
|
-
</template>
|
|
93
|
-
</el-table-column>
|
|
94
|
-
</el-table>
|
|
95
|
-
|
|
96
|
-
<!-- 分页 -->
|
|
97
|
-
<div v-if="config.pagination !== false" class="pagination-wrapper">
|
|
98
|
-
<el-pagination
|
|
99
|
-
:current-page="currentPage"
|
|
100
|
-
:page-size="pageSize"
|
|
101
|
-
:page-sizes="[10, 20, 50, 100]"
|
|
102
|
-
:total="total"
|
|
103
|
-
layout="total, sizes, prev, pager, next, jumper"
|
|
104
|
-
@size-change="handleSizeChange"
|
|
105
|
-
@current-change="handlePageChange"
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
</el-card>
|
|
109
|
-
</div>
|
|
110
|
-
</template>
|
|
111
|
-
|
|
112
|
-
<script>
|
|
113
|
-
import store from '../store';
|
|
114
|
-
import { tableApi } from '../utils/api';
|
|
115
|
-
|
|
116
|
-
export default {
|
|
117
|
-
name: 'PyTable',
|
|
118
|
-
|
|
119
|
-
props: {
|
|
120
|
-
propData: {
|
|
121
|
-
default: null
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
data() {
|
|
126
|
-
return {
|
|
127
|
-
tableData: [],
|
|
128
|
-
loading: false,
|
|
129
|
-
currentPage: 1,
|
|
130
|
-
pageSize: 10,
|
|
131
|
-
total: 0,
|
|
132
|
-
selectedRows: []
|
|
133
|
-
};
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
computed: {
|
|
137
|
-
config() {
|
|
138
|
-
return this.propData || {};
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
columns() {
|
|
142
|
-
return this.config.columns || [];
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
mounted() {
|
|
147
|
-
this.loadData();
|
|
148
|
-
|
|
149
|
-
// 监听 store 变化(如果需要)
|
|
150
|
-
const baseUrl = store.get('baseUrl');
|
|
151
|
-
if (baseUrl) {
|
|
152
|
-
console.log('[PyTable] baseUrl from store:', baseUrl);
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
methods: {
|
|
157
|
-
// 加载数据
|
|
158
|
-
async loadData() {
|
|
159
|
-
if (this.config.data) {
|
|
160
|
-
// 使用传入的数据
|
|
161
|
-
this.tableData = this.config.data;
|
|
162
|
-
this.total = this.tableData.length;
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// 通过 API 获取数据
|
|
167
|
-
if (this.config.api !== false) {
|
|
168
|
-
try {
|
|
169
|
-
this.loading = true;
|
|
170
|
-
const params = {
|
|
171
|
-
page: this.currentPage,
|
|
172
|
-
size: this.pageSize,
|
|
173
|
-
...this.config.params
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const res = await tableApi.getData(params);
|
|
177
|
-
|
|
178
|
-
// 支持自定义数据路径
|
|
179
|
-
const dataPath = this.config.dataPath || 'data';
|
|
180
|
-
const totalPath = this.config.totalPath || 'total';
|
|
181
|
-
|
|
182
|
-
this.tableData = this.getPathValue(res, dataPath) || [];
|
|
183
|
-
this.total = this.getPathValue(res, totalPath) || 0;
|
|
184
|
-
} catch (error) {
|
|
185
|
-
console.error('[PyTable] 加载数据失败:', error);
|
|
186
|
-
this.$message.error('加载数据失败');
|
|
187
|
-
} finally {
|
|
188
|
-
this.loading = false;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
// 获取对象路径值
|
|
194
|
-
getPathValue(obj, path) {
|
|
195
|
-
return path.split('.').reduce((o, p) => o && o[p], obj);
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
// 刷新数据
|
|
199
|
-
refreshData() {
|
|
200
|
-
this.currentPage = 1;
|
|
201
|
-
this.loadData();
|
|
202
|
-
this.$emit('refresh');
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
// 分页大小变化
|
|
206
|
-
handleSizeChange(size) {
|
|
207
|
-
this.pageSize = size;
|
|
208
|
-
this.loadData();
|
|
209
|
-
this.$emit('size-change', size);
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
// 页码变化
|
|
213
|
-
handlePageChange(page) {
|
|
214
|
-
this.currentPage = page;
|
|
215
|
-
this.loadData();
|
|
216
|
-
this.$emit('page-change', page);
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
// 选择变化
|
|
220
|
-
handleSelectionChange(rows) {
|
|
221
|
-
this.selectedRows = rows;
|
|
222
|
-
this.$emit('selection-change', rows);
|
|
223
|
-
},
|
|
224
|
-
|
|
225
|
-
// 编辑
|
|
226
|
-
handleEdit(row) {
|
|
227
|
-
this.$emit('edit', row);
|
|
228
|
-
},
|
|
229
|
-
|
|
230
|
-
// 删除
|
|
231
|
-
handleDelete(row) {
|
|
232
|
-
this.$emit('delete', row);
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
// 格式化日期
|
|
236
|
-
formatDate(value) {
|
|
237
|
-
if (!value) return '';
|
|
238
|
-
const date = new Date(value);
|
|
239
|
-
return date.toLocaleDateString('zh-CN');
|
|
240
|
-
},
|
|
241
|
-
|
|
242
|
-
// 获取状态类型
|
|
243
|
-
getStatusType(status) {
|
|
244
|
-
const statusMap = {
|
|
245
|
-
'active': 'success',
|
|
246
|
-
'pending': 'warning',
|
|
247
|
-
'disabled': 'info',
|
|
248
|
-
'error': 'danger'
|
|
249
|
-
};
|
|
250
|
-
return statusMap[status] || '';
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
</script>
|
|
255
|
-
|
|
256
|
-
<style scoped>
|
|
257
|
-
.py-table {
|
|
258
|
-
width: 100%;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.table-card {
|
|
262
|
-
margin-bottom: 20px;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.card-header {
|
|
266
|
-
display: flex;
|
|
267
|
-
justify-content: space-between;
|
|
268
|
-
align-items: center;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.title {
|
|
272
|
-
font-size: 16px;
|
|
273
|
-
font-weight: 500;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.pagination-wrapper {
|
|
277
|
-
margin-top: 20px;
|
|
278
|
-
text-align: right;
|
|
279
|
-
}
|
|
280
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="py-table">
|
|
3
|
+
<el-table :data="tableData" v-bind="config">
|
|
4
|
+
<el-table-column
|
|
5
|
+
v-for="(col, index) in columns"
|
|
6
|
+
:key="index"
|
|
7
|
+
:prop="col.prop"
|
|
8
|
+
:label="col.label"
|
|
9
|
+
/>
|
|
10
|
+
</el-table>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
name: 'PyTable',
|
|
17
|
+
props: {
|
|
18
|
+
propData: {
|
|
19
|
+
default: null,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
computed: {
|
|
23
|
+
tableData() {
|
|
24
|
+
return this.propData?.data || [];
|
|
25
|
+
},
|
|
26
|
+
columns() {
|
|
27
|
+
return this.propData?.columns || [];
|
|
28
|
+
},
|
|
29
|
+
config() {
|
|
30
|
+
return this.propData?.config || {};
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<style scoped>
|
|
37
|
+
.py-table {
|
|
38
|
+
width: 100%;
|
|
39
|
+
}
|
|
40
|
+
</style>
|