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