sone-ui-component-3.2.4 2.1.16 → 2.1.18

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,520 @@
1
+ <!--
2
+ * @Description: 直接copy的table 删掉了一些树的逻辑
3
+ * @Author:xjl
4
+ * @Date:2021-09-10 11:03
5
+ -->
6
+ <template>
7
+ <div class="sone_table_box" >
8
+ <div class="table-menu-left" v-if="showMenuLeft">
9
+ <slot name="menuLeft"></slot>
10
+ </div>
11
+ <div class="table-menu-right" v-if="showMenuRight">
12
+ <slot name="menuRight"></slot>
13
+ <el-dropdown :hide-on-click="false" v-if="showColumnHandleBtn" @visible-change="onColumnVisibleMenu">
14
+ <icon-button
15
+ :iconfont="false"
16
+ :tooltipDisabled="tooltipDisabled"
17
+ class="sort-btn"
18
+ content="列展示"
19
+ icon="el-icon-s-operation"
20
+ ></icon-button>
21
+ <ColumnTransfer
22
+ ref="column-transfer"
23
+ :columns.sync="internalColumns"
24
+ @dropdownList="dropdownList"
25
+ @handleCheckedColumnChange="handleCheckedColumnChange"
26
+ @selectFixed="selectFixed"
27
+ @resetColumnTransfer="$emit('resetColumnTransfer')"
28
+ ></ColumnTransfer>
29
+ </el-dropdown>
30
+ <slot name="transferRight"></slot>
31
+ </div>
32
+ <el-table
33
+ v-if="isTable"
34
+ v-loading="loading"
35
+ style="width: 100%"
36
+ :ref="tabelRef"
37
+ :class="'sone-table ' + className"
38
+ :cell-class-name="option.cellClassName"
39
+ :cell-style="option.cellStyle"
40
+ :data="tableData"
41
+ :header-cell-class-name="option.headerCellClassName"
42
+ :header-cell-style="option.headerCellStyle"
43
+ :header-row-class-name="option.headerRowClassName"
44
+ :header-row-style="option.headerRowStyle"
45
+ :height="option.height"
46
+ :highlight-current-row="option.highlightRow"
47
+ :max-height="option.maxHeight"
48
+ :row-class-name="tableRowClassName"
49
+ :row-key="option.rowKey"
50
+ :row-style="option.rowStyle"
51
+ :show-summary="option.showSummary"
52
+ :render-header="option.renderHeader"
53
+ :span-method="spanMethod"
54
+ :show-header="showHeader"
55
+ :stripe="stripe"
56
+ :border="border"
57
+ :sum-text="option.sumText"
58
+ :summary-method="summaryMethod"
59
+ @filter-change="filterChange"
60
+ @row-click="rowClick"
61
+ @header-dragend="onHeaderDragend"
62
+ @selection-change="handleSelectionChange">
63
+ <el-table-column
64
+ v-if="operation"
65
+ fixed
66
+ type="index"
67
+ :width="operation.width"
68
+ :label="operation.label ? operation.label : '操作'"
69
+ :resizable="operation.hasOwnProperty('resizable') ? operation.resizable : true">
70
+ <template slot-scope="scope">
71
+ <el-dropdown v-if="scope.row.buttonShow" class="dropdown_box_button sone-table-buttonList">
72
+ <span class="el-dropdown-link color-span menu-more" v-show="scope.row.buttonShow.filter(d=>d.isShow).length > 0">
73
+ <el-button type="text">
74
+ <i :style="{color:operation.moreIconColor}" class="el-icon-more more-handel"></i>
75
+ </el-button>
76
+ </span>
77
+ <el-dropdown-menu slot="dropdown">
78
+ <el-dropdown-item class="sone-table-dropdown" command="copy" v-for="(item, i) in scope.row.buttonShow.filter(d=>d.isShow)" :key="i">
79
+ <el-button
80
+ :icon="operation.buttonList.find(d=>d.id===item.id).icon"
81
+ :disabled="item.hasOwnProperty('isDisabled') ? item.isDisabled : false"
82
+ :style="{color:operation.buttonList.find(d=>d.id===item.id).color}"
83
+ type="text"
84
+ :title="operation.buttonList.find(d=>d.id === item.id).label"
85
+ @click.native.stop="handButton(operation.buttonList.find(d=>d.id===item.id).function, scope, item.id)"
86
+ >{{operation.buttonList.find(d=>d.id===item.id).label}}</el-button>
87
+ </el-dropdown-item>
88
+ </el-dropdown-menu>
89
+ </el-dropdown>
90
+ <el-dropdown v-else @command.stop="(command)=>{handleCommand(command,row)}" class="dropdown_box_button sone-table-buttonList">
91
+ <span class="el-dropdown-link color-span menu-more" v-show="operation.buttonList.length > 0">
92
+ <el-button type="text">
93
+ <i :style="{color:operation.moreIconColor}" class="el-icon-more more-handel"></i>
94
+ </el-button>
95
+ </span>
96
+ <el-dropdown-menu slot="dropdown">
97
+ <el-dropdown-item
98
+ class="sone-table-dropdown"
99
+ command="copy"
100
+ v-for="(item, i) in operation.buttonList"
101
+ :key="i">
102
+ <el-button
103
+ :icon="item.icon"
104
+ :style="{color:item.color}"
105
+ :title="item.label"
106
+ type="text"
107
+ @click.native.stop="handButton(item.function, scope, item.id)"
108
+ >{{item.label}}</el-button>
109
+ </el-dropdown-item>
110
+ </el-dropdown-menu>
111
+ </el-dropdown>
112
+ </template>
113
+ </el-table-column>
114
+ <el-table-column
115
+ :width="option.indexWidth||50"
116
+ fixed
117
+ :label="option.indexLabel ? option.indexLabel : '序号'"
118
+ type="index"
119
+ :index="indexMethod"
120
+ :resizable="option.hasOwnProperty('indexResizable') ? option.indexResizable : true"
121
+ v-if="option.index"
122
+ ></el-table-column>
123
+ <el-table-column
124
+ v-if="option.hasOwnProperty('selection') ? option.selection : false"
125
+ type="selection"
126
+ :width="option.selectionWidth || 45">
127
+ </el-table-column>
128
+ <template v-for="(column, index) in internalColumns">
129
+ <!-- 自定义列 -->
130
+ <slot v-if="column.slot && column.istrue" :name="column.slot"></slot>
131
+ <el-table-column
132
+ v-else-if="column.hasOwnProperty('istrue')?column.istrue:true"
133
+ :filter-method="column.filters ? filterHandler : null"
134
+ :filters="column.filters"
135
+ :fixed="column.fixed"
136
+ :key="`col_${column.prop}_${column.label}`"
137
+ :label="column.label"
138
+ :min-width="column.minWidth"
139
+ :prop="column.prop"
140
+ :width="column.width"
141
+ :align="column.hasOwnProperty('align') ? column.align : 'left'"
142
+ :show-overflow-tooltip="false"
143
+ filter-placement="bottom-end"
144
+ :header-align="column.hasOwnProperty('headerAlign') ? column.headerAlign : 'left'"
145
+ :column-key="column.hasOwnProperty('elementId')? column.elementId:column.prop"
146
+ :resizable="column.hasOwnProperty('resizable') ? column.resizable : true">
147
+ <!-- 表头 -->
148
+ <template slot="header" slot-scope="scope">
149
+ <slot
150
+ v-if="column.slotColumnHeader && isShow"
151
+ :header="{column: scope.column, $index:scope.$index }"
152
+ :name="column.slotColumnHeader"
153
+ ></slot>
154
+ <template v-if="!column.slotColumnHeader && isShow">
155
+ <div class="slot_header_class">
156
+ <span class="table-header-isRequire" v-if="column.isRequire">*</span>
157
+ <span>{{ column.label }}</span>
158
+ <span class="hide">
159
+ <i
160
+ class="iconfont icon-help icon_describe"
161
+ :title="column.headerDescribe"
162
+ v-if="column.headerDescribe"
163
+ ></i>
164
+ <span
165
+ :class="{ 'ascending': sortVal === column.prop + 'ascending', 'descending': sortVal === column.prop + 'descending' }"
166
+ class="caret-wrapper"
167
+ v-if="column.headerFilterSort">
168
+ <i
169
+ @click="handleCommand(column.prop, index, { command: 'ascending' })"
170
+ class="sort-caret ascending"
171
+ title="升序"
172
+ ></i>
173
+ <i
174
+ @click="handleCommand(column.prop, index, { command: 'descending' })"
175
+ class="sort-caret descending"
176
+ title="降序"
177
+ ></i>
178
+ </span>
179
+ </span>
180
+ </div>
181
+ </template>
182
+ </template>
183
+ <!--表体-->
184
+ <template slot-scope="scope">
185
+ <slot :index="scope.$index" :name="column.slotCell" :row="scope.row" v-if="column.slotCell"></slot>
186
+ <template v-else>
187
+ <el-tooltip :content="String(scope.row[column.prop])" placement="top" effect="light" popper-class="over_popper">
188
+ <span class="over_title">{{ scope.row[column.prop] }}</span>
189
+ </el-tooltip>
190
+ </template>
191
+ </template>
192
+ </el-table-column>
193
+ </template>
194
+ </el-table>
195
+ <div class="pagination-box" v-if="page && page.total > 0">
196
+ <el-pagination
197
+ :current-page="page.current"
198
+ :layout="page.layout ? page.layout : 'total, sizes, prev, pager, next, jumper'"
199
+ :page-size="page.size"
200
+ :page-sizes="page.pageSizes"
201
+ :total="page.total"
202
+ :page-count="page.pageCount"
203
+ :pager-count="page.pagerCount"
204
+ @current-change="currentChange"
205
+ @size-change="sizeChange"
206
+ background
207
+ ></el-pagination>
208
+ </div>
209
+ </div>
210
+ </template>
211
+
212
+ <script>
213
+ import { deepClone } from 'sone-ui-component/src/utils/util'
214
+ import ColumnTransfer from './columnTransfer.vue'
215
+ export default {
216
+ name: "SoneNormalTable",
217
+ components: { ColumnTransfer },
218
+ props: {
219
+ showMenuLeft: {
220
+ type: Boolean,
221
+ default: false
222
+ },
223
+ showMenuRight: {
224
+ type: Boolean,
225
+ default: true
226
+ },
227
+ showColumnHandleBtn: {
228
+ type: Boolean,
229
+ default: true
230
+ },
231
+ hideButtonMode: {
232
+ type: Boolean,
233
+ default: false
234
+ },
235
+ tabelRef: {
236
+ type: String,
237
+ default: 'tableDataRef'
238
+ },
239
+ loading: {
240
+ type: Boolean,
241
+ default: false,
242
+ },
243
+ showHeader: {
244
+ type: Boolean,
245
+ default: true,
246
+ },
247
+ stripe: {
248
+ type: Boolean,
249
+ default: true,
250
+ },
251
+ border: {
252
+ type: Boolean,
253
+ default: true,
254
+ },
255
+ option: {
256
+ type: Object,
257
+ default: () => {
258
+ return {
259
+ index: true,
260
+ indexWidth: 70,
261
+ height: 'auto',
262
+ maxHeight: 'auto',
263
+
264
+ }
265
+ }
266
+ },
267
+ operation: {
268
+ type: [Object, Boolean],
269
+ default: () => {
270
+ return {
271
+ width: 82,
272
+ label: '操作',
273
+ buttonList: [
274
+ {
275
+ label: '删除',
276
+ icon: 'el-icon-remove-outline',
277
+ function: 'handDetele',
278
+ tooltipContent: '删除',
279
+ color: 'red'
280
+ }, {
281
+ label: '添加',
282
+ icon: 'el-icon-circle-plus-outline',
283
+ function: 'hand',
284
+ tooltipContent: '删除',
285
+ color: 'red'
286
+ }
287
+ ]
288
+ }
289
+ }
290
+ },
291
+ page: {
292
+ type: Object,
293
+ },
294
+ columns: {
295
+ type: Array,
296
+ default: () => []
297
+ },
298
+ tableData: {
299
+ type: Array,
300
+ default: () => []
301
+ },
302
+ // 表格className
303
+ className:{
304
+ type:String,
305
+ default:''
306
+ },
307
+ // 合计小数位数
308
+ summaryToFixed:{
309
+ type:[Number, String],
310
+ default:''
311
+ },
312
+ spanMethod: Function,
313
+ indexMethod: Function,
314
+ // 默认显示按钮图标加提示,
315
+ tooltipDisabled: {
316
+ type: Boolean,
317
+ default: false,
318
+ },
319
+ },
320
+ data() {
321
+ return {
322
+ internalColumns: deepClone(this.columns).filter(d => d && !d.isHidden),
323
+ sortVal: '', // 排序
324
+ isShow: true,
325
+ isTable: true
326
+ }
327
+ },
328
+ watch: {
329
+ columns: {
330
+ deep: true,
331
+ handler() {
332
+ this.internalColumns = deepClone(this.columns).filter(d => d && !d.isHidden);
333
+ }
334
+ },
335
+ internalColumns: {
336
+ deep: true,
337
+ handler() {
338
+ this.isShow = false
339
+ this.$nextTick(() => { //不放在这里面会导致视图不刷新
340
+ this.isShow = true;
341
+ })
342
+ this.$refs[this.tabelRef] && this.$refs[this.tabelRef].doLayout();
343
+ }
344
+ },
345
+ },
346
+ methods: {
347
+ columnsCheckList(valArr) {
348
+ this.internalColumns.forEach(i => {
349
+ if (valArr.includes(i.label)) {
350
+ this.$set(i, 'istrue', true)
351
+ } else {
352
+ this.$set(i, 'istrue', false)
353
+ }
354
+ });
355
+ this.$nextTick(() => {
356
+ this.$refs[this.tabelRef] && this.$refs[this.tabelRef].doLayout();
357
+ });
358
+ },
359
+ selectFixed(items) {
360
+ this.internalColumns = deepClone(items);
361
+ this.$nextTick(() => {
362
+ this.$refs[this.tabelRef] && this.$refs[this.tabelRef].doLayout();
363
+ });
364
+
365
+ },
366
+ handleCheckedColumnChange(data, internalColumns) {
367
+ if(data){
368
+ this.columnsCheckList(data)
369
+ }
370
+ if(internalColumns && internalColumns.length){
371
+ this.$nextTick(() => {
372
+ this.internalColumns = deepClone(internalColumns);
373
+ });
374
+ }
375
+ },
376
+ dropdownList(itemset) {
377
+ this.internalColumns = deepClone(itemset);
378
+ this.isTable = false
379
+ this.$nextTick(() => {
380
+ this.isTable = true
381
+ })
382
+ },
383
+ // 下拉button
384
+ handleCommand(columnName, columnIndex, data) {
385
+ let tableData = deepClone(this.tableData)
386
+ if (data.command === "ascending" || data.command === "descending") {
387
+ if (this.sortVal && this.sortVal.indexOf(data.command) > -1) {
388
+ this.sortVal = ''
389
+ } else {
390
+ this.sortVal = columnName + data.command
391
+ }
392
+ if (this.option.defineSort) {
393
+ this.$emit('handleColumnFilter', columnName, columnIndex, data, !!!this.sortVal)
394
+ } else {
395
+ let isIncludeNaN = tableData.some(item => isNaN(Number(item[columnName])))
396
+ if ( isIncludeNaN ) { // 数据非纯数字使用原生ele方法
397
+ if(this.sortVal){
398
+ this.$refs[this.tabelRef].sort(columnName, data.command);
399
+ } else {
400
+ this.$refs[this.tabelRef].clearSort();
401
+ }
402
+ } else { // 纯数字使用sort排序
403
+ tableData.sort((a, b) => {
404
+ return data.command === 'ascending' ? a[columnName] - b[columnName] : b[columnName] - a[columnName]
405
+ })
406
+ this.$emit('update:tableData', tableData)
407
+ }
408
+ }
409
+ } else {
410
+ this.$emit('handleColumnFilter', columnName, columnIndex, data)
411
+ }
412
+ },
413
+ handleSelectionChange(val){
414
+ this.$emit('handleChecked', val);
415
+ },
416
+ toggleSelection(rows, selected = true) {
417
+ if (rows) {
418
+ rows.forEach(row => {
419
+ this.$refs[this.tabelRef].toggleRowSelection(row, selected);
420
+ });
421
+ } else {
422
+ this.$refs[this.tabelRef].clearSelection();
423
+ }
424
+ },
425
+ // 翻页
426
+ sizeChange(val) {
427
+ this.$emit('sizeChange', val)
428
+ },
429
+ currentChange(val) {
430
+ this.$emit('currentChange', val)
431
+ },
432
+ // 合计
433
+ summaryMethod({ columns, data }) {
434
+ if (this.option.summaryMethod) {
435
+ return this.option.summaryMethod({ columns, data })
436
+ }
437
+ let _columns = deepClone(this.internalColumns);
438
+ const sums = [];
439
+ // 固定列会导致窜行 待改
440
+ if ( !!this.operation ) sums.push(this.option.sumText || '合计')
441
+ if ( this.option.indexCheck || this.option.index ) {
442
+ !!this.operation ? sums.push('') : sums.push('合计')
443
+ }
444
+ _columns.forEach((column, index) => {
445
+ if ( column.istrue ) {
446
+ let num = 0
447
+ data.forEach(item => num += Number(item[column.prop]))
448
+ if ( isNaN(num) || !column.summary ) {
449
+ sums.push('')
450
+ } else if ( String(num).indexOf('.') != -1 && this.summaryToFixed ) {
451
+ sums.push(num.toFixed(this.summaryToFixed))
452
+ } else {
453
+ sums.push(num)
454
+ }
455
+ }
456
+ });
457
+ return sums;
458
+ },
459
+ // 行点击
460
+ rowClick(row, column, event) {
461
+ this.$emit('rowClick', row, column, event)
462
+ },
463
+ filterChange(filters) {
464
+ let data = deepClone(this.tableData)
465
+ // 判断是哪一列筛选
466
+ if (filters.name) {
467
+ data.name = filters.name[0]
468
+ }
469
+ this.$emit('update:tableData', data)
470
+ },
471
+ //过滤
472
+ filterHandler(value, row, column) {
473
+ const property = column['property'];
474
+ return row[property] === value;
475
+ },
476
+
477
+ // class
478
+ tableRowClassName({ row, rowIndex }) {
479
+ let rowClass = ''
480
+ if (this.option.rowClassName) {
481
+ rowClass = this.option.rowClassName({ row, rowIndex })
482
+ }
483
+ if(this.option.indexCheck === true && row.checked === true && !this.option['clickRowNoCheck']){
484
+ return `current-row ${rowClass}`;
485
+ }
486
+ return rowClass;
487
+ },
488
+ handButton(functionName, scope, id) {
489
+ this.$emit(functionName, scope, id)
490
+ },
491
+ doLayout() {
492
+ this.$refs[this.tabelRef].doLayout();
493
+ },
494
+ /* 表格-列显隐-下拉菜单 */
495
+ onColumnVisibleMenu(flag){
496
+ let arr = [
497
+ ...this.$refs['column-transfer'].leftColumns,
498
+ ...this.$refs['column-transfer'].noColumns,
499
+ ...this.$refs['column-transfer'].rightColumns
500
+ ]
501
+ // this.$emit('columnsVisibleMenu', flag, this.internalColumns );
502
+ this.$emit('columnsVisibleMenu', flag, arr );
503
+ },
504
+ /* 当拖动表头改变了列的宽度的时候会触发该事件 */
505
+ onHeaderDragend(newWidth, oldWidth, column, event){
506
+ let arr = [
507
+ ...this.$refs['column-transfer'].leftColumns,
508
+ ...this.$refs['column-transfer'].noColumns,
509
+ ...this.$refs['column-transfer'].rightColumns
510
+ ]
511
+ this.$emit('headerDragend', newWidth, oldWidth, column, arr, event);
512
+ },
513
+ /* 用于单选表格,设定某一行为选中行,如果调用时不加参数,则会取消目前高亮行的选中状态。 */
514
+ setCurrentRow(row){
515
+ this.$refs[this.tabelRef] && this.$refs[this.tabelRef].setCurrentRow(row);
516
+ this.$emit('setCurrentRow', row);
517
+ },
518
+ },
519
+ }
520
+ </script>
@@ -41,9 +41,6 @@
41
41
  <slot name="transferRight"></slot>
42
42
  </div>
43
43
  <el-table
44
- :useVirtual="option.useVirtual"
45
- :rowHeight="option.rowHeight"
46
- :excessRows="option.excessRows"
47
44
  :cell-class-name="option.cellClassName"
48
45
  :cell-style="option.cellStyle"
49
46
  :data="tableData"
package/src/index.js CHANGED
@@ -9,6 +9,7 @@ import Watermark from '../packages/watermark/index.js';
9
9
  import Form from '../packages/form/index.js';
10
10
  import Dialog from '../packages/dialog/index.js';
11
11
  import Table from '../packages/table/index.js';
12
+ import NormalTable from '../packages/normalTable/index.js';
12
13
  import Select from '../packages/select/index.js';
13
14
  import DatePicker from '../packages/datePicker/index.js';
14
15
  import DatePickerRange from '../packages/datePickerRange/index.js';
@@ -28,6 +29,7 @@ const components = [
28
29
  Form,
29
30
  Dialog,
30
31
  Table,
32
+ NormalTable,
31
33
  Select,
32
34
  DatePicker,
33
35
  DatePickerRange,
@@ -55,7 +57,7 @@ if (typeof window !== 'undefined' && window.Vue) {
55
57
  }
56
58
 
57
59
  export default {
58
- version: '2.1.16',
60
+ version: '2.1.18',
59
61
  locale: locale.use,
60
62
  i18n: locale.i18n,
61
63
  install,
@@ -68,6 +70,7 @@ export default {
68
70
  Form,
69
71
  Dialog,
70
72
  Table,
73
+ NormalTable,
71
74
  Select,
72
75
  DatePicker,
73
76
  DatePickerRange,
@@ -47,6 +47,13 @@
47
47
  right: 10px;
48
48
  top: -5px;
49
49
  }
50
+ .el-table-column--selection{
51
+ .cell{
52
+ display: flex;
53
+ justify-content: center;
54
+ align-items: center;
55
+ }
56
+ }
50
57
 
51
58
  /**/
52
59
  .caret-wrapper.active i{