ProjectInfo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <transition
  3. appear
  4. name="animate__animated"
  5. enter-active-class="animate__slideInRight"
  6. leave-active-class="animate__slideOutRight"
  7. >
  8. <div class="widget-ProjectInfo" v-if="show">
  9. <div class="head">
  10. <div class="title">
  11. <div class="icon"></div>
  12. <span class="site-info">项目情况</span>
  13. <div class="tab-list">
  14. <div class="tab-item" :class="{ 'tab-active': currentActive == 'num' }" @click="currentActive = 'num'">
  15. 按数量统计
  16. </div>
  17. <div class="tab-item" :class="{ 'tab-active': currentActive == 'money' }" @click="currentActive = 'money'">
  18. 按金额统计
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="content-info">
  24. <div class="content-item">
  25. <div class="title">
  26. <div class="icon"></div>
  27. <span class="item-name">项目状态统计</span>
  28. </div>
  29. <div class="content statusContent">
  30. <div class="statusItem" v-for="item of statusList" :key="item.title">
  31. <div class="chart">
  32. <ComAnimateChart :img="item.img" :fontSize="fontSize" />
  33. </div>
  34. <div class="statusInfo">
  35. <div class="value">{{ item.value + item.unit }}</div>
  36. <div class="name">{{ item.title }}</div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="content-item">
  42. <div class="title">
  43. <div class="icon"></div>
  44. <span class="item-name">分公司项目统计</span>
  45. </div>
  46. <div class="content">
  47. <ComStatisticPieChart v-on="{ fontSize }" :chartData="branchData" />
  48. </div>
  49. </div>
  50. <div class="content-item">
  51. <div class="title">
  52. <div class="icon"></div>
  53. <span class="item-name">项目投资排行榜</span>
  54. </div>
  55. <div class="content scrollContent" ref="scrollContent">
  56. <ComBarChart v-on="{ fontSize }" :chartData="projectData" />
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </transition>
  62. </template>
  63. <script>
  64. import { getRequestResult } from '@/views/groupPage/apis'
  65. import { setNullAndUndefinedEmpty, fontSize as fs } from '@/views/groupPage/util'
  66. import ComAnimateChart from '@/views/groupPage/components/OthersChart/ComAnimateChart.vue'
  67. import ComStatisticPieChart from '@/views/groupPage/components/PieChart/ComStatisticPieChart.vue'
  68. import ComBarChart from '@/views/groupPage/components/BarChart/ComBarChart.vue'
  69. export default {
  70. name: 'ProjectInfo', //项目情况
  71. components: {
  72. ComAnimateChart,
  73. ComStatisticPieChart,
  74. ComBarChart
  75. },
  76. props: {
  77. show: {}
  78. },
  79. data() {
  80. return {
  81. statusList: [
  82. { title: '前期项目', value: 11, unit: '个', img: require('@/views/groupPage/images/模块图标/前期项目.png') },
  83. { title: '建设项目', value: 10, unit: '个', img: require('@/views/groupPage/images/模块图标/建设项目.png') },
  84. { title: '暂停项目', value: 1, unit: '个', img: require('@/views/groupPage/images/模块图标/暂停项目.png') },
  85. { title: '移交项目', value: 0, unit: '个', img: require('@/views/groupPage/images/模块图标/移交项目.png') }
  86. ],
  87. currentActive: 'num',
  88. branchData: [
  89. {
  90. name: '三峡分公司',
  91. value: 0
  92. },
  93. {
  94. name: '重庆分公司',
  95. value: 0
  96. },
  97. {
  98. name: '上海分公司',
  99. value: 0
  100. }
  101. ],
  102. projectData: {
  103. province: [],
  104. projectName: [],
  105. investment: []
  106. }
  107. }
  108. },
  109. watch: {
  110. show(n, o) {}
  111. },
  112. computed: {
  113. setNoNull() {
  114. return setNullAndUndefinedEmpty
  115. },
  116. fontSize() {
  117. return fs
  118. }
  119. },
  120. mounted() {
  121. this.tableScroll()
  122. this.getPageData()
  123. },
  124. methods: {
  125. tableScroll() {
  126. const that = this
  127. const area = this.$refs.scrollContent
  128. // 拿到元素后,对元素进行定时增加距离顶部距离,实现滚动效果(此配置为每100毫秒移动1像素)
  129. area.scrollTop = 0
  130. function scrollUp() {
  131. if (area.scrollTop >= area.scrollHeight - area.offsetHeight) {
  132. area.scrollTop = 0
  133. } else {
  134. area.scrollTop++
  135. }
  136. }
  137. if (!this.hasScroll) {
  138. this.hasScroll = true
  139. let time = 50
  140. this.setAnimationFrame(scrollUp, time)
  141. area.onmouseover = function () {
  142. cancelAnimationFrame(that.timerId)
  143. }
  144. area.onmouseout = function () {
  145. that.setAnimationFrame(scrollUp, time)
  146. }
  147. }
  148. },
  149. //使用requestAnimationFrame重写setInterval,进行性能优化
  150. setAnimationFrame(render, time) {
  151. //当前执行时间
  152. var nowTime = 0
  153. //记录每次动画执行结束的时间
  154. var lastTime = Date.now()
  155. //我们自己定义的动画时间差值
  156. var diffTime = time
  157. //当前requestAnimationFrame的id
  158. //此处使用对象,对象存储在地址空间,函数内部更新了对象的值,函数外部也可以接收到
  159. var that = this
  160. function animloop() {
  161. //记录当前时间
  162. nowTime = Date.now()
  163. if (nowTime - lastTime > diffTime) {
  164. lastTime = nowTime
  165. render()
  166. }
  167. //timerid为数字
  168. that.timerId = requestAnimationFrame(animloop)
  169. }
  170. animloop()
  171. },
  172. roundFun(value, n) {
  173. return Math.round(value * Math.pow(10, n)) / Math.pow(10, n)
  174. },
  175. getPageData() {
  176. let data = { blockCode: 'ycepclist' }
  177. //获取全部数据
  178. getRequestResult(data)
  179. .then((res) => {
  180. res = res.map((item) => {
  181. return {
  182. ...item,
  183. indexValue:
  184. item.unit === '万元'
  185. ? this.roundFun(this.setNoNull(item.indexValue) / 10000, 2)
  186. : this.setNoNull(item.indexValue)
  187. }
  188. })
  189. this.statusList[0].value = res.filter((item) => item.indexCode === 'A33')[0].indexValue
  190. this.statusList[1].value = res.filter((item) => item.indexCode === 'A34')[0].indexValue
  191. this.statusList[2].value = res.filter((item) => item.indexCode === 'A35')[0].indexValue
  192. this.statusList[3].value = res.filter((item) => item.indexCode === 'A36')[0].indexValue
  193. //
  194. this.branchData[0].value = res.filter((item) => item.indexCode === 'A37')[0].indexValue
  195. this.branchData[1].value = res.filter((item) => item.indexCode === 'A38')[0].indexValue
  196. this.branchData[2].value = res.filter((item) => item.indexCode === 'A39')[0].indexValue
  197. })
  198. .then(() => {
  199. let data = { blockCode: 'prjInfo' }
  200. //获取全部数据
  201. getRequestResult(data).then((res) => {
  202. res.sort((a, b) => {
  203. return a.planInvestment - b.planInvestment
  204. }) //升序
  205. res.forEach((item) => {
  206. this.projectData.province.push(item.province.substring(0, 2))
  207. this.projectData.projectName.push(item.prjName)
  208. this.projectData.investment.push(this.roundFun(this.setNoNull(item.planInvestment), 2))
  209. })
  210. })
  211. })
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang='scss' scoped>
  217. .animate__slideInRight,
  218. .animate__slideOutRight {
  219. animation-duration: 3s; //动画持续时间
  220. animation-delay: 0s; //动画延迟时间
  221. }
  222. .widget-ProjectInfo {
  223. $size10: 0.052083rem /* 10/192 */;
  224. $size20: 0.104167rem /* 20/192 */;
  225. z-index: 2;
  226. //position
  227. bottom: $size10 /* 10/192 */;
  228. margin-right: $size20 /* 20/192 */;
  229. right: 0;
  230. position: absolute;
  231. //size
  232. height: calc(100% - 0.557292rem /* 107/192 */);
  233. width: 2.083333rem /* 400/192 */;
  234. //background
  235. // background-color: rgba(20, 24, 47, 0.5);
  236. color: #eee;
  237. // box-shadow: 0 0 20px rgba(1, 9, 20, 1);
  238. //font
  239. font-family: Source Han Sans CN-HEAVY;
  240. .head {
  241. height: 0.166667rem /* 32/192 */;
  242. width: 100%;
  243. background: linear-gradient(-90deg, rgba(43, 167, 255, 0.2) 0%, rgba(43, 167, 255, 0.08) 100%);
  244. .title {
  245. width: 100%;
  246. height: 100%;
  247. display: flex;
  248. font-weight: 400;
  249. .icon {
  250. height: 0.166667rem /* 32/192 */;
  251. width: 0.34375rem /* 66/192 */;
  252. background: url('~@/views/groupPage/images/模块图标/项目情况.png') no-repeat center center;
  253. background-size: 100% 100%;
  254. }
  255. span {
  256. font-weight: bold;
  257. font-size: 0.083333rem /* 16/192 */;
  258. color: #ffffff;
  259. padding: 0.041667rem /* 8/192 */;
  260. background: linear-gradient(0deg, #9bd2fa 0%, #ffffff 100%);
  261. background-clip: text;
  262. -webkit-text-fill-color: transparent;
  263. flex: 0.5;
  264. }
  265. .tab-list {
  266. display: flex;
  267. align-items: center;
  268. justify-content: space-around;
  269. width: 0.78125rem /* 150/192 */;
  270. flex: 0.5;
  271. font-family: Source Han Sans CN;
  272. font-size: 0.072917rem /* 14/192 */;
  273. font-weight: 400;
  274. .tab-item {
  275. cursor: pointer;
  276. height: 100%;
  277. display: flex;
  278. align-items: center;
  279. white-space: nowrap;
  280. overflow: hidden;
  281. text-overflow: ellipsis;
  282. }
  283. .tab-active {
  284. color: #119cff;
  285. border-bottom: 3px solid;
  286. border-image: linear-gradient(0deg, rgba(17, 156, 255, 0.9) 0%, rgba(17, 156, 255, 0.02) 3%) 1;
  287. }
  288. }
  289. }
  290. }
  291. .content-info {
  292. width: 100%;
  293. height: calc(100% - 0.166667rem);
  294. overflow: auto;
  295. padding: 2px;
  296. .content-item {
  297. font-family: Source Han Sans CN-Medium;
  298. width: 100%;
  299. height: 33%;
  300. float: left;
  301. overflow: hidden;
  302. .title {
  303. width: 100%;
  304. display: flex;
  305. // padding: .145833rem 0 .104167rem 0;
  306. padding: 0.145833rem 0 0.026042rem /* 5/192 */ 0;
  307. .icon {
  308. height: 0.072917rem /* 14/192 */;
  309. width: 0.078125rem /* 15/192 */;
  310. margin-right: 0.046875rem /* 9/192 */;
  311. background: url('~@/views/groupPage/images/三角.png') no-repeat center center;
  312. background-size: 100% 100%;
  313. }
  314. .item-name {
  315. color: #ffffff;
  316. font-size: 0.072917rem /* 14/192 */;
  317. font-weight: 500;
  318. }
  319. .item-info {
  320. color: #2ba7ff;
  321. font-size: 0.072917rem /* 14/192 */;
  322. font-weight: 500;
  323. }
  324. }
  325. .content {
  326. height: calc(100% - 0.234375rem /* 45/192 */);
  327. width: 100%;
  328. }
  329. .scrollContent {
  330. overflow: hidden;
  331. }
  332. .statusContent {
  333. display: grid;
  334. grid-template-columns: 1fr 1fr; //有几列
  335. grid-template-rows: 50% 50%; //有几行
  336. grid-gap: 0.104167rem /* 20/192 */;
  337. padding: 0.15625rem /* 30/192 */ 0.052083rem /* 10/192 */;
  338. .statusItem {
  339. width: 100%;
  340. height: 100%;
  341. display: flex;
  342. align-items: center;
  343. .chart {
  344. flex: 0.3;
  345. height: 100%;
  346. }
  347. .statusInfo {
  348. height: 80%;
  349. flex: 0.7;
  350. display: flex;
  351. flex-flow: column;
  352. align-items: center;
  353. justify-content: center;
  354. margin-left: -15%;
  355. background-image: radial-gradient(circle at -10% 50%, transparent 30%, rgba(43, 167, 255, 0.16) 21px);
  356. .value,
  357. .name {
  358. height: 50%;
  359. width: 100%;
  360. display: flex;
  361. align-items: center;
  362. justify-content: center;
  363. font-family: Source Han Sans CN;
  364. }
  365. .value {
  366. font-size: 0.083333rem /* 16/192 */;
  367. font-weight: bold;
  368. color: #ffffff;
  369. text-shadow: 0px 3px 8px rgba(3, 15, 32, 0.6);
  370. }
  371. .name {
  372. font-size: 0.072917rem /* 14/192 */;
  373. font-weight: 400;
  374. color: #2ba7ff;
  375. }
  376. }
  377. }
  378. }
  379. }
  380. }
  381. }
  382. </style>