lambo-design-bi 0.0.1
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/bi/widget/README.md +18 -0
- package/bi/widget/api/data.js +48 -0
- package/bi/widget/atom/index.vue +36 -0
- package/bi/widget/atom/test.vue +36 -0
- package/bi/widget/config/config.js +7 -0
- package/bi/widget/container/card/card-widget.vue +46 -0
- package/bi/widget/container/card/comps/indicator-card/index.js +7 -0
- package/bi/widget/container/card/comps/indicator-card/src/indicator-card-bi-search.vue +132 -0
- package/bi/widget/container/card/comps/indicator-card/src/indicator-card-bi.vue +129 -0
- package/bi/widget/container/card/comps/indicator-card/src/indicator-card-item-bi.vue +97 -0
- package/bi/widget/container/card/comps/indicator-card/src/styles/css/card-search.less +108 -0
- package/bi/widget/container/card/comps/indicator-card/src/styles/css/card.less +114 -0
- package/bi/widget/layout/col.vue +35 -0
- package/bi/widget/layout/row.vue +40 -0
- package/bi/widget/num/index.vue +101 -0
- package/bi/widget/page/index.vue +38 -0
- package/bi/widget/search/search-form.vue +85 -0
- package/bi/widget/search/search-item.vue +205 -0
- package/bi/widget/table/detail-table.vue +65 -0
- package/bi/widget/table/paging-table.vue +188 -0
- package/bi/widget/util/widget-map.js +41 -0
- package/package.json +39 -0
- package/pub/charts/echarts.vue +57 -0
- package/pub/charts/factory/charts-factory.vue +58 -0
- package/pub/charts/factory/options.js +2351 -0
- package/pub/empty/index.vue +33 -0
- package/pub/helpbox/README.md +6 -0
- package/pub/helpbox/index.vue +363 -0
- package/pub/num-index/num-index.vue +120 -0
- package/pub/table/detail-table/index.vue +41 -0
- package/pub/table/paging-table/README.md +4 -0
- package/pub/table/paging-table/comps/export-data.vue +390 -0
- package/pub/table/paging-table/comps/export-drawer.vue +429 -0
- package/pub/table/paging-table/index.js +3 -0
- package/pub/table/paging-table/index.vue +1577 -0
- package/pub/table/paging-table/styles/css/index.less +190 -0
- package/pub/theme/color.js +3 -0
- package/util/math-util.js +71 -0
- package/util/num-util.js +16 -0
|
@@ -0,0 +1,1577 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="lambo-grid-table">
|
|
3
|
+
<div ref="searchBox">
|
|
4
|
+
<slot v-if="!isExpand" name="search">
|
|
5
|
+
</slot>
|
|
6
|
+
</div>
|
|
7
|
+
<Row type="flex" justify="start" :wrap="false">
|
|
8
|
+
<Col flex="auto">
|
|
9
|
+
<div class="buttons">
|
|
10
|
+
<slot name="buttons">
|
|
11
|
+
</slot>
|
|
12
|
+
</div>
|
|
13
|
+
</Col>
|
|
14
|
+
<Col flex="1 1 360px" v-show="showTableOption && optionLayout === 'flex'">
|
|
15
|
+
<Row type="flex" justify="end">
|
|
16
|
+
<Col>
|
|
17
|
+
<Dropdown class="table-option-dropdown" placement="bottom-end" transfer>
|
|
18
|
+
<Button class="setting-bottom-button" shape="circle" title="设置" icon="ios-settings-outline">
|
|
19
|
+
{{ settingText }}
|
|
20
|
+
</Button>
|
|
21
|
+
<DropdownMenu slot="list" style="width:420px;padding:10px">
|
|
22
|
+
<div>
|
|
23
|
+
<Form label-position="top">
|
|
24
|
+
<FormItem label="默认分页条数设置" v-show="!pageDisable">
|
|
25
|
+
<RadioGroup v-model="tableSettingFormData.limitNumber">
|
|
26
|
+
<Radio v-for="(item, index) in pageSizeOpts" :key="index" :label="item">{{ item }}</Radio>
|
|
27
|
+
</RadioGroup>
|
|
28
|
+
</FormItem>
|
|
29
|
+
<FormItem label="文件名设置">
|
|
30
|
+
<Input v-model="tableSettingFormData.tableName" placeholder="请设置导出文件名称"></Input>
|
|
31
|
+
</FormItem>
|
|
32
|
+
</Form>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="setting-bottom-button-group">
|
|
35
|
+
<Button class="setting-bottom-button" type="primary" color="primary" @click="tableSettingSave">保存
|
|
36
|
+
</Button>
|
|
37
|
+
</div>
|
|
38
|
+
</DropdownMenu>
|
|
39
|
+
</Dropdown>
|
|
40
|
+
<Button class="setting-bottom-button" v-if="!pageDisable" shape="circle" icon="ios-code-download" title="导出本页"
|
|
41
|
+
@click="exportCurrentPage" :loading="exportCurrentLoading">{{ exportCurrentText }}
|
|
42
|
+
</Button>
|
|
43
|
+
<Button class="setting-bottom-button" shape="circle" icon="ios-download-outline" title="导出全部"
|
|
44
|
+
@click="exportAllData" :loading="exportAllLoading">{{ exportAllText }}
|
|
45
|
+
</Button>
|
|
46
|
+
<Dropdown class="table-option-dropdown" placement="bottom-end" transfer>
|
|
47
|
+
<Button class="setting-bottom-button" shape="circle" title="列筛选" icon="ios-funnel-outline">
|
|
48
|
+
{{ columnFilterText }}
|
|
49
|
+
</Button>
|
|
50
|
+
<DropdownMenu slot="list" style="width:420px">
|
|
51
|
+
<Tabs type="card" name="setting-tab" class="drop-down-tabs">
|
|
52
|
+
<TabPane label="列筛选" tab="setting-tab" class="tab-filter">
|
|
53
|
+
<CheckboxGroup v-model="checkAllGroup" @on-change="checkAllGroupChange" class="checkbox-group">
|
|
54
|
+
<template v-for="(item, index) in columns">
|
|
55
|
+
<Checkbox v-if="item.title" :key="'c' + item.title + item.key + index"
|
|
56
|
+
:label="'c' + item.title + item.key + index" class="checkbox-single">
|
|
57
|
+
<Tooltip :disabled="item.title.length <= 4" :content="item.title" transfer>
|
|
58
|
+
{{ item.title }}
|
|
59
|
+
</Tooltip>
|
|
60
|
+
</Checkbox>
|
|
61
|
+
</template>
|
|
62
|
+
</CheckboxGroup>
|
|
63
|
+
<div class="tab-button">
|
|
64
|
+
<Checkbox :value="checkAll" :indeterminate="false" @click.prevent.native="handleCheckAll">全选
|
|
65
|
+
</Checkbox>
|
|
66
|
+
<span style="margin-left:90px">
|
|
67
|
+
<Button class="table-column-select-btn" type="primary" @click="columnSelect">筛 选</Button>
|
|
68
|
+
|
|
69
|
+
<Button class="table-column-select-btn" type="default" @click="columnSave">保 存</Button>
|
|
70
|
+
|
|
71
|
+
<Button class="table-column-select-btn" type="default" @click="columnClear">清 除</Button>
|
|
72
|
+
</span>
|
|
73
|
+
</div>
|
|
74
|
+
</TabPane>
|
|
75
|
+
</Tabs>
|
|
76
|
+
</DropdownMenu>
|
|
77
|
+
</Dropdown>
|
|
78
|
+
<Dropdown class="table-option-dropdown" placement="bottom-end" transfer>
|
|
79
|
+
<Button v-if="showFixedColumnFilter" class="setting-bottom-button" title="列固定" shape="circle"
|
|
80
|
+
icon="ios-pricetag-outline">{{ columnFixedText }}
|
|
81
|
+
</Button>
|
|
82
|
+
<DropdownMenu slot="list" style="width:420px;">
|
|
83
|
+
<Tabs type="card" name="setting-tab" class="drop-down-tabs">
|
|
84
|
+
<TabPane label="列固定" tab="setting-tab" class="tab-filter">
|
|
85
|
+
<CheckboxGroup v-model="fixedColumns" @on-change="checkAllFixedColumnsChange" class="checkbox-group">
|
|
86
|
+
<template v-for="(item) in cloneColumns">
|
|
87
|
+
<Checkbox v-if="item.title && item.fixed !== 'right' && !isDefaultLeftFixed(item)"
|
|
88
|
+
:key="'c' + item.title + item.key + item.__origin_index"
|
|
89
|
+
:label="'c' + item.title + item.key + item.__origin_index" class="checkbox-single">
|
|
90
|
+
<Tooltip :disabled="item.title.length <= 4" :content="item.title" transfer>
|
|
91
|
+
{{ item.title }}
|
|
92
|
+
</Tooltip>
|
|
93
|
+
</Checkbox>
|
|
94
|
+
</template>
|
|
95
|
+
</CheckboxGroup>
|
|
96
|
+
<div class="tab-button">
|
|
97
|
+
<Checkbox :value="checkAllFixedColumns" :indeterminate="false"
|
|
98
|
+
@click.prevent.native="handleCheckAllFixedColumns">全选
|
|
99
|
+
</Checkbox>
|
|
100
|
+
<span style="margin-left:90px">
|
|
101
|
+
<Button class="table-column-select-btn" type="primary" @click="fixedColumnSelect">固 定</Button>
|
|
102
|
+
|
|
103
|
+
<Button class="table-column-select-btn" type="default" @click="fixedColumnSave">保 存</Button>
|
|
104
|
+
|
|
105
|
+
<Button class="table-column-select-btn" type="default" @click="fixedColumnClear">清 除</Button>
|
|
106
|
+
</span>
|
|
107
|
+
</div>
|
|
108
|
+
</TabPane>
|
|
109
|
+
</Tabs>
|
|
110
|
+
</DropdownMenu>
|
|
111
|
+
</Dropdown>
|
|
112
|
+
<template v-if="showFullViewBtn">
|
|
113
|
+
<Button v-if="!isExpand" class="setting-bottom-button" icon="md-expand" title="表格全屏"
|
|
114
|
+
@click="expandTable"></Button>
|
|
115
|
+
<Button v-else class="setting-bottom-button" icon="md-contract" title="退出全屏" @click="contractTable"></Button>
|
|
116
|
+
</template>
|
|
117
|
+
</Col>
|
|
118
|
+
</Row>
|
|
119
|
+
</Col>
|
|
120
|
+
<Col flex="1 1 250px" v-show="showTableOption && optionLayout === 'default'">
|
|
121
|
+
<Row type="flex" justify="end">
|
|
122
|
+
<Col>
|
|
123
|
+
<ButtonGroup style="font-size: 0">
|
|
124
|
+
<Tooltip content="刷新表格数据" placement="top">
|
|
125
|
+
<Button icon="md-refresh" @click="tableRefresh"></Button>
|
|
126
|
+
</Tooltip>
|
|
127
|
+
<template v-if="showFullViewBtn">
|
|
128
|
+
<Button v-if="!isExpand" icon="md-expand" title="表格全屏" @click="expandTable"></Button>
|
|
129
|
+
<Button v-else icon="md-contract" title="退出全屏" @click="contractTable"></Button>
|
|
130
|
+
</template>
|
|
131
|
+
<Dropdown class="table-option-dropdown" placement="bottom-end" transfer>
|
|
132
|
+
<Tooltip content="表格选项" placement="top">
|
|
133
|
+
<Button icon="ios-keypad" class="table-option-dropdown">
|
|
134
|
+
<Icon type="ios-arrow-down"></Icon>
|
|
135
|
+
</Button>
|
|
136
|
+
</Tooltip>
|
|
137
|
+
<DropdownMenu slot="list" style="width:420px">
|
|
138
|
+
<Tabs type="card" name="export-tab" class="drop-down-tabs">
|
|
139
|
+
<TabPane label="导出" tab="export-tab">
|
|
140
|
+
<export-data ref="exportPart" :dataUrl="dataUrl" :exportUrl="exportUrl" :exportMode="exportMode"
|
|
141
|
+
:exportName="exportTableName" :export-batch-size="exportBatchSize"
|
|
142
|
+
:export-request-limit="exportRequestLimit" :requestMethod="reqMethod"
|
|
143
|
+
:request-success-codes="requestSuccessCodes" :paginationParams="paginationParams"
|
|
144
|
+
:parsedColumns="parsedColumns" :searchParams="searchParams" :show-summary="tableShowSummary"
|
|
145
|
+
:sortParams="sortParams" :total="totalNumber" :summary-method="tableSummaryMethod"
|
|
146
|
+
:tableColumns="tableColumns" :tableName="tableName" :exportSpanColumns="exportSpanColumns">
|
|
147
|
+
</export-data>
|
|
148
|
+
</TabPane>
|
|
149
|
+
<TabPane label="列筛选" tab="export-tab" class="tab-filter">
|
|
150
|
+
<CheckboxGroup v-model="checkAllGroup" @on-change="checkAllGroupChange" class="checkbox-group">
|
|
151
|
+
<template v-for="(item, index) in columns">
|
|
152
|
+
<Checkbox v-if="item.title" :key="'c' + item.title + item.key + index"
|
|
153
|
+
:label="'c' + item.title + item.key + index" class="checkbox-single">
|
|
154
|
+
<Tooltip :disabled="item.title.length <= 4" :content="item.title" transfer>
|
|
155
|
+
{{ item.title }}
|
|
156
|
+
</Tooltip>
|
|
157
|
+
</Checkbox>
|
|
158
|
+
</template>
|
|
159
|
+
</CheckboxGroup>
|
|
160
|
+
<div class="tab-button">
|
|
161
|
+
<Checkbox :value="checkAll" :indeterminate="false" @click.prevent.native="handleCheckAll">全选
|
|
162
|
+
</Checkbox>
|
|
163
|
+
<span style="margin-left:90px">
|
|
164
|
+
<Button class="table-column-select-btn" type="primary" @click="columnSelect">筛 选</Button>
|
|
165
|
+
|
|
166
|
+
<Button class="table-column-select-btn" type="default" @click="columnSave">保 存</Button>
|
|
167
|
+
|
|
168
|
+
<Button class="table-column-select-btn" type="default" @click="columnClear">清 除</Button>
|
|
169
|
+
</span>
|
|
170
|
+
</div>
|
|
171
|
+
</TabPane>
|
|
172
|
+
<TabPane v-if="showFixedColumnFilter" label="列固定" tab="export-tab" class="tab-filter">
|
|
173
|
+
<CheckboxGroup v-model="fixedColumns" @on-change="checkAllFixedColumnsChange" class="checkbox-group">
|
|
174
|
+
<template v-for="(item) in cloneColumns">
|
|
175
|
+
<Checkbox v-if="item.title && item.fixed !== 'right' && !isDefaultLeftFixed(item)"
|
|
176
|
+
:key="'c' + item.title + item.key + item.__origin_index"
|
|
177
|
+
:label="'c' + item.title + item.key + item.__origin_index" class="checkbox-single">
|
|
178
|
+
<Tooltip :disabled="item.title.length <= 4" :content="item.title" transfer>
|
|
179
|
+
{{ item.title }}
|
|
180
|
+
</Tooltip>
|
|
181
|
+
</Checkbox>
|
|
182
|
+
</template>
|
|
183
|
+
</CheckboxGroup>
|
|
184
|
+
<div class="tab-button">
|
|
185
|
+
<Checkbox :value="checkAllFixedColumns" :indeterminate="false"
|
|
186
|
+
@click.prevent.native="handleCheckAllFixedColumns">全选
|
|
187
|
+
</Checkbox>
|
|
188
|
+
<span style="margin-left:90px">
|
|
189
|
+
<Button class="table-column-select-btn" type="primary" @click="fixedColumnSelect">固 定</Button>
|
|
190
|
+
|
|
191
|
+
<Button class="table-column-select-btn" type="default" @click="fixedColumnSave">保 存</Button>
|
|
192
|
+
|
|
193
|
+
<Button class="table-column-select-btn" type="default" @click="fixedColumnClear">清 除</Button>
|
|
194
|
+
</span>
|
|
195
|
+
</div>
|
|
196
|
+
</TabPane>
|
|
197
|
+
</Tabs>
|
|
198
|
+
</DropdownMenu>
|
|
199
|
+
</Dropdown>
|
|
200
|
+
</ButtonGroup>
|
|
201
|
+
</Col>
|
|
202
|
+
</Row>
|
|
203
|
+
</Col>
|
|
204
|
+
<Col>
|
|
205
|
+
<Button v-if="showSearchBtn && ($listeners['do-search'] || $listeners['doSearch'])" type="primary"
|
|
206
|
+
class="setting-bottom-button search-btn" :icon="showSearchIcon ? 'ios-search' : ''" @click="doSearch">查询
|
|
207
|
+
</Button>
|
|
208
|
+
</Col>
|
|
209
|
+
</Row>
|
|
210
|
+
<Row v-if="slots.message || messageInfo.content">
|
|
211
|
+
<Col flex="auto">
|
|
212
|
+
<div class="message-box" :class="messageInfo.class">
|
|
213
|
+
<div slot="message" class="message-text">
|
|
214
|
+
<slot name="message">
|
|
215
|
+
{{ messageInfo.content }}
|
|
216
|
+
</slot>
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
</Col>
|
|
220
|
+
</Row>
|
|
221
|
+
<Row style="margin-top:10px;">
|
|
222
|
+
<Col span="24">
|
|
223
|
+
<Table v-if="hackReset" ref="tableRef" :border="tableBorder" :columns="tableColumns" :data="tableData"
|
|
224
|
+
:disabledHover="disabledHover" :draggable="draggable" :height="tableHeight" :max-height="tableMaxHeight"
|
|
225
|
+
:highlightRow="highlightRow" :loading="tableLoading" :noDataText="noDataText"
|
|
226
|
+
:noFilteredDataText="noFilteredDataText" :rowClassName="rowClassName" :row-key="rowKey"
|
|
227
|
+
:show-summary="tableShowSummary" :showHeader="tableShowHeader" :size="tableSize" :spanMethod="tableSpanMethod"
|
|
228
|
+
:stripe="tableStripe" :summaryMethod="tableSummaryMethod" :tooltip-theme="tooltipTheme" :width="tableWidth"
|
|
229
|
+
@on-sort-change="onSortChange" @on-current-change="onCurrentChange" @on-select="onSelect"
|
|
230
|
+
@on-select-cancel="onSelectCancel" @on-select-all="onSelectAll" @on-select-all-cancel="onSelectAllCancel"
|
|
231
|
+
@on-selection-change="onSelectionChange" @on-filter-change="onFilterChange" @on-row-click="onRowClick"
|
|
232
|
+
@on-row-dblclick="onRowDblclick" @on-expand="onExpand" @on-drag-drop="onDragDrop"
|
|
233
|
+
@on-column-width-resize="onColumnWidthResize">
|
|
234
|
+
<div v-if="slots.header" slot="header">
|
|
235
|
+
<slot name="header"></slot>
|
|
236
|
+
</div>
|
|
237
|
+
<div v-if="slots.footer" slot="footer">
|
|
238
|
+
<slot name="footer"></slot>
|
|
239
|
+
</div>
|
|
240
|
+
<div v-if="slots.loading" slot="loading">
|
|
241
|
+
<slot name="loading"></slot>
|
|
242
|
+
</div>
|
|
243
|
+
</Table>
|
|
244
|
+
</Col>
|
|
245
|
+
</Row>
|
|
246
|
+
<Row v-if="!pageDisable" style="margin-top:15px;" ref="pageRef">
|
|
247
|
+
<Col span="24" style="text-align:right">
|
|
248
|
+
<Page :current="currentPage" :total="totalNumber" :page-size-opts="pageSizeOpts" :pageSize="limitNumber"
|
|
249
|
+
show-elevator show-sizer show-total @on-change="onPageChange" @on-page-size-change="onPageSizeChange">
|
|
250
|
+
</Page>
|
|
251
|
+
</Col>
|
|
252
|
+
</Row>
|
|
253
|
+
</div>
|
|
254
|
+
</template>
|
|
255
|
+
<script>
|
|
256
|
+
import md5 from '@lambo-design/shared/utils/crypto/md5.js'
|
|
257
|
+
import { deepCopy, isJson } from '@lambo-design/shared/utils/assist'
|
|
258
|
+
import ajax from '@lambo-design/shared/utils/ajax'
|
|
259
|
+
import exportData from './comps/export-data.vue'
|
|
260
|
+
|
|
261
|
+
export default {
|
|
262
|
+
name: 'LamboPagingTableBi',
|
|
263
|
+
components: {
|
|
264
|
+
exportData
|
|
265
|
+
},
|
|
266
|
+
props: {
|
|
267
|
+
radioSelectIndex: {
|
|
268
|
+
type: Number,
|
|
269
|
+
default: -1
|
|
270
|
+
},
|
|
271
|
+
tableName: {
|
|
272
|
+
type: String,
|
|
273
|
+
default: '表格数据'
|
|
274
|
+
},
|
|
275
|
+
//是否显示分页
|
|
276
|
+
pageDisable: {
|
|
277
|
+
type: Boolean,
|
|
278
|
+
default: false
|
|
279
|
+
},
|
|
280
|
+
//取数的url
|
|
281
|
+
dataUrl: {
|
|
282
|
+
type: String,
|
|
283
|
+
default: ''
|
|
284
|
+
},
|
|
285
|
+
//导出的url
|
|
286
|
+
exportUrl: {
|
|
287
|
+
type: String,
|
|
288
|
+
default: ''
|
|
289
|
+
},
|
|
290
|
+
//导出模式
|
|
291
|
+
exportMode: {
|
|
292
|
+
type: String,
|
|
293
|
+
default: 'front'
|
|
294
|
+
},
|
|
295
|
+
//批量导出时单次导出数量
|
|
296
|
+
exportBatchSize: {
|
|
297
|
+
type: Number,
|
|
298
|
+
default: -1
|
|
299
|
+
},
|
|
300
|
+
exportRequestLimit: {
|
|
301
|
+
type: Number,
|
|
302
|
+
default: -1
|
|
303
|
+
},
|
|
304
|
+
exportSpanColumns: {
|
|
305
|
+
type: Array,
|
|
306
|
+
default() {
|
|
307
|
+
return [];
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
requestMethod: {
|
|
311
|
+
type: String,
|
|
312
|
+
default: 'GET',
|
|
313
|
+
},
|
|
314
|
+
requestPayload: {
|
|
315
|
+
type: Boolean,
|
|
316
|
+
default: false
|
|
317
|
+
},
|
|
318
|
+
//查询条件
|
|
319
|
+
searchParams: {
|
|
320
|
+
type: Object
|
|
321
|
+
},
|
|
322
|
+
data: {
|
|
323
|
+
type: Array,
|
|
324
|
+
default() {
|
|
325
|
+
return [];
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
columns: {
|
|
329
|
+
type: Array,
|
|
330
|
+
default() {
|
|
331
|
+
return [];
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
size: {
|
|
335
|
+
type: String,
|
|
336
|
+
validator(value) {
|
|
337
|
+
return ['small', 'large', 'default'].indexOf(value) > -1;
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
width: {
|
|
341
|
+
type: [Number, String]
|
|
342
|
+
},
|
|
343
|
+
height: {
|
|
344
|
+
type: [Number, String]
|
|
345
|
+
},
|
|
346
|
+
stripe: {
|
|
347
|
+
type: Boolean,
|
|
348
|
+
default: true
|
|
349
|
+
},
|
|
350
|
+
border: {
|
|
351
|
+
type: Boolean,
|
|
352
|
+
default: true
|
|
353
|
+
},
|
|
354
|
+
showHeader: {
|
|
355
|
+
type: Boolean,
|
|
356
|
+
default: true
|
|
357
|
+
},
|
|
358
|
+
highlightRow: {
|
|
359
|
+
type: Boolean,
|
|
360
|
+
default: false
|
|
361
|
+
},
|
|
362
|
+
rowClassName: {
|
|
363
|
+
type: Function,
|
|
364
|
+
default() {
|
|
365
|
+
return '';
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
context: {
|
|
369
|
+
type: Object
|
|
370
|
+
},
|
|
371
|
+
noDataText: {
|
|
372
|
+
type: String
|
|
373
|
+
},
|
|
374
|
+
noFilteredDataText: {
|
|
375
|
+
type: String
|
|
376
|
+
},
|
|
377
|
+
disabledHover: {
|
|
378
|
+
type: Boolean
|
|
379
|
+
},
|
|
380
|
+
loading: {
|
|
381
|
+
type: Boolean,
|
|
382
|
+
default: false
|
|
383
|
+
},
|
|
384
|
+
rowKey: {
|
|
385
|
+
type: [Boolean, String],
|
|
386
|
+
default: false
|
|
387
|
+
},
|
|
388
|
+
//是否显示左固定列配置
|
|
389
|
+
showFixedColumnFilter: {
|
|
390
|
+
type: Boolean,
|
|
391
|
+
default() {
|
|
392
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.showFixedColumnFilter ? this.$IVIEW.table.showFixedColumnFilter : false;
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
//是否显示全屏按钮
|
|
396
|
+
showFullViewBtn: {
|
|
397
|
+
type: Boolean,
|
|
398
|
+
default() {
|
|
399
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.showFullViewBtn ? this.$IVIEW.table.showFullViewBtn : false;
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
//是否显示查询按钮
|
|
403
|
+
showSearchBtn: {
|
|
404
|
+
type: Boolean,
|
|
405
|
+
default() {
|
|
406
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.showSearchBtn ? this.$IVIEW.table.showSearchBtn : false;
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
showSearchIcon: {
|
|
410
|
+
type: Boolean,
|
|
411
|
+
default() {
|
|
412
|
+
return this.$IVIEW && this.$IVIEW.queryFilter && this.$IVIEW.queryFilter.showSearchIcon ? this.$IVIEW.queryFilter.showSearchIcon : false;
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
//表格是否自适应高度
|
|
416
|
+
autoFixHeight: {
|
|
417
|
+
type: Boolean,
|
|
418
|
+
default() {
|
|
419
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.autoFixHeight ? this.$IVIEW.table.autoFixHeight : false;
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
//自适应高度时,需要减去的底部高度
|
|
423
|
+
tableBottomHeight: {
|
|
424
|
+
type: Number,
|
|
425
|
+
default: 28
|
|
426
|
+
},
|
|
427
|
+
showOptionText: {
|
|
428
|
+
type: Boolean,
|
|
429
|
+
default() {
|
|
430
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.showOptionText ? this.$IVIEW.table.showOptionText : false;
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
//是否显示表格右上角内置按钮
|
|
434
|
+
showTableOption: {
|
|
435
|
+
type: Boolean,
|
|
436
|
+
default: true
|
|
437
|
+
},
|
|
438
|
+
//表格右上角设置布局方式
|
|
439
|
+
optionLayout: {
|
|
440
|
+
type: String,
|
|
441
|
+
default() {
|
|
442
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.optionLayout ? this.$IVIEW.table.optionLayout : 'default';
|
|
443
|
+
},
|
|
444
|
+
validator(value) {
|
|
445
|
+
return ['flex', 'default'].indexOf(value) > -1;
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
exportName: String,
|
|
449
|
+
transformRequest: {
|
|
450
|
+
type: Function,
|
|
451
|
+
default: function (data) {
|
|
452
|
+
return data;
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
transformResponse: {
|
|
456
|
+
type: Function,
|
|
457
|
+
default: function (data) {
|
|
458
|
+
return data;
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
draggable: {
|
|
462
|
+
type: Boolean,
|
|
463
|
+
default: false
|
|
464
|
+
},
|
|
465
|
+
tooltipTheme: {
|
|
466
|
+
type: String,
|
|
467
|
+
default: 'dark'
|
|
468
|
+
},
|
|
469
|
+
showSummary: {
|
|
470
|
+
type: Boolean,
|
|
471
|
+
default: false
|
|
472
|
+
},
|
|
473
|
+
summaryMethod: {
|
|
474
|
+
type: Function
|
|
475
|
+
},
|
|
476
|
+
spanMethod: {
|
|
477
|
+
type: Function
|
|
478
|
+
},
|
|
479
|
+
autoSearch: {
|
|
480
|
+
type: Boolean,
|
|
481
|
+
default() {
|
|
482
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.disableAutoSearch ? !this.$IVIEW.table.disableAutoSearch : true;
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
columnResizable: {
|
|
486
|
+
type: Boolean,
|
|
487
|
+
default() {
|
|
488
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.columnResizable ? this.$IVIEW.table.columnResizable : false;
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
disableColumnRefresh: {
|
|
492
|
+
type: Boolean,
|
|
493
|
+
default() {
|
|
494
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.disableColumnRefresh ? this.$IVIEW.table.disableColumnRefresh : false;
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
activatedRefresh: {
|
|
498
|
+
type: Boolean,
|
|
499
|
+
default() {
|
|
500
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.activatedRefresh ? this.$IVIEW.table.activatedRefresh : false;
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
pageSizeOpts: {
|
|
504
|
+
type: Array,
|
|
505
|
+
default: function () {
|
|
506
|
+
return [10, 20, 50, 100, 200];
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
pageSize: {
|
|
510
|
+
type: Number,
|
|
511
|
+
default() {
|
|
512
|
+
return this.$IVIEW && this.$IVIEW.table && this.$IVIEW.table.pageSize ? this.$IVIEW.table.pageSize : 10;
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
requestSuccessCodes: {
|
|
516
|
+
type: Array,
|
|
517
|
+
default: function () {
|
|
518
|
+
return [1, "1", "000"]
|
|
519
|
+
},
|
|
520
|
+
validator(value) {
|
|
521
|
+
if (value != null && [...value].slice().sort().toString() !== [1, "1", "000"].sort().toString()) {
|
|
522
|
+
console.warn("不推荐单独设置请求成功返回码");
|
|
523
|
+
}
|
|
524
|
+
return value instanceof Array;
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
messageInfo: {
|
|
528
|
+
type: Object,
|
|
529
|
+
default: function () {
|
|
530
|
+
return {
|
|
531
|
+
class: '',
|
|
532
|
+
content: ''
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
data() {
|
|
538
|
+
return {
|
|
539
|
+
tableData: this.data,
|
|
540
|
+
tableWidth: this.width,
|
|
541
|
+
tableHeight: this.height,
|
|
542
|
+
tableLoading: this.loading,
|
|
543
|
+
cloneColumns: [],
|
|
544
|
+
//样式相关
|
|
545
|
+
tableStripe: this.stripe,
|
|
546
|
+
tableBorder: this.border,
|
|
547
|
+
tableShowHeader: this.showHeader,
|
|
548
|
+
tableSize: this.size,
|
|
549
|
+
tableShowSummary: this.showSummary,
|
|
550
|
+
tableSummaryMethod: this.summaryMethod,
|
|
551
|
+
tableSpanMethod: this.spanMethod,
|
|
552
|
+
tableMaxHeight: '',
|
|
553
|
+
|
|
554
|
+
//单选控制
|
|
555
|
+
isSingleSelectModel: false,
|
|
556
|
+
selection: [],
|
|
557
|
+
|
|
558
|
+
//分页相关参数
|
|
559
|
+
totalNumber: 0,
|
|
560
|
+
currentPage: 1,
|
|
561
|
+
limitNumber: this.pageSize,
|
|
562
|
+
// 表格选项 flex版本
|
|
563
|
+
tableSettingFormData: {
|
|
564
|
+
limitNumber: this.limitNumber,
|
|
565
|
+
tableName: this.exportName
|
|
566
|
+
},
|
|
567
|
+
exportCurrentLoading: false,
|
|
568
|
+
exportAllLoading: false,
|
|
569
|
+
exportTableName: this.exportName,
|
|
570
|
+
//列筛选
|
|
571
|
+
checkAll: true,
|
|
572
|
+
checkAllGroup: [],
|
|
573
|
+
//导出格式
|
|
574
|
+
dataExportFormat: "xlsx",
|
|
575
|
+
//排序
|
|
576
|
+
sortParams: {},
|
|
577
|
+
//表格重置
|
|
578
|
+
hackReset: true,
|
|
579
|
+
columnID: '',
|
|
580
|
+
//固定列(只考虑左侧固定,右侧固定按钮不考虑)
|
|
581
|
+
checkAllFixedColumns: true,
|
|
582
|
+
fixedColumns: [],
|
|
583
|
+
//是否全屏(隐藏查询条件,自适应高度时才可使用)
|
|
584
|
+
isExpand: false,
|
|
585
|
+
observer: null,
|
|
586
|
+
topHeight: null,
|
|
587
|
+
screenHeight: null,
|
|
588
|
+
|
|
589
|
+
parsedColumns: []
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
computed: {
|
|
593
|
+
tableColumns() {
|
|
594
|
+
let self = this;
|
|
595
|
+
let columns = self.cloneColumns
|
|
596
|
+
for (let i = 0; i < columns.length; i++) {
|
|
597
|
+
let column = columns[i];
|
|
598
|
+
if ("type" in column && column.type === "single-selection") {
|
|
599
|
+
//当前iView版本单选要自己实现
|
|
600
|
+
self.isSingleSelectModel = true;
|
|
601
|
+
column.render = function (h, params) {
|
|
602
|
+
let index = params.index;
|
|
603
|
+
const disabled = params.row._disabled ? params.row._disabled : false
|
|
604
|
+
return h("Radio", {
|
|
605
|
+
props: {
|
|
606
|
+
"value": disabled ? false : self.radioSelectIndex !== -1 ? self.radioSelectIndex === index : self.selection[index] === undefined ? false : self.selection[index],
|
|
607
|
+
"disabled": disabled
|
|
608
|
+
},
|
|
609
|
+
on: {
|
|
610
|
+
"on-change": function () {
|
|
611
|
+
self.selectOnChange(params.row, index);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
})
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if (self.columnResizable) {
|
|
618
|
+
if (!("resizable" in column)) {
|
|
619
|
+
column["resizable"] = true
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
return columns;
|
|
624
|
+
},
|
|
625
|
+
columnNameArr() {
|
|
626
|
+
let arr = [];
|
|
627
|
+
for (let index = 0; index < this.columns.length; index++) {
|
|
628
|
+
let item = this.columns[index]
|
|
629
|
+
arr.push('c' + item.title + item.key + index);
|
|
630
|
+
}
|
|
631
|
+
return arr;
|
|
632
|
+
},
|
|
633
|
+
selectedColumnNameArr() {
|
|
634
|
+
let arr = [];
|
|
635
|
+
for (let index = 0; index < this.cloneColumns.length; index++) {
|
|
636
|
+
let item = this.cloneColumns[index]
|
|
637
|
+
arr.push('c' + item.title + item.key + this.cloneColumns[index]['__origin_index']);
|
|
638
|
+
}
|
|
639
|
+
return arr;
|
|
640
|
+
},
|
|
641
|
+
fixedColumnNameArr() {
|
|
642
|
+
let arr = [];
|
|
643
|
+
for (let index = 0; index < this.cloneColumns.length; index++) {
|
|
644
|
+
let column = this.cloneColumns[index];
|
|
645
|
+
if (column.fixed !== 'right' && !this.isDefaultLeftFixed(column)) {
|
|
646
|
+
arr.push('c' + column.title + column.key + column['__origin_index']);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return arr;
|
|
650
|
+
},
|
|
651
|
+
selectedFixedColumnNameArr() {
|
|
652
|
+
let arr = [];
|
|
653
|
+
for (let index = 0; index < this.cloneColumns.length; index++) {
|
|
654
|
+
let column = this.cloneColumns[index];
|
|
655
|
+
if (column.fixed === 'left' && !this.isDefaultLeftFixed(column)) {
|
|
656
|
+
arr.push('c' + column.title + column.key + column['__origin_index']);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return arr;
|
|
660
|
+
},
|
|
661
|
+
paginationParams() {
|
|
662
|
+
let self = this;
|
|
663
|
+
return {
|
|
664
|
+
offset: (self.currentPage - 1) * self.limitNumber,
|
|
665
|
+
limit: self.limitNumber
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
reqMethod() {
|
|
669
|
+
return this.requestMethod
|
|
670
|
+
},
|
|
671
|
+
slots() {
|
|
672
|
+
return this.$slots;
|
|
673
|
+
},
|
|
674
|
+
option() {
|
|
675
|
+
const { searchParams, dataUrl, columns } = this;
|
|
676
|
+
return {
|
|
677
|
+
searchParams,
|
|
678
|
+
dataUrl,
|
|
679
|
+
columns
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
settingText() {
|
|
683
|
+
let text = '';
|
|
684
|
+
if (this.showOptionText) {
|
|
685
|
+
text = '设置'
|
|
686
|
+
}
|
|
687
|
+
return text;
|
|
688
|
+
},
|
|
689
|
+
exportCurrentText() {
|
|
690
|
+
let text = '';
|
|
691
|
+
if (this.showOptionText) {
|
|
692
|
+
text = '导出本页'
|
|
693
|
+
}
|
|
694
|
+
return text;
|
|
695
|
+
},
|
|
696
|
+
exportAllText() {
|
|
697
|
+
let text = '';
|
|
698
|
+
if (this.showOptionText) {
|
|
699
|
+
text = '导出全部'
|
|
700
|
+
}
|
|
701
|
+
return text;
|
|
702
|
+
},
|
|
703
|
+
columnFilterText() {
|
|
704
|
+
let text = '';
|
|
705
|
+
if (this.showOptionText) {
|
|
706
|
+
text = '列筛选'
|
|
707
|
+
}
|
|
708
|
+
return text;
|
|
709
|
+
},
|
|
710
|
+
columnFixedText() {
|
|
711
|
+
let text = '';
|
|
712
|
+
if (this.showOptionText) {
|
|
713
|
+
text = '列固定'
|
|
714
|
+
}
|
|
715
|
+
return text;
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
watch: {
|
|
719
|
+
option: {
|
|
720
|
+
handler: function (val, oldVal) {
|
|
721
|
+
let refresh = true
|
|
722
|
+
if (val.columns !== oldVal.columns) {
|
|
723
|
+
//查询时重置页码
|
|
724
|
+
this.cloneColumns = this.getCloneColumns(val.columns, true)
|
|
725
|
+
this.columnsFilter()
|
|
726
|
+
if (!this.disableColumnRefresh) {
|
|
727
|
+
//查询时重置页码
|
|
728
|
+
this.currentPage = 1;
|
|
729
|
+
this.tableRefresh();
|
|
730
|
+
refresh = false;
|
|
731
|
+
} else {
|
|
732
|
+
refresh = false;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (val.searchParams !== oldVal.searchParams) {
|
|
736
|
+
refresh = true
|
|
737
|
+
}
|
|
738
|
+
if (val.dataUrl !== oldVal.dataUrl) {
|
|
739
|
+
refresh = true
|
|
740
|
+
}
|
|
741
|
+
if (refresh) {
|
|
742
|
+
//查询时重置页码
|
|
743
|
+
this.currentPage = 1;
|
|
744
|
+
this.tableRefresh();
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
deep: true
|
|
748
|
+
},
|
|
749
|
+
data: {
|
|
750
|
+
handler(val) {
|
|
751
|
+
this.tableData = val
|
|
752
|
+
this.totalNumber = val.length;
|
|
753
|
+
},
|
|
754
|
+
deep: true
|
|
755
|
+
},
|
|
756
|
+
showSummary: {
|
|
757
|
+
handler(val) {
|
|
758
|
+
this.tableShowSummary = val;
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
topHeight: {
|
|
762
|
+
handler: function (val, oldVal) {
|
|
763
|
+
if (val !== oldVal) {
|
|
764
|
+
this.fixTableHeight()
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
deep: true
|
|
768
|
+
},
|
|
769
|
+
screenHeight: {
|
|
770
|
+
handler: function (val, oldVal) {
|
|
771
|
+
if (val !== oldVal) {
|
|
772
|
+
this.fixTableHeight()
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
deep: true
|
|
776
|
+
},
|
|
777
|
+
},
|
|
778
|
+
methods: {
|
|
779
|
+
extractKeyTitlePairs(column) {
|
|
780
|
+
let result = {};
|
|
781
|
+
column.forEach(column => {
|
|
782
|
+
const key = column.key;
|
|
783
|
+
const type = column.type;
|
|
784
|
+
const title = column.title;
|
|
785
|
+
// 过滤到没有key、序号、单选、多选、操作列的情况
|
|
786
|
+
if (!key || ['index', 'selection', 'single-selection'].includes(type) || title === '操作') {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
result[key] = title;
|
|
790
|
+
if (column.children) {
|
|
791
|
+
Object.assign(result, this.extractKeyTitlePairs(column.children));
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
return result;
|
|
795
|
+
},
|
|
796
|
+
tableRefresh: function () {
|
|
797
|
+
let self = this;
|
|
798
|
+
self.selection = []
|
|
799
|
+
if (self.dataUrl) {
|
|
800
|
+
self.tableLoading = true;
|
|
801
|
+
let options = {
|
|
802
|
+
url: self.dataUrl,
|
|
803
|
+
method: self.reqMethod,
|
|
804
|
+
transformRequest: [...ajax.defaults.transformRequest, self.transformRequest],
|
|
805
|
+
transformResponse: [...ajax.defaults.transformResponse, self.transformResponse],
|
|
806
|
+
responseType: 'json'
|
|
807
|
+
}
|
|
808
|
+
if (self.reqMethod === 'GET') {
|
|
809
|
+
options = Object.assign({}, options,
|
|
810
|
+
{
|
|
811
|
+
params: Object.assign({}, self.pageDisable ? {} : self.paginationParams, self.sortParams, self.searchParams)
|
|
812
|
+
}
|
|
813
|
+
)
|
|
814
|
+
} else if (self.reqMethod === 'POST') {
|
|
815
|
+
options = Object.assign({}, options,
|
|
816
|
+
{
|
|
817
|
+
data: Object.assign({}, self.pageDisable ? {} : self.paginationParams, self.sortParams, self.searchParams),
|
|
818
|
+
payload: self.requestPayload
|
|
819
|
+
}
|
|
820
|
+
)
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
ajax.request(options).then(function (resp) {
|
|
824
|
+
if (resp.data) {
|
|
825
|
+
//这里是为了做IE11兼容
|
|
826
|
+
if (!isJson(resp.data)) {
|
|
827
|
+
resp.data = JSON.parse(resp.data);
|
|
828
|
+
}
|
|
829
|
+
if (self.requestSuccessCodes.includes(resp.data.code)) {
|
|
830
|
+
self.tableData = resp.data.data.rows;
|
|
831
|
+
self.totalNumber = resp.data.data.total;
|
|
832
|
+
self.$emit("on-data-load", resp.data);
|
|
833
|
+
} else if (resp.data.code === 0) {
|
|
834
|
+
console.log("请求失败:", resp)
|
|
835
|
+
if (Object.prototype.hasOwnProperty.call(resp.data, "message")) {
|
|
836
|
+
if (resp.data.message) {
|
|
837
|
+
self.$Message.error('请求失败[' + resp.data.message + ']')
|
|
838
|
+
} else {
|
|
839
|
+
self.$Message.error('请求失败')
|
|
840
|
+
}
|
|
841
|
+
} else {
|
|
842
|
+
self.$Message.error('请求失败')
|
|
843
|
+
}
|
|
844
|
+
} else {
|
|
845
|
+
self.tableData = resp.data.rows;
|
|
846
|
+
self.totalNumber = resp.data.total;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
self.tableLoading = false;
|
|
850
|
+
});
|
|
851
|
+
} else {
|
|
852
|
+
self.totalNumber = self.data.length;
|
|
853
|
+
}
|
|
854
|
+
self.parsedColumns = self.$refs.tableRef.cloneColumns;
|
|
855
|
+
},
|
|
856
|
+
columnsFilter() {
|
|
857
|
+
// 根据localStorage筛选列
|
|
858
|
+
let self = this
|
|
859
|
+
this.columnID = md5.MD5(JSON.stringify(this.$route.path + this.columns.length))
|
|
860
|
+
let inColumns = this.columns
|
|
861
|
+
let selectedColumn = [];
|
|
862
|
+
let localColumnList
|
|
863
|
+
if (typeof window !== 'undefined') {
|
|
864
|
+
localColumnList = localStorage.getItem("tableColumns")
|
|
865
|
+
}
|
|
866
|
+
if (localColumnList != null) {
|
|
867
|
+
let localColumn = JSON.parse(localColumnList)
|
|
868
|
+
let currentColumn = localColumn.filter(item => {
|
|
869
|
+
return item.id === self.columnID
|
|
870
|
+
})
|
|
871
|
+
if (currentColumn.length === 1) {
|
|
872
|
+
let list = currentColumn[0].value
|
|
873
|
+
for (let index = 0; index < inColumns.length; index++) {
|
|
874
|
+
let item = inColumns[index];
|
|
875
|
+
let characters = 'c' + item.title + item.key + index
|
|
876
|
+
if (characters !== "") {
|
|
877
|
+
let coloumn = list.filter((it) => it === characters)
|
|
878
|
+
if (coloumn.length === 0) {
|
|
879
|
+
//缓存的不显示的
|
|
880
|
+
let itemClone = Object.assign({}, item);
|
|
881
|
+
selectedColumn.push(itemClone)
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
if (selectedColumn.length > 0) {
|
|
888
|
+
this.cloneColumns = this.getCloneColumns(selectedColumn, false)
|
|
889
|
+
} else {
|
|
890
|
+
this.cloneColumns = this.getCloneColumns(this.columns, true)
|
|
891
|
+
for (let index = 0; index < this.cloneColumns.length; index++) {
|
|
892
|
+
if (this.columnResizable) {
|
|
893
|
+
if (!("resizable" in this.cloneColumns[index])) {
|
|
894
|
+
this.cloneColumns[index]["resizable"] = true
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
if (this.columns.length !== this.cloneColumns.length) {
|
|
900
|
+
this.checkAll = false
|
|
901
|
+
}
|
|
902
|
+
this.checkAllGroup = this.selectedColumnNameArr.slice(0);
|
|
903
|
+
if (this.showFixedColumnFilter) {
|
|
904
|
+
this.fixedColumnsFilter();
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
getParams: function () {
|
|
908
|
+
return Object.assign({}, this.paginationParams, this.sortParams, this.searchParams)
|
|
909
|
+
},
|
|
910
|
+
exportOper: function (type) {
|
|
911
|
+
this.$refs.exportPart.exportExcel(type);
|
|
912
|
+
},
|
|
913
|
+
onPageChange: function (currentPageIndex) {
|
|
914
|
+
this.currentPage = currentPageIndex;
|
|
915
|
+
this.tableRefresh();
|
|
916
|
+
this.$emit("on-page-change", currentPageIndex)
|
|
917
|
+
},
|
|
918
|
+
onPageSizeChange: function (currentLimitNumber) {
|
|
919
|
+
this.limitNumber = currentLimitNumber;
|
|
920
|
+
if (this.currentPage === 1) {
|
|
921
|
+
this.tableRefresh();
|
|
922
|
+
}
|
|
923
|
+
this.$emit("on-page-size-change", currentLimitNumber)
|
|
924
|
+
},
|
|
925
|
+
handleCheckAll() {
|
|
926
|
+
this.checkAll = !this.checkAll;
|
|
927
|
+
if (this.checkAll) {
|
|
928
|
+
this.checkAllGroup = this.columnNameArr.slice(0);
|
|
929
|
+
} else {
|
|
930
|
+
this.checkAllGroup = [];
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
checkAllGroupChange(data) {
|
|
934
|
+
if (data.length === this.columnNameArr.length) {
|
|
935
|
+
this.checkAll = true;
|
|
936
|
+
} else if (data.length > 0) {
|
|
937
|
+
this.checkAll = false;
|
|
938
|
+
} else {
|
|
939
|
+
this.checkAll = false;
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
initTableCustomSetting() {
|
|
943
|
+
this.columnID = md5.MD5(JSON.stringify(this.$route.path + this.columns.length));
|
|
944
|
+
let pageSize = this.getTableCustomSetting('tableSettingLimitNumber') ? parseInt(this.getTableCustomSetting('tableSettingLimitNumber')) : this.limitNumber;
|
|
945
|
+
let tableName = this.getTableCustomSetting('tableSettingTableName') ? this.getTableCustomSetting('tableSettingTableName') : (this.exportName ? this.exportName : this.$route.meta.title);
|
|
946
|
+
this.tableSettingFormData = {
|
|
947
|
+
limitNumber: pageSize,
|
|
948
|
+
tableName: tableName
|
|
949
|
+
}
|
|
950
|
+
this.limitNumber = pageSize;
|
|
951
|
+
this.exportTableName = tableName;
|
|
952
|
+
},
|
|
953
|
+
setTableCustomSetting(storageKey, value) {
|
|
954
|
+
this.columnID = md5.MD5(JSON.stringify(this.$route.path + this.columns.length));
|
|
955
|
+
let str
|
|
956
|
+
if (typeof window !== 'undefined') {
|
|
957
|
+
str = localStorage.getItem(storageKey)
|
|
958
|
+
}
|
|
959
|
+
let list = null
|
|
960
|
+
if (str == null) {
|
|
961
|
+
list = []
|
|
962
|
+
} else {
|
|
963
|
+
list = JSON.parse(str)
|
|
964
|
+
let index = list.findIndex(column => column.id === this.columnID)
|
|
965
|
+
if (index > -1) {
|
|
966
|
+
list.splice(index, 1)
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
list.push({ id: this.columnID, value: value })
|
|
970
|
+
if (typeof window !== 'undefined') {
|
|
971
|
+
localStorage.setItem(storageKey, JSON.stringify(list));
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
getTableCustomSetting(storageKey) {
|
|
975
|
+
this.columnID = md5.MD5(JSON.stringify(this.$route.path + this.columns.length));
|
|
976
|
+
let str
|
|
977
|
+
if (typeof window !== 'undefined') {
|
|
978
|
+
str = localStorage.getItem(storageKey)
|
|
979
|
+
}
|
|
980
|
+
if (str != null) {
|
|
981
|
+
let list = JSON.parse(str)
|
|
982
|
+
let item = list.filter(item => {
|
|
983
|
+
return item.id === this.columnID
|
|
984
|
+
})
|
|
985
|
+
return item && item.length > 0 ? item[0].value : null;
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
tableSettingSave() {
|
|
989
|
+
this.setTableCustomSetting('tableSettingLimitNumber', this.tableSettingFormData.limitNumber);
|
|
990
|
+
this.setTableCustomSetting('tableSettingTableName', this.tableSettingFormData.tableName);
|
|
991
|
+
this.limitNumber = this.tableSettingFormData.limitNumber;
|
|
992
|
+
this.exportTableName = this.tableSettingFormData.tableName;
|
|
993
|
+
// 设置完成后回调
|
|
994
|
+
this.onPageSizeChange(this.limitNumber);
|
|
995
|
+
this.$Message.success('保存成功');
|
|
996
|
+
},
|
|
997
|
+
// 导出按钮在外面布局时使用
|
|
998
|
+
exportCurrentPage() {
|
|
999
|
+
this.exportCurrentLoading = true;
|
|
1000
|
+
this.$refs.exportPart.exportCurrentPage();
|
|
1001
|
+
setTimeout(() => {
|
|
1002
|
+
this.exportCurrentLoading = false;
|
|
1003
|
+
}, 1000);
|
|
1004
|
+
},
|
|
1005
|
+
exportAllData() {
|
|
1006
|
+
this.exportAllLoading = true;
|
|
1007
|
+
if (this.exportBatchSize > 0) {
|
|
1008
|
+
this.$refs.exportPart.exportBatch();
|
|
1009
|
+
} else {
|
|
1010
|
+
this.$refs.exportPart.exportAllData();
|
|
1011
|
+
}
|
|
1012
|
+
setTimeout(() => {
|
|
1013
|
+
this.exportAllLoading = false;
|
|
1014
|
+
}, 1000);
|
|
1015
|
+
},
|
|
1016
|
+
onSortChange(sortParams) {
|
|
1017
|
+
this.sortParams = {
|
|
1018
|
+
sort: sortParams.column.sortField || sortParams.key,
|
|
1019
|
+
order: sortParams.order === "normal" ? "" : sortParams.order
|
|
1020
|
+
};
|
|
1021
|
+
//排序时重置页码
|
|
1022
|
+
this.currentPage = 1;
|
|
1023
|
+
this.tableRefresh();
|
|
1024
|
+
},
|
|
1025
|
+
onCurrentChange(currentRow, oldCurrentRow) {
|
|
1026
|
+
this.$emit("on-current-change", currentRow, oldCurrentRow);
|
|
1027
|
+
},
|
|
1028
|
+
onSelect(selection, row) {
|
|
1029
|
+
this.$emit("on-select", selection, row);
|
|
1030
|
+
},
|
|
1031
|
+
onSelectCancel(selection, row) {
|
|
1032
|
+
this.$emit("on-select-cancel", selection, row);
|
|
1033
|
+
},
|
|
1034
|
+
onSelectAll(selection) {
|
|
1035
|
+
this.$emit("on-select-all", selection);
|
|
1036
|
+
},
|
|
1037
|
+
onSelectAllCancel(selection) {
|
|
1038
|
+
this.$emit("on-select-all-cancel", selection);
|
|
1039
|
+
},
|
|
1040
|
+
onSelectionChange(selection) {
|
|
1041
|
+
this.$emit("on-selection-change", selection);
|
|
1042
|
+
},
|
|
1043
|
+
onFilterChange(column, key, order) {
|
|
1044
|
+
this.$emit("on-filter-change", column, key, order);
|
|
1045
|
+
},
|
|
1046
|
+
getSelection() {
|
|
1047
|
+
return this.$refs.tableRef.getSelection();
|
|
1048
|
+
},
|
|
1049
|
+
onRowClick(row, index) {
|
|
1050
|
+
if (this.isSingleSelectModel) {
|
|
1051
|
+
this.selectOnChange(row, index);
|
|
1052
|
+
this.$emit("on-single-select", row, index);
|
|
1053
|
+
}
|
|
1054
|
+
this.$emit("on-row-click", row, index);
|
|
1055
|
+
},
|
|
1056
|
+
onRowDblclick(row, index) {
|
|
1057
|
+
this.$emit("on-row-dblclick", row, index);
|
|
1058
|
+
},
|
|
1059
|
+
onExpand(row, status) {
|
|
1060
|
+
this.$emit("on-expand", row, status);
|
|
1061
|
+
},
|
|
1062
|
+
onDragDrop(index1, index2) {
|
|
1063
|
+
this.$emit("on-drag-drop", index1, index2);
|
|
1064
|
+
},
|
|
1065
|
+
columnSelect: function (quiet) {
|
|
1066
|
+
let self = this;
|
|
1067
|
+
let columnsObj = self.columns
|
|
1068
|
+
let columns = []
|
|
1069
|
+
for (let index = 0; index < columnsObj.length; index++) {
|
|
1070
|
+
let column = columnsObj[index];
|
|
1071
|
+
for (let colName of self.checkAllGroup) {
|
|
1072
|
+
if (('c' + column.title + column.key + index) === colName) {
|
|
1073
|
+
columns.push(column);
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
this.cloneColumns = columns
|
|
1080
|
+
if (!quiet) {
|
|
1081
|
+
this.$Message.success('筛选成功');
|
|
1082
|
+
}
|
|
1083
|
+
},
|
|
1084
|
+
columnSave() {
|
|
1085
|
+
let self = this
|
|
1086
|
+
this.columnSelect(true)
|
|
1087
|
+
let columnKeys = []
|
|
1088
|
+
for (let i in this.columns) {
|
|
1089
|
+
let item = this.columns[i];
|
|
1090
|
+
let characters = 'c' + item.title + item.key + i
|
|
1091
|
+
if (characters !== "") {
|
|
1092
|
+
let index = this.cloneColumns.findIndex(column => 'c' + column.title + column.key + column['__origin_index'] === characters)
|
|
1093
|
+
if (index === -1) {
|
|
1094
|
+
columnKeys.push(characters)
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
let localColumnListStr
|
|
1100
|
+
if (typeof window !== 'undefined') {
|
|
1101
|
+
localColumnListStr = localStorage.getItem("tableColumns")
|
|
1102
|
+
}
|
|
1103
|
+
let localColumnList = null
|
|
1104
|
+
if (localColumnListStr == null) {
|
|
1105
|
+
localColumnList = []
|
|
1106
|
+
} else {
|
|
1107
|
+
localColumnList = JSON.parse(localColumnListStr)
|
|
1108
|
+
let index = localColumnList.findIndex(column => column.id === self.columnID)
|
|
1109
|
+
if (index > -1) {
|
|
1110
|
+
localColumnList.splice(index, 1)
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
localColumnList.push({ id: self.columnID, value: columnKeys })
|
|
1114
|
+
if (typeof window !== 'undefined') {
|
|
1115
|
+
localStorage.setItem("tableColumns", JSON.stringify(localColumnList))
|
|
1116
|
+
}
|
|
1117
|
+
this.$Message.success('保存成功');
|
|
1118
|
+
},
|
|
1119
|
+
columnClear() {
|
|
1120
|
+
let self = this
|
|
1121
|
+
let localColumnListStr
|
|
1122
|
+
if (typeof window !== 'undefined') {
|
|
1123
|
+
localColumnListStr = localStorage.getItem("tableColumns")
|
|
1124
|
+
}
|
|
1125
|
+
let localColumnList = null
|
|
1126
|
+
if (localColumnListStr == null) {
|
|
1127
|
+
localColumnList = []
|
|
1128
|
+
} else {
|
|
1129
|
+
localColumnList = JSON.parse(localColumnListStr)
|
|
1130
|
+
let index = localColumnList.findIndex(column => column.id === self.columnID)
|
|
1131
|
+
if (index > -1) {
|
|
1132
|
+
localColumnList.splice(index, 1)
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
if (typeof window !== 'undefined') {
|
|
1136
|
+
localStorage.setItem("tableColumns", JSON.stringify(localColumnList))
|
|
1137
|
+
}
|
|
1138
|
+
//先设成全选
|
|
1139
|
+
this.checkAll = true
|
|
1140
|
+
//反转并清空
|
|
1141
|
+
this.handleCheckAll()
|
|
1142
|
+
this.columnSelect(true)
|
|
1143
|
+
this.$Message.success('清除成功');
|
|
1144
|
+
},
|
|
1145
|
+
handleCheckAllFixedColumns() {
|
|
1146
|
+
this.checkAllFixedColumns = !this.checkAllFixedColumns;
|
|
1147
|
+
if (this.checkAllFixedColumns) {
|
|
1148
|
+
this.fixedColumns = this.fixedColumnNameArr.slice(0);
|
|
1149
|
+
} else {
|
|
1150
|
+
this.fixedColumns = [];
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
checkAllFixedColumnsChange(data) {
|
|
1154
|
+
if (data.length === this.fixedColumnNameArr.length) {
|
|
1155
|
+
this.checkAllFixedColumns = true;
|
|
1156
|
+
} else if (data.length > 0) {
|
|
1157
|
+
this.checkAllFixedColumns = false;
|
|
1158
|
+
} else {
|
|
1159
|
+
this.checkAllFixedColumns = false;
|
|
1160
|
+
}
|
|
1161
|
+
},
|
|
1162
|
+
fixedColumnSelect: function (quiet) {
|
|
1163
|
+
let self = this;
|
|
1164
|
+
let columnsObj = self.cloneColumns
|
|
1165
|
+
let columns = []
|
|
1166
|
+
columnsObj.forEach(column => {
|
|
1167
|
+
if (column.fixed !== 'right') {
|
|
1168
|
+
if (this.isDefaultLeftFixed(column)) {
|
|
1169
|
+
column.fixed = 'left';
|
|
1170
|
+
} else {
|
|
1171
|
+
column.fixed = null;
|
|
1172
|
+
for (let colName of self.fixedColumns) {
|
|
1173
|
+
if (('c' + column.title + column.key + column['__origin_index']) === colName) {
|
|
1174
|
+
column.fixed = 'left';
|
|
1175
|
+
break;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
columns.push(column);
|
|
1181
|
+
})
|
|
1182
|
+
this.cloneColumns = columns
|
|
1183
|
+
if (!quiet) {
|
|
1184
|
+
this.$Message.success('固定成功');
|
|
1185
|
+
}
|
|
1186
|
+
},
|
|
1187
|
+
fixedColumnSave() {
|
|
1188
|
+
let self = this
|
|
1189
|
+
this.fixedColumnSelect(true)
|
|
1190
|
+
let columnKeys = []
|
|
1191
|
+
this.cloneColumns.forEach(item => {
|
|
1192
|
+
if (!this.isDefaultLeftFixed(item) && item.fixed === 'left') {
|
|
1193
|
+
let characters = 'c' + item.title + item.key + item['__origin_index']
|
|
1194
|
+
if (characters !== "") {
|
|
1195
|
+
columnKeys.push(characters)
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
})
|
|
1199
|
+
let localColumnListStr
|
|
1200
|
+
if (typeof window !== 'undefined') {
|
|
1201
|
+
localColumnListStr = localStorage.getItem("tableFixedColumns")
|
|
1202
|
+
}
|
|
1203
|
+
let localColumnList = null
|
|
1204
|
+
if (localColumnListStr == null) {
|
|
1205
|
+
localColumnList = []
|
|
1206
|
+
} else {
|
|
1207
|
+
localColumnList = JSON.parse(localColumnListStr)
|
|
1208
|
+
let index = localColumnList.findIndex(column => column.id === self.columnID)
|
|
1209
|
+
if (index > -1) {
|
|
1210
|
+
localColumnList.splice(index, 1)
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
localColumnList.push({ id: self.columnID, value: columnKeys })
|
|
1214
|
+
if (typeof window !== 'undefined') {
|
|
1215
|
+
localStorage.setItem("tableFixedColumns", JSON.stringify(localColumnList))
|
|
1216
|
+
}
|
|
1217
|
+
this.$Message.success('保存成功');
|
|
1218
|
+
},
|
|
1219
|
+
fixedColumnClear() {
|
|
1220
|
+
let self = this
|
|
1221
|
+
let localColumnListStr
|
|
1222
|
+
if (typeof window !== 'undefined') {
|
|
1223
|
+
localColumnListStr = localStorage.getItem("tableFixedColumns")
|
|
1224
|
+
}
|
|
1225
|
+
let localColumnList = null
|
|
1226
|
+
if (localColumnListStr == null) {
|
|
1227
|
+
localColumnList = []
|
|
1228
|
+
} else {
|
|
1229
|
+
localColumnList = JSON.parse(localColumnListStr)
|
|
1230
|
+
let index = localColumnList.findIndex(column => column.id === self.columnID)
|
|
1231
|
+
if (index > -1) {
|
|
1232
|
+
localColumnList.splice(index, 1)
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
if (typeof window !== 'undefined') {
|
|
1236
|
+
localStorage.setItem("tableFixedColumns", JSON.stringify(localColumnList))
|
|
1237
|
+
}
|
|
1238
|
+
//先设成全选
|
|
1239
|
+
this.checkAllFixedColumns = true
|
|
1240
|
+
//反转并清空
|
|
1241
|
+
this.handleCheckAllFixedColumns()
|
|
1242
|
+
this.fixedColumnSelect(true)
|
|
1243
|
+
this.$Message.success('清除成功');
|
|
1244
|
+
},
|
|
1245
|
+
fixedColumnsFilter() {
|
|
1246
|
+
// 根据localStorage筛选固定列
|
|
1247
|
+
let self = this
|
|
1248
|
+
let inColumns = this.cloneColumns;
|
|
1249
|
+
let localColumnList
|
|
1250
|
+
if (typeof window !== 'undefined') {
|
|
1251
|
+
localColumnList = localStorage.getItem("tableFixedColumns")
|
|
1252
|
+
}
|
|
1253
|
+
let list = null;
|
|
1254
|
+
if (localColumnList != null) {
|
|
1255
|
+
let localColumn = JSON.parse(localColumnList)
|
|
1256
|
+
let currentColumn = localColumn.filter(item => {
|
|
1257
|
+
return item.id === self.columnID
|
|
1258
|
+
})
|
|
1259
|
+
if (currentColumn.length === 1) {
|
|
1260
|
+
list = currentColumn[0].value
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
inColumns.forEach(item => {
|
|
1265
|
+
if (item.fixed !== 'right') {
|
|
1266
|
+
if (this.isDefaultLeftFixed(item)) {
|
|
1267
|
+
item.fixed = 'left';
|
|
1268
|
+
} else if (list !== null) {
|
|
1269
|
+
let characters = 'c' + item.title + item.key + item['__origin_index']
|
|
1270
|
+
if (characters !== "") {
|
|
1271
|
+
let column = list.filter((it) => it === characters)
|
|
1272
|
+
if (column.length >= 1) {
|
|
1273
|
+
item.fixed = 'left';
|
|
1274
|
+
} else {
|
|
1275
|
+
item.fixed = null;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
})
|
|
1281
|
+
|
|
1282
|
+
this.fixedColumns = this.selectedFixedColumnNameArr.slice(0);
|
|
1283
|
+
if (this.fixedColumns.length !== inColumns.length) {
|
|
1284
|
+
this.checkAllFixedColumns = false;
|
|
1285
|
+
}
|
|
1286
|
+
this.cloneColumns = deepCopy(this.cloneColumns)
|
|
1287
|
+
},
|
|
1288
|
+
isDefaultLeftFixed(item) {
|
|
1289
|
+
if (item.type === 'index' || item.type === 'selection' || item.type === 'single-selection') {
|
|
1290
|
+
return true;
|
|
1291
|
+
}
|
|
1292
|
+
return false;
|
|
1293
|
+
},
|
|
1294
|
+
setTableStyleGlobal: function () {
|
|
1295
|
+
if (typeof window !== 'undefined') {
|
|
1296
|
+
window.localStorage.setItem("tableBorder", this.tableBorder);
|
|
1297
|
+
window.localStorage.setItem("tableStripe", this.tableStripe);
|
|
1298
|
+
window.localStorage.setItem("tableShowHeader", this.tableShowHeader);
|
|
1299
|
+
window.localStorage.setItem("tableSize", this.tableSize);
|
|
1300
|
+
this.$Message.success('应用全局样式成功');
|
|
1301
|
+
}
|
|
1302
|
+
},
|
|
1303
|
+
getTableInstance: function () {
|
|
1304
|
+
return this.$refs.tableRef;
|
|
1305
|
+
},
|
|
1306
|
+
//组件重新渲染方法
|
|
1307
|
+
forceUpdate: function () {
|
|
1308
|
+
this.hackReset = false
|
|
1309
|
+
this.$nextTick(() => {
|
|
1310
|
+
this.hackReset = true
|
|
1311
|
+
})
|
|
1312
|
+
},
|
|
1313
|
+
//单选
|
|
1314
|
+
selectOnChange: function (row, index) {
|
|
1315
|
+
this.selection = Array(index).fill(false);
|
|
1316
|
+
this.selection.splice(index, 1, true);
|
|
1317
|
+
this.selectStore = [row];
|
|
1318
|
+
},
|
|
1319
|
+
onColumnWidthResize: function (newWidth, oldWidth, column, event) {
|
|
1320
|
+
this.$emit("on-column-width-resize", newWidth, oldWidth, column, event);
|
|
1321
|
+
},
|
|
1322
|
+
fixTableHeight() {
|
|
1323
|
+
let that = this;
|
|
1324
|
+
this.$nextTick(() => {
|
|
1325
|
+
try {
|
|
1326
|
+
let topHeight = that.$refs.tableRef.$el.getBoundingClientRect().top;
|
|
1327
|
+
let clientHeight = window.innerHeight;
|
|
1328
|
+
let height = clientHeight - topHeight;
|
|
1329
|
+
//减去底部分页按钮距离
|
|
1330
|
+
let pageHeight = 0;
|
|
1331
|
+
if (!that.pageDisable) {
|
|
1332
|
+
pageHeight = that.$refs.pageRef.$el.clientHeight;
|
|
1333
|
+
height = height - pageHeight - 15;
|
|
1334
|
+
}
|
|
1335
|
+
height = height - that.tableBottomHeight;
|
|
1336
|
+
//判断是否有横向滚动条,有的话减去滚动条高度
|
|
1337
|
+
let scrollBarHeight = 17;
|
|
1338
|
+
let contentDom = document.getElementsByClassName('content-wrapper ivu-layout-content')[0] || document.getElementById('app');
|
|
1339
|
+
if (contentDom !== undefined) {
|
|
1340
|
+
scrollBarHeight = contentDom.getBoundingClientRect().height - contentDom.clientHeight
|
|
1341
|
+
}
|
|
1342
|
+
height = height - scrollBarHeight;
|
|
1343
|
+
console.log("topHeight: " + topHeight + ", clientHeight: " + clientHeight + ", pageHeight: " + pageHeight + ", scrollBarHeight: " + scrollBarHeight + ", height: " + height);
|
|
1344
|
+
if (height < 200) {
|
|
1345
|
+
height = 200;
|
|
1346
|
+
}
|
|
1347
|
+
that.tableMaxHeight = height;
|
|
1348
|
+
} catch (e) {
|
|
1349
|
+
console.log('计算表单高度失败', e)
|
|
1350
|
+
}
|
|
1351
|
+
})
|
|
1352
|
+
},
|
|
1353
|
+
expandTable() {
|
|
1354
|
+
this.isExpand = true;
|
|
1355
|
+
this.fullScreenOrEsc(true);
|
|
1356
|
+
},
|
|
1357
|
+
contractTable() {
|
|
1358
|
+
this.isExpand = false;
|
|
1359
|
+
this.fullScreenOrEsc(false);
|
|
1360
|
+
},
|
|
1361
|
+
fullScreenOrEsc(toFull) {
|
|
1362
|
+
let element = document.documentElement;
|
|
1363
|
+
if (toFull !== this.checkScreenFull()) {
|
|
1364
|
+
if (toFull) {
|
|
1365
|
+
if (element.requestFullscreen) {
|
|
1366
|
+
element.requestFullscreen();
|
|
1367
|
+
} else if (element.webkitRequestFullScreen) {
|
|
1368
|
+
element.webkitRequestFullScreen();
|
|
1369
|
+
} else if (element.mozRequestFullScreen) {
|
|
1370
|
+
element.mozRequestFullScreen();
|
|
1371
|
+
} else if (element.msRequestFullscreen) {
|
|
1372
|
+
// IE11
|
|
1373
|
+
element.msRequestFullscreen();
|
|
1374
|
+
}
|
|
1375
|
+
} else {
|
|
1376
|
+
if (document.exitFullscreen) {
|
|
1377
|
+
document.exitFullscreen();
|
|
1378
|
+
} else if (document.webkitCancelFullScreen) {
|
|
1379
|
+
document.webkitCancelFullScreen();
|
|
1380
|
+
} else if (document.mozCancelFullScreen) {
|
|
1381
|
+
document.mozCancelFullScreen();
|
|
1382
|
+
} else if (document.msExitFullscreen) {
|
|
1383
|
+
document.msExitFullscreen();
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
},
|
|
1388
|
+
checkScreenFull() {
|
|
1389
|
+
//火狐浏览器
|
|
1390
|
+
let isFull = document.mozFullScreen ||
|
|
1391
|
+
document.fullscreen ||
|
|
1392
|
+
//谷歌浏览器及Webkit内核浏览器
|
|
1393
|
+
document.webkitIsFullScreen ||
|
|
1394
|
+
document.webkitRequestFullScreen ||
|
|
1395
|
+
document.mozRequestFullScreen ||
|
|
1396
|
+
document.msFullscreenEnabled
|
|
1397
|
+
if (isFull === undefined) {
|
|
1398
|
+
isFull = false
|
|
1399
|
+
}
|
|
1400
|
+
return isFull;
|
|
1401
|
+
},
|
|
1402
|
+
addFullScreenListener() {
|
|
1403
|
+
let element = document.documentElement;
|
|
1404
|
+
if (element.requestFullscreen) { // HTML5 W3C 提议
|
|
1405
|
+
document.addEventListener('fullscreenchange', () => {
|
|
1406
|
+
this.onFullScreenChange()
|
|
1407
|
+
})
|
|
1408
|
+
} else if (element.webkitRequestFullScreen) { // Webkit (works in Safari5.1 and Chrome 15)
|
|
1409
|
+
document.addEventListener('webkitfullscreenchange', () => {
|
|
1410
|
+
this.onFullScreenChange()
|
|
1411
|
+
})
|
|
1412
|
+
} else if (element.mozRequestFullScreen) { // Firefox (works in nightly)
|
|
1413
|
+
document.addEventListener('mozfullscreenchange', () => {
|
|
1414
|
+
this.onFullScreenChange()
|
|
1415
|
+
})
|
|
1416
|
+
} else if (element.msRequestFullscreen) { // IE 11
|
|
1417
|
+
document.addEventListener('msfullscreenchange', () => {
|
|
1418
|
+
this.onFullScreenChange()
|
|
1419
|
+
})
|
|
1420
|
+
} else {
|
|
1421
|
+
document.addEventListener('webkitfullscreenchange', () => {
|
|
1422
|
+
this.onFullScreenChange()
|
|
1423
|
+
})
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
removeFullScreenListener() {
|
|
1427
|
+
let element = document.documentElement;
|
|
1428
|
+
if (element.requestFullscreen) { // HTML5 W3C 提议
|
|
1429
|
+
document.removeEventListener('fullscreenchange', () => {
|
|
1430
|
+
this.onFullScreenChange()
|
|
1431
|
+
})
|
|
1432
|
+
} else if (element.webkitRequestFullScreen) { // Webkit (works in Safari5.1 and Chrome 15)
|
|
1433
|
+
document.removeEventListener('webkitfullscreenchange', () => {
|
|
1434
|
+
this.onFullScreenChange()
|
|
1435
|
+
})
|
|
1436
|
+
} else if (element.mozRequestFullScreen) { // Firefox (works in nightly)
|
|
1437
|
+
document.removeEventListener('mozfullscreenchange', () => {
|
|
1438
|
+
this.onFullScreenChange()
|
|
1439
|
+
})
|
|
1440
|
+
} else if (element.msRequestFullscreen) { // IE 11
|
|
1441
|
+
document.removeEventListener('msfullscreenchange', () => {
|
|
1442
|
+
this.onFullScreenChange()
|
|
1443
|
+
})
|
|
1444
|
+
} else {
|
|
1445
|
+
document.removeEventListener('webkitfullscreenchange', () => {
|
|
1446
|
+
this.onFullScreenChange()
|
|
1447
|
+
})
|
|
1448
|
+
}
|
|
1449
|
+
},
|
|
1450
|
+
onFullScreenChange() {
|
|
1451
|
+
if (this.checkScreenFull()) {
|
|
1452
|
+
if (!this.isExpand) {
|
|
1453
|
+
this.isExpand = true;
|
|
1454
|
+
}
|
|
1455
|
+
} else {
|
|
1456
|
+
if (this.isExpand) {
|
|
1457
|
+
this.isExpand = false;
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
},
|
|
1461
|
+
initObserver() {
|
|
1462
|
+
let self = this;
|
|
1463
|
+
const onResize = (offset) => {
|
|
1464
|
+
self.topHeight = offset.height;
|
|
1465
|
+
}
|
|
1466
|
+
const observer = new ResizeObserver(entities => {
|
|
1467
|
+
if (entities && entities.length) {
|
|
1468
|
+
entities.forEach(entity => {
|
|
1469
|
+
//contentRect:位置大小信息
|
|
1470
|
+
//target:dom信息
|
|
1471
|
+
const { contentRect } = entity;
|
|
1472
|
+
onResize(contentRect)//目标对象发生改变之后的逻辑操作
|
|
1473
|
+
})
|
|
1474
|
+
}
|
|
1475
|
+
})
|
|
1476
|
+
this.$nextTick(() => {
|
|
1477
|
+
observer.observe(self.$refs.searchBox)
|
|
1478
|
+
self.observer = observer
|
|
1479
|
+
|
|
1480
|
+
window.addEventListener('resize', self.screenHeightChange)
|
|
1481
|
+
})
|
|
1482
|
+
},
|
|
1483
|
+
screenHeightChange() {
|
|
1484
|
+
this.screenHeight = window.innerHeight;
|
|
1485
|
+
},
|
|
1486
|
+
doSearch: function () {
|
|
1487
|
+
this.$emit("do-search");
|
|
1488
|
+
},
|
|
1489
|
+
|
|
1490
|
+
makeResizable() {
|
|
1491
|
+
// 获取引用的table
|
|
1492
|
+
let table = this.$refs.tableRef;
|
|
1493
|
+
|
|
1494
|
+
// 如果当前table不可见则不支持拖动
|
|
1495
|
+
let tableWidth = table ? table.$el.offsetWidth : 0;
|
|
1496
|
+
if (tableWidth === 0) {
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
//缓存table自动计算好的宽度值
|
|
1500
|
+
let columnConfig = {}
|
|
1501
|
+
for (let index in table.cloneColumns) {
|
|
1502
|
+
let cloneColumn = table.cloneColumns[index];
|
|
1503
|
+
columnConfig[cloneColumn.key + "_" + cloneColumn.title + "_" + index] = cloneColumn._width;
|
|
1504
|
+
}
|
|
1505
|
+
//遍历并添加宽度值,设置为resizable
|
|
1506
|
+
for (let i in this.cloneColumns) {
|
|
1507
|
+
let cloneColumn = Object.assign({}, this.cloneColumns[i]);
|
|
1508
|
+
let width = columnConfig[cloneColumn.key + "_" + cloneColumn.title + "_" + i]
|
|
1509
|
+
if (cloneColumn.width === width && cloneColumn.resizable) {
|
|
1510
|
+
continue;
|
|
1511
|
+
}
|
|
1512
|
+
cloneColumn.width = width
|
|
1513
|
+
cloneColumn.resizable = true
|
|
1514
|
+
this.$set(this.cloneColumns, i, cloneColumn)
|
|
1515
|
+
}
|
|
1516
|
+
},
|
|
1517
|
+
getCloneColumns(columns, original) {
|
|
1518
|
+
if (original) {
|
|
1519
|
+
//标记原始索引值
|
|
1520
|
+
for (let index in columns) {
|
|
1521
|
+
columns[index]["__origin_index"] = index;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
let cloneColumns = [];
|
|
1525
|
+
for (let index in columns) {
|
|
1526
|
+
let column = columns[index];
|
|
1527
|
+
let cloneColumn = deepCopy(column);
|
|
1528
|
+
cloneColumn["__origin_index"] = column["__origin_index"];
|
|
1529
|
+
cloneColumns.push(cloneColumn);
|
|
1530
|
+
}
|
|
1531
|
+
return cloneColumns;
|
|
1532
|
+
}
|
|
1533
|
+
},
|
|
1534
|
+
created() {
|
|
1535
|
+
this.cloneColumns = this.getCloneColumns(this.columns, true);
|
|
1536
|
+
},
|
|
1537
|
+
beforeMount() {
|
|
1538
|
+
this.initTableCustomSetting();
|
|
1539
|
+
},
|
|
1540
|
+
mounted() {
|
|
1541
|
+
//样式相关 兼容ssr要求
|
|
1542
|
+
this.tableStripe = "tableStripe" in localStorage ? localStorage.getItem("tableStripe") !== "false" : this.stripe;
|
|
1543
|
+
this.tableBorder = "tableBorder" in localStorage ? localStorage.getItem("tableBorder") !== "false" : this.border;
|
|
1544
|
+
this.tableShowHeader = "tableShowHeader" in localStorage ? localStorage.getItem("tableShowHeader") !== "false" : this.showHeader;
|
|
1545
|
+
this.tableSize = "tableSize" in localStorage ? localStorage.getItem("tableSize") : this.size;
|
|
1546
|
+
if (this.autoSearch) {
|
|
1547
|
+
this.tableRefresh();
|
|
1548
|
+
}
|
|
1549
|
+
if (this.autoFixHeight) {
|
|
1550
|
+
this.initObserver()
|
|
1551
|
+
}
|
|
1552
|
+
if (this.showFullViewBtn) {
|
|
1553
|
+
this.addFullScreenListener();
|
|
1554
|
+
}
|
|
1555
|
+
this.columnsFilter();
|
|
1556
|
+
},
|
|
1557
|
+
beforeDestroy() {
|
|
1558
|
+
if (this.observer) {
|
|
1559
|
+
this.observer.unobserve(this.$refs.searchBox)
|
|
1560
|
+
}
|
|
1561
|
+
if (this.autoFixHeight) {
|
|
1562
|
+
window.removeEventListener('resize', this.screenHeightChange)
|
|
1563
|
+
}
|
|
1564
|
+
if (this.showFullViewBtn) {
|
|
1565
|
+
this.removeFullScreenListener();
|
|
1566
|
+
}
|
|
1567
|
+
},
|
|
1568
|
+
activated() {
|
|
1569
|
+
if (this.activatedRefresh) {
|
|
1570
|
+
this.tableRefresh()
|
|
1571
|
+
}
|
|
1572
|
+
},
|
|
1573
|
+
}
|
|
1574
|
+
</script>
|
|
1575
|
+
<style lang="less" scoped>
|
|
1576
|
+
@import "styles/css/index.less";
|
|
1577
|
+
</style>
|