sone-ui-component-3.2.4 2.1.16 → 2.1.17
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/lib/sone-ui.common.js +1122 -212
- package/lib/sone-ui.common.js.map +1 -1
- package/lib/sone-ui.umd.js +1122 -212
- package/lib/sone-ui.umd.js.map +1 -1
- package/lib/sone-ui.umd.min.js +3 -3
- package/lib/sone-ui.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/packages/normalTable/index.js +15 -0
- package/packages/normalTable/src/columnTransfer.vue +314 -0
- package/packages/normalTable/src/main.vue +520 -0
- package/packages/table/src/main.vue +0 -3
- package/src/index.js +4 -1
- package/src/styles/table.scss +7 -0
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Description:
|
|
3
|
+
* @Author: songlin
|
|
4
|
+
* @Date: 2021-08-26 16:39:21
|
|
5
|
+
* @LastEditTime: 2021-08-27 16:11:37
|
|
6
|
+
* @LastEditors: songlin
|
|
7
|
+
*/
|
|
8
|
+
import Table from './src/main';
|
|
9
|
+
|
|
10
|
+
Table.install = function(Vue) {
|
|
11
|
+
Vue.component(Table.name, Table);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export default Table;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Description:
|
|
3
|
+
* @Author:xjl
|
|
4
|
+
* @Date:2021-09-14 13:03
|
|
5
|
+
-->
|
|
6
|
+
<template>
|
|
7
|
+
<div>
|
|
8
|
+
<el-dropdown-menu slot="dropdown">
|
|
9
|
+
<div class="dropdown_box">
|
|
10
|
+
<div class="dropdown_title">
|
|
11
|
+
<el-checkbox
|
|
12
|
+
:indeterminate="isIndeterminate"
|
|
13
|
+
v-model="columnsCheckAll"
|
|
14
|
+
@change="handleColumnsCheckListChange"
|
|
15
|
+
>列展示</el-checkbox>
|
|
16
|
+
<el-tooltip
|
|
17
|
+
effect="light"
|
|
18
|
+
content="重置"
|
|
19
|
+
placement="top"
|
|
20
|
+
>
|
|
21
|
+
<el-button
|
|
22
|
+
class="rigth_button"
|
|
23
|
+
@click="resetList"
|
|
24
|
+
type="text"
|
|
25
|
+
>重置</el-button>
|
|
26
|
+
</el-tooltip>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="dropdown_content" :class="[dragTarClass]">
|
|
29
|
+
<div v-show="leftColumns.length">
|
|
30
|
+
<p class="title">固定在左侧</p>
|
|
31
|
+
<el-checkbox-group
|
|
32
|
+
v-model="columnsCheckList"
|
|
33
|
+
@change="handleCheckedColumnChange"
|
|
34
|
+
class="item1"
|
|
35
|
+
>
|
|
36
|
+
<div
|
|
37
|
+
class="hover_label"
|
|
38
|
+
v-for="(item,index) in leftColumns"
|
|
39
|
+
:key="item.prop+'#'+item.istrue + index"
|
|
40
|
+
>
|
|
41
|
+
<label class="el-checkbox is-checked">
|
|
42
|
+
<el-checkbox :label="item.label"></el-checkbox>
|
|
43
|
+
</label>
|
|
44
|
+
<span class="icon_display">
|
|
45
|
+
<el-tooltip
|
|
46
|
+
placement="top"
|
|
47
|
+
content="不固定"
|
|
48
|
+
effect="light"
|
|
49
|
+
>
|
|
50
|
+
<i
|
|
51
|
+
class="iconfont iconfont-action icon-close"
|
|
52
|
+
@click="selectFixed(item,false)"
|
|
53
|
+
></i>
|
|
54
|
+
</el-tooltip>
|
|
55
|
+
<el-tooltip
|
|
56
|
+
placement="top"
|
|
57
|
+
content="固定在右侧"
|
|
58
|
+
effect="light"
|
|
59
|
+
>
|
|
60
|
+
<i
|
|
61
|
+
class="iconfont iconfont-action icon-down1"
|
|
62
|
+
@click="selectFixed(item,'right')"
|
|
63
|
+
></i>
|
|
64
|
+
</el-tooltip>
|
|
65
|
+
</span>
|
|
66
|
+
</div>
|
|
67
|
+
</el-checkbox-group>
|
|
68
|
+
</div>
|
|
69
|
+
<div v-show="rightColumns.length">
|
|
70
|
+
<p class="title">固定在右侧</p>
|
|
71
|
+
<el-checkbox-group
|
|
72
|
+
v-model="columnsCheckList"
|
|
73
|
+
@change="handleCheckedColumnChange"
|
|
74
|
+
class="item2"
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
class="hover_label"
|
|
78
|
+
v-for="(item,index) in rightColumns"
|
|
79
|
+
:key="item.prop+'#'+item.istrue + index"
|
|
80
|
+
>
|
|
81
|
+
<label class="el-checkbox is-checked">
|
|
82
|
+
<el-checkbox :label="item.label"></el-checkbox>
|
|
83
|
+
</label>
|
|
84
|
+
<span class="icon_display">
|
|
85
|
+
<el-tooltip
|
|
86
|
+
placement="top"
|
|
87
|
+
content="不固定"
|
|
88
|
+
effect="light"
|
|
89
|
+
>
|
|
90
|
+
<i
|
|
91
|
+
class="iconfont iconfont-action icon-close"
|
|
92
|
+
@click="selectFixed(item, false)"
|
|
93
|
+
></i>
|
|
94
|
+
</el-tooltip>
|
|
95
|
+
<el-tooltip
|
|
96
|
+
placement="top"
|
|
97
|
+
content="固定在左侧"
|
|
98
|
+
effect="light"
|
|
99
|
+
>
|
|
100
|
+
<i
|
|
101
|
+
class="iconfont iconfont-action icon-up1"
|
|
102
|
+
@click="selectFixed(item,'left')"
|
|
103
|
+
></i>
|
|
104
|
+
</el-tooltip>
|
|
105
|
+
</span>
|
|
106
|
+
</div>
|
|
107
|
+
</el-checkbox-group>
|
|
108
|
+
</div>
|
|
109
|
+
<div v-show="noColumns.length">
|
|
110
|
+
<p class="title">不固定</p>
|
|
111
|
+
<el-checkbox-group
|
|
112
|
+
v-model="columnsCheckList"
|
|
113
|
+
@change="handleCheckedColumnChange"
|
|
114
|
+
class="item"
|
|
115
|
+
>
|
|
116
|
+
<div
|
|
117
|
+
class="hover_label"
|
|
118
|
+
v-for="(item,index) in noColumns"
|
|
119
|
+
:key="item.prop+'#'+item.istrue + index"
|
|
120
|
+
>
|
|
121
|
+
<label class="el-checkbox is-checked">
|
|
122
|
+
<el-checkbox :label="item.label"></el-checkbox>
|
|
123
|
+
</label>
|
|
124
|
+
<span class="icon_display">
|
|
125
|
+
<el-tooltip
|
|
126
|
+
placement="top"
|
|
127
|
+
content="固定在左侧"
|
|
128
|
+
effect="light"
|
|
129
|
+
>
|
|
130
|
+
<i
|
|
131
|
+
class="iconfont iconfont-action icon-up1"
|
|
132
|
+
@click="selectFixed(item,'left')"
|
|
133
|
+
></i>
|
|
134
|
+
</el-tooltip>
|
|
135
|
+
<el-tooltip
|
|
136
|
+
placement="top"
|
|
137
|
+
content="固定在右侧"
|
|
138
|
+
effect="light"
|
|
139
|
+
>
|
|
140
|
+
<i
|
|
141
|
+
class="iconfont iconfont-action icon-down1"
|
|
142
|
+
@click="selectFixed(item,'right')"
|
|
143
|
+
></i>
|
|
144
|
+
</el-tooltip>
|
|
145
|
+
</span>
|
|
146
|
+
</div>
|
|
147
|
+
</el-checkbox-group>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</el-dropdown-menu>
|
|
153
|
+
</div>
|
|
154
|
+
</template>
|
|
155
|
+
|
|
156
|
+
<script>
|
|
157
|
+
import { deepClone } from 'sone-ui-component/src/utils/util'
|
|
158
|
+
import Sortable from 'sortablejs'
|
|
159
|
+
export default {
|
|
160
|
+
name: "columnTransfer",
|
|
161
|
+
props: {
|
|
162
|
+
columns: {
|
|
163
|
+
type: Array,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
data() {
|
|
167
|
+
return {
|
|
168
|
+
dragTarClass: 'drag' + Math.random().toString(36).slice(10),
|
|
169
|
+
columnsCheckList: this.columns.map(item => { if (item.istrue) { return item.label } }).filter(v => v),
|
|
170
|
+
|
|
171
|
+
leftColumns: [],
|
|
172
|
+
rightColumns: [],
|
|
173
|
+
noColumns: [], //不定位的数组
|
|
174
|
+
copyColumns: [],
|
|
175
|
+
|
|
176
|
+
columnsCheckAll: false,
|
|
177
|
+
isIndeterminate: false,
|
|
178
|
+
dialogVisible: false,
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
watch: {
|
|
182
|
+
columns: {
|
|
183
|
+
deep: true,
|
|
184
|
+
handler(){
|
|
185
|
+
this.columnsCheckList = this.columns.map(item => { if (item.istrue) { return item.label } }).filter(v => v);
|
|
186
|
+
this.copyColumns = deepClone(this.columns);
|
|
187
|
+
this.handleCheckedColumns()
|
|
188
|
+
this.int(this.copyColumns)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
created() {
|
|
193
|
+
this.copyColumns = deepClone(this.columns);
|
|
194
|
+
this.handleCheckedColumns()
|
|
195
|
+
this.int(this.copyColumns)
|
|
196
|
+
},
|
|
197
|
+
mounted() {
|
|
198
|
+
this.rowDrop()
|
|
199
|
+
this.rowDrop1()
|
|
200
|
+
this.rowDrop2()
|
|
201
|
+
},
|
|
202
|
+
methods: {
|
|
203
|
+
int(columns) {
|
|
204
|
+
let data = deepClone(columns)
|
|
205
|
+
this.leftColumns = data.filter(item => ["left", true].includes(item.fixed))
|
|
206
|
+
this.rightColumns = data.filter(item => item.fixed == 'right')
|
|
207
|
+
this.noColumns = data.filter(item => !item.fixed)
|
|
208
|
+
},
|
|
209
|
+
rowDrop() {
|
|
210
|
+
const item = document.querySelector(`.${this.dragTarClass} .item`)
|
|
211
|
+
const _this = this
|
|
212
|
+
Sortable.create(item, {
|
|
213
|
+
ghostClass: 'table-drag-ghost',
|
|
214
|
+
onEnd({ newIndex, oldIndex }) {
|
|
215
|
+
const currRow = _this.noColumns.splice(oldIndex, 1)[0]
|
|
216
|
+
_this.noColumns.splice(newIndex, 0, currRow)
|
|
217
|
+
_this.handleColumnsDrag()
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
},
|
|
221
|
+
rowDrop1() {
|
|
222
|
+
const item = document.querySelector(`.${this.dragTarClass} .item1`)
|
|
223
|
+
const _this = this
|
|
224
|
+
Sortable.create(item, {
|
|
225
|
+
ghostClass: 'table-drag-ghost',
|
|
226
|
+
onEnd({ newIndex, oldIndex }) {
|
|
227
|
+
const currRow = _this.leftColumns.splice(oldIndex, 1)[0]
|
|
228
|
+
_this.leftColumns.splice(newIndex, 0, currRow)
|
|
229
|
+
_this.handleColumnsDrag()
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
},
|
|
233
|
+
rowDrop2() {
|
|
234
|
+
const item = document.querySelector(`.${this.dragTarClass} .item2`)
|
|
235
|
+
const _this = this
|
|
236
|
+
Sortable.create(item, {
|
|
237
|
+
ghostClass: 'table-drag-ghost',
|
|
238
|
+
onEnd({ newIndex, oldIndex }) {
|
|
239
|
+
const currRow = _this.rightColumns.splice(oldIndex, 1)[0]
|
|
240
|
+
_this.rightColumns.splice(newIndex, 0, currRow)
|
|
241
|
+
_this.handleColumnsDrag()
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
//type为false的时候为不固定,left为固定左侧,right为右侧
|
|
247
|
+
selectFixed(column, type) {
|
|
248
|
+
// let aTemp = [...this.leftColumns, ...this.noColumns, ...this.rightColumns];
|
|
249
|
+
let aTemp = deepClone(this.columns);
|
|
250
|
+
aTemp.some(item => {
|
|
251
|
+
if (item.label === column.label) {
|
|
252
|
+
if (this.columnsCheckList.includes(item.label)) {
|
|
253
|
+
this.$set(item, 'istrue', true)
|
|
254
|
+
} else {
|
|
255
|
+
this.$set(item, 'istrue', false)
|
|
256
|
+
}
|
|
257
|
+
this.$set(item, 'fixed', type)
|
|
258
|
+
return true
|
|
259
|
+
}
|
|
260
|
+
})
|
|
261
|
+
this.$emit('selectFixed', aTemp)
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
handleCheckedColumns() { // 初始化 - 判断是否默认全部选中
|
|
265
|
+
let checkedCount = this.columnsCheckList.length;
|
|
266
|
+
this.columnsCheckAll = checkedCount === this.columns.length;
|
|
267
|
+
this.isIndeterminate = checkedCount > 0 && checkedCount < this.columns.length;
|
|
268
|
+
},
|
|
269
|
+
//事件-是否勾选-列展示
|
|
270
|
+
handleColumnsCheckListChange(value) {
|
|
271
|
+
this.columnsCheckList = value ? this.columns.map(item => item.label) : [];
|
|
272
|
+
this.isIndeterminate = false;
|
|
273
|
+
let returnColumns = this.columns.map(column => {
|
|
274
|
+
this.$set(column, 'istrue', value);
|
|
275
|
+
return column
|
|
276
|
+
})
|
|
277
|
+
this.$emit('handleCheckedColumnChange', this.columnsCheckList, null)
|
|
278
|
+
},
|
|
279
|
+
handleCheckedColumnChange(value) {
|
|
280
|
+
let filteredValues = value.filter(v => v);
|
|
281
|
+
let checkedCount = filteredValues.length;
|
|
282
|
+
this.columnsCheckAll = checkedCount === this.copyColumns.length;
|
|
283
|
+
this.isIndeterminate = checkedCount > 0 && checkedCount < this.columns.map(item => item.label).length;
|
|
284
|
+
|
|
285
|
+
let returnColumns = deepClone(this.columns);
|
|
286
|
+
returnColumns.forEach(column => {
|
|
287
|
+
if (filteredValues.includes(column.label)) {
|
|
288
|
+
this.$set(column, 'istrue', value);
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
this.$emit('handleCheckedColumnChange', filteredValues, null)
|
|
292
|
+
},
|
|
293
|
+
//列显隐 重置
|
|
294
|
+
resetList() {
|
|
295
|
+
// this.columnsCheckList = this.copyColumns.map(item => { if (item.istrue) { return item.label } }).filter(v => v);
|
|
296
|
+
// let checkedCount = this.columnsCheckList.length;
|
|
297
|
+
// this.columnsCheckAll = checkedCount === this.columns.length;
|
|
298
|
+
// this.isIndeterminate = checkedCount > 0 && checkedCount < this.columns.length;
|
|
299
|
+
|
|
300
|
+
// this.leftColumns = []
|
|
301
|
+
// this.rightColumns = []
|
|
302
|
+
// this.noColumns = deepClone(this.copyColumns)
|
|
303
|
+
// this.$emit('handleCheckedColumnChange', null, this.copyColumns)
|
|
304
|
+
this.$emit('resetColumnTransfer')
|
|
305
|
+
},
|
|
306
|
+
/* 处理列拖动 */
|
|
307
|
+
handleColumnsDrag(newVal) {
|
|
308
|
+
let newColumns = [...this.leftColumns, ...this.noColumns, ...this.rightColumns];
|
|
309
|
+
this.$emit('dropdownList', newColumns)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
</script>
|
|
314
|
+
|