Commit 93f05cc3 authored by tyn's avatar tyn

🎈 perf(企业详情左侧菜单 根据map映射动态生成,遗弃下标取值 方便后期维护):

parent 4e409f63
...@@ -218,7 +218,10 @@ export default { ...@@ -218,7 +218,10 @@ export default {
}); });
}, },
createSideBarWithServerData(value) { createSideBarWithServerData(value) {
this.sideRoute = JSON.parse(JSON.stringify(this.defaultRoute)); this.sideRoute = JSON.parse(JSON.stringify(this.defaultRoute));
// server返回菜单统计数据
const _sideBarData = JSON.parse(JSON.stringify(value)); const _sideBarData = JSON.parse(JSON.stringify(value));
// {basic,behavior,business,combineMember,credit,evaluation,global,performance,personnel,qualification} // {basic,behavior,business,combineMember,credit,evaluation,global,performance,personnel,qualification}
...@@ -229,11 +232,13 @@ export default { ...@@ -229,11 +232,13 @@ export default {
_tempMap.forEach((value, key, mapOrigin) => { _tempMap.forEach((value, key, mapOrigin) => {
// 找到对应的数据源 // 找到对应的数据源
const data = this.findDataOrigin(this.statisticObj, key); const data = this.findDataOrigin(_sideBarData, key);
const sideBarOption = this.findSideBarOptions(this.sideRoute, value); const sideBarOption = this.findSideBarOption(this.sideRoute, value);
// 禁用菜单 // 禁用菜单
if (data < 1) { if (data < 1) {
if (sideBarOption) {
sideBarOption instanceof Array ? sideBarOption.forEach(item => this.$set(item, "disabled", true)) : this.$set(sideBarOption, "disabled", true);
}
} }
}); });
...@@ -258,7 +263,26 @@ export default { ...@@ -258,7 +263,26 @@ export default {
}, },
// 找菜单对象 // 找菜单对象
findSideBarOption(sideBarData, key) { findSideBarOption(sideBarData, key) {
for (const iterator of sideBarData) {
if (iterator.pathName === key) {
return iterator;
}
// map的值是数组的情况
if (key instanceof Array) {
const _tempArray = [];
key.forEach(item => {
// 找到数组中的每一个菜单对象
const itemNode = this.findSideBarOption(sideBarData, item);
if (itemNode) _tempArray.push(itemNode);
});
if (_tempArray.length == key.length) return _tempArray;
}
// 有children 递归处理
if (iterator?.children?.length) {
const _result = this.findSideBarOption(iterator?.children, key);
if (_result) return _result;
}
}
}, },
handleOpen(key, keyPath) { handleOpen(key, keyPath) {
......
...@@ -229,28 +229,25 @@ export default { ...@@ -229,28 +229,25 @@ export default {
} }
} }
}, },
beforeRouteLeave(to, from, next) {
next(vm => {
});
},
beforeRouteEnter(to, from, next) {
next(vm => {
});
},
created() { created() {
if (this.$route.params.id) { // 获取companyId this.init();
let companyId = this.$route.params.id;
this.getCompanyId(companyId);
}
if (this.$route.query.path) { // 获取跳转对应板块
this.currentPath.pathName = this.$route.query.path;
}
}, },
mounted() { mounted() {
}, },
methods: { methods: {
async init() {
try {
if (this.$route.params.id) { // 获取companyId
let companyId = this.$route.params.id;
await this.getCompanyId(companyId);
}
if (this.$route.query.path) { // 获取跳转对应板块
this.currentPath.pathName = this.$route.query.path;
}
} catch (error) {
console.log(error);
}
},
showPartPage(e) { showPartPage(e) {
this.currentPath = e; this.currentPath = e;
}, },
...@@ -259,12 +256,11 @@ export default { ...@@ -259,12 +256,11 @@ export default {
let { data } = await idRemark({ mark: companyId }); let { data } = await idRemark({ mark: companyId });
if (data) { if (data) {
this.companyId = data; this.companyId = data;
this.$nextTick(() => { await this.$nextTick();
this.listenSider(); this.listenSider();
}); await this.getStatistic();
this.getStatistic(); await this.handleQuery();
this.handleQuery(); await this.association(this.$route.query.customerId);
this.association(this.$route.query.customerId);
this.$refs.sidebar.financial(data); this.$refs.sidebar.financial(data);
} }
}, },
...@@ -286,27 +282,21 @@ export default { ...@@ -286,27 +282,21 @@ export default {
provinceIds: [this.companyInfo.provinceId], provinceIds: [this.companyInfo.provinceId],
cityIds: [this.companyInfo.cityId], cityIds: [this.companyInfo.cityId],
}; };
urbanInvestmentPage(data).then(res => { const result = await urbanInvestmentPage(data);
if (res.code == 200) { if (result.code == 200) {
if (res.data.totalCount < 1) { if (result.data.totalCount < 1) {
let arr = JSON.parse(JSON.stringify(this.$refs.sidebar.sideRoute)); let arr = JSON.parse(JSON.stringify(this.$refs.sidebar.sideRoute));
arr[4].children[2].disabled = true; arr[4].children[2].disabled = true;
this.$refs.sidebar.sideRoute = arr; this.$refs.sidebar.sideRoute = arr;
}
} }
}); }
if (this.companyInfo && this.companyInfo.companyName) { if (this.companyInfo && this.companyInfo.companyName) {
this.$nextTick(() => { this.$nextTick(() => {
document.getElementById('tagTitle').innerText = this.companyInfo.companyName; document.getElementById('tagTitle').innerText = this.companyInfo.companyName;
// let lists = this.$store.state.tagsView.visitedViews
// lists.forEach(item=>{
// if(item.fullPath == this.$route.fullPath){
let titlename = document.getElementById('tagTitles'); let titlename = document.getElementById('tagTitles');
if (titlename) { if (titlename) {
titlename.innerText = this.companyInfo.companyName; titlename.innerText = this.companyInfo.companyName;
} }
// }
// })
}); });
} }
} }
...@@ -324,60 +314,49 @@ export default { ...@@ -324,60 +314,49 @@ export default {
this.cooDetail = false; this.cooDetail = false;
}, },
// 判断客户是否关联显示修改 // 判断客户是否关联显示修改
association(id) { async association(id) {
if (id) { if (id) {
customerInfo(id).then(res => { try {
const res = await customerInfo(id);
if (res.code == 200) { if (res.code == 200) {
if (res.data.userId == this.$store.state.user.userId) { if (res.data.userId == this.$store.state.user.userId) {
this.$nextTick(() => { await this.$nextTick();
this.customerInfo = res.data; this.customerInfo = res.data;
this.customerId = res.data.customerId; this.customerId = res.data.customerId;
});
if (res.data.companyId == this.companyId) { if (res.data.companyId == this.companyId) {
this.$nextTick(() => { await this.$nextTick();
this.isCustomer = true; this.isCustomer = true;
this.isCompany = true; this.isCompany = true;
});
} else { } else {
this.$nextTick(() => { await this.$nextTick();
this.isCustomer = true; this.isCustomer = true;
this.isCompany = false; this.isCompany = false;
this.currentPath.pathName = this.$route.query.path || 'business'; this.currentPath.pathName = this.$route.query.path || 'business';
this.companyInfo = { this.companyInfo = {
companyName: this.customerInfo.companyName companyName: this.customerInfo.companyName
}; };
document.getElementById('tagTitle').innerText = this.customerInfo.companyName; document.getElementById('tagTitle').innerText = this.customerInfo.companyName;
// let lists = this.$store.state.tagsView.visitedViews let titlename = document.getElementById('tagTitles');
// lists.forEach(item=>{ if (titlename) {
// if(item.fullPath == this.$route.fullPath){ titlename.innerText = this.customerInfo.companyName;
let titlename = document.getElementById('tagTitles'); }
if (titlename) {
titlename.innerText = this.customerInfo.companyName;
}
// }
// })
});
} }
} else { } else {
this.$nextTick(() => { await this.$nextTick();
this.isCustomer = true; this.isCustomer = true;
this.isCompany = true; this.isCompany = true;
this.currentPath.pathName = 'overview'; this.currentPath.pathName = 'overview';
});
} }
} }
}).catch(err => { } catch (err) {
this.$nextTick(() => { await this.$nextTick();
this.currentPath.pathName = 'overview'; this.currentPath.pathName = 'overview';
this.isCompany = true;
});
});
} else {
this.$nextTick(() => {
this.isCompany = true; this.isCompany = true;
// this.currentPath.pathName = 'overview'; }
this.currentPath.pathName = this.$routes.query.path; } else {
}); await this.$nextTick();
this.isCompany = true;
this.currentPath.pathName = 'overview';
} }
}, },
......
...@@ -72,7 +72,7 @@ export default { ...@@ -72,7 +72,7 @@ export default {
let res = await projectTenderDataGroup({ cid: this.companyId, type: this.activeIndex }); let res = await projectTenderDataGroup({ cid: this.companyId, type: this.activeIndex });
if (res.code == 200 && res.data) { if (res.code == 200 && res.data) {
this.isSkeleton = false; this.isSkeleton = false;
let data = res.data, totalVal = data.map(item => item.value).reduce((prev, cur) => prev + cur); let data = res.data, totalVal = data.map(item => item.value).reduce((prev, cur) => {prev + cur},0);
this.viewData = data.map(item => { this.viewData = data.map(item => {
let it = { name: item.name, value: item.value, percent: parseFloat(Number(Number(item.value) / Number(totalVal) * 100).toFixed(2)) }; let it = { name: item.name, value: item.value, percent: parseFloat(Number(Number(item.value) / Number(totalVal) * 100).toFixed(2)) };
return it; return it;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment