@xjw_/vue2-npm-system 1.0.19 → 1.0.21

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.
@@ -0,0 +1,417 @@
1
+ <template>
2
+ <div :class="{'x-vxe-table-bg':xIsShowBg}" class="x-vxe-table" :style="{ height: `calc(100vh - ${xSubHeight})` }">
3
+ <vxe-toolbar
4
+ v-if="xShowToolbar"
5
+ ref="xToolbar"
6
+ class="h-plr-12"
7
+ :refresh="{ query: getList }"
8
+ perfect
9
+ export
10
+ print
11
+ custom
12
+ >
13
+ <template #buttons>
14
+ <slot name="buttons"></slot>
15
+ </template>
16
+ </vxe-toolbar>
17
+ <div :style="{height: xHeight}">
18
+ <vxe-table
19
+ ref="vxeTable"
20
+ :print-config="{}"
21
+ :export-config="{}"
22
+ :data="xShowFooter && xFooterData.length < 1 ? tableData.slice(0, -1) : tableData"
23
+ border
24
+ :size="xSize"
25
+ :stripe="xStripe"
26
+ height="100%"
27
+ align="center"
28
+ resizable
29
+ :max-height="xMaxHeight"
30
+ :show-header="xShowHeader"
31
+ :show-overflow="xShowOverflow"
32
+ :custom-config="{}"
33
+ :header-cell-class-name="xHeaderCellClassName"
34
+ :cell-class-name="xCellClassName"
35
+ :row-class-name="xRowClassName"
36
+ :show-footer="xShowFooter"
37
+ :footer-cell-class-name="xFooterCellClassName"
38
+ :sort-config="xSortConfig"
39
+ :filter-config="xFilterConfig"
40
+ :checkbox-config="xCheckboxConfig"
41
+ :radio-config="xRadioConfig"
42
+ :proxy-config="xProxyConfig"
43
+ :loading="xLoading"
44
+ :empty-text="xEmptyText"
45
+ :footer-method="internalFooterMethod"
46
+ @checkbox-change="handleCheckboxChange"
47
+ @checkbox-all="handleCheckboxAll"
48
+ @radio-change="handleRadioChange"
49
+ @sort-change="handleSortChange"
50
+ @current-change="handleCurrentChange"
51
+ @edit-closed="handleEditClosed"
52
+ @edit-actived="handleEditActived"
53
+ v-on="$listeners"
54
+ >
55
+ <vxe-column
56
+ v-if="xIsCheckbox"
57
+ type="checkbox"
58
+ width="55"
59
+ fixed="left"
60
+ >
61
+ </vxe-column>
62
+ <!-- 序号列 -->
63
+ <vxe-column v-if="xShowIndex" type="seq" fixed="left" title="序号" width="60"></vxe-column>
64
+ <!-- 支持自定义插槽:透传父组件的默认插槽和具名插槽到 vxe-table -->
65
+ <slot></slot>
66
+ </vxe-table>
67
+ <!-- 分页组件 -->
68
+ <x-pagination
69
+ v-if="xShowPagination"
70
+ class="x-pagination"
71
+ @update-page="handlePageChange"
72
+ :x-page-size="xPageSize"
73
+ :x-current-page="internalCurrentPage"
74
+ :x-total="xTotal"/>
75
+ </div>
76
+ </div>
77
+ </template>
78
+
79
+ <script>
80
+ import XPagination from './XPagination'
81
+
82
+ export default {
83
+ name: 'XVxeTable',
84
+ components: {
85
+ XPagination
86
+ },
87
+ props: {
88
+ // 表格数据
89
+ tableData: {
90
+ type: Array,
91
+ default: () => []
92
+ },
93
+ xIsShowBg: {
94
+ type: Boolean,
95
+ default: true
96
+ },
97
+ // 尺寸:large、medium、small、mini
98
+ xSize: {
99
+ type: String,
100
+ default: 'medium'
101
+ },
102
+ // 斑马纹
103
+ xStripe: {
104
+ type: Boolean,
105
+ default: false
106
+ },
107
+ // 表格高度
108
+ xSubHeight: {
109
+ type: String,
110
+ default: '130px'
111
+ },
112
+ // 最大高度
113
+ xMaxHeight: {
114
+ type: [Number, String],
115
+ default: null
116
+ },
117
+ // 是否显示表头
118
+ xShowHeader: {
119
+ type: Boolean,
120
+ default: true
121
+ },
122
+ xShowOverflow: {
123
+ type: Boolean,
124
+ default: true
125
+ },
126
+ // 表头单元格 className
127
+ xHeaderCellClassName: {
128
+ type: [String, Function],
129
+ default: ''
130
+ },
131
+ // 单元格 className
132
+ xCellClassName: {
133
+ type: [String, Function],
134
+ default: ''
135
+ },
136
+ // 行 className
137
+ xRowClassName: {
138
+ type: [String, Function],
139
+ default: ''
140
+ },
141
+ // 是否显示复选框列
142
+ xIsCheckbox: {
143
+ type: Boolean,
144
+ default: false
145
+ },
146
+ // 是否显示表尾合计行
147
+ xShowFooter: {
148
+ type: Boolean,
149
+ default: false
150
+ },
151
+ // 表尾合计文字
152
+ xShowFooterText: {
153
+ type: String,
154
+ default: ''
155
+ },
156
+ // 表尾计算方法
157
+ xFooterMethod: {
158
+ type: Function,
159
+ default: null
160
+ },
161
+ // 表尾单元格 className
162
+ xFooterCellClassName: {
163
+ type: [String, Function],
164
+ default: ''
165
+ },
166
+ // 排序配置
167
+ xSortConfig: {
168
+ type: Object,
169
+ default: () => ({})
170
+ },
171
+ // 筛选配置
172
+ xFilterConfig: {
173
+ type: Object,
174
+ default: () => ({})
175
+ },
176
+ // 复选框配置
177
+ xCheckboxConfig: {
178
+ type: Object,
179
+ default: () => ({})
180
+ },
181
+ // 单选框配置
182
+ xRadioConfig: {
183
+ type: Object,
184
+ default: () => ({})
185
+ },
186
+ // 代理配置(用于服务端加载)
187
+ xProxyConfig: {
188
+ type: Object,
189
+ default: null
190
+ },
191
+ // 是否显示加载中
192
+ xLoading: {
193
+ type: Boolean,
194
+ default: false
195
+ },
196
+ // 空数据提示文本
197
+ xEmptyText: {
198
+ type: String,
199
+ default: '暂无数据'
200
+ },
201
+ // 是否显示序号列
202
+ xShowIndex: {
203
+ type: Boolean,
204
+ default: true
205
+ },
206
+ // 是否显示分页
207
+ xShowPagination: {
208
+ type: Boolean,
209
+ default: true
210
+ },
211
+ // 每页条数
212
+ xPageSize: {
213
+ type: Number,
214
+ default: 20
215
+ },
216
+ // 当前页码
217
+ xCurrentPage: {
218
+ type: Number,
219
+ default: 1
220
+ },
221
+ // 总条数
222
+ xTotal: {
223
+ type: Number,
224
+ default: 0
225
+ },
226
+ // 表尾合计行数据,二维数组格式
227
+ xFooterData: {
228
+ type: Array,
229
+ default: []
230
+ },
231
+ xShowToolbar: {
232
+ type: Boolean,
233
+ default: true
234
+ },
235
+ xSubToolbarHeight: {
236
+ type: Number,
237
+ default: 46
238
+ },
239
+ xSubPaginationHeight: {
240
+ type: Number,
241
+ default: 46
242
+ }
243
+ },
244
+ data() {
245
+ return {
246
+ internalCurrentPage: this.xCurrentPage,
247
+ internalPageSize: this.xPageSize
248
+ }
249
+ },
250
+ computed: {
251
+ // 计算表格高度:100% - (工具栏高度 + 分页高度 + 基础边距)
252
+ xHeight() {
253
+ const baseHeight = this.xIsShowBg ? 19 : 0 // 基础边距和边框高度
254
+ const toolbarHeight = this.xShowToolbar ? this.xSubToolbarHeight : 0
255
+ const paginationHeight = this.xShowPagination ? this.xSubPaginationHeight : 0
256
+ const totalHeight = baseHeight + toolbarHeight + paginationHeight
257
+ return `calc(100% - ${totalHeight}px)`
258
+ }
259
+ },
260
+ watch: {
261
+ xCurrentPage(val) {
262
+ this.internalCurrentPage = val
263
+ },
264
+ xPageSize(val) {
265
+ this.internalPageSize = val
266
+ }
267
+ },
268
+ methods: {
269
+ // 获取 VXE Table 实例
270
+ getTableInstance() {
271
+ return this.$refs.vxeTable
272
+ },
273
+ getList(){
274
+ this.handlePageChange(1,this.xPageSize)
275
+ },
276
+ // 复选框改变
277
+ handleCheckboxChange(params) {
278
+ this.$emit('checkbox-change', params)
279
+ },
280
+
281
+ // 全选/取消全选
282
+ handleCheckboxAll(params) {
283
+ this.$emit('checkbox-all', params)
284
+ },
285
+
286
+ // 获取选中的数据
287
+ getCheckboxRecords() {
288
+ return this.$refs.vxeTable.getCheckboxRecords()
289
+ },
290
+
291
+ // 设置某行选中
292
+ setCheckboxRow(row, checked) {
293
+ this.$refs.vxeTable.setCheckboxRow(row, checked)
294
+ },
295
+
296
+ // 切换某行选中状态
297
+ toggleCheckboxRow(row) {
298
+ this.$refs.vxeTable.toggleCheckboxRow(row)
299
+ },
300
+
301
+ // 清除复选
302
+ clearCheckbox() {
303
+ this.$refs.vxeTable.clearCheckbox()
304
+ },
305
+
306
+ // 单选框改变
307
+ handleRadioChange(params) {
308
+ this.$emit('radio-change', params)
309
+ },
310
+
311
+ // 排序改变
312
+ handleSortChange(params) {
313
+ this.$emit('sort-change', params)
314
+ },
315
+
316
+ // 当前行改变
317
+ handleCurrentChange(params) {
318
+ this.$emit('current-change', params)
319
+ },
320
+
321
+ // 编辑关闭
322
+ handleEditClosed(params) {
323
+ this.$emit('edit-closed', params)
324
+ },
325
+
326
+ // 激活编辑
327
+ handleEditActived(params) {
328
+ this.$emit('edit-actived', params)
329
+ },
330
+
331
+ // 页码改变
332
+ handlePageChange(page,size) {
333
+ this.internalCurrentPage = page
334
+ this.internalPageSize = size
335
+ this.$emit('change-page', this.internalCurrentPage,this.internalPageSize)
336
+ },
337
+
338
+ // 清除排序
339
+ clearSort() {
340
+ this.$refs.vxeTable.clearSort()
341
+ },
342
+
343
+ // 滚动到指定行
344
+ scrollTo(row) {
345
+ this.$refs.vxeTable.scrollTo(row)
346
+ },
347
+
348
+ // 设置当前行
349
+ setCurrentRow(row) {
350
+ this.$refs.vxeTable.setCurrentRow(row)
351
+ },
352
+ // 内部表尾合计方法
353
+ internalFooterMethod({ columns}) {
354
+ // 2. 如果传入了合计行数据,直接返回
355
+ if (this.xFooterData.length > 0) {
356
+ return this.xFooterData
357
+ }
358
+ const data = this.tableData
359
+ // 3. 默认逻辑:取最后一行数据进行转换(如果存在数据)
360
+ if (data && data.length > 0) {
361
+ const lastRow = data[data.length - 1]
362
+ const footerRow = columns.map((column, index) => {
363
+ if (index === 0) {
364
+ return this.xShowFooterText ? this.xShowFooterText : '合计'
365
+ }
366
+ // 根据列字段获取最后一行对应的值
367
+ if (column.property) {
368
+ return lastRow[column.property] || ''
369
+ }
370
+ return ''
371
+ })
372
+ return [footerRow]
373
+ }
374
+
375
+ return []
376
+ }
377
+ }
378
+ }
379
+ </script>
380
+
381
+ <style lang="scss" scoped>
382
+ .vxe-toolbar.is--perfect{
383
+ background-color: #FFFFFF !important;
384
+ border: none;
385
+ }
386
+ .x-vxe-table {
387
+ position: relative;
388
+ }
389
+ .x-vxe-table-bg {
390
+ background: #FFFFFF;
391
+ border-radius: 4px;
392
+ padding: 0 20px;
393
+ }
394
+
395
+ ::v-deep .vxe-table .vxe-footer--row {
396
+ background: #FFF2F6;
397
+ }
398
+
399
+ ::v-deep .vxe-table .vxe-footer--cell.sum-title {
400
+ text-align: center;
401
+ font-size: 18px;
402
+ font-weight: bold;
403
+ }
404
+
405
+ ::v-deep .vxe-table .vxe-footer--cell.footer-info {
406
+ font-weight: bold;
407
+ }
408
+
409
+ /*.x-pagination {
410
+ position: absolute;
411
+ bottom: 20px;
412
+ left: 20px;
413
+ width: calc(100% - 40px);
414
+ z-index: 1000;
415
+ background-color: #ffffff;
416
+ }*/
417
+ </style>
package/lib/index.js CHANGED
@@ -4,21 +4,46 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ Object.defineProperty(exports, "XPagination", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _XPagination["default"];
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "XReportTable", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _XReportTable["default"];
17
+ }
18
+ });
7
19
  Object.defineProperty(exports, "XSearchBar", {
8
20
  enumerable: true,
9
21
  get: function get() {
10
22
  return _XSearchBar["default"];
11
23
  }
12
24
  });
25
+ Object.defineProperty(exports, "XVxeTable", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _XVxeTable["default"];
29
+ }
30
+ });
13
31
  exports["default"] = void 0;
14
32
  require("./plugins/svg-icon");
15
- require("./styles/x-ui.scss");
16
33
  var _XSearchBar = _interopRequireDefault(require("./components/XSearchBar"));
17
34
  var _SvgIcon = _interopRequireDefault(require("./components/SvgIcon"));
35
+ var _XVxeTable = _interopRequireDefault(require("./components/XVxeTable"));
36
+ var _XPagination = _interopRequireDefault(require("./components/XPagination"));
37
+ var _XReportTable = _interopRequireDefault(require("./components/XReportTable"));
18
38
  // 导入所有组件
19
39
 
40
+ // 注意:VXE-Table 需要使用者自行安装和引入
41
+ // import VXETable from 'vxe-table'
42
+ // import 'vxe-table/lib/style/index.scss'
43
+ // Vue.use(VXETable)
44
+
20
45
  // 存储组件列表(对外暴露的组件)
21
- var components = [_XSearchBar["default"]];
46
+ var components = [_XSearchBar["default"], _XVxeTable["default"], _XPagination["default"], _XReportTable["default"]];
22
47
 
23
48
  // 内部组件列表(不对外暴露)
24
49
  var internalComponents = [_SvgIcon["default"]];
@@ -40,5 +65,8 @@ var install = function install(Vue) {
40
65
  var _default = exports["default"] = {
41
66
  version: '1.0.0',
42
67
  install: install,
43
- XSearchBar: _XSearchBar["default"]
68
+ XSearchBar: _XSearchBar["default"],
69
+ XVxeTable: _XVxeTable["default"],
70
+ XPagination: _XPagination["default"],
71
+ XReportTable: _XReportTable["default"]
44
72
  }; // 单独导出各个组件(只导出公开组件)
@@ -150,7 +150,4 @@
150
150
 
151
151
  .h-t-primary {
152
152
  color: $--color-primary;
153
- }
154
- .h-t-primary2 {
155
- color: #67C23A;
156
153
  }
package/package.json CHANGED
@@ -1,67 +1,67 @@
1
- {
2
- "name": "@xjw_/vue2-npm-system",
3
- "version": "1.0.19",
4
- "description": "基于 Element-UI 的 Vue2 组件库,二次封装常用组件",
5
- "main": "lib/index.js",
6
- "files": [
7
- "lib",
8
- "dist"
9
- ],
10
- "scripts": {
11
- "build": "npm run build:lib && npm run build:es && npm run build:umd",
12
- "build:lib": "node build/build-lib.js && cross-env NODE_ENV=production babel src --out-dir lib --extensions .js --ignore **/*.vue",
13
- "build:es": "node build/build-lib.js && cross-env BABEL_MODULE=es babel src --out-dir es --extensions .js --ignore **/*.vue",
14
- "build:umd": "cross-env NODE_ENV=production webpack --config webpack.config.js",
15
- "dev": "webpack-dev-server --config webpack.config.js",
16
- "lint": "eslint src --ext .js,.vue"
17
- },
18
- "keywords": [
19
- "vue",
20
- "element-ui",
21
- "components",
22
- "jc-components"
23
- ],
24
- "author": "your-name",
25
- "license": "MIT",
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/yourusername/@xjw_/vue2-npm-system"
29
- },
30
- "peerDependencies": {
31
- "element-ui": "2.13.2",
32
- "vue": "2.6.10"
33
- },
34
- "devDependencies": {
35
- "@babel/cli": "^7.14.0",
36
- "@babel/core": "^7.14.0",
37
- "@babel/eslint-parser": "^7.28.6",
38
- "@babel/plugin-syntax-jsx": "^7.14.0",
39
- "@babel/plugin-transform-runtime": "^7.14.0",
40
- "@babel/preset-env": "^7.14.0",
41
- "babel-loader": "^8.2.0",
42
- "babel-plugin-component": "^1.1.1",
43
- "cross-env": "^7.0.3",
44
- "css-loader": "^5.2.0",
45
- "eslint": "^7.25.0",
46
- "eslint-plugin-vue": "^7.9.0",
47
- "file-loader": "^6.2.0",
48
- "html-webpack-plugin": "^4.5.2",
49
- "raw-loader": "^4.0.2",
50
- "sass": "^1.26.2",
51
- "sass-loader": "^8.0.2",
52
- "style-loader": "^2.0.0",
53
- "terser-webpack-plugin": "^4.2.3",
54
- "url-loader": "^4.1.1",
55
- "vue": "2.6.10",
56
- "vue-loader": "^15.9.0",
57
- "vue-template-compiler": "2.6.10",
58
- "vxe-table": "^3.2.20",
59
- "webpack": "^4.46.0",
60
- "webpack-cli": "^3.3.12",
61
- "webpack-dev-server": "^3.11.0",
62
- "xe-utils": "^3.2.1"
63
- },
64
- "dependencies": {
65
- "@babel/runtime": "7.14.0"
66
- }
67
- }
1
+ {
2
+ "name": "@xjw_/vue2-npm-system",
3
+ "version": "1.0.21",
4
+ "description": "基于 Element-UI 的 Vue2 组件库,二次封装常用组件",
5
+ "main": "lib/index.js",
6
+ "files": [
7
+ "lib",
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "npm run build:lib && npm run build:es && npm run build:umd",
12
+ "build:lib": "node build/build-lib.js && cross-env NODE_ENV=production babel src --out-dir lib --extensions .js --ignore **/*.vue",
13
+ "build:es": "node build/build-lib.js && cross-env BABEL_MODULE=es babel src --out-dir es --extensions .js --ignore **/*.vue",
14
+ "build:umd": "cross-env NODE_ENV=production webpack --config webpack.config.js",
15
+ "dev": "webpack-dev-server --config webpack.config.js",
16
+ "lint": "eslint src --ext .js,.vue"
17
+ },
18
+ "keywords": [
19
+ "vue",
20
+ "element-ui",
21
+ "components",
22
+ "jc-components"
23
+ ],
24
+ "author": "your-name",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/yourusername/@xjw_/vue2-npm-system"
29
+ },
30
+ "peerDependencies": {
31
+ "element-ui": "2.13.2",
32
+ "vue": "2.6.10"
33
+ },
34
+ "devDependencies": {
35
+ "@babel/cli": "^7.14.0",
36
+ "@babel/core": "^7.14.0",
37
+ "@babel/eslint-parser": "^7.28.6",
38
+ "@babel/plugin-syntax-jsx": "^7.14.0",
39
+ "@babel/plugin-transform-runtime": "^7.14.0",
40
+ "@babel/preset-env": "^7.14.0",
41
+ "babel-loader": "^8.2.0",
42
+ "babel-plugin-component": "^1.1.1",
43
+ "cross-env": "^7.0.3",
44
+ "css-loader": "^5.2.0",
45
+ "eslint": "^7.25.0",
46
+ "eslint-plugin-vue": "^7.9.0",
47
+ "file-loader": "^6.2.0",
48
+ "html-webpack-plugin": "^4.5.2",
49
+ "raw-loader": "^4.0.2",
50
+ "sass": "^1.26.2",
51
+ "sass-loader": "^8.0.2",
52
+ "style-loader": "^2.0.0",
53
+ "terser-webpack-plugin": "^4.2.3",
54
+ "url-loader": "^4.1.1",
55
+ "vue": "2.6.10",
56
+ "vue-loader": "^15.9.0",
57
+ "vue-template-compiler": "2.6.10",
58
+ "vxe-table": "^3.2.20",
59
+ "webpack": "^4.46.0",
60
+ "webpack-cli": "^3.3.12",
61
+ "webpack-dev-server": "^3.11.0",
62
+ "xe-utils": "^3.2.1"
63
+ },
64
+ "dependencies": {
65
+ "@babel/runtime": "7.14.0"
66
+ }
67
+ }