poweruse.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeName" @tab-click="tabClick">
  4. <el-tab-pane label="总览" name="summery">
  5. <div class="First">
  6. <div class="time-range-buttons">
  7. <el-button :class="{ 'is-active': selectedTimeRange === 'day' }"
  8. @click="changeTimeRange('day')">日</el-button>
  9. <el-button :class="{ 'is-active': selectedTimeRange === 'month' }"
  10. @click="changeTimeRange('month')">月</el-button>
  11. <el-button :class="{ 'is-active': selectedTimeRange === 'year' }"
  12. @click="changeTimeRange('year')">年</el-button>
  13. </div>
  14. <div class="first-content">
  15. <div>
  16. <SubTitle title="能耗统计" />
  17. <!-- 图表容器 -->
  18. <div ref="sumBySubCategoryChart" style="height: 380px;" />
  19. </div>
  20. <div>
  21. <SubTitle title="能耗总览" />
  22. <el-table border stripe show-summary :data="tableData" style="width: 100%;margin-top: 20px;">
  23. <el-table-column prop="name" align="center" label="设施名称">
  24. </el-table-column>
  25. <el-table-column prop="value" align="center" label="能耗(kW·h)">
  26. </el-table-column>
  27. </el-table>
  28. </div>
  29. </div>
  30. </div>
  31. <div>
  32. <div class="ctl-container">
  33. <SubTitle title="平均功率-15分钟" />
  34. <el-date-picker v-model="powerDate" type="datetimerange" @change="getPowerChart"
  35. :picker-options="pickerOptions" value-format="yyyy-MM-dd hh:mm:ss" range-separator="至"
  36. start-placeholder="开始日期" end-placeholder="结束日期" align="right">
  37. </el-date-picker>
  38. </div>
  39. <!--柱状图-->
  40. <div class="container-block" style="margin-top: 20px;">
  41. <BaseChart width="100%" height="350px" :option="powerLineOptions" />
  42. </div>
  43. </div>
  44. </el-tab-pane>
  45. <el-tab-pane v-for="item in facsCategoryOptions" :key="item.code" :label="item.name" :name="item.code">
  46. <el-col :span="4" :xs="24">
  47. <div class="head-container">
  48. <el-input v-model="areaName" placeholder="请输入区域名称" clearable size="small" prefix-icon="el-icon-search"
  49. style="margin-bottom: 20px" />
  50. </div>
  51. <div class="head-container" style="height: 100vh; overflow: hidden; position: relative;">
  52. <el-tree :data="areaOptions" :props="defaultProps" :expand-on-click-node="false"
  53. :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current
  54. @node-click="handleNodeClick" style="height: calc(100vh - 50px); overflow-y: auto;" />
  55. </div>
  56. </el-col>
  57. <el-col :span="20" :xs="24">
  58. <div class="container-block">
  59. <div class="ctl-container">
  60. <SubTitle :title="`设施汇总电耗【${selectedLabel}】`" />
  61. <div>
  62. <el-select v-model="objCode" placeholder="选择设施" clearable @visible-change="handleObjSelectClick"
  63. @change="getList">
  64. <el-option v-for="item in objOptions" :label="item.facsName" :value="item.facsCode"
  65. :key="item.facsCode" />
  66. </el-select>
  67. <el-date-picker v-model="dateRange" type="datetimerange" @change="getList"
  68. :picker-options="pickerOptions" value-format="yyyy-MM-dd hh:mm:ss" range-separator="至"
  69. start-placeholder="开始日期" end-placeholder="结束日期" :clearable="false" align="right">
  70. </el-date-picker>
  71. </div>
  72. </div>
  73. <!-- 表格 -->
  74. <el-table v-loading="loading" :data="sumByFacsList" style="width: 100%; margin-top: 10px">
  75. <el-table-column label="设施编码" align="center" prop="objCode">
  76. <template slot-scope="scope">
  77. <span>{{ scope.row.objCode }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="设施名称" align="center" prop="objName">
  81. <template slot-scope="scope">
  82. <span>{{ scope.row.objName }}</span>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="用电量(kW·h)" align="center" prop="elecQuantity">
  86. <template slot-scope="scope">
  87. <span>{{ scope.row.elecQuantity }}</span>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <SubTitle title="设施时段电耗" style="margin-top: 20px;" />
  92. <!--柱状图-->
  93. <div class="container-block" style="margin-top: 20px;">
  94. <BaseChart width="100%" height="300px" :option="barChartOptions" />
  95. </div>
  96. <div>
  97. <div class="ctl-container">
  98. <SubTitle title="平均功率-15分钟" />
  99. </div>
  100. <!--柱状图-->
  101. <div class="container-block" style="margin-top: 20px;">
  102. <BaseChart width="100%" height="350px" v-if="activeName !== 'summery'" :option="equipPowerLineOptions" />
  103. </div>
  104. </div>
  105. </div>
  106. </el-col>
  107. </el-tab-pane>
  108. </el-tabs>
  109. </div>
  110. </template>
  111. <script>
  112. import * as echarts from 'echarts/core';
  113. import {listHSum, sumByFacsH, sumBySubCategoryH, getPowerData, getPowerMaxLoad} from '@/api/mgr/elecUseH'
  114. import {getFacsCategorygetByCode} from '@/api/basecfg/emsfacs'
  115. import {areaWithFacsCategoryAsTree} from '@/api/basecfg/area'
  116. import {listAllFacs} from '@/api/basecfg/emsfacs'
  117. import dayjs from 'dayjs'
  118. import {DateTool} from '@/utils/DateTool'
  119. import {dateFormat} from '@/utils';
  120. import BaseChart from '@/components/BaseChart/index.vue'
  121. import SubTitle from '@/components/SubTitle'
  122. import Block from '@/components/Block/block.vue'
  123. import Treeselect from '@riophae/vue-treeselect'
  124. import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  125. export default {
  126. name: 'PowerUse',
  127. components: {
  128. Treeselect,
  129. BaseChart,
  130. Block,
  131. SubTitle
  132. },
  133. data () {
  134. const today = dateFormat(new Date(), 'yyyy-MM-dd')
  135. return {
  136. activeName: 'summery',
  137. // 遮罩层
  138. loading: true,
  139. // 选中数组
  140. ids: [],
  141. // 非单个禁用
  142. single: true,
  143. // 非多个禁用
  144. multiple: true,
  145. // 显示搜索条件
  146. showSearch: true,
  147. // 总条数
  148. total: 0,
  149. // 用能计量-小时表格数据
  150. hList: [],
  151. //查能耗
  152. sumByFacsList: [],
  153. // 弹出层标题
  154. title: '',
  155. // 是否显示弹出层
  156. open: false,
  157. facsCategory: undefined,
  158. facsSubCategory: undefined,
  159. // 区域名称
  160. areaName: undefined,
  161. selectedLabel: '全部',
  162. defaultProps: {
  163. children: 'children',
  164. label: 'label'
  165. },
  166. areaOptions: [],
  167. facsCategoryOptions: [],
  168. sumBySubCategoryChartOption: {},
  169. // 存储图表配置的变量
  170. selectedTimeRange: 'day',
  171. chartInstance: null,
  172. // 用于存储 ECharts 实例
  173. totalElecQuantity: 0,
  174. objOptions: [],
  175. objCode: undefined,
  176. dateRange: [dayjs().format(DateTool.DateFormat.YYYY_MM_DD_00_00_00), dayjs().format(DateTool.DateFormat.YYYY_MM_DD_23_59_59)],
  177. pickerOptions: {
  178. shortcuts: [
  179. {
  180. text: '最近一周',
  181. onClick (picker) {
  182. const end = new Date()
  183. const start = new Date()
  184. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  185. picker.$emit('pick', [start, end])
  186. }
  187. }, {
  188. text: '最近一个月',
  189. onClick (picker) {
  190. const end = new Date()
  191. const start = new Date()
  192. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  193. picker.$emit('pick', [start, end])
  194. }
  195. }, {
  196. text: '最近三个月',
  197. onClick (picker) {
  198. const end = new Date()
  199. const start = new Date()
  200. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
  201. picker.$emit('pick', [start, end])
  202. }
  203. }
  204. ]
  205. },
  206. // 查询参数
  207. queryParams: {
  208. pageNum: 1,
  209. pageSize: 10,
  210. areaCode: '-1',
  211. objType: 1,
  212. objCode: null,
  213. facsCategory: 'Z',
  214. facsSubCategory: null,
  215. date: null,
  216. time: null,
  217. timeIndex: null
  218. },
  219. queryObjParams: {
  220. refArea: null,
  221. facsCategory: null,
  222. subCategory: null
  223. },
  224. // 表单参数
  225. form: {},
  226. tableData: [],
  227. powerDate: [`${today} 00:00:00`, `${today} 23:59:59`],
  228. powerChartData: [],
  229. powerMaxLoad: '',
  230. equipPowerChartData: [],
  231. equipPowerMaxLoad: ''
  232. }
  233. },
  234. watch: {
  235. // 根据名称筛选区域树
  236. areaName (val) {
  237. this.$refs.tree.filter(val)
  238. }
  239. },
  240. created () {
  241. this.facsCategory = 'Z'
  242. this.facsSubCategory = ''
  243. this.getFacsCategory(this.facsCategory)
  244. this.getAreaTree(this.facsCategory, this.facsSubCategory)
  245. this.getList()
  246. this.getsumByFacsH()
  247. this.getSumBySubCategoryH();
  248. this.getPowerChart()
  249. },
  250. computed: {
  251. barChartOptions () {
  252. const xAxisData = this.hList.map(item => item.time);
  253. const seriesData = this.hList.map(item => item.elecQuantity);
  254. return {
  255. toolbox: {
  256. itemGap: 10,
  257. itemSize: 16,
  258. right: 10,
  259. top: 0,
  260. show: true,
  261. feature: {
  262. magicType: {
  263. show: true,
  264. type: ['bar', 'line']
  265. },
  266. saveAsImage: {
  267. show: true
  268. }
  269. }
  270. },
  271. tooltip: {
  272. trigger: 'axis',
  273. axisPointer: {
  274. type: 'shadow'
  275. }
  276. },
  277. legend: {
  278. data: ['用电量']
  279. },
  280. xAxis: {
  281. type: 'category',
  282. data: xAxisData
  283. },
  284. yAxis: {
  285. name: 'kW·h(千瓦时)',
  286. type: 'value',
  287. },
  288. series: [{
  289. name: '用电量',
  290. type: 'bar',
  291. data: seriesData,
  292. barWidth: 20,
  293. itemStyle: {
  294. normal: {
  295. color: '#6395FA'
  296. }
  297. }
  298. }]
  299. };
  300. },
  301. powerLineOptions () {
  302. const xAxisData = this.powerChartData.map(item => `${item.date.substr(5)} ${item.time.substr(0, 5)} `);
  303. const yData1 = this.powerChartData.map(item => parseFloat(item.s).toFixed(2));
  304. const yData2 = this.powerChartData.map(item => item.p);
  305. const yData3 = this.powerChartData.map(item => item.q);
  306. return {
  307. toolbox: {
  308. itemGap: 10,
  309. itemSize: 16,
  310. right: 10,
  311. top: 0,
  312. show: true,
  313. feature: {
  314. magicType: {
  315. show: true,
  316. type: ['bar', 'line']
  317. },
  318. saveAsImage: {
  319. show: true
  320. }
  321. }
  322. },
  323. tooltip: {
  324. trigger: 'axis',
  325. axisPointer: {
  326. type: 'shadow'
  327. }
  328. },
  329. xAxis: {
  330. type: 'category',
  331. data: xAxisData
  332. },
  333. yAxis: {
  334. name: 'W(瓦)',
  335. type: 'value',
  336. },
  337. legend: {},
  338. dataZoom: [
  339. {
  340. type: "slider",
  341. start: 0,
  342. end: 100,
  343. height: 10,
  344. bottom: '10%',
  345. showDetail: false,
  346. showDataShadow: false,
  347. borderColor: "transparent"
  348. },
  349. {
  350. type: "inside",
  351. start: 0,
  352. end: 100,
  353. },
  354. ],
  355. series: [{
  356. name: '视在功率',
  357. type: 'line',
  358. data: yData1,
  359. markLine: {
  360. symbol: 'none',
  361. silent: true,
  362. lineStyle: {normal: {type: 'dashed'}},
  363. label: {position: 'end'},
  364. data: [
  365. {
  366. yAxis: this.powerMaxLoad,
  367. lineStyle: {width: 1.656, color: '#ff6367'},
  368. label: {
  369. show: true,
  370. textStyle: {
  371. color: '#ff6367'
  372. }
  373. }
  374. },
  375. ]
  376. },
  377. markPoint: {
  378. silent: true,
  379. data: [
  380. {
  381. yAxis: this.powerMaxLoad,
  382. x: '100%',
  383. symbolSize: 0.1,
  384. symbolOffset: [0, 0],
  385. label: {
  386. textStyle: {color: '#ff6367'},
  387. fontSize: 12,
  388. position: 'left',
  389. formatter: '最高负荷'
  390. }
  391. },
  392. ]
  393. },
  394. },
  395. {
  396. name: '有功功率',
  397. type: 'line',
  398. data: yData2,
  399. },
  400. {
  401. name: '无功功率',
  402. type: 'line',
  403. data: yData3,
  404. },
  405. ]
  406. };
  407. },
  408. equipPowerLineOptions () {
  409. const xAxisData = this.equipPowerChartData.map(item => `${item.date.substr(5)} ${item.time.substr(0, 5)} `);
  410. const yData1 = this.equipPowerChartData.map(item => parseFloat(item.s).toFixed(2));
  411. const yData2 = this.equipPowerChartData.map(item => item.p);
  412. const yData3 = this.equipPowerChartData.map(item => item.q);
  413. return {
  414. toolbox: {
  415. itemGap: 10,
  416. itemSize: 16,
  417. right: 10,
  418. top: 0,
  419. show: true,
  420. feature: {
  421. magicType: {
  422. show: true,
  423. type: ['bar', 'line']
  424. },
  425. saveAsImage: {
  426. show: true
  427. }
  428. }
  429. },
  430. legend: {},
  431. tooltip: {
  432. trigger: 'axis',
  433. axisPointer: {
  434. type: 'shadow'
  435. }
  436. },
  437. xAxis: {
  438. type: 'category',
  439. data: xAxisData
  440. },
  441. yAxis: {
  442. name: 'W(瓦)',
  443. type: 'value',
  444. },
  445. dataZoom: [
  446. {
  447. type: "slider",
  448. start: 0,
  449. end: 100,
  450. height: 10,
  451. bottom: '10%',
  452. showDetail: false,
  453. showDataShadow: false,
  454. borderColor: "transparent"
  455. },
  456. {
  457. type: "inside",
  458. start: 0,
  459. end: 100,
  460. },
  461. ],
  462. series: [{
  463. name: '视在功率',
  464. type: 'line',
  465. data: yData1,
  466. markLine: {
  467. symbol: 'none',
  468. silent: true,
  469. lineStyle: {normal: {type: 'dashed'}},
  470. label: {position: 'end'},
  471. data: [
  472. {
  473. yAxis: this.equipPowerMaxLoad,
  474. lineStyle: {width: 1.656, color: '#ff6367'},
  475. label: {
  476. show: true,
  477. textStyle: {
  478. color: '#ff6367'
  479. }
  480. }
  481. },
  482. ]
  483. },
  484. markPoint: {
  485. silent: true,
  486. data: [
  487. {
  488. yAxis: this.equipPowerMaxLoad,
  489. x: '100%',
  490. symbolSize: 0.1,
  491. symbolOffset: [0, 0],
  492. label: {
  493. textStyle: {color: '#ff6367'},
  494. fontSize: 12,
  495. position: 'left',
  496. formatter: '最高负荷'
  497. }
  498. },
  499. ]
  500. },
  501. },
  502. {
  503. name: '有功功率',
  504. type: 'line',
  505. data: yData2,
  506. },
  507. {
  508. name: '无功功率',
  509. type: 'line',
  510. data: yData3,
  511. },
  512. ]
  513. };
  514. }
  515. },
  516. methods: {
  517. getPowerChart () {
  518. this.powerMaxLoad = ''
  519. this.powerChartData = []
  520. const [startTime, endTime] = this.powerDate
  521. const params = {
  522. startTime,
  523. endTime,
  524. areaCode: '-1',
  525. objType: '1',
  526. }
  527. getPowerData({
  528. ...params,
  529. pageNum: 1,
  530. pageSize: 999
  531. }).then(({code, rows}) => {
  532. if (code === 200) {
  533. this.powerChartData = rows
  534. }
  535. })
  536. getPowerMaxLoad(params).then(({code, data}) => {
  537. if (code === 200&&data) {
  538. this.powerMaxLoad = parseFloat(data.s).toFixed(2)
  539. }
  540. })
  541. },
  542. getEquipPowerChart () {
  543. this.equipPowerMaxLoad = ''
  544. this.equipPowerChartData = []
  545. const [startTime, endTime] = this.dateRange
  546. const params = {
  547. startTime,
  548. endTime,
  549. areaCode: '-1',
  550. objType: '1',
  551. facsCategory: 'Z',
  552. facsSubCategory: this.activeName,
  553. objCode: this.objCode
  554. }
  555. getPowerData({
  556. ...params,
  557. pageNum: 1,
  558. pageSize: 999
  559. }).then(({code, rows}) => {
  560. if (code === 200) {
  561. this.equipPowerChartData = rows
  562. }
  563. })
  564. getPowerMaxLoad(params).then(({code, data}) => {
  565. if (code === 200) {
  566. this.equipPowerMaxLoad = parseFloat(data.s).toFixed(2)
  567. }
  568. })
  569. },
  570. /** 查询用能计量-小时列表 */
  571. getList () {
  572. this.loading = true
  573. this.queryParams.objCode = this.objCode
  574. listHSum(this.queryParams).then(response => {
  575. this.hList = response.rows
  576. this.total = response.total
  577. this.loading = false
  578. })
  579. this.getsumByFacsH()
  580. this.getEquipPowerChart()
  581. },
  582. /**根据设施查询能耗统计 */
  583. getsumByFacsH () {
  584. const params = {
  585. startRecTime: dayjs(this.dateRange[0]).format('YYYY-MM-DD HH:mm:ss'),
  586. endRecTime: dayjs(this.dateRange[1]).format('YYYY-MM-DD HH:mm:ss'),
  587. areaCode: this.queryParams.areaCode,
  588. facsSubCategory: this.activeName,
  589. objCode: this.queryParams.objCode
  590. };
  591. sumByFacsH(params).then(response => {
  592. this.sumByFacsList = response.data
  593. console.log("能耗", this.sumByFacsList)
  594. })
  595. },
  596. /**时间范围切换按钮点击事件处理器*/
  597. changeTimeRange (rangeType) {
  598. this.selectedTimeRange = rangeType;
  599. let start = dayjs();
  600. let end = dayjs();
  601. if (rangeType === 'day') {
  602. // 日:当前日期的 00:00:00 到 23:59:59
  603. start = start.startOf('day');
  604. end = end.endOf('day');
  605. } else if (rangeType === 'month') {
  606. // 月:当前月份的第一天 00:00:00 到 最后一天 23:59:59
  607. start = start.date(1).hour(0).minute(0).second(0);
  608. end = end.endOf('month').hour(23).minute(59).second(59);
  609. } else if (rangeType === 'year') {
  610. // 年:当前年份的第一天 00:00:00 到 最后一天 23:59:59
  611. start = start.startOf('year');
  612. end = end.endOf('year').hour(23).minute(59).second(59);
  613. }
  614. this.dateRange = [start.format('YYYY-MM-DD HH:mm:ss'), end.format('YYYY-MM-DD HH:mm:ss')];
  615. this.getSumBySubCategoryH(); // 重新获取数据
  616. },
  617. /**总览饼图*/
  618. getSumBySubCategoryH () {
  619. const params = {
  620. startRecTime: dayjs(this.dateRange[0]).format('YYYY-MM-DD HH:mm:ss'),
  621. endRecTime: dayjs(this.dateRange[1]).format('YYYY-MM-DD HH:mm:ss'),
  622. areaCode: this.queryParams.areaCode,
  623. };
  624. sumBySubCategoryH(params).then(response => {
  625. this.processDataForChart(response.data); // 处理数据并生成图表配置
  626. console.log("pie图", response.data)
  627. this.tableData = response.data.map(item => ({
  628. name: item.objName,
  629. value: item.elecQuantity || 0
  630. }))
  631. })
  632. },
  633. processDataForChart (data) {
  634. this.totalElecQuantity = data.reduce((sum, item) => sum + (item.elecQuantity || 0), 0);
  635. // 处理数据,生成图表配置
  636. const seriesData = data.map(item => ({
  637. name: item.objName,
  638. value: item.elecQuantity,
  639. percent: ((item.elecQuantity || 0) / this.totalElecQuantity * 100).toFixed(2),
  640. subentry: item.subentry.map(subItem => ({
  641. name: subItem.objName,
  642. value: subItem.elecQuantity
  643. }))
  644. }));
  645. // 设置图表配置
  646. this.sumBySubCategoryChartOption = {
  647. tooltip: {
  648. trigger: 'item',
  649. formatter: function (params) {
  650. const {name, value, percent} = params;
  651. const subentries = params.data.subentry;
  652. let tooltipContent = `<div><h4>${name}</h4><p>${value} (${percent}%)</p><ul>`;
  653. subentries.forEach(subItem => {
  654. tooltipContent += `<li>${subItem.name}: ${subItem.value} kW·h</li>`;
  655. });
  656. tooltipContent += `</ul></div>`;
  657. return tooltipContent;
  658. }
  659. },
  660. legend: {
  661. orient: 'vertical',
  662. top: '5%',
  663. left: '5%'
  664. },
  665. series: [
  666. {
  667. name: '能耗',
  668. type: 'pie',
  669. radius: ['35%', '55%'],
  670. data: seriesData,
  671. emphasis: {
  672. itemStyle: {
  673. shadowBlur: 10,
  674. shadowOffsetX: 0,
  675. shadowColor: 'rgba(0, 0, 0, 0.5)',
  676. }
  677. },
  678. label: {
  679. show: true,
  680. position: 'outside',
  681. formatter: '{b}\n{d}%',
  682. },
  683. labelLine: {
  684. show: true,
  685. length: 30, // 标签线长度
  686. lineStyle: {
  687. width: 1,
  688. type: 'dashed', // 设置虚线样式
  689. }
  690. }
  691. }
  692. ]
  693. };
  694. // 渲染图表
  695. this.$nextTick(() => {
  696. const chart = echarts.init(this.$refs.sumBySubCategoryChart);
  697. chart.setOption(this.sumBySubCategoryChartOption);
  698. });
  699. },
  700. async getFacsCategory (code) {
  701. getFacsCategorygetByCode(code).then(response => {
  702. this.facsCategoryOptions = response.data.subtypeList
  703. })
  704. },
  705. async getAreaTree (category, subCategory) {
  706. await areaWithFacsCategoryAsTree(category, subCategory).then(response => {
  707. this.areaOptions = [{
  708. id: '-1',
  709. label: '全部',
  710. children: []
  711. }].concat(response.data)
  712. })
  713. },
  714. async getFacsObj (areaCode, category, subCategory) {
  715. this.queryObjParams.refArea = areaCode
  716. this.queryObjParams.facsCategory = category
  717. this.queryObjParams.subCategory = subCategory
  718. listAllFacs(this.queryObjParams).then(response => {
  719. this.objOptions = response.data
  720. })
  721. },
  722. tabClick () {
  723. this.reset()
  724. if (this.activeName !== 'summery') {
  725. this.dateRange = [dayjs().format(DateTool.DateFormat.YYYY_MM_DD_00_00_00), dayjs().format(DateTool.DateFormat.YYYY_MM_DD_23_59_59)]
  726. this.queryParams.facsCategory = this.facsCategory
  727. this.queryParams.facsSubCategory = this.activeName
  728. this.queryParams.pageNum = 1
  729. this.selectedLabel = '全部'
  730. this.getList()
  731. } else {
  732. }
  733. },
  734. /** 搜索按钮操作 */
  735. handleQuery () {
  736. this.queryParams.pageNum = 1
  737. this.getList()
  738. },
  739. handleObjSelectClick () {
  740. this.getFacsObj(this.queryParams.areaCode, this.facsCategory, this.activeName)
  741. this.getsumByFacsH();
  742. },
  743. // 筛选节点
  744. filterNode (value, data) {
  745. if (!value) return true
  746. return data.label.indexOf(value) !== -1
  747. },
  748. // 节点单击事件
  749. handleNodeClick (data) {
  750. this.queryParams.areaCode = data.id
  751. this.selectedLabel = data.label
  752. this.objCode = null
  753. this.handleQuery()
  754. },
  755. reset () {
  756. this.objCode = null
  757. this.queryParams.areaCode = '-1'
  758. this.queryParams.facsCategory = 'Z'
  759. this.queryParams.facsSubCategory = null
  760. this.queryParams.objCode = null
  761. this.objOptions = []
  762. }
  763. }
  764. }
  765. </script>
  766. <style lang="scss" scoped>
  767. .time-range-buttons {
  768. .is-active {
  769. background-color: #409eff;
  770. color: white;
  771. }
  772. }
  773. .first-content {
  774. display: flex;
  775. margin-top: 20px;
  776. >div:first-child {
  777. flex: 3;
  778. }
  779. >div:last-child {
  780. flex: 2;
  781. }
  782. }
  783. .container-block {
  784. padding-left: 20px;
  785. }
  786. .ctl-container {
  787. display: flex;
  788. justify-content: space-between;
  789. }
  790. </style>
  791. }