项目信息管理头部优化

yfy
项洋 7 days ago
parent 5b5a72f378
commit 5674ab25f2

@ -289,6 +289,7 @@ export default {
}, },
projectRemarks: [], projectRemarks: [],
loading: false, loading: false,
scrollTimeout: null,
}; };
}, },
created() { created() {
@ -473,28 +474,34 @@ export default {
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}, },
handleScroll() { handleScroll() {
//
const container = document.querySelector(".containerbody"); const container = document.querySelector(".containerbody");
if (!container) return; if (!container) return;
if (this.scrollTimeout) {
// clearTimeout(this.scrollTimeout);
const scrollPosition = container.scrollTop; // }
this.scrollTimeout = setTimeout(() => {
// const scrollPosition = container.scrollTop;
for (let i = this.sections.length - 1; i >= 0; i--) { if (scrollPosition > this.lastScrollTop) {
const element = document.getElementById(this.sections[i].id); this.scrollDirection = 'down';
if (element) { } else {
// this.scrollDirection = 'up';
const elementPosition = element.offsetTop - container.offsetTop; }
this.lastScrollTop = scrollPosition;
if (elementPosition <= scrollPosition) { const offset = this.scrollDirection === 'down' ? 500 : 200;
if (this.activeSection !== this.sections[i].id) { const adjustedScrollPosition = scrollPosition + offset;
this.activeSection = this.sections[i].id; for (let i = this.sections.length - 1; i >= 0; i--) {
const element = document.getElementById(this.sections[i].id);
if (element) {
const elementPosition = element.offsetTop - container.offsetTop;
if (elementPosition <= adjustedScrollPosition) {
if (this.activeSection !== this.sections[i].id) {
this.activeSection = this.sections[i].id;
}
break;
} }
break;
} }
} }
} }, 50);
}, },
handleMenuClick() { handleMenuClick() {
if (this.$refs.menuRef) { if (this.$refs.menuRef) {

@ -200,7 +200,7 @@ export default {
{ id: "basic", label: "基本信息" }, { id: "basic", label: "基本信息" },
{ id: "programme", label: "规划信息" }, { id: "programme", label: "规划信息" },
{ id: "buildings", label: "建筑信息" }, { id: "buildings", label: "建筑信息" },
{ id: "models", label: "要素模型信息" }, { id: "models", label: "要素模型信息" },
{ id: "months", label: "月度进展信息" }, { id: "months", label: "月度进展信息" },
{ id: "companyenter", label: "企业入驻信息" }, { id: "companyenter", label: "企业入驻信息" },
{ id: "projectpicture", label: "项目画像" }, { id: "projectpicture", label: "项目画像" },
@ -213,6 +213,9 @@ export default {
projectId: null, projectId: null,
isContainerVisible: true, isContainerVisible: true,
isSubmitted: false, isSubmitted: false,
lastScrollTop: 0,
scrollDirection: 'down',
scrollTimeout: null,
basicInformation: { basicInformation: {
acceptanceTime: "", acceptanceTime: "",
begainTime: "", begainTime: "",
@ -282,10 +285,10 @@ export default {
}, },
projectRemarks: [], projectRemarks: [],
loading: false, loading: false,
scrollTimeout: null,
}; };
}, },
created() { created() {
// projectId
this.projectId = Number(this.$route.params.id); this.projectId = Number(this.$route.params.id);
this.loadData(); this.loadData();
this.action = this.$route.query.action; this.action = this.$route.query.action;
@ -296,8 +299,6 @@ export default {
if (container) { if (container) {
container.addEventListener("scroll", this.handleScroll); container.addEventListener("scroll", this.handleScroll);
} }
//
// document.addEventListener('click', this.handleGlobalClick);
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener("scroll", this.handleScroll); window.removeEventListener("scroll", this.handleScroll);
@ -305,8 +306,6 @@ export default {
if (container) { if (container) {
container.removeEventListener("scroll", this.handleScroll); container.removeEventListener("scroll", this.handleScroll);
} }
//
// document.removeEventListener('click', this.handleGlobalClick);
}, },
methods: { methods: {
checkPermi, checkPermi,
@ -348,30 +347,37 @@ export default {
this.$router.go(-1); this.$router.go(-1);
}, },
handleScroll() { handleScroll() {
//
const container = document.querySelector(".containerbody"); const container = document.querySelector(".containerbody");
if (!container) return; if (!container) return;
if (this.scrollTimeout) {
// clearTimeout(this.scrollTimeout);
const scrollPosition = container.scrollTop; // }
this.scrollTimeout = setTimeout(() => {
// const scrollPosition = container.scrollTop;
for (let i = this.sections.length - 1; i >= 0; i--) { if (scrollPosition > this.lastScrollTop) {
const element = document.getElementById(this.sections[i].id); this.scrollDirection = 'down';
if (element) { } else {
// this.scrollDirection = 'up';
const elementPosition = element.offsetTop - container.offsetTop; }
this.lastScrollTop = scrollPosition;
if (elementPosition <= scrollPosition) { const offset = this.scrollDirection === 'down' ? 500 : 200;
if (this.activeSection !== this.sections[i].id) { const adjustedScrollPosition = scrollPosition + offset;
this.activeSection = this.sections[i].id; for (let i = this.sections.length - 1; i >= 0; i--) {
const element = document.getElementById(this.sections[i].id);
if (element) {
const elementPosition = element.offsetTop - container.offsetTop;
if (elementPosition <= adjustedScrollPosition) {
if (this.activeSection !== this.sections[i].id) {
console.log(`切换到 ${this.sections[i].label},位置: ${elementPosition},偏移: ${offset}`);
this.activeSection = this.sections[i].id;
}
break;
} }
break;
} }
} }
} }, 50);
}, },
// //
handleDataUpdate(dataKey, updatedData) { handleDataUpdate(dataKey, updatedData) {
if (dataKey === "projectOtherInfos" || dataKey === "wysmxInformations") { if (dataKey === "projectOtherInfos" || dataKey === "wysmxInformations") {
if (Array.isArray(updatedData)) { if (Array.isArray(updatedData)) {

Loading…
Cancel
Save