benchmarkingIndicBasicPage.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <template>
  2. <div class="benchmarkBasicPage">
  3. <div class="benchmarkBasicPageBtn">
  4. <div class="collectSeach" :style="$utils.collectSeachSty()">
  5. <div class="exceed exceedCas">
  6. <span class="exceedSpan" style="width: 50px">机构:</span>
  7. <el-tree-select v-model="orgVal" :data="orgSelectArr" @change="changeCas" multiple clearable
  8. collapse-tags show-checkbox check-strictly check-on-click-node />
  9. </div>
  10. <div class="exceed exceedWidth">
  11. <span class="exceedSpan" style="width: 50px">指标:</span>
  12. <el-select v-model="itemVal" placeholder="请选择指标" @change="changeItemVal">
  13. <el-option v-for="item in itemSelectArr" :key="item.irn" :label="item.itemFieldName"
  14. :value="item.irn">
  15. </el-option>
  16. </el-select>
  17. </div>
  18. <div class="exceed">
  19. <span class="exceedSpan" style="width: 70px">指标项:</span>
  20. <el-select v-model="evalVal" placeholder="请选择指标项" filterable>
  21. <el-option v-for="item in evalSelectArr" :key="item.itemsCode" :label="item.itemsName"
  22. :value="item.itemsCode">
  23. </el-option>
  24. </el-select>
  25. </div>
  26. <div class="exceed exceedWidth">
  27. <span class="exceedSpan" style="width: 50px">频度:</span>
  28. <el-select v-model="rangeVal" placeholder="请选择频度" filterable>
  29. <el-option v-for="item in rangeArr" :key="item.value" :label="item.label" :value="item.value">
  30. </el-option>
  31. </el-select>
  32. </div>
  33. <div class="exceed">
  34. <span class="exceedSpan" style="width: 50px">时间:</span>
  35. <el-date-picker v-model="resAnnual" value-format="YYYY-MM-DD" type="daterange"
  36. placeholder="请选择时间" />
  37. </div>
  38. <!-- <seachs @handleSeach="getSeachData" :showRest="false"></seachs> -->
  39. <el-row :gutter="10" class="btnsA">
  40. <el-col :span="1.5">
  41. <el-button type="primary" size="mini" @click="getSeachData('1')">
  42. <span>对标</span>
  43. </el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button type="primary" size="mini" @click="getSeachData('2')">
  47. <span>同期</span>
  48. </el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button type="primary" size="mini" @click="getSeachData('3')">
  52. <span>上期</span>
  53. </el-button>
  54. </el-col>
  55. </el-row>
  56. </div>
  57. <div class="benchmarkBasicPageTableData">
  58. <el-table :data="benchmarkBasicPageData" style="width: 100%" :class="unitRatingTableSty()"
  59. v-if="showType === '1'">
  60. <el-table-column type="index" label="序号" align="center"></el-table-column>
  61. <el-table-column v-for="(it, index) in benchmarkBasicHeader" :key="index" :label="it.name"
  62. align="center">
  63. <template #default="scope">
  64. <span>{{scope.row[it.code]}}</span>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <el-table :data="benchmarkBasicPageData" style="width: 100%" :class="unitRatingTableSty()" v-else>
  69. <el-table-column type="index" label="序号" align="center"></el-table-column>
  70. <el-table-column prop="time" label="频度" align="center"></el-table-column>
  71. <el-table-column v-for="(it, index) in benchmarkBasicHeader" :key="index" :label="it.name"
  72. align="center">
  73. <el-table-column prop="state" label="本期" align="center">
  74. <template #default="scope">
  75. <span>{{scope.row[it.code+'_b']}}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column prop="city" label="同期" v-if="showType === '2'" align="center">
  79. <template #default="scope">
  80. <span>{{scope.row[it.code+'_t']}}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="city" label="上期" v-if="showType === '3'" align="center">
  84. <template #default="scope">
  85. <span>{{scope.row[it.code]}}</span>
  86. </template>
  87. </el-table-column>
  88. </el-table-column>
  89. </el-table>
  90. <div id="basicEcharts" style="width: 100%; height: 40vh"></div>
  91. </div>
  92. </div>
  93. </div>
  94. </template>
  95. <script>
  96. import seachs from '../seachGroup.vue'
  97. // import baxicjson from '../basicJSON.json'
  98. // import baxic2json from '../basic2JSON.json'
  99. import {
  100. apiPostbenchmarkBasicList,
  101. apiPostbenchmarkcontemporaneousData,
  102. apiPostbenchmarkpreviousPeriodData,
  103. apiPostTreeSelectList1015,
  104. apiPostTreeSelectList1019,
  105. apiPostTreeSelectList1020
  106. } from '../../api/api'
  107. export default {
  108. components: {
  109. seachs
  110. },
  111. data() {
  112. return {
  113. statesVisible: false,
  114. benchmarkBasicPageData: [],
  115. benchmarkBasicHeader: [],
  116. orgVal: [],
  117. itemVal: '',
  118. evalVal: '',
  119. rangeVal: 'M',
  120. resAnnual: [],
  121. orgSelectArr: [],
  122. itemSelectArr: [],
  123. evalSelectArr: [],
  124. rangeArr: [],
  125. winPix: window.devicePixelRatio,
  126. innerWidth: window.innerWidth,
  127. showType: '1',
  128. // baxicjson: baxicjson,
  129. // baxic2json: baxic2json
  130. }
  131. },
  132. created() {
  133. this.rangeArr = [{
  134. label: '日',
  135. value: 'D'
  136. },
  137. {
  138. label: '月',
  139. value: 'M'
  140. },
  141. {
  142. label: '年',
  143. value: 'Y'
  144. }
  145. ]
  146. },
  147. mounted() {
  148. this.getorgSelectList()
  149. this.getbenchmarkBasicList('1')
  150. this.resAnnual = [this.getTime(new Date(new Date().getTime() - 6 * 30 * 24 * 60 * 60 * 1000)), this.getTime(
  151. new Date(new Date().getTime()))]
  152. },
  153. methods: {
  154. // 获取组织机构数据
  155. getorgSelectList() {
  156. let that = this
  157. let params = {
  158. type: 1015,
  159. map: {
  160. orgLevel: "3"
  161. }
  162. }
  163. apiPostTreeSelectList1015(params).then(datas => {
  164. if (datas && datas.data) {
  165. let arr = []
  166. datas.data.forEach(it => {
  167. let obj = {
  168. value: it.orgCode,
  169. label: it.orgName,
  170. children: it.children ? that.changeSelect(it.children) : []
  171. }
  172. arr.push(obj)
  173. })
  174. that.orgSelectArr = arr
  175. that.orgVal = [datas.data[0].orgCode, datas.data[1].orgCode]
  176. that.getfiledDatatypeList()
  177. }
  178. })
  179. },
  180. changeSelect(child) {
  181. let arr = []
  182. child.forEach(it => {
  183. let obj = {
  184. value: it.orgCode,
  185. label: it.orgName,
  186. children: it.children ? this.changeSelect(it.children) : []
  187. }
  188. arr.push(obj)
  189. })
  190. return arr
  191. },
  192. changeItemVal(val) {
  193. this.evalSelectArr = []
  194. this.getevalDatatypeList(val)
  195. },
  196. //查询主题域
  197. getfiledDatatypeList() {
  198. let that = this
  199. let params = {
  200. type: 1019,
  201. map: {
  202. pId: ""
  203. }
  204. }
  205. apiPostTreeSelectList1019(params).then(datas => {
  206. if (datas && datas.data.data) {
  207. that.itemSelectArr = datas.data.data
  208. // that.itemVal = datas.data.data[0].itemFieldCode
  209. that.itemVal = datas.data.data[1].irn
  210. that.getevalDatatypeList(that.itemVal)
  211. }
  212. })
  213. },
  214. //查询指标项
  215. getevalDatatypeList(val) {
  216. let that = this
  217. let params = {
  218. type: 1020,
  219. map: {
  220. irn: val
  221. }
  222. }
  223. apiPostTreeSelectList1020(params).then(datas => {
  224. if (datas && datas.data.data) {
  225. that.evalSelectArr = datas.data.data
  226. that.evalVal = datas.data.data[0].itemsCode
  227. that.getbenchmarkBasicList('1')
  228. }
  229. })
  230. },
  231. //获取指标数据
  232. getbenchmarkBasicList(type) {
  233. let that = this
  234. let params = {
  235. type: '1011',
  236. map: {
  237. sysCode: that.orgVal,
  238. itemCode: [that.evalVal],
  239. fdlx: [
  240. "FDLX100",
  241. "FDLX400",
  242. "FDLX200"
  243. ],
  244. range: that.rangeVal,
  245. dataType: '429668',
  246. kj: 'JT',
  247. startTime: that.resAnnual[0],
  248. endTime: that.resAnnual[1]
  249. }
  250. }
  251. if (type === '1') {
  252. apiPostbenchmarkBasicList(params).then(datas => {
  253. that.changeData(datas)
  254. })
  255. } else if (type === '2') {
  256. apiPostbenchmarkcontemporaneousData(params).then(datas => {
  257. that.changeData(datas)
  258. })
  259. } else if (type === '3') {
  260. apiPostbenchmarkpreviousPeriodData(params).then(datas => {
  261. that.changeData(datas)
  262. })
  263. }
  264. },
  265. changeData(showData) {
  266. if (showData.data.title) {
  267. that.benchmarkBasicHeader = showData.data.title
  268. }
  269. if (showData.data.list) {
  270. that.benchmarkBasicPageData = showData.data.list
  271. let xaxisArr = []
  272. let seriesArr = []
  273. that.benchmarkBasicPageData.forEach(it => {
  274. xaxisArr.push(it.time)
  275. })
  276. that.benchmarkBasicHeader.forEach(iv => {
  277. if (iv.code !== 'time') {
  278. let seriesitemArr = []
  279. that.benchmarkBasicPageData.forEach(item => {
  280. seriesitemArr.push(item[iv.code])
  281. })
  282. let obj = {
  283. name: iv.name,
  284. type: type === '1' ? 'line' : 'bar',
  285. data: seriesitemArr
  286. }
  287. if (type === '1') {
  288. obj.symbol = 'none'
  289. }
  290. seriesArr.push(obj)
  291. }
  292. })
  293. that.getEchartsData(xaxisArr, seriesArr)
  294. }
  295. },
  296. //获取echarts数据
  297. getEchartsData(xaxisArr, seriesArr) {
  298. let option = {
  299. tooltip: {
  300. trigger: 'axis'
  301. },
  302. grid: {
  303. left: '5%',
  304. right: '5%'
  305. },
  306. xAxis: {
  307. type: 'category',
  308. data: xaxisArr
  309. },
  310. yAxis: {
  311. type: 'value'
  312. },
  313. series: seriesArr
  314. }
  315. let dom = document.getElementById('basicEcharts');
  316. dom.removeAttribute("_echarts_instance_") ? dom.removeAttribute("_echarts_instance_") : ''
  317. let chat = this.$echarts.init(dom)
  318. chat.setOption(option);
  319. window.addEventListener("resize", function () {
  320. chat.resize()
  321. })
  322. },
  323. getPowerBar(xAxis, series) {
  324. let option = {
  325. tooltip: {
  326. trigger: 'axis',
  327. axisPointer: {
  328. type: 'shadow'
  329. }
  330. },
  331. grid: {
  332. left: '2%',
  333. right: '2%',
  334. bottom: '5%',
  335. height: '90px',
  336. containLabel: true
  337. },
  338. legend: {
  339. right: '20',
  340. top: '20',
  341. itemWidth: 5,
  342. itemHeight: 5,
  343. data: ['日发电量', '上网电量', '购网电量']
  344. },
  345. xAxis: [{
  346. type: 'category',
  347. axisTick: {
  348. show: false
  349. },
  350. data: xAxis
  351. }],
  352. yAxis: [{
  353. type: 'value'
  354. }],
  355. series: series
  356. };
  357. // 基于准备好的dom,初始化echarts实例
  358. let dom = document.getElementById('basicEcharts');
  359. dom.removeAttribute("_echarts_instance_") ? dom.removeAttribute("_echarts_instance_") : ''
  360. let myChart = this.$echarts.init(dom);
  361. myChart.setOption(option);
  362. window.addEventListener("resize", function () {
  363. myChart.resize()
  364. })
  365. },
  366. getTime(date) {
  367. var y = date.getFullYear();
  368. var m = date.getMonth() + 1;
  369. m = m < 10 ? ('0' + m) : m;
  370. var d = date.getDate();
  371. d = d < 10 ? ('0' + d) : d;
  372. let timeF = y + '-' + m + '-' + d
  373. return timeF
  374. },
  375. getSeachData(type) {
  376. this.showType = type
  377. this.getbenchmarkBasicList(type)
  378. },
  379. unitRatingTableSty() {
  380. if (this.winPix === 1.25 || this.innerWidth < 1800) {
  381. return 'unitRating125Table'
  382. } else {
  383. return 'unitRating100Table'
  384. }
  385. }
  386. }
  387. }
  388. </script>
  389. <style lang="less">
  390. .benchmarkBasicPage {
  391. .benchmarkBasicPageBtn {
  392. .collectSeach {
  393. display: flex;
  394. padding: 24px 20px;
  395. border-bottom: 1px solid#D6DBEA;
  396. .exceed {
  397. display: flex;
  398. .exceedSpan {
  399. width: 100px;
  400. height: 12px;
  401. font-size: 14px;
  402. font-family: Microsoft YaHei;
  403. font-weight: 400;
  404. color: #8991B0;
  405. line-height: 12px;
  406. margin-top: 14px;
  407. }
  408. .el-input {
  409. margin-right: 10px;
  410. height: 40px;
  411. .el-input__inner {
  412. height: 40px;
  413. }
  414. .el-input__suffix {
  415. .el-select__caret {
  416. line-height: 30px;
  417. }
  418. }
  419. }
  420. .el-date-editor {
  421. height: 40px;
  422. }
  423. }
  424. .btnsA {
  425. .el-button {
  426. width: 80px !important;
  427. }
  428. }
  429. .exceedWidth {
  430. .el-select {
  431. width: 70px;
  432. }
  433. }
  434. .exceedCas {
  435. .el-cascader {
  436. width: 230px;
  437. .el-cascader__tags {
  438. .el-tag {
  439. .el-tag__content {
  440. width: 30px;
  441. }
  442. }
  443. .is-closable {
  444. .el-tag__content {
  445. width: 100px;
  446. }
  447. }
  448. }
  449. }
  450. }
  451. .el-select {
  452. margin-right: 10px;
  453. .el-input__inner {
  454. height: 30px;
  455. }
  456. .el-input__suffix {
  457. .el-select__caret {
  458. line-height: 30px;
  459. }
  460. }
  461. }
  462. }
  463. span {
  464. font-size: 14px;
  465. }
  466. .PeriodBtn {
  467. display: flex;
  468. justify-content: flex-end;
  469. padding: 20px 0;
  470. }
  471. .el-button {
  472. height: 30px;
  473. // width:100px;
  474. padding: 0 20px;
  475. // padding-top: 8px;
  476. span {
  477. margin: 0;
  478. }
  479. }
  480. .benchmarkBasicPageTableData {
  481. .unitRating125Table {
  482. .el-table__body-wrapper {
  483. height: 30vh !important;
  484. }
  485. }
  486. .unitRating100Table {
  487. .el-table__body-wrapper {
  488. height: 35vh !important;
  489. }
  490. }
  491. .el-table {
  492. .el-input__inner {
  493. height: 30px !important;
  494. }
  495. .el-radio__label {
  496. display: none;
  497. }
  498. .tooltipCC {
  499. width: 300px !important;
  500. display: inline-block;
  501. overflow: hidden;
  502. text-overflow: ellipsis;
  503. white-space: nowrap;
  504. }
  505. .tooltipCCDes {
  506. width: 50px;
  507. display: inline-block;
  508. overflow: hidden;
  509. text-overflow: ellipsis;
  510. white-space: nowrap;
  511. }
  512. .indicitem {
  513. color: #409EFF;
  514. font-size: 12px;
  515. margin-right: 20px;
  516. cursor: pointer;
  517. &:hover {
  518. text-decoration: underline;
  519. }
  520. }
  521. }
  522. .el-pagination {
  523. margin-top: 20px;
  524. text-align: end;
  525. position: relative;
  526. }
  527. }
  528. .el-overlay {
  529. .startToDia {
  530. .el-dialog__body {
  531. padding: 30px 60px 30px 20px !important;
  532. .periodFrom {
  533. .el-select,
  534. .el-input {
  535. width: 100%;
  536. }
  537. .el-input {
  538. height: 30px;
  539. }
  540. }
  541. .flowSty {
  542. width: 100%;
  543. height: 70vh;
  544. }
  545. }
  546. }
  547. }
  548. }
  549. }
  550. </style>