ol-base-components 3.4.5 → 3.4.7
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/dist/index.mjs +7105 -0
- package/dist/index.umd.js +1 -0
- package/dist/style.css +1 -0
- package/package.json +18 -4
- package/.eslintrc +0 -59
- package/.github/deploy.yml +0 -81
- package/.prettierignore +0 -6
- package/.prettierrc +0 -13
- package/.trae/rules/project.md +0 -2
- package/babel.config.js +0 -5
- package/jsconfig.json +0 -19
- package/readme1.md +0 -164
- package/src/App.vue +0 -932
- package/src/assets/Snipaste_2025-09-03_14-30-49.png +0 -0
- package/src/assets/api.png +0 -0
- package/src/assets/css/iconfont.css +0 -342
- package/src/assets/duojibiaotou.png +0 -0
- package/src/assets/effectPicture.png +0 -0
- package/src/assets/generator0.png +0 -0
- package/src/assets/generator1.png +0 -0
- package/src/assets/generator2.png +0 -0
- package/src/assets/icon/printModel.svg +0 -1
- package/src/assets/init.png +0 -0
- package/src/assets/logo.png +0 -0
- package/src/assets/olBaseComponentsLogo.svg +0 -100
- package/src/assets/print.svg +0 -1
- package/src/assets/run.png +0 -0
- package/src/assets/vscodecj.png +0 -0
- package/src/bin/initTemplate.js +0 -409
- package/src/bin/news.js +0 -171
- package/src/bin/openCloseloop.js +0 -154
- package/src/bin/openLoop.js +0 -154
- package/src/main.js +0 -13
- package/src/package/customSearch/index.js +0 -7
- package/src/package/customSearch/src/index.vue +0 -120
- package/src/package/dialog/index.js +0 -7
- package/src/package/dialog/src/index.vue +0 -419
- package/src/package/form/index.js +0 -7
- package/src/package/form/src/index.vue +0 -405
- package/src/package/formSearch/index.js +0 -7
- package/src/package/formSearch/src/components/SearchConfigDialog.vue +0 -957
- package/src/package/formSearch/src/index.js +0 -29
- package/src/package/formSearch/src/index.vue +0 -928
- package/src/package/index.js +0 -243
- package/src/package/numberRange/index.js +0 -7
- package/src/package/numberRange/src/index.vue +0 -351
- package/src/package/print/index.js +0 -76
- package/src/package/print/src/components/PaperSelector.vue +0 -109
- package/src/package/print/src/index.vue +0 -622
- package/src/package/print/src/provide/provider1.js +0 -215
- package/src/package/printModel/index.js +0 -7
- package/src/package/printModel/src/index.vue +0 -493
- package/src/package/table/index.js +0 -12
- package/src/package/table/src/TableColumn.vue +0 -77
- package/src/package/table/src/components/PrintTemplateSelector.vue +0 -210
- package/src/package/table/src/index.vue +0 -945
- package/src/package/table/src/nodata.jpg +0 -0
- package/src/package/table/src/printTable.vue +0 -196
- package/src/utils/getEnum.js +0 -8
- package/src/utils/initData.js +0 -138
- package/vue.config.js +0 -21
- /package/{public → dist}/favicon.ico +0 -0
- /package/{public → dist}/index.html +0 -0
- /package/{public → dist}/print-lock.css +0 -0
|
@@ -1,945 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="table_list_fix">
|
|
3
|
-
<!-- 扩展性内容 -->
|
|
4
|
-
<slot name="content_context" />
|
|
5
|
-
<template
|
|
6
|
-
v-if="
|
|
7
|
-
btnlist.length ||
|
|
8
|
-
tableData.options.headTool ||
|
|
9
|
-
tableData.options.refreshBtn ||
|
|
10
|
-
tableData.options.downloadBtn
|
|
11
|
-
"
|
|
12
|
-
>
|
|
13
|
-
<div v-if="showBtnBox" class="btnbox">
|
|
14
|
-
<!-- 左侧按钮 -->
|
|
15
|
-
<div>
|
|
16
|
-
<el-button
|
|
17
|
-
v-for="(btn, index) in btnlist"
|
|
18
|
-
:key="index"
|
|
19
|
-
size="small"
|
|
20
|
-
:type="btn.types ? btn.types : 'primary'"
|
|
21
|
-
@click="btn.method"
|
|
22
|
-
>
|
|
23
|
-
<i v-if="btn.icon" :class="btn.icon" />
|
|
24
|
-
{{ btn.title }}
|
|
25
|
-
</el-button>
|
|
26
|
-
</div>
|
|
27
|
-
<!-- 右侧工具按钮 -->
|
|
28
|
-
<div class="toolbox">
|
|
29
|
-
<!-- 工具按钮前插槽 -->
|
|
30
|
-
<slot
|
|
31
|
-
name="toolbox-before"
|
|
32
|
-
:tableData="tableData"
|
|
33
|
-
:multipleSelection="multipleSelection"
|
|
34
|
-
:paginations="paginations"
|
|
35
|
-
:loading="tableData.loading"
|
|
36
|
-
></slot>
|
|
37
|
-
<el-dropdown
|
|
38
|
-
v-if="tableData.options.headTool"
|
|
39
|
-
class="avatar-container right-menu-item hover-effect"
|
|
40
|
-
trigger="click"
|
|
41
|
-
>
|
|
42
|
-
<div class="avatar-wrapper">
|
|
43
|
-
<div class="layui-table-tool-self">
|
|
44
|
-
<i class="el-icon-s-operation" />
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
<el-dropdown-menu slot="dropdown" style="padding: 5px">
|
|
48
|
-
<el-checkbox-group v-model="checkedTableColumns">
|
|
49
|
-
<el-checkbox
|
|
50
|
-
v-for="column in checkedTableList"
|
|
51
|
-
:key="column.prop"
|
|
52
|
-
class="checkbox"
|
|
53
|
-
:label="column.prop"
|
|
54
|
-
>{{ column.label }}
|
|
55
|
-
</el-checkbox>
|
|
56
|
-
</el-checkbox-group>
|
|
57
|
-
</el-dropdown-menu>
|
|
58
|
-
</el-dropdown>
|
|
59
|
-
<div
|
|
60
|
-
v-if="tableData.options.refreshBtn"
|
|
61
|
-
class="avatar-container right-menu-item hover-effect el-dropdown"
|
|
62
|
-
@click="refreshTable"
|
|
63
|
-
>
|
|
64
|
-
<div class="avatar-wrapper">
|
|
65
|
-
<div class="layui-table-tool-self">
|
|
66
|
-
<i class="el-icon-refresh" />
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
<div
|
|
71
|
-
v-if="tableData.options.downloadBtn"
|
|
72
|
-
class="avatar-container right-menu-item hover-effect el-dropdown"
|
|
73
|
-
@click="printTable"
|
|
74
|
-
>
|
|
75
|
-
<div class="avatar-wrapper">
|
|
76
|
-
<div class="layui-table-tool-self">
|
|
77
|
-
<i class="el-icon-printer" />
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
<div
|
|
82
|
-
v-if="isSmartPrintBtn"
|
|
83
|
-
class="avatar-container right-menu-item hover-effect el-dropdown"
|
|
84
|
-
>
|
|
85
|
-
<div class="avatar-wrapper">
|
|
86
|
-
<div class="layui-table-tool-self">
|
|
87
|
-
<print-template-selector
|
|
88
|
-
:menuId="menuId"
|
|
89
|
-
:printData="tableData.printData"
|
|
90
|
-
:multipleSelection="multipleSelection"
|
|
91
|
-
v-bind="$attrs"
|
|
92
|
-
/>
|
|
93
|
-
</div>
|
|
94
|
-
</div>
|
|
95
|
-
</div>
|
|
96
|
-
<!-- 工具按钮后插槽 -->
|
|
97
|
-
<slot
|
|
98
|
-
name="toolbox-after"
|
|
99
|
-
:tableData="tableData"
|
|
100
|
-
:multipleSelection="multipleSelection"
|
|
101
|
-
:paginations="paginations"
|
|
102
|
-
:loading="tableData.loading"
|
|
103
|
-
></slot>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
</template>
|
|
107
|
-
|
|
108
|
-
<!-- 表格 -->
|
|
109
|
-
<div class="tablebox" :key="tableData.columns.length">
|
|
110
|
-
<el-table
|
|
111
|
-
:ref="tableRef"
|
|
112
|
-
v-loading="tableData.loading"
|
|
113
|
-
border
|
|
114
|
-
v-bind="tableData.options"
|
|
115
|
-
:data="tableData.rows"
|
|
116
|
-
style="width: 100%"
|
|
117
|
-
height="100%"
|
|
118
|
-
:default-sort="tableData.sort"
|
|
119
|
-
v-on="tableEvents"
|
|
120
|
-
@selection-change="SelectionChange"
|
|
121
|
-
@select="select"
|
|
122
|
-
@select-all="selectAll"
|
|
123
|
-
@row-click="rowClick"
|
|
124
|
-
>
|
|
125
|
-
<el-table-column
|
|
126
|
-
v-if="tableData.options && tableData.options.selection"
|
|
127
|
-
width="60"
|
|
128
|
-
align="center"
|
|
129
|
-
type="selection"
|
|
130
|
-
label=""
|
|
131
|
-
/>
|
|
132
|
-
<el-table-column
|
|
133
|
-
v-if="tableData.options && tableData.options.index"
|
|
134
|
-
width="60"
|
|
135
|
-
align="center"
|
|
136
|
-
type="index"
|
|
137
|
-
:index="computeTableIndex"
|
|
138
|
-
label="序号"
|
|
139
|
-
/>
|
|
140
|
-
<!-- 新增插槽,允许父组件自定义表头 -->
|
|
141
|
-
<!-- <template v-if="tableData.options && tableData.options.useSlotHeader">
|
|
142
|
-
<slot
|
|
143
|
-
name="table-columns"
|
|
144
|
-
:columns="bindTableColumns"
|
|
145
|
-
>
|
|
146
|
-
<template v-for="(item, index) in bindTableColumns">
|
|
147
|
-
<my-table-column
|
|
148
|
-
:column="item"
|
|
149
|
-
:key="index"
|
|
150
|
-
/>
|
|
151
|
-
</template>
|
|
152
|
-
</slot>
|
|
153
|
-
</template> -->
|
|
154
|
-
<!-- 防止之前逻辑出现纰漏,故保留之前逻辑再扩展自定义插槽方式渲染 -->
|
|
155
|
-
<!-- <template v-else> -->
|
|
156
|
-
<!-- <template v-for="(item, index) in bindTableColumns">
|
|
157
|
-
<el-table-column
|
|
158
|
-
:key="index"
|
|
159
|
-
:label="item.label"
|
|
160
|
-
:prop="item.prop"
|
|
161
|
-
:min-width="item.minWidth || '150px'"
|
|
162
|
-
:show-overflow-tooltip="item.overHidden || true"
|
|
163
|
-
:type="item.type || 'normal'"
|
|
164
|
-
v-bind="{
|
|
165
|
-
align: 'center',
|
|
166
|
-
width: item.width,
|
|
167
|
-
fixed: item.fixed || false,
|
|
168
|
-
sortable: item.sortable || false,
|
|
169
|
-
...item.attrs,
|
|
170
|
-
}"
|
|
171
|
-
>
|
|
172
|
-
<template v-slot:header>
|
|
173
|
-
<el-tooltip
|
|
174
|
-
:content="`${item.label} ${item.prop}`"
|
|
175
|
-
placement="top"
|
|
176
|
-
>
|
|
177
|
-
<span>{{ item.label }}</span>
|
|
178
|
-
</el-tooltip>
|
|
179
|
-
</template>
|
|
180
|
-
<template
|
|
181
|
-
v-if="item.render"
|
|
182
|
-
v-slot="scope"
|
|
183
|
-
>
|
|
184
|
-
<render-dom :render="() => item.render(scope.row)" />
|
|
185
|
-
</template>
|
|
186
|
-
<template
|
|
187
|
-
v-else-if="item.renderSlot"
|
|
188
|
-
v-slot="scope"
|
|
189
|
-
>
|
|
190
|
-
<slot
|
|
191
|
-
:row="scope.row"
|
|
192
|
-
:name="item.prop"
|
|
193
|
-
/>
|
|
194
|
-
</template>
|
|
195
|
-
</el-table-column>
|
|
196
|
-
</template> -->
|
|
197
|
-
<!-- </template> -->
|
|
198
|
-
|
|
199
|
-
<template v-for="(item, index) in this.tableData.columns">
|
|
200
|
-
<TableColumn
|
|
201
|
-
:column="item"
|
|
202
|
-
:key="`${item.prop || item.label}-${item.show}-${index}`"
|
|
203
|
-
:id="`${item.prop}-${item.show}-${index}`"
|
|
204
|
-
>
|
|
205
|
-
<template v-for="(slotFn, name) in $scopedSlots" v-slot:[name]="slotProps">
|
|
206
|
-
<slot :name="name" v-bind="slotProps" />
|
|
207
|
-
</template>
|
|
208
|
-
</TableColumn>
|
|
209
|
-
</template>
|
|
210
|
-
<el-table-column
|
|
211
|
-
v-if="tableData.operates && tableData.operates.length > 0"
|
|
212
|
-
label="操作"
|
|
213
|
-
align="center"
|
|
214
|
-
v-bind="tableData.operatesAttrs"
|
|
215
|
-
>
|
|
216
|
-
<template slot-scope="scope">
|
|
217
|
-
<div class="operate-group">
|
|
218
|
-
<template v-for="(btn, key) in tableData.operates">
|
|
219
|
-
<span
|
|
220
|
-
v-if="!btn.isShow || (btn.isShow && btn.isShow(scope.row, scope.$index))"
|
|
221
|
-
:key="key"
|
|
222
|
-
>
|
|
223
|
-
<el-button
|
|
224
|
-
:style="btn.style || ''"
|
|
225
|
-
:size="btn.size || 'small'"
|
|
226
|
-
:type="btn.type || `text`"
|
|
227
|
-
:icon="btn.icon"
|
|
228
|
-
:plain="btn.plain"
|
|
229
|
-
:disabled="btn.disabled && btn.disabled(scope.row, scope.$index)"
|
|
230
|
-
@click.stop="btn.method(scope.row, scope.$index)"
|
|
231
|
-
>{{ btn.label
|
|
232
|
-
}}{{ tableData.operates.length >= 2 ? " " : "" }}</el-button
|
|
233
|
-
>
|
|
234
|
-
</span>
|
|
235
|
-
</template>
|
|
236
|
-
</div> </template
|
|
237
|
-
>·
|
|
238
|
-
</el-table-column>
|
|
239
|
-
<div slot="empty" class="empty">
|
|
240
|
-
<img v-if="tableData.rows.length == 0" :src="nodata" />
|
|
241
|
-
</div>
|
|
242
|
-
</el-table>
|
|
243
|
-
</div>
|
|
244
|
-
<!-- 分页 -->
|
|
245
|
-
<div class="pagebox">
|
|
246
|
-
<el-row>
|
|
247
|
-
<el-col :span="24">
|
|
248
|
-
<el-pagination
|
|
249
|
-
v-if="paginations.pagetionShow && paginations.total > 0"
|
|
250
|
-
:current-page.sync="paginations.page"
|
|
251
|
-
:page-sizes="paginations.page_sizes || pageSizes"
|
|
252
|
-
:page-size="paginations.limit"
|
|
253
|
-
layout="total, sizes, prev, pager, next, jumper,slot"
|
|
254
|
-
:total="paginations.total"
|
|
255
|
-
@size-change="handleSizeChange"
|
|
256
|
-
@current-change="handleindexChange"
|
|
257
|
-
>
|
|
258
|
-
<div
|
|
259
|
-
v-if="paginations.refresh"
|
|
260
|
-
:key="1"
|
|
261
|
-
class="avatar-container right-menu-item hover-effect el-dropdown"
|
|
262
|
-
style="margin-left: 10px"
|
|
263
|
-
@click="refreshTableBTN"
|
|
264
|
-
>
|
|
265
|
-
<div class="avatar-wrapper">
|
|
266
|
-
<div class="layui-table-tool-self">
|
|
267
|
-
<i class="el-icon-refresh" />
|
|
268
|
-
</div>
|
|
269
|
-
</div>
|
|
270
|
-
</div>
|
|
271
|
-
</el-pagination>
|
|
272
|
-
</el-col>
|
|
273
|
-
</el-row>
|
|
274
|
-
</div>
|
|
275
|
-
<printTemplate v-show="false" class="printTemplate" :print-list-obj="printListObj" />
|
|
276
|
-
</div>
|
|
277
|
-
</template>
|
|
278
|
-
<script>
|
|
279
|
-
import { getData } from "../../index.js";
|
|
280
|
-
import nodata from "./nodata.jpg";
|
|
281
|
-
import printTemplate from "./printTable.vue";
|
|
282
|
-
import TableColumn from "./TableColumn.vue";
|
|
283
|
-
import PrintTemplateSelector from "./components/PrintTemplateSelector.vue";
|
|
284
|
-
|
|
285
|
-
export default {
|
|
286
|
-
name: "table",
|
|
287
|
-
components: {
|
|
288
|
-
printTemplate,
|
|
289
|
-
TableColumn,
|
|
290
|
-
PrintTemplateSelector,
|
|
291
|
-
// 函数式组件注册
|
|
292
|
-
renderDom: {
|
|
293
|
-
functional: true,
|
|
294
|
-
props: {
|
|
295
|
-
render: Function,
|
|
296
|
-
},
|
|
297
|
-
render(createElement, renDom) {
|
|
298
|
-
return <div>{renDom.props.render()}</div>;
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
// myTableColumn: {
|
|
302
|
-
// functional: true,
|
|
303
|
-
// props: {
|
|
304
|
-
// column: { type: Object, required: true }
|
|
305
|
-
// },
|
|
306
|
-
// render(h, ctx) {
|
|
307
|
-
// const col = ctx.props.column;
|
|
308
|
-
|
|
309
|
-
// // 多级表头处理
|
|
310
|
-
// if (col.children && col.children.length) {
|
|
311
|
-
// return h(
|
|
312
|
-
// 'el-table-column',
|
|
313
|
-
// {
|
|
314
|
-
// props: {
|
|
315
|
-
// label: col.label,
|
|
316
|
-
// align: 'center',
|
|
317
|
-
// ...col.attrs,
|
|
318
|
-
// }
|
|
319
|
-
// },
|
|
320
|
-
// col.children.map((child, idx) =>
|
|
321
|
-
// h(ctx.parent.$options.components.myTableColumn, {
|
|
322
|
-
// props: { column: child },
|
|
323
|
-
// key: idx
|
|
324
|
-
// })
|
|
325
|
-
// )
|
|
326
|
-
// );
|
|
327
|
-
// }
|
|
328
|
-
|
|
329
|
-
// // 单列表头处理
|
|
330
|
-
// return h(
|
|
331
|
-
// 'el-table-column',
|
|
332
|
-
// {
|
|
333
|
-
// props: {
|
|
334
|
-
// label: col.label,
|
|
335
|
-
// prop: col.prop,
|
|
336
|
-
// minWidth: col.minWidth || '150px',
|
|
337
|
-
// showOverflowTooltip: col.overHidden || true,
|
|
338
|
-
// type: col.type || 'normal',
|
|
339
|
-
// align: 'center',
|
|
340
|
-
// width: col.width,
|
|
341
|
-
// fixed: col.fixed || false,
|
|
342
|
-
// sortable: col.sortable || false,
|
|
343
|
-
// ...col.attrs
|
|
344
|
-
// }
|
|
345
|
-
// },
|
|
346
|
-
// [
|
|
347
|
-
// // 表头插槽 - 添加 el-tooltip
|
|
348
|
-
// h('template', { slot: 'header' }, [
|
|
349
|
-
// h('el-tooltip', {
|
|
350
|
-
// props: {
|
|
351
|
-
// content: `${col.label} ${col.prop}`,
|
|
352
|
-
// placement: 'top'
|
|
353
|
-
// }
|
|
354
|
-
// }, [
|
|
355
|
-
// h('span', col.label)
|
|
356
|
-
// ])
|
|
357
|
-
// ]),
|
|
358
|
-
// // 内容插槽 - 支持自定义渲染
|
|
359
|
-
// col.render ? h('template', { slot: 'default' }, {
|
|
360
|
-
// render: (scope) => h(ctx.parent.$options.components.renderDom, {
|
|
361
|
-
// props: { render: () => col.render(scope.row) }
|
|
362
|
-
// })
|
|
363
|
-
// }) : null,
|
|
364
|
-
// // 插槽渲染
|
|
365
|
-
// col.renderSlot ? h('template', { slot: 'default' }, {
|
|
366
|
-
// render: (scope) => ctx.parent.$scopedSlots[col.prop] ?
|
|
367
|
-
// ctx.parent.$scopedSlots[col.prop](scope) : null
|
|
368
|
-
// }) : null
|
|
369
|
-
// ].filter(Boolean)
|
|
370
|
-
// );
|
|
371
|
-
// }
|
|
372
|
-
// }
|
|
373
|
-
},
|
|
374
|
-
model: {
|
|
375
|
-
prop: "multipleSelection",
|
|
376
|
-
event: "SelectionChange",
|
|
377
|
-
},
|
|
378
|
-
props: {
|
|
379
|
-
// 模板打印的id,不传就默认当前菜单id
|
|
380
|
-
menuId: {
|
|
381
|
-
type: String,
|
|
382
|
-
default: "",
|
|
383
|
-
},
|
|
384
|
-
url: {
|
|
385
|
-
type: String,
|
|
386
|
-
default: "",
|
|
387
|
-
}, // 接口地址
|
|
388
|
-
printListObj: {
|
|
389
|
-
type: Object,
|
|
390
|
-
default: () => {
|
|
391
|
-
return {
|
|
392
|
-
title: "",
|
|
393
|
-
tableHeader: "",
|
|
394
|
-
tableData: "",
|
|
395
|
-
};
|
|
396
|
-
},
|
|
397
|
-
}, // 打印参数
|
|
398
|
-
btnlist: Array,
|
|
399
|
-
outTable: {
|
|
400
|
-
type: Object,
|
|
401
|
-
default: () => {
|
|
402
|
-
return {
|
|
403
|
-
tableProp: {},
|
|
404
|
-
};
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
// exportBut: {
|
|
408
|
-
// type: Array,
|
|
409
|
-
// default: [],
|
|
410
|
-
// },
|
|
411
|
-
// 表格传的形式
|
|
412
|
-
tableData: {
|
|
413
|
-
type: Object,
|
|
414
|
-
default: () => {
|
|
415
|
-
return {
|
|
416
|
-
loading: false,
|
|
417
|
-
options: {
|
|
418
|
-
selection: null, // 多选框
|
|
419
|
-
index: null, // 序号
|
|
420
|
-
headTool: true, // 开启头部工具栏
|
|
421
|
-
refreshBtn: true, // 开启表格头部刷新按钮
|
|
422
|
-
downloadBtn: true, // 开启表格头部下载按钮
|
|
423
|
-
// smartPrintBtn: false,// 是否启用智能打印,字段不存在时候用全局配置
|
|
424
|
-
}, // 序号和复选框
|
|
425
|
-
rows: [], // 表数据
|
|
426
|
-
columns: [], // 表头
|
|
427
|
-
operates: [], // 表格里面的操作按钮
|
|
428
|
-
// tableHeightDiff: 300,
|
|
429
|
-
operatesAttrs: {},
|
|
430
|
-
printData: {}, // 模板打印的数据
|
|
431
|
-
};
|
|
432
|
-
},
|
|
433
|
-
},
|
|
434
|
-
tableDataShow: {
|
|
435
|
-
type: Boolean,
|
|
436
|
-
default: true,
|
|
437
|
-
},
|
|
438
|
-
pageSizes: {
|
|
439
|
-
type: Array,
|
|
440
|
-
default: () => {
|
|
441
|
-
return [20, 30, 40, 60, 100, 200];
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
paginations: {
|
|
445
|
-
// 显示复选框,
|
|
446
|
-
type: Object,
|
|
447
|
-
default: () => {
|
|
448
|
-
return {
|
|
449
|
-
page: 1, // 当前位于那页面
|
|
450
|
-
total: 0, // 总数
|
|
451
|
-
limit: 30, // 一页显示多少条
|
|
452
|
-
pagetionShow: true,
|
|
453
|
-
};
|
|
454
|
-
},
|
|
455
|
-
},
|
|
456
|
-
emptyImg: {
|
|
457
|
-
// 显示复选框,
|
|
458
|
-
type: Boolean,
|
|
459
|
-
default: false,
|
|
460
|
-
},
|
|
461
|
-
tableEvents: Object,
|
|
462
|
-
showBtnBox: {
|
|
463
|
-
type: Boolean,
|
|
464
|
-
default: true,
|
|
465
|
-
},
|
|
466
|
-
//获取swagger后的钩子,返回swagger结构数据。用于处理swagger数据
|
|
467
|
-
onSwagger: {
|
|
468
|
-
type: Function,
|
|
469
|
-
default: null,
|
|
470
|
-
},
|
|
471
|
-
// swagger与本地columns合并完成后的钩子,允许父组件二次处理columns,一般用于不影响顺序的属性修改。区别于直接column中添加
|
|
472
|
-
onMerged: {
|
|
473
|
-
type: Function,
|
|
474
|
-
default: null,
|
|
475
|
-
},
|
|
476
|
-
// 请求方式 post get
|
|
477
|
-
method: {
|
|
478
|
-
type: String,
|
|
479
|
-
},
|
|
480
|
-
},
|
|
481
|
-
|
|
482
|
-
data() {
|
|
483
|
-
return {
|
|
484
|
-
nodata,
|
|
485
|
-
tableRef: this.tableData.tableRef || "tableRef", // ref
|
|
486
|
-
toggleRowFlage: this.tableData.toggleRowFlage || false, // 点击行高亮select标识
|
|
487
|
-
// screenWidth: 0,
|
|
488
|
-
// tableHeight:
|
|
489
|
-
// document.documentElement.clientHeight - this.tableData.tableHeightDiff,
|
|
490
|
-
pagetionShow: this.paginations.pagetionShow || true,
|
|
491
|
-
twinPage: 1,
|
|
492
|
-
columnsWatcher: null,
|
|
493
|
-
key: 0,
|
|
494
|
-
};
|
|
495
|
-
},
|
|
496
|
-
computed: {
|
|
497
|
-
bindTableColumns() {
|
|
498
|
-
return this.tableData.columns.filter(column =>
|
|
499
|
-
Object.keys(column).includes("show") ? column.show : true
|
|
500
|
-
);
|
|
501
|
-
},
|
|
502
|
-
|
|
503
|
-
checkedTableList: {
|
|
504
|
-
get() {
|
|
505
|
-
// 返回选中的列名
|
|
506
|
-
return this.getAllColumnsWithProp(this.tableData.columns);
|
|
507
|
-
},
|
|
508
|
-
},
|
|
509
|
-
/* 这里使用了getter和setter,这样写的好处不用自己手动监听复选框的选中事件 */
|
|
510
|
-
checkedTableColumns: {
|
|
511
|
-
get() {
|
|
512
|
-
// 返回选中的列名
|
|
513
|
-
return this.getAllLabelsWithProp();
|
|
514
|
-
},
|
|
515
|
-
set(checked) {
|
|
516
|
-
this.setColumnsShow(checked);
|
|
517
|
-
this.$nextTick(() => {
|
|
518
|
-
this.$refs.tableRef.doLayout();
|
|
519
|
-
});
|
|
520
|
-
},
|
|
521
|
-
},
|
|
522
|
-
// 优先级:props > 全局配置 > 默认值
|
|
523
|
-
finalMethod() {
|
|
524
|
-
return this.method || (this.$olBaseConfig && this.$olBaseConfig.method) || "get";
|
|
525
|
-
},
|
|
526
|
-
isSmartPrintBtn() {
|
|
527
|
-
const hasKey = Object.keys(this.tableData.options).includes("smartPrintBtn");
|
|
528
|
-
if (hasKey) {
|
|
529
|
-
return !!this.tableData.options.smartPrintBtn;
|
|
530
|
-
}
|
|
531
|
-
return (this.$olBaseConfig && this.$olBaseConfig.smartPrintBtn) || false;
|
|
532
|
-
},
|
|
533
|
-
},
|
|
534
|
-
created() {
|
|
535
|
-
// 通过swagger完善columns
|
|
536
|
-
if (this.url) this.init();
|
|
537
|
-
},
|
|
538
|
-
// 组件销毁时清理监听器
|
|
539
|
-
beforeDestroy() {
|
|
540
|
-
this.stopColumnsWatching();
|
|
541
|
-
},
|
|
542
|
-
methods: {
|
|
543
|
-
init() {
|
|
544
|
-
// 从 IndexedDB 中获取 Swagger 数据
|
|
545
|
-
getData()
|
|
546
|
-
.then(async swaggerData => {
|
|
547
|
-
let swaggerColumns =
|
|
548
|
-
swaggerData.paths[this.url][this.finalMethod].responses["200"].content[
|
|
549
|
-
"application/json"
|
|
550
|
-
].schema.properties.items.items.properties;
|
|
551
|
-
if (typeof this.onSwagger === "function") {
|
|
552
|
-
try {
|
|
553
|
-
const res = await this.onSwagger({ columns: swaggerColumns });
|
|
554
|
-
if (res) swaggerColumns = res;
|
|
555
|
-
} catch (err) {}
|
|
556
|
-
}
|
|
557
|
-
// 递归映射函数
|
|
558
|
-
const mapSwaggerToColumns = columns => {
|
|
559
|
-
columns.forEach(column => {
|
|
560
|
-
if (column.children && column.children.length) {
|
|
561
|
-
mapSwaggerToColumns(column.children);
|
|
562
|
-
} else {
|
|
563
|
-
if (column.prop && swaggerColumns[column.prop]) {
|
|
564
|
-
const swaggerItem = swaggerColumns[column.prop];
|
|
565
|
-
this.$set(column, "label", swaggerItem.description);
|
|
566
|
-
if (!Object.keys(column).includes("show")) this.$set(column, "show", true);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
};
|
|
571
|
-
// 自定义columns数据
|
|
572
|
-
mapSwaggerToColumns(this.tableData.columns);
|
|
573
|
-
|
|
574
|
-
Object.keys(swaggerColumns).forEach(key => {
|
|
575
|
-
const item = swaggerColumns[key];
|
|
576
|
-
if (item.description) {
|
|
577
|
-
const obj = {
|
|
578
|
-
prop: key,
|
|
579
|
-
label: item.description,
|
|
580
|
-
show: true,
|
|
581
|
-
sortable: false,
|
|
582
|
-
attrs: {},
|
|
583
|
-
};
|
|
584
|
-
// 如果是枚举值直接转成Desc结尾的,swagger中没有Desc但是后端接口会返回带Desc的字段,用于前端展示枚举值的中文
|
|
585
|
-
if (item.enum && Array.isArray(item.enum)) {
|
|
586
|
-
obj.prop = `${key}Desc`;
|
|
587
|
-
obj.label = item.description.replace(/(枚举|枚举值)/g, "");
|
|
588
|
-
}
|
|
589
|
-
// 如果是boolean类型,加上Text后缀
|
|
590
|
-
if (item.type === "boolean") {
|
|
591
|
-
obj.prop = `${key}Text`;
|
|
592
|
-
}
|
|
593
|
-
if (!this.findColumnByProp(this.tableData.columns, obj.prop))
|
|
594
|
-
this.tableData.columns.push(obj);
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
|
-
// 根据beforeProp排序
|
|
598
|
-
this.sortColumns(this.tableData.columns);
|
|
599
|
-
|
|
600
|
-
// 添加show, 最后添加show是为了后期swagger可能会增加show字段(扩展)
|
|
601
|
-
// 递归根据当前是否有show键名,没有show就添加show:true
|
|
602
|
-
const addShow = columns => {
|
|
603
|
-
columns.forEach(column => {
|
|
604
|
-
if (!column.hasOwnProperty("show")) this.$set(column, "show", true);
|
|
605
|
-
if (column.children && column.children.length) {
|
|
606
|
-
addShow(column.children);
|
|
607
|
-
} else {
|
|
608
|
-
if (!column.hasOwnProperty("show")) {
|
|
609
|
-
// 用set修改
|
|
610
|
-
this.$set(column, "show", true);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
};
|
|
615
|
-
// 添加show,这里的show只显示隐藏,通过checkbox能实现显示隐藏。如果不想checkbox中出现可添加hidden(这是区别于老框架的逻辑)
|
|
616
|
-
addShow(this.tableData.columns);
|
|
617
|
-
console.log(`\x1b[36m\x1b[4mol插件-表格`, this.tableData.columns);
|
|
618
|
-
|
|
619
|
-
// 合并完成后,暴露处理钩子
|
|
620
|
-
if (typeof this.onMerged === "function") {
|
|
621
|
-
try {
|
|
622
|
-
const res = await this.onMerged({
|
|
623
|
-
columns: this.tableData.columns,
|
|
624
|
-
});
|
|
625
|
-
if (Array.isArray(res)) {
|
|
626
|
-
this.tableData.columns = res;
|
|
627
|
-
}
|
|
628
|
-
} catch (e) {}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// init 执行完成后,添加深度监听
|
|
632
|
-
this.startColumnsWatching();
|
|
633
|
-
})
|
|
634
|
-
.catch(error => {
|
|
635
|
-
console.error("获取 Swagger 数据失败:", error);
|
|
636
|
-
});
|
|
637
|
-
},
|
|
638
|
-
// 多级表头顺序调整,只争对有多级表头的且包含beforeProp字段的,规则:通过多级表头的beforeProp字段将整个多级表头移到这个字段位置之后。(只会一级出现beforeProp,多级中的排序都要手动实现)
|
|
639
|
-
sortColumns(columns) {
|
|
640
|
-
let index = 0;
|
|
641
|
-
columns.forEach(column => {
|
|
642
|
-
if (!column.beforeProp) {
|
|
643
|
-
column.sort = index;
|
|
644
|
-
index++;
|
|
645
|
-
const tempItem = columns.find(e => e.beforeProp == column.prop);
|
|
646
|
-
if (tempItem) {
|
|
647
|
-
tempItem.sort = index;
|
|
648
|
-
index++;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
columns.sort((a, b) => a.sort - b.sort);
|
|
653
|
-
},
|
|
654
|
-
// 递归查找列配置的辅助方法
|
|
655
|
-
findColumnByProp(columns, prop) {
|
|
656
|
-
for (const column of columns) {
|
|
657
|
-
if (column.children && column.children.length) {
|
|
658
|
-
const found = this.findColumnByProp(column.children, prop);
|
|
659
|
-
if (found) return found;
|
|
660
|
-
} else if (column.prop === prop) {
|
|
661
|
-
return column;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
return null;
|
|
665
|
-
},
|
|
666
|
-
radioChange() {
|
|
667
|
-
this.$emit("radioChange", this.twinPage);
|
|
668
|
-
},
|
|
669
|
-
// 刷新表格
|
|
670
|
-
refreshTable() {
|
|
671
|
-
const view = this.$router.history.current;
|
|
672
|
-
this.$store.dispatch("tagsView/delCachedView", view).then(() => {
|
|
673
|
-
const { fullPath } = view;
|
|
674
|
-
this.$nextTick(() => {
|
|
675
|
-
this.$router.replace({
|
|
676
|
-
path: "/redirect" + fullPath,
|
|
677
|
-
});
|
|
678
|
-
});
|
|
679
|
-
});
|
|
680
|
-
this.$emit("refreshTable");
|
|
681
|
-
},
|
|
682
|
-
printTable() {
|
|
683
|
-
console.log("printTable");
|
|
684
|
-
if (this.tableData.rows.length <= 0) return;
|
|
685
|
-
this.printListObj.title = this.$router.history.current.name;
|
|
686
|
-
this.printListObj.tableHeader = this.tableData.columns;
|
|
687
|
-
this.printListObj.tableData = this.tableData.rows;
|
|
688
|
-
console.log(this.printListObj);
|
|
689
|
-
setTimeout(() => {
|
|
690
|
-
$(".printTemplate").show();
|
|
691
|
-
$(".printTemplate").jqprint();
|
|
692
|
-
$(".printTemplate").hide();
|
|
693
|
-
}, 50);
|
|
694
|
-
this.$emit("printTable");
|
|
695
|
-
},
|
|
696
|
-
selectAll(val) {
|
|
697
|
-
this.$emit("selectAll", val);
|
|
698
|
-
},
|
|
699
|
-
select(val, row) {
|
|
700
|
-
this.$emit("selectTab", val, row);
|
|
701
|
-
},
|
|
702
|
-
refreshTableBTN() {
|
|
703
|
-
this.$emit("refreshTableBTN");
|
|
704
|
-
},
|
|
705
|
-
rowClick(row, column) {
|
|
706
|
-
if (column.label === "操作") return; // 操作列不处罚行点击事件
|
|
707
|
-
this.$emit("rowClick", row);
|
|
708
|
-
if (
|
|
709
|
-
this.tableData.columns.every(item => {
|
|
710
|
-
return item.label !== "是否只出样件";
|
|
711
|
-
})
|
|
712
|
-
) {
|
|
713
|
-
// 为true时 点击行高亮select
|
|
714
|
-
this.$refs.tableRef.toggleRowSelection(row);
|
|
715
|
-
}
|
|
716
|
-
},
|
|
717
|
-
computeTableIndex(index) {
|
|
718
|
-
return (this.paginations.page - 1) * this.paginations.limit + index + 1;
|
|
719
|
-
},
|
|
720
|
-
// 挑选的数据
|
|
721
|
-
SelectionChange(val) {
|
|
722
|
-
this.multipleSelection = val;
|
|
723
|
-
this.$emit("SelectionChange", val);
|
|
724
|
-
},
|
|
725
|
-
// 分页选择
|
|
726
|
-
handleSizeChange(val) {
|
|
727
|
-
this.paginations.limit = val;
|
|
728
|
-
this.$emit("handleSizeChange", val);
|
|
729
|
-
},
|
|
730
|
-
handleindexChange(val) {
|
|
731
|
-
this.paginations.page = val;
|
|
732
|
-
this.$emit("handleindexChange", val);
|
|
733
|
-
},
|
|
734
|
-
getCheckboxList() {
|
|
735
|
-
return this.tableData.column;
|
|
736
|
-
},
|
|
737
|
-
setCheckboxList(val) {},
|
|
738
|
-
|
|
739
|
-
getAllColumnsWithProp(columns) {
|
|
740
|
-
const result = [];
|
|
741
|
-
const propMap = new Map(); // 使用Map存储prop -> column的映射
|
|
742
|
-
|
|
743
|
-
const traverse = cols => {
|
|
744
|
-
cols.forEach(column => {
|
|
745
|
-
if (column.children && column.children.length) {
|
|
746
|
-
// 如果有子列,递归处理子列
|
|
747
|
-
traverse(column.children);
|
|
748
|
-
} else if (column.prop) {
|
|
749
|
-
// 如果包含prop属性且未重复,添加到结果数组
|
|
750
|
-
if (!propMap.has(column.prop)) {
|
|
751
|
-
propMap.set(column.prop, column);
|
|
752
|
-
result.push(column);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
});
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
traverse(columns);
|
|
759
|
-
return result;
|
|
760
|
-
},
|
|
761
|
-
|
|
762
|
-
// checkbox的显示隐藏
|
|
763
|
-
getAllLabelsWithProp() {
|
|
764
|
-
const result = [];
|
|
765
|
-
|
|
766
|
-
const traverse = cols => {
|
|
767
|
-
cols.forEach(column => {
|
|
768
|
-
if (column.children && column.children.length) {
|
|
769
|
-
// 如果有子列,递归处理子列
|
|
770
|
-
traverse(column.children);
|
|
771
|
-
} else if (column.prop && column.show) {
|
|
772
|
-
// 如果包含prop属性且未重复,添加到结果数组
|
|
773
|
-
if (!result.includes(column.prop) && column.show) {
|
|
774
|
-
result.push(column.prop);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
};
|
|
779
|
-
traverse(this.tableData.columns);
|
|
780
|
-
return result;
|
|
781
|
-
},
|
|
782
|
-
setColumnsShow(checkedList) {
|
|
783
|
-
// 递归更新tableData.columns的show属性
|
|
784
|
-
const traverse = cols => {
|
|
785
|
-
cols.forEach(column => {
|
|
786
|
-
if (column.children && column.children.length) {
|
|
787
|
-
traverse(column.children);
|
|
788
|
-
} else if (column.prop) {
|
|
789
|
-
// 用set修改
|
|
790
|
-
if (checkedList.includes(column.prop)) {
|
|
791
|
-
this.$set(column, "show", true);
|
|
792
|
-
} else {
|
|
793
|
-
this.$set(column, "show", false);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
});
|
|
797
|
-
};
|
|
798
|
-
traverse(this.tableData.columns);
|
|
799
|
-
},
|
|
800
|
-
|
|
801
|
-
// 开启 columns 监听,(二级菜单是递归组件,数据变化dom没有发送变化,故监听直接更新dom)
|
|
802
|
-
startColumnsWatching() {
|
|
803
|
-
this.stopColumnsWatching();
|
|
804
|
-
this.columnsWatcher = this.$watch("tableData.columns", () => (this.key += 1), {
|
|
805
|
-
deep: true, // 深度监听
|
|
806
|
-
immediate: false,
|
|
807
|
-
});
|
|
808
|
-
},
|
|
809
|
-
|
|
810
|
-
// 停止 columns 监听
|
|
811
|
-
stopColumnsWatching() {
|
|
812
|
-
if (this.columnsWatcher) {
|
|
813
|
-
this.columnsWatcher();
|
|
814
|
-
this.columnsWatcher = null;
|
|
815
|
-
}
|
|
816
|
-
},
|
|
817
|
-
},
|
|
818
|
-
};
|
|
819
|
-
</script>
|
|
820
|
-
|
|
821
|
-
<style lang="scss" scoped>
|
|
822
|
-
.table_list_fix {
|
|
823
|
-
overflow: auto;
|
|
824
|
-
flex: 1;
|
|
825
|
-
display: flex;
|
|
826
|
-
flex-direction: column;
|
|
827
|
-
justify-content: space-between;
|
|
828
|
-
padding: 10px;
|
|
829
|
-
gap: 10px;
|
|
830
|
-
|
|
831
|
-
::v-deep .el-table {
|
|
832
|
-
td {
|
|
833
|
-
padding: 0px;
|
|
834
|
-
|
|
835
|
-
div {
|
|
836
|
-
line-height: 28px;
|
|
837
|
-
font-size: 12px;
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
th {
|
|
842
|
-
padding: 0px;
|
|
843
|
-
background: #f5f7fa;
|
|
844
|
-
|
|
845
|
-
div {
|
|
846
|
-
line-height: 28px;
|
|
847
|
-
color: #909399;
|
|
848
|
-
font-size: 12px;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
.btn-operates {
|
|
854
|
-
margin: 10px 0px 10px 15px;
|
|
855
|
-
|
|
856
|
-
::v-deep a {
|
|
857
|
-
color: #fff;
|
|
858
|
-
text-decoration: none;
|
|
859
|
-
display: inline-block;
|
|
860
|
-
margin: 0px 5px;
|
|
861
|
-
|
|
862
|
-
::v-deep .el-button {
|
|
863
|
-
width: 100%;
|
|
864
|
-
padding: 7px;
|
|
865
|
-
font-size: 13px;
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
.table-header {
|
|
872
|
-
padding-top: 10px;
|
|
873
|
-
|
|
874
|
-
.table-header_button {
|
|
875
|
-
text-align: right;
|
|
876
|
-
float: right;
|
|
877
|
-
margin-bottom: 12px;
|
|
878
|
-
line-height: 40px;
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
.newjump {
|
|
883
|
-
text-decoration: none;
|
|
884
|
-
color: dodgerblue;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
.tablebox {
|
|
888
|
-
box-sizing: border-box;
|
|
889
|
-
flex: 1;
|
|
890
|
-
overflow: auto;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
::v-deep .el-table__body tr.current-row > td {
|
|
894
|
-
background-color: rgb(24, 144, 255) !important;
|
|
895
|
-
color: #fff;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
::v-deep .redrow {
|
|
899
|
-
background: #fde6e6 !important;
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
.btnbox {
|
|
903
|
-
width: 100%;
|
|
904
|
-
display: flex;
|
|
905
|
-
align-items: center;
|
|
906
|
-
justify-content: space-between;
|
|
907
|
-
|
|
908
|
-
.upload-demo {
|
|
909
|
-
display: -webkit-inline-box;
|
|
910
|
-
margin-left: 10px;
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
.el-form-item {
|
|
914
|
-
margin-bottom: 0px;
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
.layui-table-tool-self {
|
|
919
|
-
display: block;
|
|
920
|
-
width: 26px;
|
|
921
|
-
height: 26px;
|
|
922
|
-
padding: 5px;
|
|
923
|
-
line-height: 16px;
|
|
924
|
-
text-align: center;
|
|
925
|
-
color: #333;
|
|
926
|
-
border: 1px solid #ccc;
|
|
927
|
-
cursor: pointer;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
.checkbox {
|
|
931
|
-
display: block;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
// 操作列按钮布局
|
|
935
|
-
.operate-group {
|
|
936
|
-
display: flex;
|
|
937
|
-
align-items: center;
|
|
938
|
-
justify-content: space-around;
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
.toolbox {
|
|
942
|
-
display: flex;
|
|
943
|
-
gap: 10px;
|
|
944
|
-
}
|
|
945
|
-
</style>
|