You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
6.4 KiB

  1. <template>
  2. <div class="d_cards">
  3. <div
  4. class="card-item"
  5. v-for="(card, i) in myData"
  6. :key="i"
  7. >
  8. <div class="card-header">
  9. <div class="card-header-left">{{ card.title }}</div>
  10. <div class="card-header-right">{{ '0' + (i + 1) }}</div>
  11. </div>
  12. <dv-charts class="ring-charts" :option="card.ring" />
  13. <div class="card-footer">
  14. <div class="card-footer-item">
  15. <div class="footer-title">总工作量</div>
  16. <div class="footer-detail">
  17. <dv-digital-flop :config="card.total" style="width:70%;height:35px;" />人月
  18. </div>
  19. </div>
  20. <div class="card-footer-item">
  21. <div class="footer-title">当前进度</div>
  22. <div class="footer-detail">
  23. <dv-digital-flop :config="card.num" style="width:70%;height:35px;" />%
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. name: 'Cards',
  33. props:['data'],
  34. computed:{
  35. myData(){
  36. if(this.data && this.data.length>0){
  37. var cards= this.data.map(i=>{
  38. var card=JSON.parse(JSON.stringify(this.cardConfig))
  39. card.title=i.productName
  40. card.total.number=[i.planWorkload/8/20];//累计工作量 人月
  41. card.num.number=[i.finishRate];//当前进度
  42. //资金占比
  43. card.ring.series[0].data[0].value=(i.planWorkload/i.totalPlanWorkload) //工作量占比
  44. return card
  45. });
  46. if(cards.length<5){
  47. var count=5-cards.length
  48. for(var i=0;i<count;i++){
  49. cards.push(this.cards[i]);
  50. }
  51. }
  52. return cards;
  53. }else{
  54. return this.cards;
  55. }
  56. }
  57. },
  58. data () {
  59. return {
  60. cards: [],
  61. cardConfig:{
  62. title: '',
  63. total: {
  64. number: [10],
  65. content: '{nt}',
  66. textAlign: 'right',
  67. style: {
  68. fill: '#ea6027',
  69. fontWeight: 'bold'
  70. }
  71. },
  72. num: {
  73. number: [20],
  74. content: '{nt}',
  75. textAlign: 'right',
  76. style: {
  77. fill: '#26fcd8',
  78. fontWeight: 'bold'
  79. }
  80. },
  81. ring: {
  82. series: [
  83. {
  84. type: 'gauge',
  85. startAngle: -Math.PI / 2,
  86. endAngle: Math.PI * 1.5,
  87. arcLineWidth: 13,
  88. radius: '80%',
  89. data: [
  90. { name: '工作量占比', value: 22 }
  91. ],
  92. axisLabel: {
  93. show: false
  94. },
  95. axisTick: {
  96. show: false
  97. },
  98. pointer: {
  99. show: false
  100. },
  101. backgroundArc: {
  102. style: {
  103. stroke: '#224590'
  104. }
  105. },
  106. details: {
  107. show: true,
  108. formatter: '工作量占比{value}%',
  109. style: {
  110. fill: '#1ed3e5',
  111. fontSize: 20
  112. }
  113. }
  114. }
  115. ],
  116. color: ['#03d3ec']
  117. }
  118. }
  119. }
  120. },
  121. methods: {
  122. createData () {
  123. const { randomExtend } = this
  124. const productNames=['商城','营销','项目管理工具','支付','智慧党建']
  125. this.cards = new Array(5).fill(0).map((foo, i) => ({
  126. title: productNames[i],
  127. total: {
  128. number: [randomExtend(90, 100)],
  129. content: '{nt}',
  130. textAlign: 'right',
  131. style: {
  132. fill: '#ea6027',
  133. fontWeight: 'bold'
  134. }
  135. },
  136. num: {
  137. number: [randomExtend(30, 60)],
  138. content: '{nt}',
  139. textAlign: 'right',
  140. style: {
  141. fill: '#26fcd8',
  142. fontWeight: 'bold'
  143. }
  144. },
  145. ring: {
  146. series: [
  147. {
  148. type: 'gauge',
  149. startAngle: -Math.PI / 2,
  150. endAngle: Math.PI * 1.5,
  151. arcLineWidth: 13,
  152. radius: '80%',
  153. data: [
  154. { name: '资金占比', value: randomExtend(40, 60) }
  155. ],
  156. axisLabel: {
  157. show: false
  158. },
  159. axisTick: {
  160. show: false
  161. },
  162. pointer: {
  163. show: false
  164. },
  165. backgroundArc: {
  166. style: {
  167. stroke: '#224590'
  168. }
  169. },
  170. details: {
  171. show: true,
  172. formatter: '资金占比{value}%',
  173. style: {
  174. fill: '#1ed3e5',
  175. fontSize: 20
  176. }
  177. }
  178. }
  179. ],
  180. color: ['#03d3ec']
  181. }
  182. }))
  183. },
  184. randomExtend (minNum, maxNum) {
  185. if (arguments.length === 1) {
  186. return parseInt(Math.random() * minNum + 1, 10)
  187. } else {
  188. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)
  189. }
  190. }
  191. },
  192. mounted () {
  193. const { createData } = this
  194. createData()
  195. setInterval(this.createData, 300)
  196. }
  197. }
  198. </script>
  199. <style lang="less">
  200. .d_cards {
  201. display: flex;
  202. width: 100%;
  203. justify-content: space-between;
  204. height: 100%;
  205. margin-left: 15px;
  206. margin-top: 10px;
  207. .card-item {
  208. background-color: rgba(6, 30, 93, 0.5);
  209. border-top: 2px solid rgba(1, 153, 209, .5);
  210. width: 19%;
  211. display: flex;
  212. flex-direction: column;
  213. justify-content: space-around;
  214. }
  215. .card-header {
  216. display: flex;
  217. height: 20%;
  218. align-items: center;
  219. justify-content: space-between;
  220. .card-header-left {
  221. font-size: 18px;
  222. font-weight: bold;
  223. padding-left: 20px;
  224. }
  225. .card-header-right {
  226. padding-right: 20px;
  227. font-size: 40px;
  228. color: #03d3ec;
  229. }
  230. }
  231. .ring-charts {
  232. height: 55%;
  233. }
  234. .card-footer {
  235. height: 25%;
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-around;
  239. }
  240. .card-footer-item {
  241. padding: 5px 10px 0px 10px;
  242. box-sizing: border-box;
  243. width: 40%;
  244. background-color: rgba(6, 30, 93, 0.7);
  245. border-radius: 3px;
  246. .footer-title {
  247. font-size: 15px;
  248. margin-bottom: 5px;
  249. }
  250. .footer-detail {
  251. font-size: 20px;
  252. color: #1294fb;
  253. display: flex;
  254. font-size: 18px;
  255. align-items: center;
  256. .dv-digital-flop {
  257. margin-right: 5px;
  258. }
  259. }
  260. }
  261. }
  262. </style>