Skip to content

Commit

Permalink
Merge pull request #109 from nejinn/dev
Browse files Browse the repository at this point in the history
修复 table fixed bug
  • Loading branch information
nejinn authored Dec 19, 2020
2 parents defb6a7 + cb9bb2d commit 54e2cf7
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,64 +74,71 @@ export default {
customRight: 0
};
},
methods: {
fixedDate() {
this.$nextTick(() => {
if (this.computedFieldsRef) {
this.computedFieldsRef.forEach((e, ei) => {
const e_a = this.$refs[e];
if (ei === 0) {
this.customLeft += e_a[0].$el.clientWidth;
}
if (ei !== 0) {
e_a.forEach(f => {
f.$el.style.left = `${this.customLeft}px`;
});
this.customLeft += e_a[0].$el.clientWidth;
}
// customLeft += e_array[0].$el.clientWidth;
});
}
if (this.computedFieldsRightRef) {
this.computedFieldsRightRef.forEach((e, ei) => {
const e_a = this.$refs[e];
if (ei === 0) {
e_a.forEach(f => {
if (
f.$el.className.indexOf("nly-table-sticky-column-right") ===
-1
) {
f.$el.classList.add("nly-table-sticky-column-right");
}
if (f.$el.className.indexOf("nly-table-sticky-column") !== -1) {
f.$el.classList.remove("nly-table-sticky-column");
}
});
this.customRight += e_a[0].$el.clientWidth;
}
if (ei !== 0) {
e_a.forEach(f => {
if (
f.$el.className.indexOf("nly-table-sticky-column-right") ===
-1
) {
f.$el.classList.add("nly-table-sticky-column-right");
}
if (f.$el.className.indexOf("nly-table-sticky-column") !== -1) {
f.$el.classList.remove("nly-table-sticky-column");
}
f.$el.style.right = `${this.customRight}px`;
});
this.customRight += e_a[0].$el.clientWidth;
}
// if (ei === this.computedFieldsRightRef.length - 1) {
// e_a.forEach(f => {
// if (f.$el.className.indexOf("elevation-left") === -1) {
// f.$el.classList.add("elevation-left");
// }
// });
// }
// customLeft += e_array[0].$el.clientWidth;
});
}
});
}
},
mounted() {
this.$nextTick(() => {
if (this.computedFieldsRef) {
this.computedFieldsRef.forEach((e, ei) => {
const e_a = this.$refs[e];
if (ei === 0) {
this.customLeft += e_a[0].$el.clientWidth;
}
if (ei !== 0) {
e_a.forEach(f => {
f.$el.style.left = `${this.customLeft}px`;
});
this.customLeft += e_a[0].$el.clientWidth;
}
// customLeft += e_array[0].$el.clientWidth;
});
}
if (this.computedFieldsRightRef) {
this.computedFieldsRightRef.forEach((e, ei) => {
const e_a = this.$refs[e];
if (ei === 0) {
e_a.forEach(f => {
if (
f.$el.className.indexOf("nly-table-sticky-column-right") === -1
) {
f.$el.classList.add("nly-table-sticky-column-right");
}
if (f.$el.className.indexOf("nly-table-sticky-column") !== -1) {
f.$el.classList.remove("nly-table-sticky-column");
}
});
this.customRight += e_a[0].$el.clientWidth;
}
if (ei !== 0) {
e_a.forEach(f => {
if (
f.$el.className.indexOf("nly-table-sticky-column-right") === -1
) {
f.$el.classList.add("nly-table-sticky-column-right");
}
if (f.$el.className.indexOf("nly-table-sticky-column") !== -1) {
f.$el.classList.remove("nly-table-sticky-column");
}
f.$el.style.right = `${this.customRight}px`;
});
this.customRight += e_a[0].$el.clientWidth;
}
// if (ei === this.computedFieldsRightRef.length - 1) {
// e_a.forEach(f => {
// if (f.$el.className.indexOf("elevation-left") === -1) {
// f.$el.classList.add("elevation-left");
// }
// });
// }
// customLeft += e_array[0].$el.clientWidth;
});
}
});
this.fixedDate();
},
computed: {
// Layout related computed props
Expand Down Expand Up @@ -225,6 +232,14 @@ export default {
};
}
},
watch: {
items: {
handler: function() {
this.fixedDate();
},
deep: true
}
},
render(h) {
const $content = [];

Expand Down
129 changes: 72 additions & 57 deletions src/components/table/plugin/mixin-table-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,64 +74,71 @@ export default {
customRight: 0
};
},
methods: {
fixedDate() {
this.$nextTick(() => {
if (this.computedFieldsRef) {
this.computedFieldsRef.forEach((e, ei) => {
const e_a = this.$refs[e];
if (ei === 0) {
this.customLeft += e_a[0].$el.clientWidth;
}
if (ei !== 0) {
e_a.forEach(f => {
f.$el.style.left = `${this.customLeft}px`;
});
this.customLeft += e_a[0].$el.clientWidth;
}
// customLeft += e_array[0].$el.clientWidth;
});
}
if (this.computedFieldsRightRef) {
this.computedFieldsRightRef.forEach((e, ei) => {
const e_a = this.$refs[e];
if (ei === 0) {
e_a.forEach(f => {
if (
f.$el.className.indexOf("nly-table-sticky-column-right") ===
-1
) {
f.$el.classList.add("nly-table-sticky-column-right");
}
if (f.$el.className.indexOf("nly-table-sticky-column") !== -1) {
f.$el.classList.remove("nly-table-sticky-column");
}
});
this.customRight += e_a[0].$el.clientWidth;
}
if (ei !== 0) {
e_a.forEach(f => {
if (
f.$el.className.indexOf("nly-table-sticky-column-right") ===
-1
) {
f.$el.classList.add("nly-table-sticky-column-right");
}
if (f.$el.className.indexOf("nly-table-sticky-column") !== -1) {
f.$el.classList.remove("nly-table-sticky-column");
}
f.$el.style.right = `${this.customRight}px`;
});
this.customRight += e_a[0].$el.clientWidth;
}
// if (ei === this.computedFieldsRightRef.length - 1) {
// e_a.forEach(f => {
// if (f.$el.className.indexOf("elevation-left") === -1) {
// f.$el.classList.add("elevation-left");
// }
// });
// }
// customLeft += e_array[0].$el.clientWidth;
});
}
});
}
},
mounted() {
this.$nextTick(() => {
if (this.computedFieldsRef) {
this.computedFieldsRef.forEach((e, ei) => {
const e_a = this.$refs[e];
if (ei === 0) {
this.customLeft += e_a[0].$el.clientWidth;
}
if (ei !== 0) {
e_a.forEach(f => {
f.$el.style.left = `${this.customLeft}px`;
});
this.customLeft += e_a[0].$el.clientWidth;
}
// customLeft += e_array[0].$el.clientWidth;
});
}
if (this.computedFieldsRightRef) {
this.computedFieldsRightRef.forEach((e, ei) => {
const e_a = this.$refs[e];
if (ei === 0) {
e_a.forEach(f => {
if (
f.$el.className.indexOf("nly-table-sticky-column-right") === -1
) {
f.$el.classList.add("nly-table-sticky-column-right");
}
if (f.$el.className.indexOf("nly-table-sticky-column") !== -1) {
f.$el.classList.remove("nly-table-sticky-column");
}
});
this.customRight += e_a[0].$el.clientWidth;
}
if (ei !== 0) {
e_a.forEach(f => {
if (
f.$el.className.indexOf("nly-table-sticky-column-right") === -1
) {
f.$el.classList.add("nly-table-sticky-column-right");
}
if (f.$el.className.indexOf("nly-table-sticky-column") !== -1) {
f.$el.classList.remove("nly-table-sticky-column");
}
f.$el.style.right = `${this.customRight}px`;
});
this.customRight += e_a[0].$el.clientWidth;
}
// if (ei === this.computedFieldsRightRef.length - 1) {
// e_a.forEach(f => {
// if (f.$el.className.indexOf("elevation-left") === -1) {
// f.$el.classList.add("elevation-left");
// }
// });
// }
// customLeft += e_array[0].$el.clientWidth;
});
}
});
this.fixedDate();
},
computed: {
// Layout related computed props
Expand Down Expand Up @@ -225,6 +232,14 @@ export default {
};
}
},
watch: {
items: {
handler: function() {
this.fixedDate();
},
deep: true
}
},
render(h) {
const $content = [];

Expand Down

0 comments on commit 54e2cf7

Please sign in to comment.