| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <template>
- <transition
- appear
- name="animate__animated"
- enter-active-class="animate__slideInRight"
- leave-active-class="animate__slideOutRight"
- >
- <div class="widget-ProjectInfo" v-if="show">
- <div class="head">
- <div class="title">
- <div class="icon"></div>
- <span class="site-info">项目情况</span>
- <div class="tab-list">
- <div class="tab-item" :class="{ 'tab-active': currentActive == 'num' }" @click="currentActive = 'num'">
- 按数量统计
- </div>
- <div class="tab-item" :class="{ 'tab-active': currentActive == 'money' }" @click="currentActive = 'money'">
- 按金额统计
- </div>
- </div>
- </div>
- </div>
- <div class="content-info">
- <div class="content-item">
- <div class="title">
- <div class="icon"></div>
- <span class="item-name">项目状态统计</span>
- </div>
- <div class="content statusContent">
- <div class="statusItem" v-for="item of statusList" :key="item.title">
- <div class="chart">
- <ComAnimateChart :img="item.img" :fontSize="fontSize" />
- </div>
- <div class="statusInfo">
- <div class="value">{{ item.value + item.unit }}</div>
- <div class="name">{{ item.title }}</div>
- </div>
- </div>
- </div>
- </div>
- <div class="content-item">
- <div class="title">
- <div class="icon"></div>
- <span class="item-name">分公司项目统计</span>
- </div>
- <div class="content">
- <ComStatisticPieChart v-on="{ fontSize }" :chartData="branchData" />
- </div>
- </div>
- <div class="content-item">
- <div class="title">
- <div class="icon"></div>
- <span class="item-name">项目投资排行榜</span>
- </div>
- <div class="content scrollContent" ref="scrollContent">
- <ComBarChart v-on="{ fontSize }" :chartData="projectData" />
- </div>
- </div>
- </div>
- </div>
- </transition>
- </template>
- <script>
- import { getRequestResult } from '@/views/groupPage/apis'
- import { setNullAndUndefinedEmpty, fontSize as fs } from '@/views/groupPage/util'
- import ComAnimateChart from '@/views/groupPage/components/OthersChart/ComAnimateChart.vue'
- import ComStatisticPieChart from '@/views/groupPage/components/PieChart/ComStatisticPieChart.vue'
- import ComBarChart from '@/views/groupPage/components/BarChart/ComBarChart.vue'
- export default {
- name: 'ProjectInfo', //项目情况
- components: {
- ComAnimateChart,
- ComStatisticPieChart,
- ComBarChart
- },
- props: {
- show: {}
- },
- data() {
- return {
- statusList: [
- { title: '前期项目', value: 11, unit: '个', img: require('@/views/groupPage/images/模块图标/前期项目.png') },
- { title: '建设项目', value: 10, unit: '个', img: require('@/views/groupPage/images/模块图标/建设项目.png') },
- { title: '暂停项目', value: 1, unit: '个', img: require('@/views/groupPage/images/模块图标/暂停项目.png') },
- { title: '移交项目', value: 0, unit: '个', img: require('@/views/groupPage/images/模块图标/移交项目.png') }
- ],
- currentActive: 'num',
- branchData: [
- {
- name: '三峡分公司',
- value: 0
- },
- {
- name: '重庆分公司',
- value: 0
- },
- {
- name: '上海分公司',
- value: 0
- }
- ],
- projectData: {
- province: [],
- projectName: [],
- investment: []
- }
- }
- },
- watch: {
- show(n, o) {}
- },
- computed: {
- setNoNull() {
- return setNullAndUndefinedEmpty
- },
- fontSize() {
- return fs
- }
- },
- mounted() {
- this.tableScroll()
- this.getPageData()
- },
- methods: {
- tableScroll() {
- const that = this
- const area = this.$refs.scrollContent
- // 拿到元素后,对元素进行定时增加距离顶部距离,实现滚动效果(此配置为每100毫秒移动1像素)
- area.scrollTop = 0
- function scrollUp() {
- if (area.scrollTop >= area.scrollHeight - area.offsetHeight) {
- area.scrollTop = 0
- } else {
- area.scrollTop++
- }
- }
- if (!this.hasScroll) {
- this.hasScroll = true
- let time = 50
- this.setAnimationFrame(scrollUp, time)
- area.onmouseover = function () {
- cancelAnimationFrame(that.timerId)
- }
- area.onmouseout = function () {
- that.setAnimationFrame(scrollUp, time)
- }
- }
- },
- //使用requestAnimationFrame重写setInterval,进行性能优化
- setAnimationFrame(render, time) {
- //当前执行时间
- var nowTime = 0
- //记录每次动画执行结束的时间
- var lastTime = Date.now()
- //我们自己定义的动画时间差值
- var diffTime = time
- //当前requestAnimationFrame的id
- //此处使用对象,对象存储在地址空间,函数内部更新了对象的值,函数外部也可以接收到
- var that = this
- function animloop() {
- //记录当前时间
- nowTime = Date.now()
- if (nowTime - lastTime > diffTime) {
- lastTime = nowTime
- render()
- }
- //timerid为数字
- that.timerId = requestAnimationFrame(animloop)
- }
- animloop()
- },
- roundFun(value, n) {
- return Math.round(value * Math.pow(10, n)) / Math.pow(10, n)
- },
- getPageData() {
- let data = { blockCode: 'ycepclist' }
- //获取全部数据
- getRequestResult(data)
- .then((res) => {
- res = res.map((item) => {
- return {
- ...item,
- indexValue:
- item.unit === '万元'
- ? this.roundFun(this.setNoNull(item.indexValue) / 10000, 2)
- : this.setNoNull(item.indexValue)
- }
- })
- this.statusList[0].value = res.filter((item) => item.indexCode === 'A33')[0].indexValue
- this.statusList[1].value = res.filter((item) => item.indexCode === 'A34')[0].indexValue
- this.statusList[2].value = res.filter((item) => item.indexCode === 'A35')[0].indexValue
- this.statusList[3].value = res.filter((item) => item.indexCode === 'A36')[0].indexValue
- //
- this.branchData[0].value = res.filter((item) => item.indexCode === 'A37')[0].indexValue
- this.branchData[1].value = res.filter((item) => item.indexCode === 'A38')[0].indexValue
- this.branchData[2].value = res.filter((item) => item.indexCode === 'A39')[0].indexValue
- })
- .then(() => {
- let data = { blockCode: 'prjInfo' }
- //获取全部数据
- getRequestResult(data).then((res) => {
- res.sort((a, b) => {
- return a.planInvestment - b.planInvestment
- }) //升序
- res.forEach((item) => {
- this.projectData.province.push(item.province.substring(0, 2))
- this.projectData.projectName.push(item.prjName)
- this.projectData.investment.push(this.roundFun(this.setNoNull(item.planInvestment), 2))
- })
- })
- })
- }
- }
- }
- </script>
- <style lang='scss' scoped>
- .animate__slideInRight,
- .animate__slideOutRight {
- animation-duration: 3s; //动画持续时间
- animation-delay: 0s; //动画延迟时间
- }
- .widget-ProjectInfo {
- $size10: 0.052083rem /* 10/192 */;
- $size20: 0.104167rem /* 20/192 */;
- z-index: 2;
- //position
- bottom: $size10 /* 10/192 */;
- margin-right: $size20 /* 20/192 */;
- right: 0;
- position: absolute;
- //size
- height: calc(100% - 0.557292rem /* 107/192 */);
- width: 2.083333rem /* 400/192 */;
- //background
- // background-color: rgba(20, 24, 47, 0.5);
- color: #eee;
- // box-shadow: 0 0 20px rgba(1, 9, 20, 1);
- //font
- font-family: Source Han Sans CN-HEAVY;
- .head {
- height: 0.166667rem /* 32/192 */;
- width: 100%;
- background: linear-gradient(-90deg, rgba(43, 167, 255, 0.2) 0%, rgba(43, 167, 255, 0.08) 100%);
- .title {
- width: 100%;
- height: 100%;
- display: flex;
- font-weight: 400;
- .icon {
- height: 0.166667rem /* 32/192 */;
- width: 0.34375rem /* 66/192 */;
- background: url('~@/views/groupPage/images/模块图标/项目情况.png') no-repeat center center;
- background-size: 100% 100%;
- }
- span {
- font-weight: bold;
- font-size: 0.083333rem /* 16/192 */;
- color: #ffffff;
- padding: 0.041667rem /* 8/192 */;
- background: linear-gradient(0deg, #9bd2fa 0%, #ffffff 100%);
- background-clip: text;
- -webkit-text-fill-color: transparent;
- flex: 0.5;
- }
- .tab-list {
- display: flex;
- align-items: center;
- justify-content: space-around;
- width: 0.78125rem /* 150/192 */;
- flex: 0.5;
- font-family: Source Han Sans CN;
- font-size: 0.072917rem /* 14/192 */;
- font-weight: 400;
- .tab-item {
- cursor: pointer;
- height: 100%;
- display: flex;
- align-items: center;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .tab-active {
- color: #119cff;
- border-bottom: 3px solid;
- border-image: linear-gradient(0deg, rgba(17, 156, 255, 0.9) 0%, rgba(17, 156, 255, 0.02) 3%) 1;
- }
- }
- }
- }
- .content-info {
- width: 100%;
- height: calc(100% - 0.166667rem);
- overflow: auto;
- padding: 2px;
- .content-item {
- font-family: Source Han Sans CN-Medium;
- width: 100%;
- height: 33%;
- float: left;
- overflow: hidden;
- .title {
- width: 100%;
- display: flex;
- // padding: .145833rem 0 .104167rem 0;
- padding: 0.145833rem 0 0.026042rem /* 5/192 */ 0;
- .icon {
- height: 0.072917rem /* 14/192 */;
- width: 0.078125rem /* 15/192 */;
- margin-right: 0.046875rem /* 9/192 */;
- background: url('~@/views/groupPage/images/三角.png') no-repeat center center;
- background-size: 100% 100%;
- }
- .item-name {
- color: #ffffff;
- font-size: 0.072917rem /* 14/192 */;
- font-weight: 500;
- }
- .item-info {
- color: #2ba7ff;
- font-size: 0.072917rem /* 14/192 */;
- font-weight: 500;
- }
- }
- .content {
- height: calc(100% - 0.234375rem /* 45/192 */);
- width: 100%;
- }
- .scrollContent {
- overflow: hidden;
- }
- .statusContent {
- display: grid;
- grid-template-columns: 1fr 1fr; //有几列
- grid-template-rows: 50% 50%; //有几行
- grid-gap: 0.104167rem /* 20/192 */;
- padding: 0.15625rem /* 30/192 */ 0.052083rem /* 10/192 */;
- .statusItem {
- width: 100%;
- height: 100%;
- display: flex;
- align-items: center;
- .chart {
- flex: 0.3;
- height: 100%;
- }
- .statusInfo {
- height: 80%;
- flex: 0.7;
- display: flex;
- flex-flow: column;
- align-items: center;
- justify-content: center;
- margin-left: -15%;
- background-image: radial-gradient(circle at -10% 50%, transparent 30%, rgba(43, 167, 255, 0.16) 21px);
- .value,
- .name {
- height: 50%;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-family: Source Han Sans CN;
- }
- .value {
- font-size: 0.083333rem /* 16/192 */;
- font-weight: bold;
- color: #ffffff;
- text-shadow: 0px 3px 8px rgba(3, 15, 32, 0.6);
- }
- .name {
- font-size: 0.072917rem /* 14/192 */;
- font-weight: 400;
- color: #2ba7ff;
- }
- }
- }
- }
- }
- }
- }
- </style>
|