From edff6eef7b12bcd0b97c8d263695e5c7ca53ec2c Mon Sep 17 00:00:00 2001 From: haha Date: Sat, 12 Aug 2023 14:16:43 +0800 Subject: [PATCH] update code --- src/api/project/index.js | 68 +++++++++++- src/components/project-overview-chart.js | 11 +- src/components/rank-chart.js | 5 +- src/pages/index.vue | 132 ++++++++++++++++------- src/pages/projectProgress.vue | 65 ++++++----- 5 files changed, 205 insertions(+), 76 deletions(-) diff --git a/src/api/project/index.js b/src/api/project/index.js index 2ecc7e6..4126f8a 100644 --- a/src/api/project/index.js +++ b/src/api/project/index.js @@ -20,10 +20,70 @@ const getProgressProjects=()=>{ }) }; -export default{ - findProjectByDept, - getProjectBuildNode, - getProgressProjects +const groupByProjectCategory=(cb)=>{ + request({ + url:`bgscreen/project/groupByProjectCategory`, + method: 'get' + }).then(res=>{ + let objs=(res.data||[]).map(it=>{ + return { + id:it.deptName, + label:it.projectName, + schedule:it.projectSchedule, + cnt:it.deptId + } + }); + const getItems=(id,schedule)=>{ + let tmps=objs.filter(d=>d.id==id && d.schedule==schedule); + if(tmps.length>0){ + return tmps[0]; + } + return { + id:id,schedule:schedule,cnt:0 + } + } + let ret1= [getItems(1,1),getItems(1,2)]; + let ret2= [getItems(2,1),getItems(2,2)]; + let ret3= [getItems(3,1),getItems(3,2)]; + let rets= [ + ret1,ret2,ret3 + ]; + if(cb){ + cb(rets); + } + }); +}; + +const groupByCategory=(deptId,type)=>{ + return request({ + url: `bgscreen/project/groupByCategory`, + method: 'post', + data:{ + deptId:deptId, + id:type + } + }) +} + +const groupByLevel=(deptId,type)=>{ + return request({ + url: `bgscreen/project/groupByLevel`, + method: 'post', + data:{ + deptId:deptId, + id:type + } + }) +} + + +export default{ + findProjectByDept, + getProjectBuildNode, + getProgressProjects, + groupByProjectCategory, + groupByCategory, + groupByLevel } diff --git a/src/components/project-overview-chart.js b/src/components/project-overview-chart.js index 7c9d833..470c445 100644 --- a/src/components/project-overview-chart.js +++ b/src/components/project-overview-chart.js @@ -124,20 +124,23 @@ Vue.component("project-overview-chart", { title: { text: this.maintitle||total_datas, subtext: this.text, - x: "85", - y: "89", + textAlign:'center', + top:'top', + itemGap :10, textStyle: { color: "#0dd2fd", fontSize: 24, fontWeight: "bold", - align: "center", - width: "200px", + align: "center", }, subtextStyle: { color: "#a5b5f0", fontSize: 12, align: "center", }, + padding:[95,0,0,110], + left:'left' + }, tooltip: { trigger: 'item', diff --git a/src/components/rank-chart.js b/src/components/rank-chart.js index 28040b4..8ffe944 100644 --- a/src/components/rank-chart.js +++ b/src/components/rank-chart.js @@ -10,6 +10,9 @@ Vue.component("rank-chart", { height:{ type:Number }, + width:{ + type:Number + }, showval:{ type:Boolean, default:false @@ -119,7 +122,7 @@ Vue.component("rank-chart", { fontSize:'14', }, name: { - width: this.showval?280:300, + width: this.width?this.width:this.showval?280:300, color: '#c6d9fa', padding:[0,0,0,10], fontSize:'16', diff --git a/src/pages/index.vue b/src/pages/index.vue index 3830191..22d7e88 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -8,7 +8,7 @@
- +
@@ -29,7 +29,7 @@ :maintitle="overviewTotal" :legend-opt="legendOpt1" :typedata="typeDistributionData" :text="overviewText" :height="230"> - + @@ -75,13 +75,13 @@ + style="position: absolute;cursor: pointer;right: 13px;top: 12px;" @click="doShowDlg2">
-
在建项目 +
在建项目({{ getPrjCateCount(0) }})
-
拟建项目 +
拟建项目({{ getPrjCateCount(1) }})
-
前期项目 +
前期项目({{ getPrjCateCount(2) }})
@@ -302,10 +302,7 @@ export default { //原因类型分析 availabilityData: [ - { value: 7, prop: 42.9, text: '新区级' }, - { value: 9, prop: 22.9, text: '省级' }, - { value: 10, prop: 20, text: '市级' }, - { value: 39, prop: 14.2, text: '新城级' }, + ], overviewText: '项目数量', overviewTotal: 100, @@ -476,6 +473,9 @@ export default { ], warningTypeInterval: undefined, warningTypeIndex: 0, + projectCategory:[], + projectCategoryWidth:200, + deptInfo:{}, } }, created() { @@ -491,6 +491,10 @@ export default { this.investmentAmountData2[0].value = "" + res.onAccountAmount * 1.0; this.elKey++; }); + this.$bus.$on("deptChange",dept=>{ + this.deptInfo=dept; + this.onClickoOverview(0) + }); }, methods: { numberWithCommas(x) { @@ -509,14 +513,36 @@ export default { doShowDlg2() { this.$refs.dlg2.showDialog(this.prjProcessNav) }, + getPrjCateCount(n){ + if(this.projectCategory.length0){ + let sum=0; + tmps.forEach(d=>{ + sum+=d.cnt; + }) + return sum; + } + return 0; + }, init() { - + this.$api.project.groupByProjectCategory(datas=>{ + this.projectCategory=datas; + this.prjPrcessTotal=this.getPrjCateCount(0); + let item=this.projectCategory.length>0?this.projectCategory[0]:null; + this.prjPrcessData[0].value=item && item.length>0?item[0].cnt:0; + this.prjPrcessData[1].value=item && item.length>1?item[1].cnt:0; + this.elKey++; + }); + this.localStorage = JSON.parse(localStorage.getItem("data1")) //地图数据 this.chartMap() //设备概况点击事件定时器 - this.overviewInterval = setInterval(this.overviewClick, 5000); + //this.overviewInterval = setInterval(this.overviewClick, 5000); //重大节点预期预警 this.majorInterval = setInterval(this.timer, 5000); //正在发生 定时器 @@ -527,29 +553,11 @@ export default { doPrjProcess(n, text) { this.prjProcessNav = n; this.prjPrcessText = text; - if (n == 0) { - this.prjPrcessTotal = 100; - this.prjPrcessData = [ - { text: "正常推进项目", value: 13 }, - { text: "进度滞后项目", value: 22 }, - ] - } - if (n == 1) { - this.prjPrcessTotal = 90; - this.prjPrcessData = [ - { text: "规划中项目", value: 4 }, - { text: "审批中项目", value: 9 }, - { text: "设计中项目", value: 8 }, - ] - } - if (n == 2) { - this.prjPrcessTotal = 130; - this.prjPrcessData = [ - { text: "进度滞后项目", value: 0 }, - { text: "正常推进项目", value: 0 }, - - ] - } + this.prjPrcessTotal=this.getPrjCateCount(n); + let item=this.projectCategory.length>n?this.projectCategory[n]:null; + this.prjPrcessData[0].value=item && item.length>0?item[0].cnt:0; + this.prjPrcessData[1].value=item && item.length>1?item[1].cnt:0; + this.elKey++; }, //劳务人员概况 onWarningInfoNav(n, text) { @@ -591,19 +599,67 @@ export default { //设备概况点击事件 onClickoOverview(n) { this.overview = n + if (this.overview == 0) { - this.overviewTotal = 65; + this.projectCategoryWidth=290; this.overviewText = "项目数"; this.surveyUrlSb = 'images/survey_icon_1.png' + } else if (this.overview == 1) { - this.overviewTotal = 515.97; + this.projectCategoryWidth=210; this.overviewText = "项目总投资"; this.surveyUrlSb = 'images/survey_icon_2.png' + } else { - this.overviewTotal = 134.86; + this.projectCategoryWidth=210; this.overviewText = "项目年投资"; this.surveyUrlSb = 'images/survey_icon_3.png' } + this.$api.project.groupByCategory(this.deptInfo.id,n).then(d=>{ + let tmps=(d.data||[]).map(it=>{ + return { + id:it.id, + name:it.projectName, + value:it.deptId/10000.0 + } + }); + let sum=0; + tmps.forEach(it=>{ + sum+=it.value; + }) + this.overviewTotal=sum; + this.typeDistributionData=tmps; + this.elKey++; + }) + this.$api.project.groupByLevel(this.deptInfo.id,n).then(d=>{ + let tmps=(d.data||[]).map(it=>{ + return { + id:it.id, + text:it.projectName, + value:it.deptId/10000.0, + prop:0, + } + }); + let sum=0; + tmps.forEach(it=>{ + sum+=it.value; + }) + let total=0; + tmps.forEach((it,idx)=>{ + it.prop=sum==0?0:(it.value*100.0/sum).toFixed(1) + + if(idx0){ + it.prop=(100-total).toFixed(1); + } + } + }) + this.availabilityData=tmps; + this.elKey++; + }) + }, //地图数据 chartMap() { diff --git a/src/pages/projectProgress.vue b/src/pages/projectProgress.vue index dba0c39..f5b0d87 100644 --- a/src/pages/projectProgress.vue +++ b/src/pages/projectProgress.vue @@ -83,12 +83,12 @@ - +
-
在建项目(100)
-
拟建项目(20)
-
验收项目(10)
+
在建项目({{ getPrjCateCount(0) }})
+
拟建项目({{ getPrjCateCount(1) }})
+
前期项目({{ getPrjCateCount(2) }})
@@ -268,6 +268,7 @@ export default { }, data() { return { + elKey:0, //节点完成率 completionData:[ {name:"泾河新城荟锦坊二期",cnt:50,step:'施工阶段'}, @@ -282,8 +283,8 @@ export default { pushText:'在建项目', pushCount:35, pushData:[ - { text:"正常推进项目", value:13 }, - { text:"进度滞后项目", value:22 }, + { text:"正常推进项目", value:0 }, + { text:"进度滞后项目", value:1 }, ], costIndex:0, direction:'right', @@ -328,13 +329,13 @@ export default { prjInfo:{}, scheduleInfo:null, projects:[], - + projectCategory:[] } }, created() { this.init() }, - mounted() { + mounted() { this.$bus.$on("projectChange",res=>{ this.loadProjectConstructionProgress(); }); @@ -396,26 +397,12 @@ export default { doPushNav(n,t){ this.pushNav=n; this.pushText=t; - this.pushCount=[35,21,0][n]; this.pushUrl=['images/company_6.png','images/company_5.png','images/company_4.png'][n] - if(n==0){ - this.pushData=[ - { text:"正常推进项目", value:13 }, - { text:"进度滞后项目", value:22 } - ] - } - if(n==1){ - this.pushData=[ - { text:"正常推进项目", value:4 }, - { text:"进度滞后项目", value:17 } - ] - } - if(n==2){ - this.pushData=[ - { text:"正常推进项目", value:0 }, - { text:"进度滞后项目", value:0 } - ] - } + this.pushCount=this.getPrjCateCount(n); + let item=this.projectCategory.length>n?this.projectCategory[n]:null; + this.pushData[0].value=item && item.length>0?item[0].cnt:0; + this.pushData[1].value=item && item.length>1?item[1].cnt:0; + this.elKey++; }, modifyLeftBtn(){ this.direction = 'left' @@ -484,7 +471,20 @@ export default { planMouseout(){ this.planInterval=setInterval(this.manufacturingPlanRoll,5000); }, - + getPrjCateCount(n){ + if(this.projectCategory.length0){ + let sum=0; + tmps.forEach(d=>{ + sum+=d.cnt; + }) + return sum; + } + return 0; + }, init(){ if(localStorage.length == 0){ var company = {text:'城投公司',id:1,type:1} @@ -498,7 +498,14 @@ export default { this.localStorage1 = JSON.parse(localStorage.getItem("company")) this.localStorage2 = JSON.parse(localStorage.getItem("project")) } - + this.$api.project.groupByProjectCategory(datas=>{ + this.projectCategory=datas; + this.pushCount=this.getPrjCateCount(0); + let item=this.projectCategory.length>0?this.projectCategory[0]:null; + this.pushData[0].value=item && item.length>0?item[0].cnt:0; + this.pushData[1].value=item && item.length>1?item[1].cnt:0; + this.elKey++; + }); //设备概况点击事件定时器 this.overviewInterval = setInterval(this.overviewClick,5000); //重大节点预期预警