|
@@ -1,10 +1,14 @@
|
|
|
<template>
|
|
|
- <div class="shaanxiNewslunjian">
|
|
|
+ <div class="shaanxiNewsSimulcast">
|
|
|
+ <el-button type="primary" class="export" @click="exportfun">
|
|
|
+ 导出
|
|
|
+ </el-button>
|
|
|
<el-table
|
|
|
:data="tableData"
|
|
|
v-if="tableData.length"
|
|
|
:header-cell-style="{ backgroundColor: '#f4f5f7', color: '#333333' }"
|
|
|
@expand-change="rowClick"
|
|
|
+ @sort-change="sortFun"
|
|
|
style="width: 100%"
|
|
|
>
|
|
|
<el-table-column type="expand">
|
|
@@ -22,9 +26,27 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column align="center" label="日期" prop="stadate" />
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ label="日期"
|
|
|
+ prop="stadate"
|
|
|
+ sortable="custom"
|
|
|
+ />
|
|
|
<el-table-column align="center" label="栏目" prop="program_name" />
|
|
|
- <el-table-column align="center" label="收视率" prop="watchrate">
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ label="市场占有率"
|
|
|
+ prop="occrate"
|
|
|
+ sortable="custom"
|
|
|
+ >
|
|
|
+ <template #default="scope"> {{ scope.row.occrate }}% </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ label="收视率"
|
|
|
+ prop="watchrate"
|
|
|
+ sortable="custom"
|
|
|
+ >
|
|
|
<template #default="scope">
|
|
|
<watchrate-ele
|
|
|
:watchrate="scope.row.watchrate"
|
|
@@ -33,14 +55,24 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
- <el-pagination
|
|
|
+ <!-- <el-pagination
|
|
|
v-if="total / size > 1"
|
|
|
:page-size="size"
|
|
|
v-model:current-page="current"
|
|
|
@current-change="changePage"
|
|
|
:total="total"
|
|
|
>
|
|
|
- </el-pagination>
|
|
|
+ </el-pagination> -->
|
|
|
+ <el-button
|
|
|
+ type="default"
|
|
|
+ style="margin: 5px auto;display: block"
|
|
|
+ v-if="total > tableData.length"
|
|
|
+ :loading="load"
|
|
|
+ @click="changePage"
|
|
|
+ size="mini"
|
|
|
+ >
|
|
|
+ {{ load ? "加载中..." : "加载更多" }}
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -61,6 +93,7 @@ import {
|
|
|
} from "echarts/components";
|
|
|
import { LabelLayout, UniversalTransition } from "echarts/features";
|
|
|
import { CanvasRenderer } from "echarts/renderers";
|
|
|
+import config from "../../../config/index";
|
|
|
echarts.use([
|
|
|
TitleComponent,
|
|
|
TooltipComponent,
|
|
@@ -75,6 +108,8 @@ echarts.use([
|
|
|
]);
|
|
|
const openList = [];
|
|
|
const openLi = [];
|
|
|
+let type = "WATCHRATE",
|
|
|
+ direction = "DESC";
|
|
|
export default {
|
|
|
name: "shaanxiNewsSimulcast",
|
|
|
props: ["item"],
|
|
@@ -82,31 +117,32 @@ export default {
|
|
|
return {
|
|
|
tableData: [],
|
|
|
size: 10,
|
|
|
- current: 1,
|
|
|
+ load: false,
|
|
|
+ current: 0,
|
|
|
total: 1,
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
- epgResult({
|
|
|
- programId: this.item.id,
|
|
|
- page: this.current,
|
|
|
- pageSize: this.size,
|
|
|
- }).then(programList => {
|
|
|
- this.total = programList.total;
|
|
|
- this.tableData = programList.data;
|
|
|
- });
|
|
|
+ this.changePage(this.current);
|
|
|
},
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
- changePage(newPage) {
|
|
|
- this.current = newPage;
|
|
|
- epgResult({
|
|
|
+ changePage() {
|
|
|
+ // this.current = newPage;
|
|
|
+ if (this.load) return;
|
|
|
+ this.current++;
|
|
|
+ this.load = true;
|
|
|
+ const p = {
|
|
|
programId: this.item.id,
|
|
|
page: this.current,
|
|
|
pageSize: this.size,
|
|
|
- }).then(programList => {
|
|
|
+ };
|
|
|
+ type && (p.sort = type);
|
|
|
+ direction && (p.order = direction);
|
|
|
+ epgResult(p).then(programList => {
|
|
|
this.total = programList.total;
|
|
|
- this.tableData = programList.data;
|
|
|
+ this.tableData = [...this.tableData, ...programList.data];
|
|
|
+ this.load = false;
|
|
|
});
|
|
|
},
|
|
|
rowClick(row) {
|
|
@@ -125,17 +161,19 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
this.$nextTick(() => {
|
|
|
- epgDetail({ epgId: row.epg_id, target: ".loadare" + row.epg_id }).then(res => {
|
|
|
- let more = this.createChart(
|
|
|
- this.$refs["shaanxiNewsChart" + row.epg_id],
|
|
|
- res
|
|
|
- );
|
|
|
- openList[row.epg_id] = more.chart;
|
|
|
- openLi[row.epg_id] = this.createBarChart(
|
|
|
- this.$refs["shaanxiNewsListChart" + row.epg_id],
|
|
|
- more.height
|
|
|
- );
|
|
|
- });
|
|
|
+ epgDetail({ epgId: row.epg_id, target: ".loadare" + row.epg_id }).then(
|
|
|
+ res => {
|
|
|
+ let more = this.createChart(
|
|
|
+ this.$refs["shaanxiNewsChart" + row.epg_id],
|
|
|
+ res
|
|
|
+ );
|
|
|
+ openList[row.epg_id] = more.chart;
|
|
|
+ openLi[row.epg_id] = this.createBarChart(
|
|
|
+ this.$refs["shaanxiNewsListChart" + row.epg_id],
|
|
|
+ more.height
|
|
|
+ );
|
|
|
+ }
|
|
|
+ );
|
|
|
});
|
|
|
},
|
|
|
createChart(ele, list) {
|
|
@@ -301,6 +339,45 @@ export default {
|
|
|
option && chart.setOption(option);
|
|
|
return chart;
|
|
|
},
|
|
|
+ sortFun(column) {
|
|
|
+ direction = column.order ? config.order[column.order] : "DESC";
|
|
|
+ type = column.prop ? column.prop.toUpperCase() : "WATCHRATE";
|
|
|
+ this.changePage(1);
|
|
|
+ },
|
|
|
+ exportfun() {
|
|
|
+ let xhttp,
|
|
|
+ that = this;
|
|
|
+ if (window.XMLHttpRequest) xhttp = new XMLHttpRequest();
|
|
|
+ else xhttp = new window.ActiveXObject("Microsoft.XMLHTTP");
|
|
|
+ xhttp.responseType = "blob";
|
|
|
+ xhttp.open(
|
|
|
+ "GET",
|
|
|
+ config.base.url2 + "/epg-export?programId=" + that.item.id,
|
|
|
+ true
|
|
|
+ );
|
|
|
+ xhttp.send();
|
|
|
+ xhttp.onreadystatechange = function() {
|
|
|
+ if (this.readyState != 4 || this.status != 200) return;
|
|
|
+ // 组装a标签
|
|
|
+ let elink = document.createElement("a");
|
|
|
+ // 设置下载文件名
|
|
|
+ let D = new Date(),
|
|
|
+ M = D.getMonth() + 1,
|
|
|
+ E = D.getDate();
|
|
|
+ M > 9 ? "" : (M = ["0", M].join(""));
|
|
|
+ E > 9 ? "" : (E = ["0", E].join(""));
|
|
|
+ elink.download =
|
|
|
+ that.item.programName +
|
|
|
+ " " +
|
|
|
+ [D.getFullYear(), M, E].join("-") +
|
|
|
+ ".csv";
|
|
|
+ elink.style.display = "none";
|
|
|
+ elink.href = URL.createObjectURL(this.response);
|
|
|
+ document.body.appendChild(elink);
|
|
|
+ elink.click();
|
|
|
+ document.body.removeChild(elink);
|
|
|
+ };
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
beforeUnmount: function() {},
|