index.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. <template>
  2. <div>
  3. <!-- 地图通用组件:历史曲线 -->
  4. <el-dialog v-dialogDrag title="历史监测信息" :visible.sync="dialogVisible" :modal="false" :append-to-body="true" width="1200px">
  5. <div class="top">
  6. <el-form ref="form" :model="form" label-width="auto" size="small">
  7. <el-row :gutter="24">
  8. <el-col :span="7">
  9. <el-form-item label="监测站点">
  10. <el-cascader v-model="form.siteId" :props="customProps" :options="siteOption" :show-all-levels="false" clearable @change="value=>{siteChange(1,value)}" placeholder="选择站点" style="width:100%"></el-cascader>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="7">
  14. <el-form-item label="监测指标">
  15. <el-select v-model="targets" filterable multiple collapse-tags placeholder="选择站点" style="width:100%">
  16. <el-option v-for="(item,index) in targetOptions1" :key="index" :label="item.targetName" :value="item.targetCode">
  17. </el-option>
  18. </el-select>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="10">
  22. <el-form-item label="时间范围">
  23. <el-date-picker v-model="form.date" type="daterange" align="right" unlink-panels range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" value-format="yyyy-MM-dd"
  24. format="yyyy/MM/dd" style="width:100%" :clearable="false">
  25. </el-date-picker>
  26. </el-form-item>
  27. </el-col>
  28. </el-row>
  29. <el-row :gutter="24">
  30. <el-col :span="7">
  31. <el-form-item label="对比监测站点">
  32. <el-cascader v-model="form.siteId2" :props="customProps" :options="siteOption" :show-all-levels="false" clearable @change="value=>{siteChange(2,value)}" placeholder="选择站点" style="width:100%"></el-cascader>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="7">
  36. <el-form-item label="对比监测指标">
  37. <el-select v-model="targets2" filterable multiple collapse-tags placeholder="选择站点" style="width:100%">
  38. <el-option v-for="(item,index) in targetOptions2" :key="index" :label="item.targetName" :value="item.targetCode">
  39. </el-option>
  40. </el-select>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="7">
  44. <el-form-item label="同比开始时间">
  45. <!-- <el-date-picker v-model="form.date2" type="date" placeholder="选择日期" style="width: 100%;"></el-date-picker> -->
  46. <el-date-picker v-model="form.date2" type="datetime" placeholder="选择日期时间" style="width: 100%;">
  47. </el-date-picker>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="2">
  51. <el-form-item label-width="0">
  52. <el-button type="primary" size="small" style="width:85px" @click="query()">查询</el-button>
  53. </el-form-item>
  54. </el-col>
  55. <!-- <el-col :span="2">
  56. <el-form-item label-width="0">
  57. <el-button type="primary" size="small" style="width:85px">导出</el-button>
  58. </el-form-item>
  59. </el-col> -->
  60. </el-row>
  61. </el-form>
  62. </div>
  63. <div class="time-select">
  64. <el-radio-group v-model="radio">
  65. <el-radio :label="1">实时数据</el-radio>
  66. <el-radio :label="2">每小时均值</el-radio>
  67. <el-radio :label="3">每日均值</el-radio>
  68. </el-radio-group>
  69. </div>
  70. <!-- 标签页 -->
  71. <el-tabs v-model="activeName" style="height:550px">
  72. <el-tab-pane label="图表" name="first" :disabled="tabPaneDisabled">
  73. <div class="chartsdiv" ref="chartsdiv">
  74. <div class="chart-div" v-for="(value,key) in targetObj">
  75. <div class="chart-title" v-cloak>{{targetObj[key].target.targetName}}({{targetObj[key].target.targetCode}})</div>
  76. <div :ref="targetObj[key].target.targetCode" class="chartBox"></div>
  77. </div>
  78. </div>
  79. </el-tab-pane>
  80. <el-tab-pane label="列表" name="second" style="height:100%" :disabled="tabPaneDisabled">
  81. <el-table :data="pageTableData" stripe height="calc(100% - 45px)" style="width:100%" :header-cell-style="{background:'#e0eafb',color:'rgb(50,59,65)',height:'39px',textAlign:'center',fontWeight:'600'}">
  82. <template slot="empty">
  83. <img src="@/assets/icon/null.png" alt="" />
  84. </template>
  85. <el-table-column prop="date" label="序号" width="50" align="center">
  86. <template slot-scope="scope">{{scope.$index+1}}</template>
  87. </el-table-column>
  88. <el-table-column prop="collectionDates" label="采集时间" align="center"></el-table-column>
  89. <el-table-column v-for="(item,index) in targetData" :key="index" :prop="item.targetCode+'s'" :label="item.targetName" align="center">
  90. </el-table-column>
  91. </el-table>
  92. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.current" small :page-sizes="[20, 50, 100, 150]" :page-size="pagination.size" layout="total, sizes, prev, pager, next"
  93. :total="pagination.total">
  94. </el-pagination>
  95. </el-tab-pane>
  96. </el-tabs>
  97. </el-dialog>
  98. </div>
  99. </template>
  100. <script>
  101. import {
  102. getCurve,
  103. getHourCurve,
  104. getDayCurve,
  105. getSites,
  106. getGroupSite,
  107. getTargetByType,
  108. getRainfallHour
  109. } from '@/views/spectrum/dynamicMonitor/api/api'
  110. import elementResizeDetectorMaker from 'element-resize-detector'
  111. import * as echarts from 'echarts'
  112. export default {
  113. name: 'historyCurve',
  114. data() {
  115. return {
  116. pickerOptions: {
  117. shortcuts: [
  118. {
  119. text: '昨天',
  120. onClick(picker) {
  121. const start = new Date()
  122. const end = new Date()
  123. start.setTime(start.getTime() - 3600 * 1000 * 24)
  124. end.setTime(end.getTime() - 3600 * 1000 * 24)
  125. picker.$emit('pick', [start, end])
  126. }
  127. },
  128. {
  129. text: '最近一周',
  130. onClick(picker) {
  131. const end = new Date()
  132. const start = new Date()
  133. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  134. picker.$emit('pick', [start, end])
  135. }
  136. },
  137. {
  138. text: '最近半个月',
  139. onClick(picker) {
  140. const end = new Date()
  141. const start = new Date()
  142. start.setTime(start.getTime() - 3600 * 1000 * 24 * 15)
  143. picker.$emit('pick', [start, end])
  144. }
  145. },
  146. {
  147. text: '最近一个月',
  148. onClick(picker) {
  149. const end = new Date()
  150. const start = new Date()
  151. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
  152. picker.$emit('pick', [start, end])
  153. }
  154. },
  155. {
  156. text: '最近三个月',
  157. onClick(picker) {
  158. const end = new Date()
  159. const start = new Date()
  160. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
  161. picker.$emit('pick', [start, end])
  162. }
  163. },
  164. {
  165. text: '最近半年',
  166. onClick(picker) {
  167. const end = new Date()
  168. const start = new Date()
  169. start.setTime(start.getTime() - 3600 * 1000 * 24 * 180)
  170. picker.$emit('pick', [start, end])
  171. }
  172. },
  173. {
  174. text: '最近一年',
  175. onClick(picker) {
  176. const end = new Date()
  177. const start = new Date()
  178. start.setTime(start.getTime() - 3600 * 1000 * 24 * 365)
  179. picker.$emit('pick', [start, end])
  180. }
  181. }
  182. ]
  183. },
  184. areaColor: [
  185. ['rgba(126, 215, 243)', 'rgba(250, 253, 254)'],
  186. ['rgba(128, 255, 165)', 'rgba(1, 191, 236)'],
  187. ['rgba(0, 221, 255)', 'rgba(77, 119, 255)'],
  188. ['rgba(55, 162, 255)', 'rgba(116, 21, 219)'],
  189. ['rgba(255, 0, 135)', 'rgba(135, 0, 157)'],
  190. ['rgba(255, 191, 0)', 'rgba(224, 62, 76)'],
  191. ['rgba(0, 221, 255)', 'rgba(77, 119, 255)'],
  192. ['rgba(0, 221, 255)', 'rgba(77, 119, 255)']
  193. ], // 曲线图表颜色
  194. dialogVisible: false,
  195. siteOption: [],
  196. form: {
  197. date: []
  198. },
  199. targets: [],
  200. targets2: [],
  201. radio: 2,
  202. activeName: 'first',
  203. targetObj: {},
  204. targetOptions1: [],
  205. targetOptions2: [],
  206. targetData: [], // 图表类型
  207. tableData: [], // 列表数据
  208. pageTableData: [], // 列表分页数据
  209. dialogDragWidth: '520px',
  210. timeType: 1,
  211. customProps: {
  212. value: 'id',
  213. label: 'name',
  214. children: 'data'
  215. },
  216. totleTargets: [],
  217. pagination: { current: 1, size: 50, total: 0 },
  218. loadingState: null,
  219. tabPaneDisabled: false
  220. }
  221. },
  222. mounted() { },
  223. watch: {
  224. radio(val, oldVal) {
  225. this.query()
  226. },
  227. targets2(val, oldVal) {
  228. if (oldVal.length == 0 && val.length > 0 && this.form.date && this.form.date.length > 0) {
  229. this.$set(this.form, 'date2', this.form.date[0])
  230. }
  231. }
  232. },
  233. methods: {
  234. /**
  235. * 选择主站点
  236. */
  237. siteChange(type, value) {
  238. if (type == 1) {
  239. this.targetOptions1 = []
  240. this.targets = []
  241. } else {
  242. this.targetOptions2 = []
  243. this.targets2 = []
  244. }
  245. if (!value || value.length == 0) {
  246. return
  247. }
  248. const divice = this.getDivice(value[1])
  249. const typeId = divice.site.deviceType || null
  250. if (typeId) this.getTargetByType(type, typeId)
  251. },
  252. /**
  253. * 根据设备类型id获取指标
  254. */
  255. async getTargetByType(type, typeId) {
  256. await getTargetByType({ current: 1, size: 10000, typeId: typeId }).then((res) => {
  257. if (res.code == 1) {
  258. if (type == 1) {
  259. this.targetOptions1 = res.result.records
  260. let targets = this.targetOptions1.length > 0 ? [this.targetOptions1[0].targetCode] : []
  261. this.targets = targets
  262. } else {
  263. this.targetOptions2 = res.result.records
  264. let targets2 = this.targetOptions2.length > 0 ? [this.targetOptions2[0].targetCode] : []
  265. this.targets2 = targets2
  266. }
  267. }
  268. })
  269. },
  270. /**
  271. * 根据设站点id获取站点信息
  272. */
  273. getDivice(value) {
  274. let _group = null
  275. let _site = null
  276. for (let i = 0; i < this.siteOption.length; i++) {
  277. const group = this.siteOption[i]
  278. for (let j = 0; j < group.data.length; j++) {
  279. const site = group.data[j]
  280. if (site.id == value) {
  281. _group = group
  282. _site = site
  283. break
  284. }
  285. }
  286. }
  287. return {
  288. group: _group,
  289. site: _site
  290. }
  291. },
  292. /**
  293. * 展示曲线
  294. */
  295. async show(siteId = null) {
  296. Object.assign(this.$data, this.$options.data.call(this))
  297. await this.getSites(siteId)
  298. this.dialogVisible = true
  299. if (siteId != null) {
  300. this.getHistoryCurve({ siteId: siteId, checkCodes: this.targets.join(',') })
  301. }
  302. },
  303. /**
  304. * 获取站点
  305. */
  306. async getSites(siteId) {
  307. await getGroupSite({ projectId: this.$store.state.project.project.id }).then(async (res) => {
  308. if (res.code && res.code == 1) {
  309. this.siteOption = res.result.records
  310. this.siteOption = res.result.map((item) => {
  311. item['name'] = `${item.groupName}(${item.size})`
  312. item['id'] = item.groupName
  313. item.data = item.data.map((item2) => {
  314. item2['name'] = item2.siteName
  315. return item2
  316. })
  317. return item
  318. })
  319. if (!siteId) return
  320. let { group, site } = this.getDivice(siteId)
  321. // 初始化选中站点
  322. if (group && site) this.$set(this.form, 'siteId', [group.id, siteId])
  323. if (site.deviceType) await this.getTargetByType(1, site.deviceType)
  324. }
  325. })
  326. },
  327. /**
  328. * 请求参数
  329. */
  330. readyParams() {
  331. // let timeInterval = this.getQueryTime() // 查询时间段一
  332. let timeInterval = {
  333. startTime: this.$moment(this.form.date[0]).format('YYYY-MM-DD 00:00:00'),
  334. endTime: this.$moment(this.form.date[1]).format('YYYY-MM-DD 23:59:59')
  335. }
  336. let params = {
  337. siteId: this.form.siteId[1],
  338. beginTime: timeInterval.startTime,
  339. endTime: timeInterval.endTime,
  340. checkCodes: this.targets.join(','),
  341. comprasionCheckCodes: this.targets2.join(',')
  342. }
  343. if (this.form.siteId2) params['comprasionSiteIds'] = this.form.siteId2[1]
  344. // 同比开始时间
  345. if (this.form.date2) params['comprasionBeginTime'] = this.$moment(this.form.date2).format('YYYY-MM-DD HH:mm:ss')
  346. // 时间差
  347. let seconds = this.$moment(timeInterval.endTime).diff(this.$moment(timeInterval.startTime), 'seconds')
  348. // 同比结束时间
  349. if (this.form.date2)
  350. params['comprasionEndTime'] = this.$moment(params.comprasionBeginTime)
  351. .add(seconds, 'second')
  352. .format('YYYY-MM-DD HH:mm:ss')
  353. return params
  354. },
  355. /**
  356. * 处理返回的曲线数据
  357. */
  358. async dealCurveData(params, res) {
  359. if (res.code && res.code == 1) {
  360. if (!res.result || !res.result.list || res.result.list instanceof Array == false) {
  361. this.targetObj = {}
  362. this.targetData = []
  363. this.tableData = []
  364. return
  365. }
  366. // const tableData = res.result.list[0]
  367. // 显示最新时间
  368. if (!params.hasOwnProperty('beginTime') && !params.hasOwnProperty('endTime')) {
  369. this.timeType = 7
  370. this.form.date = [res.result.map.X1[0], res.result.map.X1[res.result.map.X1.length - 1]]
  371. }
  372. let rainData = null;
  373. if (this.radio != 3) {
  374. const startDate = this.$moment(this.form.date[0]).format("YYYY-MM-DD")
  375. const endDate = this.$moment(this.$moment(this.form.date[1]).add(1, 'd')).format("YYYY-MM-DD")
  376. // 雨量
  377. // this.getRainfallHour(params.siteId, startDate, endDate)
  378. const getRainfallParams = {
  379. siteId: params.siteId,
  380. beginDate: startDate,
  381. endDate: endDate
  382. }
  383. let { result: rainFall } = await getRainfallHour(getRainfallParams);
  384. rainData = this.groupRainfallData(res.result.map.X1, rainFall.rainFallVos)
  385. }
  386. // 主站点
  387. let mainData = res.result.list.find((item) => {
  388. return item.type == 'X1'
  389. })
  390. // 表格字段
  391. this.targetData = mainData.targetVos.filter((item) => {
  392. return this.targets.indexOf(item.targetCode) >= 0
  393. })
  394. this.loadTable(mainData)
  395. // 图表
  396. let targetObj = this.groupResponseData(res)
  397. this.targetObj = targetObj
  398. for (const key in targetObj) {
  399. const item = targetObj[key]
  400. // 加载图表
  401. this.$nextTick(() => {
  402. let { series, legends } = this.getChartData(item.data, rainData)
  403. this.loadChart(item.target.targetCode, legends, res.result.map, series)
  404. })
  405. }
  406. this.$nextTick(() => {
  407. this.loadingClose()
  408. })
  409. }
  410. },
  411. /**
  412. * 获取图表雨量数据
  413. */
  414. groupRainfallData(x1Data, rainFallData) {
  415. let myRainFallData = []
  416. for (let index = 0; index < x1Data.length; index++) {
  417. const x1Item = this.$moment(x1Data[index]).format("YYYY-MM-DD HH");
  418. const rain = rainFallData.find(item => { return this.$moment(item.xposition).format("YYYY-MM-DD HH") == x1Item })
  419. myRainFallData.push(rain ? rain.maxFall : null)
  420. }
  421. return myRainFallData
  422. },
  423. /**
  424. * 组织返回的数据
  425. */
  426. groupResponseData(response) {
  427. let obj = {}
  428. const array = response.result.list
  429. for (let index = 0; index < array.length; index++) {
  430. const listItem = array[index]
  431. let targetVos = listItem.targetVos
  432. // 所有指标
  433. let targets = this.targets.concat(this.targets2)
  434. const totleTargets = Array.from(new Set(targets))
  435. // 组合数据
  436. for (let index2 = 0; index2 < targetVos.length; index2++) {
  437. const targetItem = targetVos[index2]
  438. if (totleTargets.indexOf(targetItem.targetCode) < 0) continue
  439. let targetData = {
  440. list: listItem[targetItem.targetCode + 's'],
  441. type: listItem.type
  442. }
  443. if (!obj.hasOwnProperty(targetItem.targetCode)) {
  444. obj[targetItem.targetCode] = {
  445. target: targetItem,
  446. data: [targetData]
  447. }
  448. } else {
  449. obj[targetItem.targetCode].data.push(targetData)
  450. }
  451. }
  452. }
  453. return obj
  454. },
  455. /**
  456. * 获取监测曲线数据
  457. */
  458. getHistoryCurve(params) {
  459. this.loading()
  460. if (this.radio == 1) {
  461. getCurve(params).then((res) => {
  462. this.dealCurveData(params, res)
  463. })
  464. } else if (this.radio == 2) {
  465. getHourCurve(params).then((res) => {
  466. this.dealCurveData(params, res)
  467. })
  468. } else if (this.radio == 3) {
  469. getDayCurve(params).then((res) => {
  470. this.dealCurveData(params, res)
  471. })
  472. }
  473. },
  474. /**
  475. * 获取查询时间
  476. */
  477. // getQueryTime() {
  478. // // 当前时间
  479. // const CURRENT_TIME = this.$moment().format('YYYY-MM-DD HH:mm:ss')
  480. // let endTime = ''
  481. // let startTime = ''
  482. // // 获取时间
  483. // switch (this.timeType) {
  484. // case 1: // 近24小时
  485. // endTime = CURRENT_TIME // 当前时间
  486. // startTime = this.$moment(CURRENT_TIME).subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss')
  487. // break
  488. // case 2: // 今天
  489. // endTime = this.$moment(CURRENT_TIME).format('YYYY-MM-DD HH:mm:ss')
  490. // startTime = this.$moment(CURRENT_TIME).format('YYYY-MM-DD 00:00:00')
  491. // break
  492. // case 3: // 昨天
  493. // endTime = this.$moment(CURRENT_TIME).subtract(1, 'day').format('YYYY-MM-DD 23:59:59')
  494. // startTime = this.$moment(CURRENT_TIME).subtract(1, 'day').format('YYYY-MM-DD 00:00:00')
  495. // break
  496. // case 4: // 近7天
  497. // endTime = this.$moment(CURRENT_TIME).subtract(1, 'day').format('YYYY-MM-DD 23:59:59')
  498. // startTime = this.$moment(endTime).subtract(7, 'day').format('YYYY-MM-DD 00:00:00')
  499. // break
  500. // case 5: // 近15天
  501. // endTime = this.$moment(CURRENT_TIME).subtract(1, 'day').format('YYYY-MM-DD 23:59:59')
  502. // startTime = this.$moment(endTime).subtract(15, 'day').format('YYYY-MM-DD 00:00:00')
  503. // break
  504. // case 6:
  505. // endTime = this.$moment(CURRENT_TIME).subtract(1, 'day').format('YYYY-MM-DD 23:59:59')
  506. // startTime = this.$moment(endTime).subtract(30, 'day').format('YYYY-MM-DD 00:00:00')
  507. // break
  508. // case 7:
  509. // endTime = this.$moment(this.form.date[1]).format('YYYY-MM-DD 23:59:59')
  510. // startTime = this.$moment(this.form.date[0]).format('YYYY-MM-DD 00:00:00')
  511. // break
  512. // }
  513. // return {
  514. // startTime: startTime,
  515. // endTime: endTime
  516. // }
  517. // },
  518. /**
  519. * 查询
  520. */
  521. query() {
  522. let params = this.readyParams()
  523. this.getHistoryCurve(params)
  524. },
  525. /**
  526. * 图表数据
  527. */
  528. getChartData(seriesList, rainFallData = null) {
  529. let series = []
  530. let legends = []
  531. seriesList.forEach((item) => {
  532. const siteInfo = item.type == 'X1' ? this.getDivice(this.form.siteId[1]) : this.getDivice(this.form.siteId2[1])
  533. const siteName = siteInfo.site.siteName || '未知站点'
  534. legends.push(siteName)
  535. series.push({
  536. name: siteName,
  537. xAxisIndex: item.type == 'X1' ? 0 : 1,
  538. sampling: 'average', //降采样策略
  539. type: 'line',
  540. smooth: true,
  541. lineStyle: {
  542. width: 2
  543. },
  544. showSymbol: false,
  545. label: {
  546. show: true,
  547. position: 'top'
  548. },
  549. emphasis: {
  550. focus: 'series'
  551. },
  552. data: item.list
  553. })
  554. })
  555. if (rainFallData) {
  556. series.unshift({
  557. name: '雨量',
  558. xAxisIndex: 0,
  559. sampling: 'average', //降采样策略
  560. type: 'bar',
  561. yAxisIndex: 1,
  562. emphasis: {
  563. focus: 'series'
  564. },
  565. data: rainFallData
  566. })
  567. legends.unshift('雨量')
  568. }
  569. return {
  570. series: series,
  571. legends: legends
  572. }
  573. },
  574. /**
  575. * 加载图表
  576. */
  577. loadChart(domIndex, legends, xAxisList, seriesList) {
  578. const chartDom = this.$refs[domIndex][0]
  579. const myChart = echarts.init(chartDom)
  580. const option = {
  581. tooltip: {
  582. trigger: 'axis',
  583. axisPointer: {
  584. type: 'cross',
  585. label: {
  586. backgroundColor: '#6a7985'
  587. }
  588. }
  589. },
  590. legend: {
  591. data: legends
  592. },
  593. grid: {
  594. top: '10%',
  595. left: '3%',
  596. right: '4%',
  597. bottom: '15%',
  598. containLabel: true
  599. },
  600. dataZoom: [
  601. {
  602. type: 'inside',
  603. start: 0
  604. // end: 20
  605. },
  606. {
  607. start: 0
  608. // end: 20
  609. }
  610. ],
  611. xAxis: [
  612. {
  613. type: 'category',
  614. boundaryGap: false,
  615. data: xAxisList.X1,
  616. axisLabel: {
  617. formatter: (dateTime) => {
  618. return this.formatAxisLabel(dateTime)
  619. }
  620. }
  621. },
  622. {
  623. type: 'category',
  624. boundaryGap: false,
  625. data: xAxisList.X2,
  626. axisLabel: {
  627. formatter: (dateTime) => {
  628. return this.formatAxisLabel(dateTime)
  629. }
  630. }
  631. }
  632. ],
  633. yAxis: [
  634. {
  635. type: 'value'
  636. },
  637. {
  638. nameLocation: 'start',
  639. alignTicks: true,
  640. type: 'value'
  641. }
  642. ],
  643. series: seriesList
  644. }
  645. myChart.clear()
  646. option && myChart.setOption(option)
  647. elementResizeDetectorMaker().listenTo(chartDom, () => {
  648. this.$nextTick(() => {
  649. myChart.resize()
  650. })
  651. })
  652. },
  653. /**
  654. * 格式化 X 轴指标标签
  655. */
  656. formatAxisLabel(axisLabel) {
  657. if (this.radio == 3) return this.$moment(axisLabel).format('MM月DD日')
  658. else if (this.radio == 2) return this.$moment(axisLabel).format('MM月DD日HH时')
  659. else if (this.radio == 1) return this.$moment(axisLabel).format('MM月DD日HH时')
  660. },
  661. /**
  662. * 加载列表
  663. */
  664. loadTable(data) {
  665. let arr = []
  666. data.collectionDates.forEach((item, index) => {
  667. arr.push({ serialnum: index + 1 })
  668. const targetVos = data.targetVos
  669. for (let index1 = 0; index1 < targetVos.length; index1++) {
  670. const item1 = targetVos[index1]
  671. if (this.targets.indexOf(item1.targetCode) < 0) continue
  672. let columnName = item1.targetCode + 's'
  673. let columnVal = data[columnName]
  674. arr[index][columnName] = columnVal[index] ? columnVal[index] : '/'
  675. }
  676. arr[index]['collectionDates'] = item
  677. })
  678. this.tableData = arr
  679. this.getPageList()
  680. },
  681. /**
  682. * 分页操作
  683. */
  684. getPageList() {
  685. const { current, size } = this.pagination
  686. this.pageTableData = this.tableData.filter(
  687. (item, index) => index < current * size && index >= size * (current - 1)
  688. )
  689. this.pagination.total = this.tableData.length
  690. },
  691. //处理切换页码
  692. handleSizeChange(val) {
  693. this.pagination.size = val
  694. this.getPageList()
  695. },
  696. handleCurrentChange(val) {
  697. this.pagination.current = val
  698. this.getPageList()
  699. },
  700. /**
  701. * 加载状态
  702. */
  703. loading() {
  704. this.$nextTick(() => {
  705. this.tabPaneDisabled = true
  706. this.loadingState = this.$loading({
  707. target: this.$refs.chartsdiv,
  708. lock: false,
  709. text: '正在加载……',
  710. spinner: 'el-icon-loading',
  711. background: 'rgb(255, 255, 255)'
  712. });
  713. })
  714. },
  715. /**
  716. * 关闭加载状态
  717. */
  718. loadingClose() {
  719. this.tabPaneDisabled = false
  720. if (this.loadingState) this.loadingState.close()
  721. }
  722. }
  723. }
  724. </script>
  725. <style lang="scss" scoped>
  726. // 覆盖层元素增加可穿透点击事件
  727. .el-dialog__wrapper {
  728. pointer-events: none;
  729. overflow: hidden;
  730. >>> .el-dialog {
  731. // 弹窗层元素不可穿透点击事件(不影响弹窗层元素的点击事件)
  732. pointer-events: auto;
  733. .el-dialog__header {
  734. background-color: #2d74e7;
  735. padding: 10px 20px 10px;
  736. .el-dialog__title {
  737. color: #ffffff;
  738. font-size: 16px;
  739. }
  740. .el-dialog__headerbtn {
  741. top: 15px;
  742. }
  743. .el-dialog__close {
  744. color: #ffffff !important;
  745. }
  746. }
  747. .el-dialog__full {
  748. position: absolute;
  749. top: 15px;
  750. right: 45px;
  751. i {
  752. color: #fff !important;
  753. }
  754. }
  755. }
  756. .el-form {
  757. >>> .el-form-item {
  758. .el-form-item__content {
  759. .el-radio-group {
  760. .el-radio {
  761. margin-right: 15px !important;
  762. }
  763. }
  764. }
  765. }
  766. }
  767. .time-select {
  768. position: absolute;
  769. right: 15px;
  770. top: 20p;
  771. margin-top: 15px;
  772. z-index: 99;
  773. .el-radio {
  774. >>> .el-radio__label {
  775. padding-left: 2px !important;
  776. }
  777. }
  778. }
  779. .el-tabs {
  780. >>> .el-tabs__content {
  781. height: calc(100% - 55px);
  782. .chartsdiv {
  783. width: 100%;
  784. height: 100%;
  785. overflow-y: auto;
  786. .el-loading-spinner {
  787. font-size: 30px;
  788. }
  789. .chart-div {
  790. margin-bottom: 20px;
  791. .chart-title {
  792. font-size: 16px;
  793. font-family: '宋体';
  794. color: #333333;
  795. line-height: 18px;
  796. margin: 10px 0;
  797. font-weight: 600;
  798. &::before {
  799. content: '';
  800. display: inline-block;
  801. width: 3px;
  802. height: 16px;
  803. background: #2a77f7;
  804. vertical-align: top;
  805. margin-right: 5px;
  806. }
  807. }
  808. .chartBox {
  809. width: 100%;
  810. height: 430px;
  811. }
  812. }
  813. }
  814. }
  815. }
  816. .el-table {
  817. >>> th > .cell {
  818. white-space: pre-line;
  819. }
  820. >>> .el-table__body {
  821. td.el-table__cell {
  822. height: 35px;
  823. padding: 0 !important;
  824. }
  825. }
  826. ::v-deep .el-table__body,
  827. ::v-deep .el-table__header,
  828. ::v-deep .el-table__empty-block {
  829. width: 100% !important;
  830. }
  831. }
  832. .el-pagination {
  833. margin-top: 10px;
  834. }
  835. }
  836. </style>