sone-ui-component-3.2.4 2.1.32 → 2.1.34

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