index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="report">
  3. <company-header></company-header>
  4. <view class="report_main">
  5. <view class="report_DataAll" v-for="(item,index) in reportProgressData" :key="index">
  6. <uni-row class="report_Data flex justify-between">
  7. <uni-col :span="8" class="report_Data_1 flex">
  8. <image src="../../static/jnImage/indexPage/windIcon.png" mode=""></image>
  9. <text>{{item.inPower}}</text>
  10. </uni-col>
  11. <uni-col :span="8" class="report_Data_2">
  12. <text>{{item.name}}</text>
  13. </uni-col>
  14. <uni-col :span="8" class="report_Data_3 flex justify-end">
  15. <text>{{item.allPower}}</text>
  16. </uni-col>
  17. </uni-row>
  18. <view class="report_Data_msg">
  19. <view class="show_msg" :style="showProgress(item)">
  20. </view>
  21. </view>
  22. </view>
  23. <view class="yearTab">
  24. <text v-for="(item,index) in yearData" :key="index" @click="changeYearTab(item)"
  25. :style="item.showColor ? 'background: #4287FF;color:#fff': ''">{{item.nameZN}}</text>
  26. </view>
  27. <view class="reportTable">
  28. <uni-table ref="table" border emptyText="暂无更多数据" width="100%">
  29. <uni-tr>
  30. <uni-th align="center">性能指标</uni-th>
  31. <uni-th width="125" align="center">数据</uni-th>
  32. </uni-tr>
  33. <uni-tr v-for="(item, index) in tableData" :key="index">
  34. <uni-td>{{ item.name }}</uni-td>
  35. <uni-td align="center">{{ item.value }}</uni-td>
  36. </uni-tr>
  37. </uni-table>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. bulletinappBulletinApi
  45. } from '../../api/report.js'
  46. import companyHeader from '../common/companyHeader.vue'
  47. export default {
  48. onLoad: function() {},
  49. components: {
  50. companyHeader
  51. },
  52. data() {
  53. return {
  54. reportProgressData: [],
  55. yearTab: 'day',
  56. yearData: [],
  57. tableData: [],
  58. reportDataAll: {}
  59. }
  60. },
  61. created() {
  62. this.getReportData()
  63. this.yearData = [{
  64. nameZN: '日简报',
  65. nameEN: 'day',
  66. showColor: true
  67. },
  68. {
  69. nameZN: '月简报',
  70. nameEN: 'month',
  71. showColor: false
  72. },
  73. {
  74. nameZN: '年简报',
  75. nameEN: 'year',
  76. showColor: false
  77. }
  78. ]
  79. },
  80. methods: {
  81. showProgress(item) {
  82. return `width: ${item.progress};`
  83. },
  84. changeYearTab(item) {
  85. this.tableData = []
  86. this.yearData.forEach(it => {
  87. it.showColor = false
  88. if (it.nameEN === item.nameEN) {
  89. item.showColor = true
  90. this.yearTab = it.nameEN
  91. }
  92. })
  93. for (let i in this.reportDataAll) {
  94. let obj = {}
  95. if (this.yearTab === 'day' && i.indexOf('日') > -1) {
  96. obj = {
  97. name: i,
  98. value: this.reportDataAll[i]
  99. }
  100. this.tableData.push(obj)
  101. }
  102. if (this.yearTab === 'month' && i.indexOf('月') > -1) {
  103. obj = {
  104. name: i,
  105. value: this.reportDataAll[i]
  106. }
  107. this.tableData.push(obj)
  108. }
  109. if (this.yearTab === 'year' && i.indexOf('年') > -1) {
  110. obj = {
  111. name: i,
  112. value: this.reportDataAll[i]
  113. }
  114. this.tableData.push(obj)
  115. }
  116. }
  117. },
  118. getReportData() {
  119. let that = this
  120. that.tableData = []
  121. that.reportDataAll = {}
  122. bulletinappBulletinApi({
  123. wpId: 'KGDL_FGS0'
  124. }).then(res => {
  125. if (res && res.data) {
  126. that.reportDataAll = res.data
  127. let datas = res.data
  128. let nowDay = that.getDayOfYear()
  129. let nowPro = nowDay / 365 * 100
  130. that.reportProgressData = [{
  131. inPower: datas['年发电量'] + '万kWh',
  132. allPower: datas['年计划发电量'] + '万kWh',
  133. progress: datas['年完成率'],
  134. name: '年发电量'
  135. },
  136. {
  137. inPower: nowDay + '天',
  138. allPower: '365天',
  139. progress: nowPro + '%',
  140. name: '日历进度'
  141. },
  142. {
  143. inPower: '日历进程',
  144. allPower: '年发电量',
  145. progress: datas['年完成率'],
  146. name: '完成度'
  147. },
  148. ]
  149. for (let i in datas) {
  150. let obj = {}
  151. if (that.yearTab === 'day' && i.indexOf('日') > -1) {
  152. obj = {
  153. name: i,
  154. value: datas[i]
  155. }
  156. that.tableData.push(obj)
  157. }
  158. }
  159. }
  160. })
  161. },
  162. getDayOfYear() {
  163. var date = new Date();
  164. var start = new Date(date.getFullYear(), 0, 0);
  165. var diff = (date - start) + ((start.getTimezoneOffset() - date.getTimezoneOffset()) * 60 * 1000);
  166. var oneDay = 1000 * 60 * 60 * 24;
  167. var dayOfYear = Math.floor(diff / oneDay);
  168. return dayOfYear;
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. page {
  175. background-color: #202246;
  176. }
  177. .report {
  178. width: 100vw;
  179. background: url('../../static/jnImage/loginPage/windBack.png'), url('../../static/jnImage/loginPage/backWav.png');
  180. background-repeat: no-repeat, repeat;
  181. background-size: 100% 260px, 100% 5px;
  182. .report_main {
  183. padding: 0 20px;
  184. .report_DataAll {
  185. margin-top: 10px;
  186. .report_Data {
  187. .report_Data_1 {
  188. image {
  189. width: 18px;
  190. height: 18px;
  191. }
  192. text {
  193. margin-left: 5px;
  194. font-size: 28upx;
  195. color: #A49EAC;
  196. position: relative;
  197. top: 0px;
  198. }
  199. }
  200. .report_Data_2 {
  201. text {
  202. font-size: 32upx;
  203. color: #A49EAC;
  204. }
  205. }
  206. .report_Data_3 {
  207. text {
  208. font-size: 28upx;
  209. color: #A49EAC;
  210. }
  211. }
  212. }
  213. .report_Data_msg {
  214. width: 100%;
  215. height: 20px;
  216. border-radius: 5px;
  217. background: #0B143E;
  218. .show_msg {
  219. height: 20px;
  220. background: #00BC6F;
  221. border-radius: 5px 0 0 5px;
  222. }
  223. }
  224. }
  225. .yearTab {
  226. width: 99%;
  227. height: 30px;
  228. border-radius: 5px;
  229. background: #0B143E;
  230. margin-top: 20px;
  231. text {
  232. display: inline-block;
  233. width: 33%;
  234. height: 30px;
  235. text-align: center;
  236. color: #4287FF;
  237. line-height: 30px;
  238. }
  239. text:nth-of-type(1) {
  240. border-radius: 5px 0 0 5px;
  241. }
  242. text:nth-of-type(3) {
  243. border-radius: 0 5px 5px 0;
  244. }
  245. }
  246. .reportTable {
  247. width: 100%;
  248. margin-top: 10px;
  249. .table--border {
  250. border: 1px solid rgba(255, 255, 255, 0.3);
  251. }
  252. .uni-table {
  253. background-color: rgba(255, 255, 255, 0);
  254. .uni-table-tr {
  255. .table--border {
  256. border: 1px solid rgba(255, 255, 255, 0.3);
  257. }
  258. .uni-table-th {
  259. background-color: #2E336D;
  260. }
  261. .uni-table-th,
  262. .uni-table-td {
  263. color: #fff;
  264. font-size: 26upx;
  265. }
  266. .uni-table-th:nth-of-type(1) {
  267. background-color: #6C4B9E;
  268. }
  269. }
  270. .uni-table-tr:hover {
  271. background-color: rgba(255, 255, 255, 0);
  272. }
  273. }
  274. }
  275. }
  276. }
  277. </style>