ui-ddy-pc 0.0.1-beta

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.
Files changed (53) hide show
  1. package/.env.development +4 -0
  2. package/.env.prod +1 -0
  3. package/.env.stage +3 -0
  4. package/.vscode/extensions.json +3 -0
  5. package/README.md +7 -0
  6. package/build/configure/package.json +11 -0
  7. package/index.html +13 -0
  8. package/index.js +4 -0
  9. package/package.json +33 -0
  10. package/src/App.vue +20 -0
  11. package/src/assets/table/empty-data.png +0 -0
  12. package/src/assets/table/magnifier.svg +7 -0
  13. package/src/assets/vue.svg +1 -0
  14. package/src/components/tableTest.vue +101 -0
  15. package/src/components/topSearch/search.vue +302 -0
  16. package/src/components/topSearch/searchItem.vue +80 -0
  17. package/src/components/topSign/topSign.vue +170 -0
  18. package/src/components/topTable/topTable.vue +854 -0
  19. package/src/docs/.vitepress/cache/deps/@theme_index.js +258 -0
  20. package/src/docs/.vitepress/cache/deps/@theme_index.js.map +7 -0
  21. package/src/docs/.vitepress/cache/deps/_metadata.json +40 -0
  22. package/src/docs/.vitepress/cache/deps/chunk-KGHB62SH.js +11434 -0
  23. package/src/docs/.vitepress/cache/deps/chunk-KGHB62SH.js.map +7 -0
  24. package/src/docs/.vitepress/cache/deps/chunk-TBELKJNH.js +9088 -0
  25. package/src/docs/.vitepress/cache/deps/chunk-TBELKJNH.js.map +7 -0
  26. package/src/docs/.vitepress/cache/deps/package.json +3 -0
  27. package/src/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +2588 -0
  28. package/src/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  29. package/src/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +567 -0
  30. package/src/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  31. package/src/docs/.vitepress/cache/deps/vue.js +323 -0
  32. package/src/docs/.vitepress/cache/deps/vue.js.map +7 -0
  33. package/src/docs/.vitepress/config.js +28 -0
  34. package/src/docs/api-examples.md +49 -0
  35. package/src/docs/combinedTable.md +158 -0
  36. package/src/docs/index.md +25 -0
  37. package/src/docs/markdown-examples.md +98 -0
  38. package/src/docs/unitTests/searchTest.vue +109 -0
  39. package/src/main.js +16 -0
  40. package/src/packages/index.js +3 -0
  41. package/src/router/index.js +24 -0
  42. package/src/store/index.js +35 -0
  43. package/src/style.css +73 -0
  44. package/src/utils/common.js +254 -0
  45. package/src/utils/currency.js +256 -0
  46. package/src/utils/errorCode.js +6 -0
  47. package/src/utils/request.js +220 -0
  48. package/src/utils/top.js +233 -0
  49. package/ui-ddy-pc/package.json +11 -0
  50. package/ui-ddy-pc/style.css +1 -0
  51. package/ui-ddy-pc/ui-ddy-pc.js +26436 -0
  52. package/ui-ddy-pc/ui-ddy-pc.umd.cjs +83 -0
  53. package/vite.config.js +54 -0
@@ -0,0 +1,854 @@
1
+ <template>
2
+ <div class="cmp-container">
3
+
4
+ <!-- 搜索组件 -->
5
+ <div ref="formObj" :class="{ 'search-container': true }" v-if="needSearch" :style="searchStyle">
6
+ <el-form class="search-row" :inline="true" :label-width="refObjs.maxWidth">
7
+ <el-form-item v-for="(item, index) in obj.items" :label="item.label" :key="index">
8
+ <template #label>
9
+ <div :id='`label-${item.field}`' class="item-label">{{ item.label }}</div>
10
+ </template>
11
+ <div :id='`content-${item.field}`'>
12
+ <search-item :config="item" :data="searchConfig.data" @search="handleSubmit(false)"></search-item>
13
+ </div>
14
+ </el-form-item>
15
+
16
+ <div class="buttons row-item" v-if="remainWidth > 270">
17
+ <div class="btn" v-if="hasHide" @click="handleExpan">
18
+ <div class="icon">
19
+ <el-icon size="18" color="#ccc">
20
+ <CaretBottom v-if="obj.isShow" />
21
+ <CaretTop v-else />
22
+ </el-icon>
23
+ </div>
24
+ <div class="text">{{ obj.isShow ? '展开' : '收起' }}</div>
25
+ </div>
26
+ <el-button @click="handleSubmit(false)" color="#436EE6">查询
27
+ <template #icon>
28
+ <img src="@/assets/table/magnifier.svg">
29
+ </template>
30
+ </el-button>
31
+ <el-button @click="handleSubmit(true)" class="reset">
32
+ <template #icon>
33
+ <el-icon>
34
+ <Refresh :size="24" />
35
+ </el-icon>
36
+ </template>
37
+ 重置</el-button>
38
+ </div>
39
+
40
+ <!-- 独占一行 -->
41
+ <div class="buttons individual" v-else>
42
+ <el-button @click="handleSubmit(true)" style="margin-left: 12px;" class="reset">
43
+ <template #icon>
44
+ <el-icon>
45
+ <Refresh :size="24" />
46
+ </el-icon>
47
+ </template>
48
+ 重置</el-button>
49
+ <el-button @click="handleSubmit(false)" color="#436EE6" style="margin-left: 0;">查询
50
+ <template #icon>
51
+ <img src="@/assets/table/magnifier.svg">
52
+ </template>
53
+ </el-button>
54
+ <div class="btn" v-if="hasHide" @click="handleExpan">
55
+ <div class="icon">
56
+ <el-icon size="18" color="#ccc">
57
+ <CaretBottom v-if="obj.isShow" />
58
+ <CaretTop v-else />
59
+ </el-icon>
60
+ </div>
61
+ <div class="text">{{ obj.isShow ? '展开' : '收起' }}</div>
62
+ </div>
63
+ </div>
64
+ </el-form>
65
+ </div>
66
+
67
+ <div id="table-with-page" :style="tWPStyle">
68
+ <!-- 表格 -->
69
+ <div class="table-container">
70
+ <el-table ref="multipleTable" v-loading="tableConfig.Loading" tooltip-effect="dark" :data="tableConfig.data"
71
+ style="width: 100%" :height="fixedHeight == 'false' ? tableConfig.tableHeight : fixedHeight"
72
+ :header-row-style="headerRowStyle" v-bind="$attrs" @selection-change="handleSelectionChange"
73
+ @select="handleSelect" @select-all="handleSelectAll" @row-click="checkRows" @sort-change="sortChange"
74
+ :span-method="spanMethod" :row-class-name="rowClassName" :row-key="rowKey" :sum-text="sumText"
75
+ :summary-method="summaryMethod" :border="true" :highlight-current-row="highlightCurrentRow"
76
+ :header-cell-style="{ background: '#F5F7FA', color: '#606266' }" class="m-table" :lazy="lazy" :load="load"
77
+ :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" @expand-change="handleExpandChange">
78
+ <template v-for="(item, index) in tableColumn">
79
+ <el-table-column type="expand" v-if="item.type == 'expand' && item.slot">
80
+ <template #default="scope">
81
+ <slot v-if="item.slot" :name="item.slot" :data="{ ...scope }" :index="scope.$index"></slot>
82
+ </template>
83
+ </el-table-column>
84
+ <el-table-column v-else-if="item.type === 'index'" align="center" v-bind="{ ...item }"
85
+ :label="item.title || item.label || '序号'">
86
+ <template #default="scope">
87
+ <template v-if="scope.row.hasOwnProperty('__row__id__')">
88
+ {{ scope.row.__row__id__ }}
89
+ </template>
90
+ <template v-else>
91
+ {{ getOrderNumber(scope.$index) }}
92
+ </template>
93
+ </template>
94
+ </el-table-column>
95
+ <el-table-column v-else-if="item.autoIndex" :key="index" v-bind="{ ...item }">
96
+ <template #default="scope">
97
+ {{ ((pageConfig.pageNum < 1 ? 1 : pageConfig.pageNum) - 1) * pageConfig.pageSize + scope.$index + 1 }}
98
+ </template>
99
+ </el-table-column>
100
+ <el-table-column v-else-if="item.type == 'selection'" :key="index + 1" :label="item.label || ''"
101
+ :fixed="item.fixed" :reserve-selection="item.reserveSelection" :type="item.type" :width="item.width"
102
+ :align="item.align ? item.align : defaultAlign" :selectable="(e) => {
103
+ if (item.type === 'selection' && item.selectable) {
104
+ return item.selectable(e)
105
+ } else {
106
+ return true
107
+ }
108
+ }">
109
+ </el-table-column>
110
+ <el-table-column v-else-if="item.type" :key="index + 2" :label="item.label || ''" :fixed="item.fixed"
111
+ :reserve-selection="item.reserveSelection" :type="item.type" :width="item.width"
112
+ :align="item.align ? item.align : defaultAlign" :selectable="(e) => {
113
+ if (item.type === 'selection' && item.selectable) {
114
+ return item.selectable(e)
115
+ } else {
116
+ return true
117
+ }
118
+ }">
119
+ <template slot="header" #default="scope">
120
+ <span>{{ item.title }}</span>
121
+ </template>
122
+ </el-table-column>
123
+ <el-table-column v-else :key="item.key ? item.key : index" :prop="item.prop" v-show="item.hidden || true"
124
+ :label="item.label" :align="item.align ? item.align : defaultAlign" :width="item.width"
125
+ :min-width="item.minWidth" :fixed="item.fixed" :sortable="item.sortable" :sortMethod="item.sortMethod"
126
+ :show-overflow-tooltip="item.showOverflowTooltip === false || item.prop == 'action' ? false : { offset: offset }"
127
+ :type="item.type">
128
+ <template #header>
129
+ <section v-if="item.tooltip" class="tooltip-wrap"
130
+ :style="{ 'justify-content': computedAlingn(item.align) }">
131
+ <span style="margin-right: 5px;">{{ item.label }}</span>
132
+ <el-tooltip :effect="item.effect || 'dark'" placement="top">
133
+ <el-icon>
134
+ <QuestionFilled />
135
+ </el-icon>
136
+ <template #content> {{ item.tooltip }} </template>
137
+ </el-tooltip>
138
+ </section>
139
+ <section v-else-if="item.custom">
140
+ <div v-html="item.label"></div>
141
+ </section>
142
+ <slot v-else-if="item.headSlot" :name="item.headSlot" :data="{ ...scope }" :index="scope.$index" />
143
+ <span v-else>{{ item.label || item.title }}</span>
144
+ </template>
145
+ <template #default="scope">
146
+ <slot v-if="item.slot" :name="item.slot" :data="{ ...scope }" :index="scope.$index" />
147
+ <span v-else-if="item.stress" class="stress" @click="$emit('view-detail', scope.row)">
148
+ {{
149
+ scope.row[item.prop]
150
+ ? scope.row[item.prop]
151
+ : item.placeholder
152
+ ? item.placeholder
153
+ : "--"
154
+ }}
155
+ </span>
156
+ <!-- 将表格中的单价和合价格式化 1,223.00元 -->
157
+ <span v-else-if="item.filter != undefined">{{ item.filter(scope.row[item.prop], totalLastText)
158
+ }}</span>
159
+ <span v-else-if="item.settleAmout">
160
+ <div v-if="scope.row[item.prop] >= scope.row['ticketAmout']">
161
+ {{ scope.row[item.prop] + '/' + scope.row['ticketAmout'] }}
162
+ </div>
163
+ <div v-else class="red">
164
+ {{ scope.row[item.prop] + '/' + scope.row['ticketAmout'] }}
165
+ </div>
166
+ </span>
167
+ <section v-else-if="item.fit">
168
+ <div v-if="scope.row[item.prop]">
169
+ <el-image :src="handleImageSrc(scope.row[item.prop])" :fit="item.fit"
170
+ :preview-src-list="handleImageSrcList(scope.row[item.prop])" class="images" />
171
+ <p class="images-tip">
172
+ {{ handleImageSrcLength(scope.row[item.prop]) }}
173
+ </p>
174
+ </div>
175
+ <span v-else>暂无图片</span>
176
+ </section>
177
+ <span v-else-if="item.getRow">
178
+ {{ item.getRow(scope.row) }}
179
+ </span>
180
+ <span style="width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" v-else>
181
+ {{
182
+ scope.row[item.prop]
183
+ ? scope.row[item.prop]
184
+ : scope.row[item.prop] === 0
185
+ ? 0
186
+ : noValue
187
+ }}
188
+ </span>
189
+ </template>
190
+ </el-table-column>
191
+ </template>
192
+ <template #empty>
193
+ <section class="empty-area">
194
+ <img width="370" height="199" src="@/assets/table/empty-data.png" />
195
+ <p>{{ nodataTitme }}</p>
196
+ </section>
197
+ </template>
198
+ </el-table>
199
+ </div>
200
+
201
+ <!-- 分页 -->
202
+ <div class="pagination-container">
203
+ <el-pagination :hide-on-single-page="hideOnSinglePage" :layout="layout" :page-sizes="pageSizes"
204
+ :default-page-size="pageConfig.pageSize" v-model:page-size="pageConfig.pageSize"
205
+ v-model:current-page="pageConfig.pageNum" :total="pageConfig.total" @size-change="getSize"
206
+ @current-change="getPage">
207
+ </el-pagination>
208
+ </div>
209
+ </div>
210
+
211
+ </div>
212
+ </template>
213
+ <script setup>
214
+ import { ref, computed, onMounted, reactive, watch, nextTick, onUnmounted, toRefs } from 'vue';
215
+ import searchItem from '@/components/topSearch/searchItem.vue'
216
+ import req from "@/utils/request.js";
217
+
218
+ const props = defineProps({
219
+ searchConfig: {
220
+ type: Object,
221
+ default: () => ({
222
+ config: [],
223
+ data: {}
224
+ })
225
+ },
226
+ needSearch: {
227
+ type: Boolean,
228
+ default: true
229
+ },
230
+ rowClassName: {
231
+ type: String,
232
+ default: ''
233
+ },
234
+ nodataTitme: {
235
+ type: String,
236
+ default: '暂无数据'
237
+ },
238
+ column: {
239
+ type: Array,
240
+ default: () => []
241
+ },
242
+ defaultAlign: {
243
+ // 默认对齐方式
244
+ type: String,
245
+ default: 'left'
246
+ },
247
+ rowClickSelect: {
248
+ // 单击行是否选中
249
+ type: Boolean,
250
+ default: false
251
+ },
252
+ headerRowStyle: {
253
+ type: Object || Function,
254
+ default: () => ({
255
+ 'background-color': '#f1f1f1',
256
+ color: '#333'
257
+ })
258
+ },
259
+ autoHeight: {
260
+ type: Boolean,
261
+ default: true
262
+ },
263
+ modalAuto: {
264
+ type: Boolean,
265
+ default: false
266
+ },
267
+ height: {
268
+ type: String,
269
+ default: 'auto'
270
+ },
271
+ hasFooter: {
272
+ type: Boolean,
273
+ default: true
274
+ },
275
+ fixedHeight: {
276
+ type: String,
277
+ default: 'false'
278
+ },
279
+ spanMethod: {
280
+ type: Function,
281
+ default: () => { }
282
+ },
283
+ sumText: {
284
+ type: String,
285
+ default: ''
286
+ },
287
+ summaryMethod: {
288
+ type: Function,
289
+ default() {
290
+ return true
291
+ }
292
+ },
293
+ lazy: {
294
+ type: Boolean,
295
+ default: false,
296
+ },
297
+ load: {
298
+ type: Function,
299
+ default() {
300
+ return true
301
+ }
302
+ },
303
+ border: {
304
+ type: Boolean,
305
+ default: false,
306
+ },
307
+ highlightCurrentRow: {
308
+ type: Boolean,
309
+ default: false,
310
+ },
311
+ // 单元格无数据时显示内容
312
+ noValue: {
313
+ type: String,
314
+ default: "--"
315
+ },
316
+ // 表格高度计算需要额外减去得额外高度
317
+ minusHeight: {
318
+ type: Number,
319
+ default: 0,
320
+ },
321
+ totalLastText: {
322
+ type: String,
323
+ default: ''
324
+ },
325
+ rowKey: {
326
+ type: String,
327
+ default: 'id'
328
+ },
329
+ needResize: {
330
+ type: Boolean,
331
+ default: true
332
+ },
333
+ hideOnSinglePage: {
334
+ type: Boolean,
335
+ default: false,
336
+ },
337
+ pageSizes: {
338
+ type: Array,
339
+ default: () => [20, 50, 100, 200],
340
+ },
341
+ layout: {
342
+ type: String,
343
+ default: "total, sizes, prev, pager, next, jumper",
344
+ },
345
+ pageNum: {
346
+ type: Number,
347
+ default: 1,
348
+ },
349
+ tableApi: {
350
+ type: Object,
351
+ default: () => { },
352
+ },
353
+ searchStyle: {
354
+ type: Object,
355
+ default: () => ({
356
+ 'background-color': '#ebedf2',
357
+ 'margin': '10px',
358
+ 'border-radius': '10px',
359
+ 'padding': '20px 20px 0 20px',
360
+ 'box-sizing': 'border-box',
361
+ 'transition': '.3s linear',
362
+ })
363
+ },
364
+ tWPStyle: {
365
+ type: Object,
366
+ default: () => ({
367
+ 'margin': '0 10px 10px',
368
+ 'border-radius': '10px',
369
+ 'background-color': '#ebedf2',
370
+ 'box-sizing': 'border-box',
371
+ 'padding': '20px',
372
+ })
373
+ },
374
+ })
375
+ const emit = defineEmits(['search', 'show', 'current-change', 'selection-change', 'select', 'select-all', 'sortChange', 'view-detail', 'expand-change'])
376
+ const getList = async () => {
377
+ try {
378
+ let continueReq = true
379
+ if (props.tableApi.beforeCb) {
380
+ continueReq = await props.tableApi.beforeCb()
381
+ }
382
+ const { pageNum, pageSize } = pageConfig
383
+ let res
384
+ tableConfig.Loading = true
385
+ if (props.tableApi.method == 'get') {
386
+ res = await req.get(`${props.tableApi.url}`, { pageNum, pageSize, ...props.searchConfig.data, ...(props.tableApi.params) })
387
+ }
388
+ else {
389
+ res = await req.post(`${props.tableApi.url}`, { pageNum, pageSize, ...props.searchConfig.data, ...(props.tableApi.params) })
390
+ }
391
+ if (res.code == 200) {
392
+ tableConfig.data = res.data || res.rows
393
+ pageConfig.total = res.total
394
+ console.log(pageConfig);
395
+ }
396
+ tableConfig.Loading = false
397
+ }
398
+ catch (err) {
399
+ console.log(err)
400
+ tableConfig.Loading = false
401
+ }
402
+ }
403
+ const handleSubmit = (isReset) => {
404
+ if (isReset) {
405
+ // 重置除额外参数外的所有参数
406
+ props.searchConfig.data = { ...props.searchConfig.defaultData }
407
+ pageConfig.pageSize = 20
408
+ pageConfig.total = 0
409
+ }
410
+ pageConfig.pageNum = 1
411
+ getList()
412
+ }
413
+ const obj = reactive({
414
+ items: props.searchConfig.config,
415
+ isShow: true
416
+ })
417
+ const fixedNums = ref(0)
418
+ const getLastRowNums = (arr) => {
419
+ // 每行最多放下数量
420
+ let currentLength = 0
421
+ arr.forEach(item => {
422
+ // 换行清空
423
+ currentLength = currentLength + item + refObjs.maxWidth + 10 <= windowWidth.value ? currentLength + item + refObjs.maxWidth + 10 : item + refObjs.maxWidth + 10
424
+ })
425
+ remainWidth.value = windowWidth.value - currentLength
426
+ // console.log(remainWidth.value, '展开后最后一行剩余宽度');
427
+ }
428
+ const handleExpan = async () => {
429
+ isInit.value = false
430
+ const isExpan = obj.items.length < props.searchConfig.config.length
431
+ // 展示的内容小于配置时即展开
432
+ obj.items = isExpan ? props.searchConfig.config : props.searchConfig.config.slice(0, fixedNums.value)
433
+ await nextTick()
434
+ // 展开
435
+ if (isExpan) {
436
+ // 获取content所有宽度
437
+ getContent(props.searchConfig.config)
438
+ getLastRowNums(refObjs.widthArray)
439
+ }
440
+ // 收起
441
+ else {
442
+ remainWidth.value = 271
443
+ }
444
+ obj.isShow = !obj.isShow;
445
+ emit('show', obj.isShow)
446
+ resizeTableHeight()
447
+ }
448
+
449
+ const formObj = ref(null)
450
+ const windowWidth = ref(0)
451
+ const refObjs = reactive({
452
+ labelArray: [],
453
+ contentArray: [],
454
+ widthArray: [],
455
+ maxWidth: 40
456
+ })
457
+
458
+ const isInit = ref(true)
459
+ const remainWidth = ref(0)
460
+ // 暂定传入 预留空间
461
+ const getLabel = (arr) => {
462
+ refObjs.labelArray = arr.map(item => {
463
+ if (item) {
464
+ return document.getElementById('label-' + item.field)
465
+ }
466
+ }).filter(item2 => item2 !== undefined)
467
+ // console.log(refObjs.labelArray, 'label元素数组');
468
+ refObjs.maxWidth = refObjs.labelArray.reduce((maxWidth, item) => {
469
+ return Math.max(maxWidth, item.offsetWidth + 12)
470
+ }, 40)
471
+ // console.log(refObjs.maxWidth, 'label最大宽度');
472
+ }
473
+
474
+ // 暂定传入 预留空间
475
+ const getContent = (arr) => {
476
+ refObjs.contentArray = arr.map(item => {
477
+ if (item) {
478
+ return document.getElementById('content-' + item.field)
479
+ }
480
+ }).filter(item2 => item2 !== undefined)
481
+ // console.log(refObjs.contentArray, 'content元素数组');
482
+ refObjs.widthArray = refObjs.contentArray.map(item => {
483
+ return item.offsetWidth
484
+ })
485
+ // console.log(refObjs.widthArray, 'content所有元素的宽度');
486
+ }
487
+
488
+ // 递归计算一行可展示最大个数
489
+ const calcNum = (clientWidth, widthArray, val = '') => {
490
+ const sum = widthArray.reduce((sumVal, currentVal) => {
491
+ // 累加元素内容宽度 + 标签宽度 + margin
492
+ return sumVal + currentVal + refObjs.maxWidth + 10
493
+ }, 0)
494
+ // console.log(sum, '计算总长');
495
+ // 折叠状态为按钮组预留宽度
496
+ if (sum && sum + 270 > clientWidth) {
497
+ return calcNum(clientWidth, widthArray.slice(0, widthArray.length - 1), val)
498
+ }
499
+ else {
500
+ // console.log(sum, '当前可展示区域长度');
501
+ // 首行可显示个数
502
+ remainWidth.value = clientWidth - sum
503
+ val = widthArray.length
504
+ return val
505
+ }
506
+ }
507
+
508
+ // 设置当前宽度 仅该页面的宽度
509
+ const handleInit = async (changeTab = false) => {
510
+ isInit.value = true
511
+ // 全部渲染出 获取所有的labelWidth contentWidth
512
+ obj.items = props.searchConfig.config
513
+ await nextTick()
514
+ // 设置当前屏幕宽度
515
+ windowWidth.value = formObj.value.clientWidth
516
+ if (windowWidth.value == 0) {
517
+ setTimeout(handleInit(changeTab), 500)
518
+ return;
519
+ }
520
+ // console.log(windowWidth.value, '当前页面视口宽度');
521
+ // 获取label最大宽度 设置label宽
522
+ getLabel(props.searchConfig.config)
523
+ // 获取content所有宽度
524
+ getContent(props.searchConfig.config)
525
+ fixedNums.value = calcNum(windowWidth.value, refObjs.widthArray)
526
+ // console.log(fixedNums.value, 'fixedNums.value');
527
+ // 修正当前可显示值
528
+ obj.items = props.searchConfig.config.slice(0, fixedNums.value)
529
+ if (changeTab) {
530
+ resizeTableHeight()
531
+ }
532
+ }
533
+
534
+ const hasHide = computed(() => {
535
+ // 未点击过展开或收起
536
+ if (isInit.value) {
537
+ // 当前展示长度和传入值长度不一致即显示展开按钮
538
+ return obj?.items ? obj.items.length !== props.searchConfig.config.length : true
539
+ }
540
+ else {
541
+ return true
542
+ }
543
+ })
544
+ const handleResize = () => {
545
+ // 重置展开
546
+ obj.isShow = true
547
+ handleInit()
548
+ }
549
+
550
+ window.onChangeEmit = () => {
551
+ obj.isShow = true
552
+ handleInit(true)
553
+ }
554
+
555
+
556
+ const tableConfig = reactive({
557
+ tableHeight: props.height,
558
+ data: [],
559
+ Loading: false,
560
+ })
561
+ const multipleTable = ref('')
562
+ const handleSelectionChange = (val) => {
563
+ // 翻页也会触发该事件
564
+ emit('selection-change', val);
565
+ }
566
+ const handleSelect = (selection, row) => {
567
+ emit('select', selection, row)
568
+ }
569
+ const handleSelectAll = (selection) => {
570
+ emit('select', selection)
571
+ }
572
+ const checkRows = (row, current, event) => {
573
+ if (props.rowClickSelect) {
574
+ multipleTable.value.toggleRowSelection(row);
575
+ emit('current-change', row)
576
+ } else {
577
+ emit('current-change', row, current, event)
578
+ }
579
+ }
580
+ const sortChange = (param) => {
581
+ let { column, prop, order } = param;
582
+ emit("sortChange", { column, prop, order })
583
+ }
584
+ const handleExpandChange = (row, expanded) => {
585
+ emit('expand-change', row, expanded)
586
+ }
587
+ const tableColumn = computed(() => {
588
+ if (props.column.length == 0) return
589
+ return props.column.filter(item => item.hidden !== true);
590
+ })
591
+
592
+ const clearSelection = () => {
593
+ multipleTable.value.clearSelection();
594
+ }
595
+ const allSelection = () => {
596
+ multipleTable.value.toggleAllSelection();
597
+ }
598
+ const offset = -window.pageYOffset
599
+
600
+ const resizeTableHeight = () => {
601
+ const footerHeight = props.hasFooter ? 44 : 0;
602
+ // 搜索组件需要时间计算渲染 高度才能获取正确
603
+ // let otherComponentHeight = document.getElementById('searchComponent').offsetHeight
604
+ setTimeout(() => {
605
+ if (multipleTable.value && props.needResize) {
606
+ // 表格
607
+ let el = multipleTable.value.$el;
608
+ // 分页
609
+ let pageEl = document.getElementById('table-with-page')
610
+ let pageComputedStyle = window.getComputedStyle(pageEl)
611
+ let containerPAM = parseFloat(pageComputedStyle.getPropertyValue('margin-bottom')) + parseFloat(pageComputedStyle.getPropertyValue('padding-bottom'))
612
+ // 表格与顶部距离
613
+ let top = el.getBoundingClientRect().top;
614
+ console.log(top, 'top-distance');
615
+ console.log(window.parent.innerHeight, 'window.innerHeight');
616
+ // window.innerHeight 视口高度不变 为嵌入的块的高度 需减去top-ui顶部高度
617
+ const height = window.parent.innerHeight - top - footerHeight - props.minusHeight - containerPAM
618
+ console.log(height, 'currentHeight');
619
+ tableConfig.tableHeight = height < 200 ? 200 : height;
620
+ }
621
+ }, 100)
622
+ }
623
+
624
+ const computedAlingn = (align) => {
625
+ const method = align || props.defaultAlign;
626
+ const mapping = {
627
+ center: 'center',
628
+ left: 'flex-start',
629
+ right: 'flex-end'
630
+ };
631
+ return mapping[method];
632
+ }
633
+
634
+ const getOrderNumber = (index) => {
635
+ if (!pageConfig.pageSize) {
636
+ return index + 1;
637
+ }
638
+ const current = pageConfig.pageNum
639
+ const size = pageConfig.pageSize
640
+
641
+ return ((current < 1 ? 1 : current) - 1) * size + index + 1;
642
+ }
643
+
644
+
645
+ const pageConfig = reactive({
646
+ pageNum: 1,
647
+ pageSize: 20,
648
+ total: 0
649
+ })
650
+
651
+ const getPage = (val) => {
652
+ pageConfig.pageNum = val
653
+ getList()
654
+ };
655
+ const getSize = (val) => {
656
+ pageConfig.pageSize = val
657
+ getList()
658
+ };
659
+
660
+ onMounted(async () => {
661
+ getList()
662
+ if (props.needSearch) {
663
+ window.addEventListener('resize', handleResize);
664
+ handleInit()
665
+ }
666
+ if (props.autoHeight) {
667
+ // emitter.on('componentHeightChange', (val) => {
668
+ // resizeTableHeight()
669
+ // });
670
+ // 监听窗口大小变化
671
+ window.addEventListener("resize", resizeTableHeight);
672
+ await nextTick()
673
+ resizeTableHeight();
674
+ }
675
+ })
676
+ // 监听屏幕改变
677
+ onUnmounted(() => {
678
+ if (props.needSearch) {
679
+ window.removeEventListener('resize', handleResize); // 在组件销毁时移除事件监听器
680
+ }
681
+ });
682
+
683
+ watch(() => tableConfig.data, async (newValue) => {
684
+ await nextTick()
685
+ setTimeout(() => {
686
+ multipleTable.value?.scrollBarRef.update()
687
+ }, 0)
688
+ }, { immediate: true })
689
+ // 页数变化 滚动条长度重置
690
+ watch(() => pageConfig.pageNum, async (newValue) => {
691
+ await nextTick()
692
+ setTimeout(() => {
693
+ multipleTable.value.setScrollTop(0)
694
+ multipleTable.value?.scrollBarRef.update()
695
+ }, 0)
696
+ })
697
+
698
+ defineExpose({
699
+ clearSelection,
700
+ allSelection,
701
+ handleInit
702
+ })
703
+ </script>
704
+ <style lang="scss" scoped>
705
+ .cmp-container {
706
+ box-sizing: border-box;
707
+
708
+ .search-container {
709
+
710
+ position: relative;
711
+ min-height: 32px;
712
+
713
+ .search-row {
714
+ position: relative;
715
+
716
+ .item-label {
717
+ white-space: nowrap;
718
+ }
719
+
720
+ .buttons {
721
+ align-items: center;
722
+ margin-bottom: 18px;
723
+ display: inline-flex;
724
+ vertical-align: middle;
725
+
726
+ .btn {
727
+ display: flex;
728
+ align-items: center;
729
+ padding: 0px 20px;
730
+ cursor: pointer;
731
+ user-select: none;
732
+
733
+ .icon {
734
+ margin-top: 3px;
735
+ }
736
+
737
+ .text {
738
+ color: #303133;
739
+ font-size: 14px;
740
+ padding-left: 10px;
741
+ }
742
+ }
743
+ }
744
+
745
+ .row-item {
746
+ .el-col:nth-child(4n) {
747
+ .el-form-item {
748
+ margin-right: 0 !important;
749
+ }
750
+ }
751
+
752
+ position: absolute;
753
+ right: 0;
754
+ }
755
+
756
+ .el-form-item {
757
+ margin-right: 10px !important;
758
+ }
759
+
760
+ .individual {
761
+ display: flex;
762
+ flex-direction: row-reverse;
763
+ }
764
+ }
765
+ }
766
+
767
+ #table-with-page {
768
+
769
+ .table-container {
770
+ :deep(.el-table) {
771
+ width: 99.9% !important;
772
+
773
+ th {
774
+ color: inherit;
775
+ background-color: inherit;
776
+ }
777
+
778
+ .cell.el-tooltip {
779
+ width: 100% !important;
780
+ }
781
+
782
+ .warning-row {
783
+ background: oldlace;
784
+ }
785
+
786
+ .success-row {
787
+ background: #f0f9eb;
788
+ }
789
+ }
790
+
791
+ .stress {
792
+ color: #0088f4;
793
+ text-decoration: underline;
794
+ cursor: pointer;
795
+ }
796
+
797
+ .images {
798
+ width: 60px;
799
+ height: 60px;
800
+ }
801
+
802
+ .images-tip {
803
+ width: 60px;
804
+ text-align: center;
805
+ }
806
+
807
+ .tooltip-wrap {
808
+ display: flex;
809
+ align-items: center;
810
+
811
+ .tip-icon {
812
+ margin-left: 4px;
813
+ font-size: 15px;
814
+ color: #080505;
815
+ }
816
+ }
817
+
818
+ :deep(.empty-area) {
819
+ padding: 40px 0;
820
+
821
+ .empty-image {
822
+ width: 35%;
823
+ }
824
+
825
+ p {
826
+ line-height: 2;
827
+ font-weight: 500;
828
+ color: #333;
829
+ }
830
+ }
831
+ }
832
+
833
+ .pagination-container {
834
+ text-align: center;
835
+ margin: 12px 0 0 0;
836
+ position: relative;
837
+ height: 32px;
838
+ display: flex;
839
+ align-items: center;
840
+ width: 100%;
841
+ box-sizing: border-box;
842
+ justify-content: flex-end;
843
+ }
844
+ }
845
+ }
846
+ </style>
847
+ <style>
848
+ /* .m-table {
849
+
850
+ .el-scrollbar__view {
851
+ height: 100%;
852
+ }
853
+ } */
854
+ </style>