single.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="single-page">
  3. <navigation title="单一设备"></navigation>
  4. <view class="title" :style="{ color:productStatus == 1? '#2fc25b': 'red'}">{{equipmentName}}</view>
  5. <view class="chart-box">
  6. <qiun-data-charts type="line" :opts="opts" :chartData="chartData" />
  7. </view>
  8. <view class="chart-box">
  9. <qiun-data-charts type="line" :opts="optsMix" :chartData="chartDataMix" />
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. productStatus: '',
  18. equipmentName: '',
  19. equipmentCode: '',
  20. chartData: {},
  21. opts: {
  22. color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
  23. "#ea7ccc"
  24. ],
  25. padding: [15, 10, 10, 15],
  26. legend: {
  27. position: 'top'
  28. },
  29. xAxis: {
  30. disableGrid: true,
  31. rotateLabel: true, //【旋转】数据点(刻度点)文字
  32. rotateAngle: 20 //开启上面旋转功能后,文字旋转的角度,取值范围(-90至90)
  33. },
  34. yAxis: {
  35. gridType: "dash",
  36. dashLength: 2,
  37. data: [{
  38. tofix: 2,
  39. }]
  40. },
  41. extra: {
  42. line: {
  43. type: "curve",
  44. width: 2
  45. }
  46. },
  47. dataLabel: false, //是否显示图表区域内数据点上方的数据文案
  48. },
  49. chartDataMix: {},
  50. optsMix: {
  51. color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
  52. "#ea7ccc"
  53. ],
  54. padding: [15, 10, 10, 15],
  55. enableScroll: false,
  56. legend: {
  57. position: 'top'
  58. },
  59. xAxis: {
  60. disableGrid: true,
  61. rotateLabel: true,
  62. rotateAngle: 20,
  63. labelCount: 7
  64. },
  65. yAxis: {
  66. gridType: "dash",
  67. dashLength: 2,
  68. data: [{
  69. tofix: 2,
  70. }]
  71. },
  72. extra: {
  73. line: {
  74. type: "curve",
  75. width: 2
  76. }
  77. },
  78. dataLabel: false,
  79. }
  80. }
  81. },
  82. onLoad(option) {
  83. this.productStatus = option.productStatus
  84. this.equipmentName = option.equipmentName
  85. this.equipmentCode = option.equipmentCode
  86. this.listDayCropRate()
  87. this.listTagDifferenceHours()
  88. },
  89. methods: {
  90. listDayCropRate() {
  91. let params = {
  92. tag: 'Product_Status',
  93. start: this.dayjs().subtract(6, 'day').format('YYYY-MM-DD'),
  94. end: this.dayjs().format('YYYY-MM-DD'),
  95. equipmentCode: this.equipmentCode
  96. }
  97. this.$api.listDayCropRate(params).then(res => {
  98. let tempList = []
  99. for (const key in res.data) {
  100. let night0 = 0
  101. let night1 = 0
  102. let day0 = 0
  103. let day1 = 0
  104. for (const key1 in res.data[key]) {
  105. day0 = day0 + res.data[key][key1].day['0']
  106. day1 = day1 + res.data[key][key1].day['1']
  107. night0 = night0 + res.data[key][key1].night['0']
  108. night1 = night1 + res.data[key][key1].night['1']
  109. }
  110. tempList.push({
  111. day: key,
  112. day0: day0,
  113. day1: day1,
  114. night0: night0,
  115. night1: night1,
  116. })
  117. }
  118. tempList.sort(function(a, b) {
  119. return a.day < b.day ? -1 : 1
  120. })
  121. let xData = []
  122. let day = []
  123. let night = []
  124. for (let i = 0; i < tempList.length; i++) {
  125. xData.push(this.dayjs(tempList[i]['day']).format('MM-DD'))
  126. day.push(
  127. ((tempList[i]['day1'] * 100) / (tempList[i]['day0'] + tempList[i]['day1']))
  128. .toFixed(2),
  129. )
  130. night.push(
  131. ((tempList[i]['night1'] * 100) / (tempList[i]['night0'] + tempList[i]['night1']))
  132. .toFixed(
  133. 2,
  134. ),
  135. )
  136. }
  137. this.chartData = {
  138. categories: xData,
  139. series: [{
  140. name: "白班",
  141. data: day,
  142. pointShape: "none"
  143. }, {
  144. name: "夜班",
  145. data: night,
  146. pointShape: "none"
  147. }]
  148. }
  149. }).catch(err => {})
  150. },
  151. listTagDifferenceHours() {
  152. let params = {
  153. tag: 'TotalPower',
  154. rq: this.dayjs().format('YYYY-MM-DD'),
  155. equipmentCode: this.equipmentCode
  156. }
  157. this.$api.listTagDifferenceHours(params).then(res => {
  158. let dataList = res.data.hours.number
  159. let list = []
  160. let xData = []
  161. let data = []
  162. for (var j in dataList) {
  163. list.push({
  164. time: this.dayjs(j).format('MM-DD HH'),
  165. val: dataList[j],
  166. })
  167. }
  168. list.map((item) => {
  169. xData.push(item.time)
  170. data.push(item.val)
  171. })
  172. this.chartDataMix = {
  173. categories: xData,
  174. series: [{
  175. name: "用电量(度)",
  176. data: data,
  177. pointShape: "none"
  178. }]
  179. }
  180. }).catch(err => {})
  181. },
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .single-page {
  187. .title {
  188. margin: 24rpx;
  189. font-size: 30rpx;
  190. }
  191. .chart-box {
  192. background-color: #fff;
  193. margin: 24rpx;
  194. padding: 20rpx;
  195. border-radius: 12rpx;
  196. }
  197. }
  198. </style>