xt-element-ui 1.1.0 → 1.1.2
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/css/2.3f7aa432.css +1 -0
- package/lib/css/3.ffcc175d.css +1 -0
- package/lib/css/4.9abd1f2b.css +1 -0
- package/lib/css/5.1a31ed8a.css +1 -0
- package/lib/css/6.c2d0d77e.css +1 -0
- package/lib/index.common.0.js +120208 -0
- package/lib/index.common.2.js +1053 -0
- package/lib/index.common.3.js +996 -0
- package/lib/index.common.4.js +1108 -0
- package/lib/index.common.5.js +1009 -0
- package/lib/index.common.6.js +973 -0
- package/lib/index.common.js +8003 -211
- package/lib/index.css +1 -1
- package/lib/index.umd.0.js +120208 -0
- package/lib/index.umd.2.js +1053 -0
- package/lib/index.umd.3.js +996 -0
- package/lib/index.umd.4.js +1108 -0
- package/lib/index.umd.5.js +1009 -0
- package/lib/index.umd.6.js +973 -0
- package/lib/index.umd.js +8003 -211
- package/lib/index.umd.min.0.js +34 -0
- package/lib/index.umd.min.2.js +1 -0
- package/lib/index.umd.min.3.js +1 -0
- package/lib/index.umd.min.4.js +1 -0
- package/lib/index.umd.min.5.js +1 -0
- package/lib/index.umd.min.6.js +1 -0
- package/lib/index.umd.min.js +1 -1
- package/package.json +7 -3
- package/src/components/button/index.vue +5 -5
- package/src/components/button/style/index.scss +743 -90
- package/src/components/chart/ExBar.vue +203 -0
- package/src/components/chart/ExLine.vue +146 -0
- package/src/components/chart/ExMulti.vue +257 -0
- package/src/components/chart/ExPie.vue +159 -0
- package/src/components/chart/ExTrend.vue +121 -0
- package/src/components/chart/index.js +2 -0
- package/src/components/chart/index.vue +51 -0
- package/src/components/chart/pieList.vue +110 -0
- package/src/components/chart/theme/blue.js +91 -0
- package/src/components/chart/theme/dark.js +91 -0
- package/src/components/chart/theme/orange.js +92 -0
- package/src/components/chart/theme/starry.js +106 -0
- package/src/components/chart/theme/white.js +110 -0
- package/src/components/chart/utils.js +273 -0
- package/src/components/config-provider/index.vue +150 -51
- package/src/components/config-provider/style/index.scss +2 -2
- package/src/components/date-picker/SearchDate.vue +45 -0
- package/src/components/date-picker/index.js +2 -0
- package/src/components/date-picker/index.vue +131 -0
- package/src/components/date-picker/quarter.vue +152 -0
- package/src/components/grid-box/index.js +2 -0
- package/src/components/grid-box/index.vue +42 -0
- package/src/components/layout/BaseCollapse.vue +48 -0
- package/src/components/layout/ExFieldset.vue +204 -0
- package/src/components/page/index.js +0 -0
- package/src/components/page/index.vue +109 -0
- package/src/components/select-tree/index.js +0 -0
- package/src/components/select-tree/index.vue +386 -0
- package/src/components/table/ExCell.vue +27 -0
- package/src/components/table/ExColumn.vue +36 -0
- package/src/components/table/index.js +2 -0
- package/src/components/table/index.vue +731 -0
- package/src/components/table/processor.js +380 -0
- package/src/components/text/index.vue +79 -2
- package/src/components/text/style/index.scss +28 -6
- package/src/components/upload/index.js +2 -0
- package/src/components/upload/index.vue +225 -0
- package/src/components/upload/preview.vue +333 -0
- package/src/index.js +11 -2
- package/src/styles/css-variables.scss +238 -148
- package/src/styles/theme/background.scss +1 -1
- package/src/styles/theme/colors.scss +90 -1
- package/src/styles/variables.scss +1 -1
- package/src/components/button/style/index copy.scss +0 -221
|
@@ -0,0 +1,731 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ExTable">
|
|
3
|
+
<slot name="title">
|
|
4
|
+
<BaseFlexBox content="between" style="padding: 0 10px;">
|
|
5
|
+
<div class="small-title" style="padding: 10px; 0" v-if="title">{{ title }}</div>
|
|
6
|
+
<el-button size="small" type="primary" plain v-if="toolExport" icon="el-icon-download" @click="exportTableData">导出</el-button>
|
|
7
|
+
</BaseFlexBox>
|
|
8
|
+
</slot>
|
|
9
|
+
<el-table
|
|
10
|
+
ref="ExtendTable"
|
|
11
|
+
v-loading="loading"
|
|
12
|
+
element-loading-text="加载中..."
|
|
13
|
+
v-bind="getAttrs()"
|
|
14
|
+
:data="spanFields ? spanTableData : tableData"
|
|
15
|
+
v-on="$listeners"
|
|
16
|
+
@current-change="rowChange"
|
|
17
|
+
@row-click="rowClick"
|
|
18
|
+
@sort-change="changeTableSort"
|
|
19
|
+
@selection-change="selectionChange"
|
|
20
|
+
>
|
|
21
|
+
<el-table-column v-if="(hasLoad || !tbId) ? expand : false" type="expand" :fixed="defaultColumnsFixed">
|
|
22
|
+
<template slot-scope="scope">
|
|
23
|
+
<slot name="expand" :scopeData="scope" :row="scope.row" :column="scope.column" :index="scope.$index" />
|
|
24
|
+
</template>
|
|
25
|
+
</el-table-column>
|
|
26
|
+
<el-table-column
|
|
27
|
+
v-if="(hasLoad || !tbId) && showIndex"
|
|
28
|
+
type="index"
|
|
29
|
+
align="center"
|
|
30
|
+
width="80"
|
|
31
|
+
:fixed="defaultColumnsFixed?'left':null"
|
|
32
|
+
:index="showRealIndex ? realIndexRender : indexRender"
|
|
33
|
+
>
|
|
34
|
+
<template slot="header" slot-scope="scope">
|
|
35
|
+
<el-popover v-if="showColumsFilter" width="170" trigger="click" placement="bottom-start">
|
|
36
|
+
<el-checkbox-group v-model="checkedColumns" class="drop-body">
|
|
37
|
+
<el-checkbox v-for="(item,ind) in diyColumns" v-show="item.prop" :key="ind" :label="item.prop" class="checkli" @change="(v) => handleToggle(v, item)">{{ item.label }}</el-checkbox>
|
|
38
|
+
</el-checkbox-group>
|
|
39
|
+
<i slot="reference" class="el-icon-s-operation" style="cursor: pointer" title="定制列" />
|
|
40
|
+
</el-popover>
|
|
41
|
+
<div v-else>序号</div>
|
|
42
|
+
</template>
|
|
43
|
+
</el-table-column>
|
|
44
|
+
<el-table-column
|
|
45
|
+
v-if="(hasLoad || !tbId) && selection"
|
|
46
|
+
type="selection"
|
|
47
|
+
align="center"
|
|
48
|
+
width="50"
|
|
49
|
+
:fixed="defaultColumnsFixed?'left':null"
|
|
50
|
+
>
|
|
51
|
+
</el-table-column>
|
|
52
|
+
<template v-for="(group, groupIndex) in groupColumns">
|
|
53
|
+
<el-table-column :key="`group-${groupIndex}`" v-bind="setAttrs(group)">
|
|
54
|
+
<template slot-scope="{row}"><span>{{ row[group.prop] }}</span></template>
|
|
55
|
+
</el-table-column>
|
|
56
|
+
</template>
|
|
57
|
+
<template v-for="(column, index) in tableColumns">
|
|
58
|
+
<el-table-column v-if="column.slotName ||column.formatter" :key="index" v-bind="setAttrs(column)">
|
|
59
|
+
<template slot="header" slot-scope="scope">
|
|
60
|
+
<slot :name="column.slotHeader || 'header'" :column="scope.column">
|
|
61
|
+
<span> {{ scope.column.label }}</span>
|
|
62
|
+
</slot>
|
|
63
|
+
</template>
|
|
64
|
+
<template v-if="column.slotName" slot-scope="scope">
|
|
65
|
+
<slot :name="column.slotName" :scopeData="scope" :row="scope.row" :column="scope.column" :index="scope.$index" />
|
|
66
|
+
</template>
|
|
67
|
+
<ExCell v-else :formatter="column.formatter" :index="scope.$index + startIndex" :row="scope.row" :column="column">
|
|
68
|
+
</ExCell>
|
|
69
|
+
</el-table-column>
|
|
70
|
+
<ExColumn v-else-if="column.children && column.children.length" :key="index" :column="column">
|
|
71
|
+
</ExColumn>
|
|
72
|
+
<el-table-column v-else v-bind="setAttrs(column)" :prop="column.prop" :label="column.label" :key="index">
|
|
73
|
+
<template slot="header" slot-scope="scope">
|
|
74
|
+
<slot :name="column.slotHeader || 'header'" :column="scope.column">
|
|
75
|
+
<span> {{ scope.column.label }}</span>
|
|
76
|
+
</slot>
|
|
77
|
+
</template>
|
|
78
|
+
</el-table-column>
|
|
79
|
+
</template>
|
|
80
|
+
<template v-slot:empty>
|
|
81
|
+
<div style="text-align:center" v-show="hasLoadData&&!loading">
|
|
82
|
+
<img :src="emptyIcon" height="150px" />
|
|
83
|
+
<div class="empty-title">暂无数据</div>
|
|
84
|
+
<div class="empty-subtitle">{{emptSubTitle}}</div>
|
|
85
|
+
</div>
|
|
86
|
+
</template>
|
|
87
|
+
</el-table>
|
|
88
|
+
<div ref="toolBar" class="toolBar left">
|
|
89
|
+
<slot name="pagination">
|
|
90
|
+
<BasePagination v-if="pagination" :total="total" :page-sizes="pageSizes" :is-simple="simplePage" :page-drop-show="simplePage" :page-size="pagination.PageSize" :current-page="pagination.PageNum" @current-change="pageChange" @size-change="sizeChange"></BasePagination>
|
|
91
|
+
</slot>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</template>
|
|
95
|
+
<script>
|
|
96
|
+
import ExColumn from "./ExColumn";
|
|
97
|
+
import ExCell from "./ExCell";
|
|
98
|
+
import exportExcell from "@/views/compreSafeInsIos/mixin/exportExcell.js";
|
|
99
|
+
import { GetSelfData, SaveIsShowInfo } from "@/api/compreSafeInsIos/common.js";
|
|
100
|
+
export default {
|
|
101
|
+
name: "ExTable",
|
|
102
|
+
components: {
|
|
103
|
+
ExCell,
|
|
104
|
+
ExColumn
|
|
105
|
+
},
|
|
106
|
+
mixins: [exportExcell],
|
|
107
|
+
inheritAttrs: false,
|
|
108
|
+
props: {
|
|
109
|
+
tbId: {
|
|
110
|
+
type: [Number, String],
|
|
111
|
+
default: ""
|
|
112
|
+
},
|
|
113
|
+
tableData: {
|
|
114
|
+
type: Array,
|
|
115
|
+
default() {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
height: {
|
|
120
|
+
type: [Number, String, Function],
|
|
121
|
+
default: () => null
|
|
122
|
+
},
|
|
123
|
+
elementLoadingText: {
|
|
124
|
+
type: String,
|
|
125
|
+
default: "拼命加载中"
|
|
126
|
+
},
|
|
127
|
+
headerCellStyle: {
|
|
128
|
+
type: Object,
|
|
129
|
+
default: () => {
|
|
130
|
+
return {
|
|
131
|
+
background: "#F8F8F9",
|
|
132
|
+
color: "#606266"
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
loading: {
|
|
137
|
+
type: Boolean,
|
|
138
|
+
default: false
|
|
139
|
+
},
|
|
140
|
+
pageSizes: {
|
|
141
|
+
type: Array,
|
|
142
|
+
default: () => [20, 50, 100, 200]
|
|
143
|
+
},
|
|
144
|
+
pagination: {
|
|
145
|
+
type: Object,
|
|
146
|
+
default: null
|
|
147
|
+
},
|
|
148
|
+
total: {
|
|
149
|
+
type: Number,
|
|
150
|
+
default: 0
|
|
151
|
+
},
|
|
152
|
+
columns: {
|
|
153
|
+
type: Array,
|
|
154
|
+
default() {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
// 自定义 插入列
|
|
159
|
+
insertColumns: {
|
|
160
|
+
type: Array,
|
|
161
|
+
default() {
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
selectable: {
|
|
166
|
+
type: Function,
|
|
167
|
+
default() {
|
|
168
|
+
return () => true;
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
selection: {
|
|
172
|
+
type: Boolean,
|
|
173
|
+
default: false
|
|
174
|
+
},
|
|
175
|
+
showIndex: {
|
|
176
|
+
type: Boolean,
|
|
177
|
+
default: true
|
|
178
|
+
},
|
|
179
|
+
showRealIndex: {
|
|
180
|
+
type: Boolean,
|
|
181
|
+
default: true
|
|
182
|
+
},
|
|
183
|
+
expand: {
|
|
184
|
+
type: Boolean,
|
|
185
|
+
default: false
|
|
186
|
+
},
|
|
187
|
+
showColumsFilter: {
|
|
188
|
+
type: Boolean,
|
|
189
|
+
default: false
|
|
190
|
+
},
|
|
191
|
+
defaultColumnsFixed: {
|
|
192
|
+
type: Boolean,
|
|
193
|
+
default: true
|
|
194
|
+
},
|
|
195
|
+
autoSetHeight: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
default: true
|
|
198
|
+
},
|
|
199
|
+
simplePage: {
|
|
200
|
+
type: Boolean,
|
|
201
|
+
default: false
|
|
202
|
+
},
|
|
203
|
+
border: {
|
|
204
|
+
type: Boolean,
|
|
205
|
+
default: true
|
|
206
|
+
},
|
|
207
|
+
indexRender: Function,
|
|
208
|
+
spanFields: {
|
|
209
|
+
type: Object
|
|
210
|
+
},
|
|
211
|
+
groupColumns: { // 左侧合并分组列
|
|
212
|
+
type: Array,
|
|
213
|
+
default() {
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
emptyIcon: {
|
|
218
|
+
type: String,
|
|
219
|
+
default: () => {
|
|
220
|
+
return require("@/assets/images/common/noData.png");
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
title: {},
|
|
224
|
+
emptSubTitle: {},
|
|
225
|
+
toolExport: {
|
|
226
|
+
type: Boolean,
|
|
227
|
+
default: false
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
data() {
|
|
231
|
+
return {
|
|
232
|
+
startIndex: 0,
|
|
233
|
+
inTableHeight: 0,
|
|
234
|
+
dropvisible: false,
|
|
235
|
+
hasLoad: false,
|
|
236
|
+
hasLoadData: false,
|
|
237
|
+
diyColumns: this.columns || [], // 自定义列数据源
|
|
238
|
+
checkedColumns: [],
|
|
239
|
+
tableColumns: []
|
|
240
|
+
};
|
|
241
|
+
},
|
|
242
|
+
computed: {
|
|
243
|
+
spanTableData() {
|
|
244
|
+
return this.calculateGroupSpans(this.tableData, this.spanFields);
|
|
245
|
+
},
|
|
246
|
+
constColums() {
|
|
247
|
+
const _isFixed = this.defaultColumnsFixed ? "left" : null;
|
|
248
|
+
const _index = { type: "index", align: "center", label: this.showColumsFilter ? "" : "序号", width: "80", fixed: _isFixed, index: this.indexRender };
|
|
249
|
+
const _selection = { type: "selection", align: "center", width: "50", fixed: _isFixed };
|
|
250
|
+
if (this.hasLoad || !this.tbId) {
|
|
251
|
+
return this.selection ? this.showIndex ? [_index, _selection] : [_selection] : (this.showIndex ? [_index] : []);
|
|
252
|
+
} else {
|
|
253
|
+
return [];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
watch: {
|
|
258
|
+
height(val) {
|
|
259
|
+
this.changeTableHight();
|
|
260
|
+
},
|
|
261
|
+
insertColumns: {
|
|
262
|
+
deep: true,
|
|
263
|
+
handler(val) {
|
|
264
|
+
this.getTableColumns().then(list => {
|
|
265
|
+
this.diyColumns = list;
|
|
266
|
+
const _insertColumns = this.insertColumns;
|
|
267
|
+
_insertColumns.forEach(custom => {
|
|
268
|
+
list.splice(custom.insertIndex, 0, {
|
|
269
|
+
type: "custom",
|
|
270
|
+
...custom
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
this.tableColumns = list.filter(item => (item.show === undefined ? true : item.show));
|
|
274
|
+
this.checkedColumns = this.updateCheckColumns(this.tableColumns);
|
|
275
|
+
this.changeTableHight();
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
columns: {
|
|
280
|
+
deep: true,
|
|
281
|
+
immediate: true,
|
|
282
|
+
handler(val) {
|
|
283
|
+
this.getTableColumns().then(list => {
|
|
284
|
+
this.diyColumns = list;
|
|
285
|
+
this.tableColumns = list.filter(item => (item.show === undefined ? true : item.show));
|
|
286
|
+
this.checkedColumns = this.updateCheckColumns(this.tableColumns);
|
|
287
|
+
this.changeTableHight();
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
tableData: {
|
|
292
|
+
handler(val) {
|
|
293
|
+
this.$nextTick(() => {
|
|
294
|
+
this.changeTableHight();
|
|
295
|
+
this.hasLoadData = true;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
mounted() {
|
|
301
|
+
this.$nextTick(() => {
|
|
302
|
+
// 表格高度自适应浏览器大小
|
|
303
|
+
this.changeTableHight();
|
|
304
|
+
if (!this.height) {
|
|
305
|
+
window.onresize = () => {
|
|
306
|
+
this.changeTableHight();
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
activated() {
|
|
312
|
+
this.doLayout();
|
|
313
|
+
},
|
|
314
|
+
beforeDestroy() {
|
|
315
|
+
document.removeEventListener("click", this.handleDocumentClick);
|
|
316
|
+
},
|
|
317
|
+
methods: {
|
|
318
|
+
realIndexRender(index) {
|
|
319
|
+
if (this.pagination) {
|
|
320
|
+
return this.pagination.PageSize * (this.pagination.PageNum - 1) + index + 1;
|
|
321
|
+
}
|
|
322
|
+
return index + 1;
|
|
323
|
+
},
|
|
324
|
+
updateCheckColumns(columnsData) {
|
|
325
|
+
const checkArr = [];
|
|
326
|
+
columnsData.forEach(item => {
|
|
327
|
+
const { prop, show } = item;
|
|
328
|
+
if (prop) {
|
|
329
|
+
const isHidden = (show !== undefined) && !show;
|
|
330
|
+
!isHidden && checkArr.push(prop);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
return checkArr;
|
|
334
|
+
},
|
|
335
|
+
getTableColumns() {
|
|
336
|
+
const _columns = [];
|
|
337
|
+
return new Promise((resolve, reject) => {
|
|
338
|
+
if (!this.hasLoad && this.tbId) {
|
|
339
|
+
GetSelfData({
|
|
340
|
+
gridViewTypeId: this.tbId
|
|
341
|
+
}).then((res) => {
|
|
342
|
+
const { code, data } = res;
|
|
343
|
+
if (code === 200 && data.Result) {
|
|
344
|
+
const _resColumns = JSON.parse(data.Data);
|
|
345
|
+
// 解决 slotName问题 接口数据根据DATAFIELD 匹配 slotName
|
|
346
|
+
this.columns.map((item, ind) => {
|
|
347
|
+
const _fItem = _resColumns.find(it => item.prop == it.DATAFIELD);
|
|
348
|
+
if (_fItem && item.prop) {
|
|
349
|
+
_columns.push({
|
|
350
|
+
...item,
|
|
351
|
+
label: _fItem.HEADERTEXT,
|
|
352
|
+
show: _fItem.ISSHOW || false,
|
|
353
|
+
OrderNum: _fItem.ORDERNUM || ind
|
|
354
|
+
});
|
|
355
|
+
} else if (item.label == "操作") {
|
|
356
|
+
_columns.push(item);
|
|
357
|
+
} else {
|
|
358
|
+
return item;
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
resolve(_columns.sort((pre, aft) => {
|
|
362
|
+
return pre.OrderNum - aft.OrderNum;
|
|
363
|
+
}));
|
|
364
|
+
} else {
|
|
365
|
+
resolve(this.columns);
|
|
366
|
+
this.$emit("update:showColumsFilter", false);
|
|
367
|
+
}
|
|
368
|
+
this.hasLoad = true;
|
|
369
|
+
}).catch(() => {
|
|
370
|
+
this.hasLoad = true;
|
|
371
|
+
resolve(this.columns);
|
|
372
|
+
this.$emit("update:showColumsFilter", false);
|
|
373
|
+
});
|
|
374
|
+
} else {
|
|
375
|
+
resolve(this.columns);
|
|
376
|
+
this.$emit("update:showColumsFilter", false);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
},
|
|
380
|
+
handleDropVisible() {
|
|
381
|
+
this.dropvisible = !this.dropvisible;
|
|
382
|
+
if (this.dropvisible) {
|
|
383
|
+
document.addEventListener("click", this.handleDocumentClick);
|
|
384
|
+
} else {
|
|
385
|
+
document.removeEventListener("click", this.handleDocumentClick);
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
handleDocumentClick(event) {
|
|
389
|
+
const popoverEl = document.querySelector(".filter-tool");
|
|
390
|
+
if (!popoverEl.contains(event.target)) {
|
|
391
|
+
this.dropvisible = false;
|
|
392
|
+
document.removeEventListener("click", this.handleDocumentClick);
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
handleToggle(show, item) {
|
|
396
|
+
if (this.checkedColumns.length === 0) {
|
|
397
|
+
this.$Message.MessageWarning("至少选择一列显示!");
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
this.$emit("update:loading", true);
|
|
401
|
+
item.show = show;
|
|
402
|
+
this.tableColumns = this.diyColumns.filter(item => (item.show === undefined ? true : item.show));
|
|
403
|
+
this.checkedColumns = this.updateCheckColumns(this.tableColumns);
|
|
404
|
+
this.dropvisible = false;
|
|
405
|
+
// 设置定制列
|
|
406
|
+
this.changeTableHight();
|
|
407
|
+
this.$nextTick(() => {
|
|
408
|
+
this.doLayout();
|
|
409
|
+
});
|
|
410
|
+
if (this.tbId) {
|
|
411
|
+
const params = {
|
|
412
|
+
dataField: item.prop,
|
|
413
|
+
isShow: show ? 1 : 0,
|
|
414
|
+
gridviewTypeId: this.tbId
|
|
415
|
+
};
|
|
416
|
+
SaveIsShowInfo(params).then((res) => {
|
|
417
|
+
const { code } = res;
|
|
418
|
+
this.$emit("update:loading", false);
|
|
419
|
+
if (code !== 200) {
|
|
420
|
+
// 取消勾选处理
|
|
421
|
+
} else {
|
|
422
|
+
this.$Message.MessageSuccess("设置成功");
|
|
423
|
+
}
|
|
424
|
+
}).catch(() => {
|
|
425
|
+
this.$emit("update:loading", false);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
doLayout() {
|
|
430
|
+
this.$refs.ExtendTable && this.$refs.ExtendTable.doLayout();
|
|
431
|
+
},
|
|
432
|
+
getAttrs() {
|
|
433
|
+
return {
|
|
434
|
+
height: this.autoSetHeight ? this.inTableHeight : undefined,
|
|
435
|
+
border: this.border,
|
|
436
|
+
stripe: true,
|
|
437
|
+
highlightCurrentRow: true,
|
|
438
|
+
headerCellStyle: this.headerCellStyle,
|
|
439
|
+
elementLoadingText: this.elementLoadingText,
|
|
440
|
+
spanMethod: this.spanFields || this.groupColumns.length ? this.handleSpanMethod : null,
|
|
441
|
+
...this.$attrs
|
|
442
|
+
};
|
|
443
|
+
},
|
|
444
|
+
handleSpanMethod({ row, column, rowIndex, columnIndex }) {
|
|
445
|
+
if (this.spanFields) {
|
|
446
|
+
const field = this.spanFields[columnIndex];
|
|
447
|
+
if (field && row[`_${field}_start`]) {
|
|
448
|
+
return {
|
|
449
|
+
rowspan: row[`_${field}_span`],
|
|
450
|
+
colspan: 1
|
|
451
|
+
};
|
|
452
|
+
} else if (field && !row[`_${field}_start`]) {
|
|
453
|
+
return {
|
|
454
|
+
rowspan: 0,
|
|
455
|
+
colspan: 0
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (this.groupColumns.length) {
|
|
460
|
+
const leftIndex = (Number(this.selection) + Number(this.showIndex));
|
|
461
|
+
const groupColumnIndex = columnIndex - leftIndex;
|
|
462
|
+
if (columnIndex >= leftIndex && columnIndex < leftIndex + this.groupColumns.length) {
|
|
463
|
+
const groupIndex = groupColumnIndex;
|
|
464
|
+
if (groupIndex >= 0 && groupColumnIndex < this.groupColumns.length) {
|
|
465
|
+
return this.getSpan(rowIndex, groupIndex);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return { rowspan: 1, colspan: 1 };
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
getSpan(rowIndex, groupIndex) {
|
|
472
|
+
const spans = this.calculateSpans();
|
|
473
|
+
if (spans[rowIndex] && spans[rowIndex][groupIndex]) {
|
|
474
|
+
return spans[rowIndex][groupIndex];
|
|
475
|
+
}
|
|
476
|
+
return { rowspan: 1, colspan: 1 };
|
|
477
|
+
},
|
|
478
|
+
calculateSpans() {
|
|
479
|
+
const spans = [];
|
|
480
|
+
const rowCount = this.tableData.length;
|
|
481
|
+
|
|
482
|
+
if (rowCount === 0) return spans;
|
|
483
|
+
|
|
484
|
+
// 初始化数组
|
|
485
|
+
for (let i = 0; i < rowCount; i++) {
|
|
486
|
+
spans[i] = [];
|
|
487
|
+
for (let j = 0; j < this.groupColumns.length; j++) {
|
|
488
|
+
spans[i][j] = { rowspan: 1, colspan: 1 };
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// 分级计算合并
|
|
493
|
+
|
|
494
|
+
for (let level = 0; level < this.groupColumns.length; level++) {
|
|
495
|
+
let pos = 0;
|
|
496
|
+
while (pos < rowCount) {
|
|
497
|
+
const startPos = pos;
|
|
498
|
+
|
|
499
|
+
let endPos = startPos;
|
|
500
|
+
const currentValue = this.tableData[startPos][this.groupColumns[level].prop];
|
|
501
|
+
|
|
502
|
+
// 检查上级是否相同
|
|
503
|
+
|
|
504
|
+
let sameParent = true;
|
|
505
|
+
|
|
506
|
+
for (let parentLevel = 0; parentLevel < level; parentLevel++) {
|
|
507
|
+
if (this.tableData[startPos][this.groupColumns[parentLevel].prop] !== this.tableData[endPos][this.groupColumns[parentLevel].prop]) {
|
|
508
|
+
sameParent = false;
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (sameParent) {
|
|
514
|
+
while (endPos + 1 < rowCount && this.tableData[endPos + 1][this.groupColumns[level].prop] === currentValue && this.checkParentSame(startPos, endPos + 1, level)) {
|
|
515
|
+
endPos++;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (endPos > startPos) {
|
|
520
|
+
spans[startPos][level].rowspan = endPos - startPos + 1;
|
|
521
|
+
for (let i = startPos + 1; i <= endPos; i++) {
|
|
522
|
+
spans[i][level].rowspan = 0;
|
|
523
|
+
spans[i][level].colspan = 0;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
pos = endPos + 1;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return spans;
|
|
531
|
+
},
|
|
532
|
+
checkParentSame(rowIndex1, rowIndex2, currentLevel) {
|
|
533
|
+
for (let level = 0; level < currentLevel; level++) {
|
|
534
|
+
const prop = this.groupColumns[level].prop;
|
|
535
|
+
if (this.tableData[rowIndex1][prop] != this.tableData[rowIndex2][prop]) {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return true;
|
|
540
|
+
},
|
|
541
|
+
calculateGroupSpans(data, spanFields) {
|
|
542
|
+
const result = data.map(item => ({ ...item }));
|
|
543
|
+
for (const fieldIndex in spanFields) {
|
|
544
|
+
const field = spanFields[fieldIndex];
|
|
545
|
+
let currentValue = null;
|
|
546
|
+
let startIndex = 0;
|
|
547
|
+
|
|
548
|
+
result.forEach((row, index) => {
|
|
549
|
+
if (row[field] !== currentValue) {
|
|
550
|
+
currentValue = row[field];
|
|
551
|
+
startIndex = index;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
row[`_${field}_span`] = 0;
|
|
555
|
+
row[`_${field}_start`] = false;
|
|
556
|
+
|
|
557
|
+
let endIndex = index;
|
|
558
|
+
|
|
559
|
+
while (endIndex + 1 < result.length && result[endIndex + 1][field] === currentValue) {
|
|
560
|
+
endIndex++;
|
|
561
|
+
}
|
|
562
|
+
if (index === startIndex) {
|
|
563
|
+
row[`_${field}_span`] = endIndex - startIndex + 1;
|
|
564
|
+
row[`_${field}_start`] = true;
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
return result;
|
|
569
|
+
},
|
|
570
|
+
changeTableHight() {
|
|
571
|
+
try {
|
|
572
|
+
if (!this.autoSetHeight) return;
|
|
573
|
+
if (this.height) {
|
|
574
|
+
// 如果有传进来高度就取消自适应
|
|
575
|
+
this.inTableHeight = (this.height - 1 - (this.title ? 40 : 0));
|
|
576
|
+
this.$nextTick(() => {
|
|
577
|
+
this.doLayout();
|
|
578
|
+
});
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
let tableHeight = window.innerHeight || document.body.clientHeight;
|
|
582
|
+
// 高度设置
|
|
583
|
+
const disTop = this.$refs.ExtendTable.$el;
|
|
584
|
+
tableHeight -= (disTop.getBoundingClientRect().top + 20 + 1);
|
|
585
|
+
tableHeight -= this.$refs.toolBar.offsetHeight;
|
|
586
|
+
this.inTableHeight = tableHeight;
|
|
587
|
+
// 重绘表格
|
|
588
|
+
this.doLayout();
|
|
589
|
+
} catch (err) {
|
|
590
|
+
console.log(err);
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
setAttrs(params) {
|
|
594
|
+
const { ...options } = params;
|
|
595
|
+
if (!options.align) {
|
|
596
|
+
options.align = "center";
|
|
597
|
+
}
|
|
598
|
+
// if (!options.resizable) {
|
|
599
|
+
// options.resizable = true;
|
|
600
|
+
// }
|
|
601
|
+
if (options.showTip) {
|
|
602
|
+
options.showOverflowTooltip = true;
|
|
603
|
+
}
|
|
604
|
+
return { ...options };
|
|
605
|
+
},
|
|
606
|
+
// 排序
|
|
607
|
+
changeTableSort(column) {
|
|
608
|
+
const sortingType = column.order;
|
|
609
|
+
const sidx = sortingType ? column.prop : "";
|
|
610
|
+
let sord = "";
|
|
611
|
+
if (sortingType === "descending") {
|
|
612
|
+
sord = "desc";
|
|
613
|
+
} else if (sortingType === "ascending") {
|
|
614
|
+
sord = "asc";
|
|
615
|
+
}
|
|
616
|
+
this.$emit("changeTableSort", sidx, sord);
|
|
617
|
+
},
|
|
618
|
+
getSelection() {
|
|
619
|
+
return this.$refs.ExtendTable.store.states.selection;
|
|
620
|
+
},
|
|
621
|
+
clearSelection() {
|
|
622
|
+
this.$refs.ExtendTable.store.clearSelection();
|
|
623
|
+
this.$refs.ExtendTable.store.updateAllSelected();
|
|
624
|
+
return this;
|
|
625
|
+
},
|
|
626
|
+
toggleRowSelection(rows, selected) {
|
|
627
|
+
this.$refs.ExtendTable.toggleRowSelection(rows, true);
|
|
628
|
+
},
|
|
629
|
+
toggleRowsSelection(rows, selected) {
|
|
630
|
+
if (rows instanceof Array) {
|
|
631
|
+
rows.forEach(row => {
|
|
632
|
+
this.$refs.ExtendTable.store.toggleRowSelection(row, selected, true);
|
|
633
|
+
});
|
|
634
|
+
} else {
|
|
635
|
+
this.$refs.ExtendTable.store.toggleRowSelection(rows, selected, true);
|
|
636
|
+
}
|
|
637
|
+
this.$refs.ExtendTable.store.updateAllSelected();
|
|
638
|
+
},
|
|
639
|
+
rowChange(newVal, oldVal) {
|
|
640
|
+
this.$emit("currentChange", newVal, oldVal);
|
|
641
|
+
},
|
|
642
|
+
rowClick(row) {
|
|
643
|
+
this.$emit("rowClick", row);
|
|
644
|
+
},
|
|
645
|
+
pageChange(val) {
|
|
646
|
+
this.$emit("pageChange", val);
|
|
647
|
+
},
|
|
648
|
+
sizeChange(val) {
|
|
649
|
+
this.$emit("sizeChange", val);
|
|
650
|
+
},
|
|
651
|
+
selectionChange(selections) {
|
|
652
|
+
this.$emit("selectionChange", selections);
|
|
653
|
+
},
|
|
654
|
+
exportTableData() {
|
|
655
|
+
const title = this.title;
|
|
656
|
+
const list = [];
|
|
657
|
+
this.tableData.forEach(r => {
|
|
658
|
+
const obj = { ...r };
|
|
659
|
+
list.push(obj);
|
|
660
|
+
});
|
|
661
|
+
// 复制一份数据解决导出数据问题
|
|
662
|
+
this.doExport(list, title, null, this.column);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
</script>
|
|
667
|
+
<style lang="scss" scoped>
|
|
668
|
+
.toolBar {
|
|
669
|
+
display: flex;
|
|
670
|
+
align-items: center;
|
|
671
|
+
justify-content: flex-end;
|
|
672
|
+
position: relative;
|
|
673
|
+
&.left{
|
|
674
|
+
justify-content: flex-start;
|
|
675
|
+
}
|
|
676
|
+
&.center{
|
|
677
|
+
justify-content: center;
|
|
678
|
+
}
|
|
679
|
+
&.right{
|
|
680
|
+
justify-content: flex-end;
|
|
681
|
+
}
|
|
682
|
+
/deep/.pagination {
|
|
683
|
+
padding: 15px 10px;
|
|
684
|
+
width: 100%;
|
|
685
|
+
// background-color: #ffffff;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
.drop-body{
|
|
689
|
+
height: 175px;
|
|
690
|
+
overflow: hidden auto;
|
|
691
|
+
.checkli{
|
|
692
|
+
padding: 5px;
|
|
693
|
+
display: block;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
.empty{
|
|
697
|
+
&-title{
|
|
698
|
+
font-size: 16px;
|
|
699
|
+
color: #333333;
|
|
700
|
+
}
|
|
701
|
+
&-subtitle{
|
|
702
|
+
font-size: 12px;
|
|
703
|
+
color: #999999;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
@mixin setColorType($color) {
|
|
707
|
+
color: $color;
|
|
708
|
+
&.effect-light{
|
|
709
|
+
background-color: rgba($color: $color, $alpha: .2);
|
|
710
|
+
}
|
|
711
|
+
&.effect-dark{
|
|
712
|
+
color: #ffffff;
|
|
713
|
+
background-color: $color;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/deep/.el-table__cell,/deep/.el-table__row{
|
|
718
|
+
&.warn{
|
|
719
|
+
@include setColorType($darkWarning);
|
|
720
|
+
}
|
|
721
|
+
&.error{
|
|
722
|
+
@include setColorType($darkDanger);
|
|
723
|
+
}
|
|
724
|
+
&.info{
|
|
725
|
+
@include setColorType($darkPrimary);
|
|
726
|
+
}
|
|
727
|
+
&.success{
|
|
728
|
+
@include setColorType($darkSuccess);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
</style>
|