|
|
@@ -86,6 +86,7 @@ const props = withDefaults(
|
|
|
scroll?: Scroll
|
|
|
/* rowspan */
|
|
|
rowSpanSuffix?: string // rowspan 的字段后缀 后台应该组成 `${字段}${后缀}`
|
|
|
+ colSpanSuffix?: string // colspan 的字段后缀 后台应该组成 `${字段}${后缀}`
|
|
|
/* tree */
|
|
|
isTree?: boolean
|
|
|
expandDepth?: number
|
|
|
@@ -146,6 +147,7 @@ const props = withDefaults(
|
|
|
fixedNumber: 0,
|
|
|
fixedRightNumber: 0,
|
|
|
rowSpanSuffix: "_rowSpan",
|
|
|
+ colSpanSuffix: "_colSpan",
|
|
|
isTree: false,
|
|
|
parentField: "parent_id",
|
|
|
childrenField: "children",
|
|
|
@@ -778,6 +780,7 @@ provide(symbolKeys.bodyTr, {
|
|
|
provide(symbolKeys.bodyTds, {
|
|
|
columns: rowColumns,
|
|
|
rowSpanSuffix: props.rowSpanSuffix,
|
|
|
+ colSpanSuffix: props.colSpanSuffix,
|
|
|
expandDepth: props.expandDepth,
|
|
|
intervalLeft: props.intervalLeft,
|
|
|
iconField: props.iconField,
|
|
|
@@ -982,36 +985,44 @@ function BindInterEvent() {
|
|
|
|
|
|
function initFixedColumns() {
|
|
|
if (fixedColumn.value) {
|
|
|
- const tr = tableRef.value?.querySelector("tbody tr")
|
|
|
- if (tr && tr.children) {
|
|
|
- let width = 0
|
|
|
- if (leftFixedRef.value) {
|
|
|
- let num = props.fixedNumber
|
|
|
- if (props.hasCheckbox || props.checkMultiple || props.checkPageMultiple) {
|
|
|
- num += 1
|
|
|
- }
|
|
|
- for (let i = 0; i < num; i++) {
|
|
|
- width += tr.children[i]?.clientWidth ?? 0
|
|
|
- }
|
|
|
- leftFixedRef.value.style.width = width + "px"
|
|
|
- leftFixedRef.value.firstElementChild.style.width = tableRef.value.clientWidth + "px"
|
|
|
- }
|
|
|
- if (rightFixedRef.value) {
|
|
|
- width = 0
|
|
|
- const trLength = tr.children.length
|
|
|
- for (let i = trLength - 1; i >= trLength - props.fixedRightNumber; i--) {
|
|
|
- width += tr.children[i]?.clientWidth ?? 0
|
|
|
+ setTimeout(() => {
|
|
|
+ const tr = tableRef.value?.querySelector("thead tr")
|
|
|
+ if (tr && tr.children) {
|
|
|
+ let width = 0,
|
|
|
+ _temp = 0
|
|
|
+ if (leftFixedRef.value) {
|
|
|
+ let num = props.fixedNumber
|
|
|
+ if (props.hasCheckbox || props.checkMultiple || props.checkPageMultiple) {
|
|
|
+ num += 1
|
|
|
+ }
|
|
|
+ for (let i = 0; _temp < num; i++) {
|
|
|
+ const item = tr.children[i]
|
|
|
+ _temp += Number(item.getAttribute("colspan"))
|
|
|
+ width += tr.children[i]?.clientWidth ?? 0
|
|
|
+ }
|
|
|
+ leftFixedRef.value.style.width = width + "px"
|
|
|
+ leftFixedRef.value.firstElementChild.style.width = tableRef.value.clientWidth + "px"
|
|
|
}
|
|
|
- rightFixedRef.value.style.width = width + "px"
|
|
|
- rightFixedRef.value.firstElementChild.style.width = tableRef.value.clientWidth + "px"
|
|
|
- rightFixedRef.value.firstElementChild.style.transform = `translateX(-${
|
|
|
- tableRef.value.clientWidth - width
|
|
|
- }px)`
|
|
|
- if (tableRef.value.clientWidth <= tableResponsiveRef.value.clientWidth) {
|
|
|
- rightFixedRef.value.className += " no-shadow"
|
|
|
+ if (rightFixedRef.value) {
|
|
|
+ width = 0
|
|
|
+ _temp = 0
|
|
|
+ const trLength = tr.children.length
|
|
|
+ for (let i = trLength - 1; _temp < props.fixedRightNumber; i--) {
|
|
|
+ const item = tr.children[i]
|
|
|
+ _temp += Number(item.getAttribute("colspan"))
|
|
|
+ width += tr.children[i]?.clientWidth ?? 0
|
|
|
+ }
|
|
|
+ rightFixedRef.value.style.width = width + "px"
|
|
|
+ rightFixedRef.value.firstElementChild.style.width = tableRef.value.clientWidth + "px"
|
|
|
+ rightFixedRef.value.firstElementChild.style.transform = `translateX(-${
|
|
|
+ tableRef.value.clientWidth - width
|
|
|
+ }px)`
|
|
|
+ if (tableRef.value.clientWidth <= tableResponsiveRef.value.clientWidth) {
|
|
|
+ rightFixedRef.value.className += " no-shadow"
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }, 10)
|
|
|
}
|
|
|
}
|
|
|
function init() {
|