123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <template>
- <div :class="$style.title">
- <span class="header_sd-header_common"
- ><span :class="['toptitle', $style.toptitle]">{{ title }}</span></span
- >
- <div>
- <div v-show="!hasData">
- <a-empty />
- </div>
- <div v-show="hasData">
- <sd-echart :key="tableKey" :class="$style.echarts" :options="echartsData" autoresize />
- </div>
- <div v-show="hasData">
- <sd-data-table
- :key="tableKey"
- ref="dataTable"
- :class="$style.childTable"
- row-key="indi_id"
- :columns="columns"
- form-id="kpiIndiDef"
- data-url="api/xcoa-mobile/v1/kpi-assay/getKpiAssayList"
- :modal-props="{ class: 'noBottom' }"
- :process-req="processReq"
- :process-res="processRes"
- @dataLoaded="dataLoaded"
- >
- </sd-data-table>
- </div>
- </div>
- </div>
- </template>
- <script>
- import 'echarts/lib/chart/treemap'
- import 'echarts/lib/chart/line'
- import 'echarts/lib/chart/pictorialBar'
- import 'echarts/lib/component/title'
- import 'echarts/lib/chart/bar'
- import 'echarts/lib/component/legend'
- import 'echarts/lib/component/legendScroll'
- import 'echarts/lib/component/tooltip'
- import kpiAnalysisFormService from './kpi-analysis-form-service'
- import components from './_import-components/kpi-analysis-form-echarts-import'
- export default {
- name: 'KpiAnalysisFormEcharts',
- metaInfo: {
- title: 'KpiAnalysisFormEcharts',
- },
- components,
- props: {
- title: {
- type: String,
- default: '',
- },
- indiId: {
- type: Number,
- default: -1,
- require: true,
- },
- params: {
- type: Object,
- default: () => {
- return {}
- },
- require: true,
- },
- },
- data() {
- return {
- hasData: false,
- columns: [],
- tableKey: 0,
- echartsData: {
- tooltip: {
- trigger: 'axis',
- },
- legend: {
- selectedMode: false,
- bottom: 15,
- data: [],
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '35',
- containLabel: true,
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: [],
- show: false,
- },
- yAxis: {
- type: 'value',
- },
- series: [],
- },
- }
- },
- created() {
- kpiAnalysisFormService.getKpiAssayHeader(this.params).then((resData) => {
- this.columns = [
- {
- title: '序号',
- customRender: (text, record, index) => `${index + 1}`,
- width: '80px',
- },
- {
- title: '监测单位',
- dataIndex: '监测单位',
- },
- ]
- resData.data.forEach((item) => {
- if (item !== '监测单位') {
- this.echartsData.xAxis.data.push(item)
- this.columns.push({
- title: item,
- dataIndex: item,
- })
- }
- })
- this.tableKey++
- })
- },
- methods: {
- dataLoaded() {
- this.$refs.dataTable.$refs.table.reset()
- },
- processReq(req) {
- req.data = {
- ...req.data,
- ...this.params,
- indiId: this.indiId,
- pageIndex: req.data.startPosition,
- pageSize: req.data.maxResults,
- }
- return req
- },
- processRes(res) {
- this.echartsData.series = []
- this.echartsData.legend.data = []
- this.hasData = true
- if (res.data.length === 0) this.hasData = false
- res.data.forEach((item) => {
- const data = []
- this.echartsData.xAxis.data.forEach((xAxis) => {
- data.push(item[xAxis])
- })
- this.echartsData.series.push({
- name: item['监测单位'],
- type: 'line',
- stack: 'Total',
- data: data,
- })
- this.echartsData.legend.data.push({
- name: item['监测单位'],
- icon: 'roundRect',
- })
- })
- if ((this.columns.length !== 0) | (res.data.length === 0)) return res
- this.tableKey++
- return res
- // if ((this.columns.length !== 0) | (res.data.length === 0)) return res
- // this.columns.push({
- // title: '序号',
- // customRender: (text, record, index) => `${index + 1}`,
- // width: '80px',
- // })
- // const row = res.data[0]
- // for (const key in row) {
- // this.columns.push({
- // title: key,
- // dataIndex: key,
- // })
- // }
- // this.tableKey++
- // return res
- },
- },
- }
- </script>
- <style module lang="scss">
- @use '@/common/design' as *;
- .title {
- text-align: center;
- }
- .toptitle {
- color: #404040;
- font-weight: bold;
- font-size: 22px;
- }
- .echarts {
- width: 90%;
- margin: auto;
- }
- .child-table {
- :global(.ant-table-body) {
- overflow: auto;
- }
- table:first-child {
- colgroup {
- :not(col:first-child) {
- width: 150px;
- }
- }
- }
- }
- </style>
|