Commit 93f05cc3 authored by tyn's avatar tyn

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

parent 4e409f63
......@@ -218,7 +218,10 @@ export default {
});
},
createSideBarWithServerData(value) {
this.sideRoute = JSON.parse(JSON.stringify(this.defaultRoute));
// server返回菜单统计数据
const _sideBarData = JSON.parse(JSON.stringify(value));
// {basic,behavior,business,combineMember,credit,evaluation,global,performance,personnel,qualification}
......@@ -229,11 +232,13 @@ export default {
_tempMap.forEach((value, key, mapOrigin) => {
// 找到对应的数据源
const data = this.findDataOrigin(this.statisticObj, key);
const sideBarOption = this.findSideBarOptions(this.sideRoute, value);
const data = this.findDataOrigin(_sideBarData, key);
const sideBarOption = this.findSideBarOption(this.sideRoute, value);
// 禁用菜单
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 {
},
// 找菜单对象
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) {
......
......@@ -229,28 +229,25 @@ export default {
}
}
},
beforeRouteLeave(to, from, next) {
next(vm => {
});
created() {
this.init();
},
beforeRouteEnter(to, from, next) {
next(vm => {
});
mounted() {
},
created() {
methods: {
async init() {
try {
if (this.$route.params.id) { // 获取companyId
let companyId = this.$route.params.id;
this.getCompanyId(companyId);
await this.getCompanyId(companyId);
}
if (this.$route.query.path) { // 获取跳转对应板块
this.currentPath.pathName = this.$route.query.path;
}
} catch (error) {
console.log(error);
}
},
mounted() {
},
methods: {
showPartPage(e) {
this.currentPath = e;
},
......@@ -259,12 +256,11 @@ export default {
let { data } = await idRemark({ mark: companyId });
if (data) {
this.companyId = data;
this.$nextTick(() => {
await this.$nextTick();
this.listenSider();
});
this.getStatistic();
this.handleQuery();
this.association(this.$route.query.customerId);
await this.getStatistic();
await this.handleQuery();
await this.association(this.$route.query.customerId);
this.$refs.sidebar.financial(data);
}
},
......@@ -286,27 +282,21 @@ export default {
provinceIds: [this.companyInfo.provinceId],
cityIds: [this.companyInfo.cityId],
};
urbanInvestmentPage(data).then(res => {
if (res.code == 200) {
if (res.data.totalCount < 1) {
const result = await urbanInvestmentPage(data);
if (result.code == 200) {
if (result.data.totalCount < 1) {
let arr = JSON.parse(JSON.stringify(this.$refs.sidebar.sideRoute));
arr[4].children[2].disabled = true;
this.$refs.sidebar.sideRoute = arr;
}
}
});
if (this.companyInfo && this.companyInfo.companyName) {
this.$nextTick(() => {
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');
if (titlename) {
titlename.innerText = this.companyInfo.companyName;
}
// }
// })
});
}
}
......@@ -324,22 +314,21 @@ export default {
this.cooDetail = false;
},
// 判断客户是否关联显示修改
association(id) {
async association(id) {
if (id) {
customerInfo(id).then(res => {
try {
const res = await customerInfo(id);
if (res.code == 200) {
if (res.data.userId == this.$store.state.user.userId) {
this.$nextTick(() => {
await this.$nextTick();
this.customerInfo = res.data;
this.customerId = res.data.customerId;
});
if (res.data.companyId == this.companyId) {
this.$nextTick(() => {
await this.$nextTick();
this.isCustomer = true;
this.isCompany = true;
});
} else {
this.$nextTick(() => {
await this.$nextTick();
this.isCustomer = true;
this.isCompany = false;
this.currentPath.pathName = this.$route.query.path || 'business';
......@@ -347,37 +336,27 @@ export default {
companyName: this.customerInfo.companyName
};
document.getElementById('tagTitle').innerText = this.customerInfo.companyName;
// let lists = this.$store.state.tagsView.visitedViews
// lists.forEach(item=>{
// if(item.fullPath == this.$route.fullPath){
let titlename = document.getElementById('tagTitles');
if (titlename) {
titlename.innerText = this.customerInfo.companyName;
}
// }
// })
});
}
} else {
this.$nextTick(() => {
await this.$nextTick();
this.isCustomer = true;
this.isCompany = true;
this.currentPath.pathName = 'overview';
});
}
}
}).catch(err => {
this.$nextTick(() => {
} catch (err) {
await this.$nextTick();
this.currentPath.pathName = 'overview';
this.isCompany = true;
});
});
}
} else {
this.$nextTick(() => {
await this.$nextTick();
this.isCompany = true;
// this.currentPath.pathName = 'overview';
this.currentPath.pathName = this.$routes.query.path;
});
this.currentPath.pathName = 'overview';
}
},
......
......@@ -72,7 +72,7 @@ export default {
let res = await projectTenderDataGroup({ cid: this.companyId, type: this.activeIndex });
if (res.code == 200 && res.data) {
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 => {
let it = { name: item.name, value: item.value, percent: parseFloat(Number(Number(item.value) / Number(totalVal) * 100).toFixed(2)) };
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