|
|
@@ -17,6 +17,7 @@ const props = withDefaults(
|
|
|
defineProps<{
|
|
|
columns: Header[]
|
|
|
columnsFun?: () => Header[]
|
|
|
+
|
|
|
tableTitle?: string
|
|
|
emptyTableText?: string
|
|
|
keyField?: string
|
|
|
@@ -335,7 +336,8 @@ const tableBoxClass = computed(() => {
|
|
|
|
|
|
return classStr
|
|
|
})
|
|
|
-const _tableBoxStyle = ref(calcTableBoxStyle())
|
|
|
+// const _tableBoxStyle = ref(calcTableBoxStyle())
|
|
|
+const _tableBoxStyle = ref()
|
|
|
const fixedColumn = computed(() => props.fixedNumber > 0 || props.fixedRightNumber > 0)
|
|
|
const tableStyle = computed(() => {
|
|
|
let style = ""
|
|
|
@@ -412,7 +414,7 @@ const defaultHandleFuns = {
|
|
|
})
|
|
|
},
|
|
|
handleExport: () => {
|
|
|
- console.log("TE")
|
|
|
+ // console.log("TE")
|
|
|
if (props.exportUrl) {
|
|
|
download(
|
|
|
props.exportUrl,
|
|
|
@@ -552,7 +554,6 @@ const isContentSlots = (name: string | number): boolean => {
|
|
|
}) != null
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
const loadHandleBtns = () => {
|
|
|
toolbarHandleBtns.value = []
|
|
|
const _handleFuns = Object.assign({}, defaultHandleFuns, props.handleFuns ?? {})
|
|
|
@@ -636,21 +637,20 @@ function calcTableBoxStyle() {
|
|
|
if (props.tableBoxHeight) {
|
|
|
style.height = Number(props.tableBoxHeight) ? props.tableBoxHeight + "px" : props.tableBoxHeight
|
|
|
} else {
|
|
|
- nextTick(() => {
|
|
|
- const tableBoxAutoHeight =
|
|
|
- document.documentElement.clientHeight -
|
|
|
- (document.querySelector(".app-header")?.clientHeight ?? 0) -
|
|
|
- (document.querySelector(".app-footer")?.clientHeight ?? 0) -
|
|
|
- 5
|
|
|
- style.height = tableBoxAutoHeight + "px"
|
|
|
- })
|
|
|
+ const tableBoxAutoHeight =
|
|
|
+ document.documentElement.clientHeight -
|
|
|
+ (document.querySelector(".app-header")?.clientHeight ?? 0) -
|
|
|
+ (document.querySelector(".app-footer")?.clientHeight ?? 0) -
|
|
|
+ 5
|
|
|
+ style.height = tableBoxAutoHeight + "px"
|
|
|
}
|
|
|
if (props.tableBoxWidth) {
|
|
|
style.width = Number(props.tableBoxWidth) ? props.tableBoxWidth + "px" : props.tableBoxWidth
|
|
|
} else {
|
|
|
style.width = "100%"
|
|
|
}
|
|
|
- return style
|
|
|
+ _tableBoxStyle.value = style
|
|
|
+ // return style
|
|
|
}
|
|
|
function query(query?: any) {
|
|
|
if (query) {
|
|
|
@@ -672,8 +672,8 @@ function search(isReset = true) {
|
|
|
function getQueryParams() {
|
|
|
return innerQueryParams.value
|
|
|
}
|
|
|
-function setQueryParams(params: any) {
|
|
|
- innerQueryParams.value = params
|
|
|
+function setQueryParams(queryParams: any) {
|
|
|
+ return (innerQueryParams.value = queryParams)
|
|
|
}
|
|
|
function getSelected() {
|
|
|
return getSelecteds()[0]
|
|
|
@@ -883,8 +883,8 @@ const onReset = () => {
|
|
|
}
|
|
|
const onTreeToggle = (v: any) => {
|
|
|
const row = toValue(v)
|
|
|
- const id = "tr_" + row[keyField.value]
|
|
|
- const tr = tableBoxRef.value?.querySelector(`#${id}`)
|
|
|
+ const tr_id = "tr_" + row[keyField.value]
|
|
|
+ const tr = tableBoxRef.value?.querySelector(`#${tr_id}`)
|
|
|
const icon = tr?.querySelector(".icon")
|
|
|
if (!tr || !icon) {
|
|
|
return
|
|
|
@@ -893,21 +893,21 @@ const onTreeToggle = (v: any) => {
|
|
|
// 已有children可展开的直接展开,不在调用懒加载
|
|
|
if (tr.className.search("hasChildren") >= 0) {
|
|
|
if (tr.className.search("tr-expand") >= 0 || !props.isLazySearch) {
|
|
|
- toggle(tr, icon, id)
|
|
|
+ toggle(tr, icon, tr_id)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- remote(id).then((res) => {
|
|
|
+ remote(row[keyField.value]).then((res) => {
|
|
|
if (res == 1 && props.isLazySearch) {
|
|
|
nextTick(() => {
|
|
|
- showChildren(id)
|
|
|
+ showChildren(tr_id)
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
tr.className = tr.className.replace("tr-collapse", "tr-expand")
|
|
|
icon.className = icon.className.replace("ki-add-folder", "ki-minus-folder")
|
|
|
} else {
|
|
|
- toggle(tr, icon, id)
|
|
|
+ toggle(tr, icon, tr_id)
|
|
|
}
|
|
|
function toggle(_tr: HTMLElement, _icon: HTMLElement, id: string) {
|
|
|
if (_tr.className.search("tr-expand") >= 0) {
|
|
|
@@ -945,14 +945,21 @@ const onTreeToggle = (v: any) => {
|
|
|
}
|
|
|
}
|
|
|
const onFixedScrollX = () => {
|
|
|
- leftFixedRef.value.className = leftFixedRef.value.className.replace("no-shadow", "")
|
|
|
- rightFixedRef.value.className = rightFixedRef.value.className.replace("no-shadow", "")
|
|
|
+ if (leftFixedRef.value) {
|
|
|
+ leftFixedRef.value.className = leftFixedRef.value.className.replace("no-shadow", "")
|
|
|
+ }
|
|
|
+ if (rightFixedRef.value) {
|
|
|
+ rightFixedRef.value.className = rightFixedRef.value.className.replace("no-shadow", "")
|
|
|
+ }
|
|
|
if (tableResponsiveRef.value) {
|
|
|
const left = tableResponsiveRef.value.scrollLeft
|
|
|
- if (left == 0) {
|
|
|
+ if (left == 0 && leftFixedRef.value) {
|
|
|
leftFixedRef.value.className += " no-shadow"
|
|
|
}
|
|
|
- if (left >= tableRef.value.clientWidth - tableResponsiveRef.value.clientWidth) {
|
|
|
+ if (
|
|
|
+ rightFixedRef.value &&
|
|
|
+ left >= tableRef.value.clientWidth - tableResponsiveRef.value.clientWidth
|
|
|
+ ) {
|
|
|
rightFixedRef.value.className += " no-shadow"
|
|
|
}
|
|
|
}
|
|
|
@@ -976,7 +983,7 @@ function BindInterEvent() {
|
|
|
|
|
|
function initFixedColumns() {
|
|
|
if (fixedColumn.value) {
|
|
|
- const tr = tableRef.value?.querySelector("tr")
|
|
|
+ const tr = tableRef.value?.querySelector("tbody tr")
|
|
|
if (tr && tr.children) {
|
|
|
let width = 0
|
|
|
if (leftFixedRef.value) {
|
|
|
@@ -1014,12 +1021,11 @@ function init() {
|
|
|
customSearch()
|
|
|
}
|
|
|
loadHandleBtns()
|
|
|
- nextTick(() => {
|
|
|
- initFixedColumns()
|
|
|
- BindInterEvent()
|
|
|
- })
|
|
|
+ initFixedColumns()
|
|
|
+ BindInterEvent()
|
|
|
+ calcTableBoxStyle()
|
|
|
window.addEventListener("resize", () => {
|
|
|
- _tableBoxStyle.value = calcTableBoxStyle()
|
|
|
+ calcTableBoxStyle()
|
|
|
})
|
|
|
}
|
|
|
onMounted(init)
|