@ctzy-web-client/plugin-component-vue 1.0.51 → 1.0.52
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/es/data-table/data-table.mjs +3 -57
- package/es/datatable-settings/datatable-settings.mjs +1 -0
- package/lib/data-table/data-table.js +2 -56
- package/lib/datatable-settings/datatable-settings.js +1 -0
- package/package.json +1 -1
- package/src/data-table/data-table.vue +2 -65
- package/src/datatable-settings/datatable-settings.vue +1 -1
- /package/es/{make-installer.css → utils.css} +0 -0
- /package/lib/{make-installer.css → utils.css} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, useAttrs, ref, computed,
|
|
1
|
+
import { defineComponent, useAttrs, ref, computed, unref, watch, provide, reactive, nextTick, onUnmounted, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot, createVNode, mergeProps, withCtx, createBlock, createElementVNode, createCommentVNode, Fragment, renderList, createTextVNode, toDisplayString } from 'vue';
|
|
2
2
|
import { ElMessage, ElTable, ElTableColumn, ElPagination } from 'element-plus';
|
|
3
3
|
import { useService, useGlobalConfig, dataTableKey, useNamespace, useEventDispatcher } from '@ctzy-web-client/web-base-client-vue';
|
|
4
4
|
import DynamicComponent from './dynamic-component.mjs';
|
|
@@ -81,60 +81,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
81
81
|
const dataTable = props.dataTable;
|
|
82
82
|
dataTable._userService = (_a = userService.value) == null ? void 0 : _a.getUserList;
|
|
83
83
|
const dataTableEl = ref(null);
|
|
84
|
-
const realHeight = computed(() =>
|
|
85
|
-
if (props.height !== "auto") {
|
|
86
|
-
return props.height;
|
|
87
|
-
}
|
|
88
|
-
return tableAutoHeight.value;
|
|
89
|
-
});
|
|
90
|
-
const maxHeight = ref(0);
|
|
91
|
-
const maxHeightNumber = ref(0);
|
|
92
|
-
function updateMaxHeight(list) {
|
|
93
|
-
nextTick(() => {
|
|
94
|
-
if (!elTable.value)
|
|
95
|
-
return;
|
|
96
|
-
let h = (list == null ? void 0 : list.length) ? list.length * 40 : void 0;
|
|
97
|
-
maxHeightNumber.value = h;
|
|
98
|
-
if (h) {
|
|
99
|
-
elTable.value.$el.style.maxHeight = h + "px";
|
|
100
|
-
} else {
|
|
101
|
-
elTable.value.$el.style.maxHeight = "";
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
const tableAutoHeight = ref(300);
|
|
106
|
-
const PAGINATION_HEIGHT = 160;
|
|
107
|
-
function calcTableHeight() {
|
|
108
|
-
nextTick(() => {
|
|
109
|
-
if (!dataTableEl.value)
|
|
110
|
-
return;
|
|
111
|
-
const top = dataTableEl.value.offsetTop;
|
|
112
|
-
const viewHeight = window.innerHeight;
|
|
113
|
-
const height = viewHeight - top - PAGINATION_HEIGHT - 40;
|
|
114
|
-
console.log(height);
|
|
115
|
-
tableAutoHeight.value = Math.max(height, 100);
|
|
116
|
-
elTable.value.$el.style.maxHeight = tableAutoHeight.value + "px";
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
let resizeTimer = null;
|
|
120
|
-
function watchResize() {
|
|
121
|
-
clearTimeout(resizeTimer);
|
|
122
|
-
resizeTimer = setTimeout(calcTableHeight, 100);
|
|
123
|
-
}
|
|
124
|
-
onMounted(() => {
|
|
125
|
-
calcTableHeight();
|
|
126
|
-
window.addEventListener("resize", watchResize);
|
|
127
|
-
nextTick(() => {
|
|
128
|
-
var _a2;
|
|
129
|
-
if ((_a2 = props.dataTable.data) == null ? void 0 : _a2.length) {
|
|
130
|
-
updateMaxHeight(props.dataTable.data);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
onBeforeUnmount(() => {
|
|
135
|
-
window.removeEventListener("resize", watchResize);
|
|
136
|
-
clearTimeout(resizeTimer);
|
|
137
|
-
});
|
|
84
|
+
const realHeight = computed(() => props.height);
|
|
138
85
|
const displayColumns = computed(
|
|
139
86
|
() => unref(dataTable).getDisplayColumns() || []
|
|
140
87
|
);
|
|
@@ -331,7 +278,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
331
278
|
createVNode(unref(ElTable), mergeProps({
|
|
332
279
|
class: "content",
|
|
333
280
|
height: realHeight.value,
|
|
334
|
-
"max-height": maxHeight.value,
|
|
335
281
|
ref_key: "elTable",
|
|
336
282
|
ref: elTable,
|
|
337
283
|
data: data.value,
|
|
@@ -419,7 +365,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
419
365
|
renderSlot(_ctx.$slots, "column-append")
|
|
420
366
|
]),
|
|
421
367
|
_: 3
|
|
422
|
-
}, 16, ["height", "
|
|
368
|
+
}, 16, ["height", "data", "row-key", "onSelectionChange", "border"])
|
|
423
369
|
]),
|
|
424
370
|
__props.showPagination ? (openBlock(), createElementBlock("div", {
|
|
425
371
|
key: 0,
|
|
@@ -318,6 +318,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
318
318
|
createVNode(unref(ElSwitch), {
|
|
319
319
|
modelValue: column.visible,
|
|
320
320
|
"onUpdate:modelValue": ($event) => column.visible = $event,
|
|
321
|
+
size: "small",
|
|
321
322
|
disabled: column.settings.disabled,
|
|
322
323
|
onChange: (val) => handleColumnVisibleChange(column, val)
|
|
323
324
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "onChange"])
|
|
@@ -85,60 +85,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
85
85
|
const dataTable = props.dataTable;
|
|
86
86
|
dataTable._userService = (_a = userService.value) == null ? void 0 : _a.getUserList;
|
|
87
87
|
const dataTableEl = vue.ref(null);
|
|
88
|
-
const realHeight = vue.computed(() =>
|
|
89
|
-
if (props.height !== "auto") {
|
|
90
|
-
return props.height;
|
|
91
|
-
}
|
|
92
|
-
return tableAutoHeight.value;
|
|
93
|
-
});
|
|
94
|
-
const maxHeight = vue.ref(0);
|
|
95
|
-
const maxHeightNumber = vue.ref(0);
|
|
96
|
-
function updateMaxHeight(list) {
|
|
97
|
-
vue.nextTick(() => {
|
|
98
|
-
if (!elTable.value)
|
|
99
|
-
return;
|
|
100
|
-
let h = (list == null ? void 0 : list.length) ? list.length * 40 : void 0;
|
|
101
|
-
maxHeightNumber.value = h;
|
|
102
|
-
if (h) {
|
|
103
|
-
elTable.value.$el.style.maxHeight = h + "px";
|
|
104
|
-
} else {
|
|
105
|
-
elTable.value.$el.style.maxHeight = "";
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
const tableAutoHeight = vue.ref(300);
|
|
110
|
-
const PAGINATION_HEIGHT = 160;
|
|
111
|
-
function calcTableHeight() {
|
|
112
|
-
vue.nextTick(() => {
|
|
113
|
-
if (!dataTableEl.value)
|
|
114
|
-
return;
|
|
115
|
-
const top = dataTableEl.value.offsetTop;
|
|
116
|
-
const viewHeight = window.innerHeight;
|
|
117
|
-
const height = viewHeight - top - PAGINATION_HEIGHT - 40;
|
|
118
|
-
console.log(height);
|
|
119
|
-
tableAutoHeight.value = Math.max(height, 100);
|
|
120
|
-
elTable.value.$el.style.maxHeight = tableAutoHeight.value + "px";
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
let resizeTimer = null;
|
|
124
|
-
function watchResize() {
|
|
125
|
-
clearTimeout(resizeTimer);
|
|
126
|
-
resizeTimer = setTimeout(calcTableHeight, 100);
|
|
127
|
-
}
|
|
128
|
-
vue.onMounted(() => {
|
|
129
|
-
calcTableHeight();
|
|
130
|
-
window.addEventListener("resize", watchResize);
|
|
131
|
-
vue.nextTick(() => {
|
|
132
|
-
var _a2;
|
|
133
|
-
if ((_a2 = props.dataTable.data) == null ? void 0 : _a2.length) {
|
|
134
|
-
updateMaxHeight(props.dataTable.data);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
vue.onBeforeUnmount(() => {
|
|
139
|
-
window.removeEventListener("resize", watchResize);
|
|
140
|
-
clearTimeout(resizeTimer);
|
|
141
|
-
});
|
|
88
|
+
const realHeight = vue.computed(() => props.height);
|
|
142
89
|
const displayColumns = vue.computed(
|
|
143
90
|
() => vue.unref(dataTable).getDisplayColumns() || []
|
|
144
91
|
);
|
|
@@ -335,7 +282,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
335
282
|
vue.createVNode(vue.unref(ElementPlus.ElTable), vue.mergeProps({
|
|
336
283
|
class: "content",
|
|
337
284
|
height: realHeight.value,
|
|
338
|
-
"max-height": maxHeight.value,
|
|
339
285
|
ref_key: "elTable",
|
|
340
286
|
ref: elTable,
|
|
341
287
|
data: data.value,
|
|
@@ -423,7 +369,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
423
369
|
vue.renderSlot(_ctx.$slots, "column-append")
|
|
424
370
|
]),
|
|
425
371
|
_: 3
|
|
426
|
-
}, 16, ["height", "
|
|
372
|
+
}, 16, ["height", "data", "row-key", "onSelectionChange", "border"])
|
|
427
373
|
]),
|
|
428
374
|
__props.showPagination ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
429
375
|
key: 0,
|
|
@@ -322,6 +322,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
322
322
|
vue.createVNode(vue.unref(ElementPlus.ElSwitch), {
|
|
323
323
|
modelValue: column.visible,
|
|
324
324
|
"onUpdate:modelValue": ($event) => column.visible = $event,
|
|
325
|
+
size: "small",
|
|
325
326
|
disabled: column.settings.disabled,
|
|
326
327
|
onChange: (val) => handleColumnVisibleChange(column, val)
|
|
327
328
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "onChange"])
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<ElTable
|
|
6
6
|
class="content"
|
|
7
7
|
:height="realHeight"
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
ref="elTable"
|
|
10
10
|
:data="data"
|
|
11
11
|
:row-key="dataTable.primaryKey"
|
|
@@ -204,71 +204,8 @@ dataTable._userService = userService.value?.getUserList
|
|
|
204
204
|
|
|
205
205
|
const dataTableEl = ref(null);
|
|
206
206
|
// const realHeight = computed(() => props.height)
|
|
207
|
-
const realHeight = computed(() =>
|
|
208
|
-
// 如果用户传了 height,就用用户的
|
|
209
|
-
if (props.height !== 'auto') {
|
|
210
|
-
return props.height
|
|
211
|
-
}
|
|
212
|
-
// 否则自动计算表格高度
|
|
213
|
-
return tableAutoHeight.value
|
|
214
|
-
})
|
|
215
|
-
const maxHeight = ref(0)
|
|
216
|
-
const maxHeightNumber = ref(0)
|
|
217
|
-
// 计算最大高度
|
|
218
|
-
function updateMaxHeight(list) {
|
|
219
|
-
nextTick(()=>{
|
|
220
|
-
if(!elTable.value) return
|
|
221
|
-
let h = list?.length ? list.length * 40 : undefined
|
|
222
|
-
maxHeightNumber.value = h
|
|
223
|
-
if(h){
|
|
224
|
-
elTable.value.$el.style.maxHeight = h + 'px'
|
|
225
|
-
}else{
|
|
226
|
-
elTable.value.$el.style.maxHeight = ''
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
}
|
|
230
|
-
// ====================
|
|
231
|
-
// 自动高度计算(react-base-table 同款逻辑)
|
|
232
|
-
// ====================
|
|
233
|
-
const tableAutoHeight = ref(300)
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
// 分页高度(固定,根据你的样式调整)
|
|
237
|
-
const PAGINATION_HEIGHT = 160
|
|
238
|
-
|
|
239
|
-
// 计算表格高度 = 屏幕高度 - 自身offsetTop高度 - 分页高度
|
|
240
|
-
function calcTableHeight() {
|
|
241
|
-
nextTick(() => {
|
|
242
|
-
if (!dataTableEl.value) return
|
|
243
|
-
const top = dataTableEl.value.offsetTop // 自动获取顶部距离
|
|
244
|
-
const viewHeight = window.innerHeight
|
|
245
|
-
const height = viewHeight - top - PAGINATION_HEIGHT-40
|
|
246
|
-
console.log(height)
|
|
247
|
-
tableAutoHeight.value = Math.max(height, 100) // 最小200px
|
|
248
|
-
elTable.value.$el.style.maxHeight = tableAutoHeight.value + 'px'
|
|
249
|
-
})
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// 防抖监听窗口缩放
|
|
253
|
-
let resizeTimer = null
|
|
254
|
-
function watchResize() {
|
|
255
|
-
clearTimeout(resizeTimer)
|
|
256
|
-
resizeTimer = setTimeout(calcTableHeight, 100)
|
|
257
|
-
}
|
|
258
|
-
onMounted(() => {
|
|
259
|
-
calcTableHeight()
|
|
260
|
-
window.addEventListener('resize', watchResize)
|
|
261
|
-
nextTick(()=>{
|
|
262
|
-
if(props.dataTable.data?.length){
|
|
263
|
-
updateMaxHeight(props.dataTable.data)
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
})
|
|
207
|
+
const realHeight = computed(() => props.height)
|
|
267
208
|
|
|
268
|
-
onBeforeUnmount(() => {
|
|
269
|
-
window.removeEventListener('resize', watchResize)
|
|
270
|
-
clearTimeout(resizeTimer)
|
|
271
|
-
})
|
|
272
209
|
|
|
273
210
|
const displayColumns = computed(
|
|
274
211
|
() => unref(dataTable).getDisplayColumns() || []
|
|
File without changes
|
|
File without changes
|