index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div class="app-container electricityFeeAnalysis">
  3. <div class="top">
  4. <div class="search">
  5. <div :class="['switch',dateType == '1' ? 'active': '']" @click="dateSwitch(1)">年度</div>
  6. <div :class="['switch',dateType == '2' ? 'active': '']" @click="dateSwitch(2)">任意时段</div>
  7. <div class="date">
  8. <el-date-picker
  9. v-model="year"
  10. type="year"
  11. v-if="dateType == 1"
  12. :picker-options="pickerOptions"
  13. :disabled-date="disabledDate"
  14. style="width:100px;margin-top:-4px;display: inline-block;"
  15. />
  16. <el-date-picker
  17. v-model="day"
  18. type="datetimerange"
  19. v-if="dateType == 2"
  20. range-separator="至"
  21. start-placeholder="开始时间"
  22. end-placeholder="结束时间"
  23. style="width:350px;margin-top:-4px;display: inline-block;"
  24. />
  25. </div>
  26. <div style="display: inline-block;">
  27. <el-button type="primary" @click="search" style="margin-top:-4px;">查询</el-button>
  28. <el-button type="warning" @click="export" style="margin-top:-4px;">导出</el-button>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="content">
  33. <div class="chart">
  34. <div class="top">
  35. <img src="@/assets/images/time.png" alt="">
  36. <span>每日总电费趋势</span>
  37. </div>
  38. <chart :data="dfqs"/>
  39. </div>
  40. <div class="table">
  41. <tableD :data="tableData"/>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script setup>
  47. import { ref,onMounted } from "vue";
  48. import tableD from "./components/tableD";
  49. import chart from "./components/chart";
  50. onMounted(() => {
  51. init()
  52. })
  53. const dateType = ref(1) //日期类型 1:年度 2:任意时段
  54. const year = ref(new Date().getFullYear().toString()) //年份
  55. const day = ref() //日期
  56. const pickerOptions = {
  57. disabledDate(time) {
  58. return time.getFullYear() > new Date().getFullYear(); // 禁止选择当前年份之后的年份
  59. }
  60. }
  61. const dfqs = ref({
  62. xAxis:["2025-1", "2025-2", "2025-3", "2025-4", "2025-5", "2025-6", "2025-7", "2025-8", "2025-9", "2025-10", "2025-11", "2025-12"],
  63. type:["电度电费","基本电费","力调电费"],
  64. data:[
  65. [100, 101, 120, 50, 70, 95, 65, 120, 5, 14, 78, 32],
  66. [5, 4, 10, 15, 13, 14, 9, 12, 45, 25, 32],
  67. [100,89,101,110,99,94,45,89,99,100,110,102],
  68. ],
  69. unit:"元",
  70. color:["#41BED8","#FCD011","#9283EA"]
  71. })
  72. const tableData = ref([
  73. { a: 1000 },
  74. { a: 1000 },
  75. ]) //列表数据
  76. function dateSwitch(val){
  77. dateType.value = val
  78. }
  79. function init(){
  80. }
  81. /**
  82. * 切换模式
  83. * @param {Number} val 1:表格模式 2:图表模式
  84. */
  85. function switchMode(val) {
  86. mode.value = val
  87. // if(val == 1){
  88. // setTimeout(() => {
  89. // init()
  90. // site(1)
  91. // })
  92. // }
  93. }
  94. /**
  95. * 切换模式
  96. * @param {Number} val 1:电量模式 2:电费模式
  97. */
  98. function switchMode2(val) {
  99. mode2.value = val
  100. }
  101. /**
  102. * 全选事件
  103. */
  104. function siteAllChange(){
  105. if(selectAll.value[0]){
  106. siteSelectArray.value = [1,2,3,4]
  107. }else{
  108. siteSelectArray.value = []
  109. }
  110. }
  111. /**
  112. * 站点列表点击事件
  113. * @param val
  114. */
  115. function siteClick(val){
  116. if(siteSelectArray.value.length == siteList.value.length){
  117. selectAll.value = [1]
  118. console.log(selectAll.value)
  119. }else{
  120. selectAll.value = []
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .electricityFeeAnalysis{
  126. background: none !important;
  127. padding:0 !important;
  128. }
  129. .search{
  130. .switch{
  131. text-align: center;
  132. margin-right:16px;
  133. padding:6px 8px;
  134. background: #fff;
  135. color:rgba(0,0,0,0.65);
  136. border: 1px solid #d9d9d9;
  137. display: inline-block;
  138. cursor: pointer;
  139. }
  140. .active{
  141. background: #6c7fff;
  142. color:#fff;
  143. }
  144. .date{
  145. display: inline-block;
  146. margin-right:16px;
  147. >span{
  148. vertical-align: middle;
  149. display: inline-block;
  150. margin-top:-5px;
  151. }
  152. >div:first-child{
  153. width:60px;
  154. }
  155. >div:last-child{
  156. width:calc(100% - 70px);
  157. }
  158. }
  159. }
  160. .content{
  161. margin-top:16px;
  162. background: #fff;
  163. .chart{
  164. .top{
  165. background: #fafafa;
  166. padding:8px;
  167. img{
  168. width:20px;
  169. }
  170. img,span{
  171. display: inline-block;
  172. vertical-align: middle;
  173. }
  174. span{
  175. font-size: 16px;
  176. margin-left:10px;
  177. }
  178. }
  179. }
  180. .table{
  181. padding:10px;
  182. }
  183. }
  184. </style>