|
@@ -13,6 +13,14 @@
|
|
|
label-width="120px"
|
|
|
class="demo-form-inline"
|
|
|
>
|
|
|
+ <el-form-item label="主频道">
|
|
|
+ <el-autocomplete
|
|
|
+ v-model="form.program"
|
|
|
+ :fetch-suggestions="querySearchAsync"
|
|
|
+ placeholder="请输入频道"
|
|
|
+ @select="handleSelect"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="日期">
|
|
|
<el-date-picker
|
|
|
v-model="form.date"
|
|
@@ -25,38 +33,21 @@
|
|
|
>
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="主频道">
|
|
|
- <el-select
|
|
|
- v-model="form.channel"
|
|
|
- placeholder="请选择频道"
|
|
|
- multiple
|
|
|
- collapse-tags
|
|
|
- @change="channelSelect"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in channelList"
|
|
|
- :key="item.label"
|
|
|
- :label="item.label"
|
|
|
- :value="item.label"
|
|
|
- :disabled="item.disabled"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
<el-form-item label="对比频道">
|
|
|
<el-select
|
|
|
- v-model="form.contrastChannel"
|
|
|
- placeholder="请选择频道"
|
|
|
+ v-model="form.vs"
|
|
|
+ placeholder="请选择时段"
|
|
|
multiple
|
|
|
collapse-tags
|
|
|
- @change="channelSelect"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ :multiple-limit="4"
|
|
|
>
|
|
|
<el-option
|
|
|
- v-for="item in channelList"
|
|
|
- :key="item.label"
|
|
|
- :label="item.label"
|
|
|
- :value="item.label"
|
|
|
- :disabled="item.disabled"
|
|
|
+ v-for="item in tvList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
@@ -69,8 +60,8 @@
|
|
|
></el-cascader>
|
|
|
</el-form-item>
|
|
|
<el-form-item style="float: right">
|
|
|
- <el-button type="primary" @click="onSubmit">查询</el-button>
|
|
|
- <el-button type="primary" @click="onExport">导出</el-button>
|
|
|
+ <el-button type="primary" :loading="loading" @click="onSubmit">查询</el-button>
|
|
|
+ <el-button type="primary" :loading="loading1" @click="onExport">导出</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-card>
|
|
@@ -78,7 +69,8 @@
|
|
|
<el-card class="box-card">
|
|
|
<line-charts
|
|
|
:list="tableDate"
|
|
|
- xName="day"
|
|
|
+ v-if="tableDate.length"
|
|
|
+ xName="timestamp"
|
|
|
:keys="chartKeys"
|
|
|
></line-charts>
|
|
|
</el-card>
|
|
@@ -87,9 +79,9 @@
|
|
|
|
|
|
<script>
|
|
|
// @ is an alias to /src
|
|
|
-// import { } from "@/api/index";
|
|
|
+import { overlapSearchTitle, tvvscountry, tvlist,tvlistexport } from "@/api/kuyun";
|
|
|
|
|
|
-import lineCharts from "@/views/Country/components/lineCharts";
|
|
|
+import lineCharts from "@/views/Country/components/lineCharts1";
|
|
|
|
|
|
import config from "@/config/index";
|
|
|
export default {
|
|
@@ -98,127 +90,45 @@ export default {
|
|
|
return {
|
|
|
form: {
|
|
|
channel: 0,
|
|
|
- contrastChannel:0,
|
|
|
- date: [
|
|
|
- new Date(new Date() - 86400000),
|
|
|
- new Date(new Date() - 86400000),
|
|
|
- ],
|
|
|
+ date: [],
|
|
|
+ vs: [],
|
|
|
region: -1,
|
|
|
},
|
|
|
- tableData: [
|
|
|
- {
|
|
|
- channel_2: "陕西卫视",
|
|
|
- day: "2021-10-13",
|
|
|
- indicators_arrive: 0.007999,
|
|
|
- indicators_arrive_rank: 2,
|
|
|
- indicators_market_ratings: 0.003225,
|
|
|
- indicators_market_ratings_rank: 2,
|
|
|
- indicators_tv_ratings: 0.000193,
|
|
|
- indicators_tv_ratings_rank: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- channel_2: "陕西卫视",
|
|
|
- day: "2021-10-14",
|
|
|
- indicators_arrive: 0.009549,
|
|
|
- indicators_arrive_rank: 2,
|
|
|
- indicators_market_ratings: 0.003733,
|
|
|
- indicators_market_ratings_rank: 2,
|
|
|
- indicators_tv_ratings: 0.000228,
|
|
|
- indicators_tv_ratings_rank: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- channel_2: "安徽卫视",
|
|
|
- day: "2021-10-13",
|
|
|
- indicators_arrive: 0.017338,
|
|
|
- indicators_arrive_rank: 1,
|
|
|
- indicators_market_ratings: 0.009368,
|
|
|
- indicators_market_ratings_rank: 1,
|
|
|
- indicators_tv_ratings: 0.000561,
|
|
|
- indicators_tv_ratings_rank: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- channel_2: "安徽卫视",
|
|
|
- day: "2021-10-14",
|
|
|
- indicators_arrive: 0.019002,
|
|
|
- indicators_arrive_rank: 1,
|
|
|
- indicators_market_ratings: 0.009943,
|
|
|
- indicators_market_ratings_rank: 1,
|
|
|
- indicators_tv_ratings: 0.000608,
|
|
|
- indicators_tv_ratings_rank: 1,
|
|
|
- },
|
|
|
- ],
|
|
|
+ tvList: [],
|
|
|
+ tableDate: [],
|
|
|
+ loading: false,
|
|
|
+ loading1: false,
|
|
|
};
|
|
|
},
|
|
|
- mounted() {},
|
|
|
+ mounted() {
|
|
|
+ const d = new Date(Date.now() - 86400000);
|
|
|
+ let Y = d.getFullYear(),
|
|
|
+ M = d.getMonth() + 1,
|
|
|
+ D = d.getDate();
|
|
|
+ M > 9 ? "" : (M = "0" + M);
|
|
|
+ D > 9 ? "" : (D = "0" + D);
|
|
|
+ this.form.date = [[Y - 1, M, D].join("-"), [Y, M, D].join("-")];
|
|
|
+ tvlist().then(r => {
|
|
|
+ this.tvList = r || [];
|
|
|
+ });
|
|
|
+ },
|
|
|
computed: {
|
|
|
- channelList() {
|
|
|
- return config.channelNameList;
|
|
|
- },
|
|
|
- tableDate() {
|
|
|
- const obj = {};
|
|
|
-
|
|
|
- const b = [
|
|
|
- {
|
|
|
- key: "indicators_tv_ratings",
|
|
|
- name: "直播关注度",
|
|
|
- },
|
|
|
- {
|
|
|
- key: "indicators_market_ratings",
|
|
|
- name: "市占率",
|
|
|
- },
|
|
|
- {
|
|
|
- key: "indicators_arrive",
|
|
|
- name: "到达率",
|
|
|
- },
|
|
|
- ];
|
|
|
- for (let i = 0; i < this.tableData.length; i++) {
|
|
|
- const v = this.tableData[i];
|
|
|
- if (typeof obj[v.channel_2] !== "object") obj[v.channel_2] = {};
|
|
|
- obj[v.channel_2][v.day] = v;
|
|
|
- }
|
|
|
- let li = [],
|
|
|
- keys = Object.keys(obj),
|
|
|
- dataLen = Object.keys(obj[keys[0]]);
|
|
|
- for (let i = 0; i < dataLen.length; i++) {
|
|
|
- let p = {};
|
|
|
- for (let o = 0; o < keys.length; o++) {
|
|
|
- const v = obj[keys[o]][dataLen[i]];
|
|
|
- b.map(k => {
|
|
|
- p[keys[o] + "_" + k.key] = v[k.key];
|
|
|
- });
|
|
|
- }
|
|
|
- li.push({
|
|
|
- date: dataLen[i],
|
|
|
- ...p,
|
|
|
- });
|
|
|
- }
|
|
|
- return li;
|
|
|
- },
|
|
|
chartKeys() {
|
|
|
const obj = {},
|
|
|
li = [];
|
|
|
- for (let i = 0; i < this.tableData.length; i++) {
|
|
|
+ for (let i = 0; i < this.tableDate.length; i++) {
|
|
|
const b = [
|
|
|
{
|
|
|
- key: "indicators_tv_ratings",
|
|
|
+ key: "tv_ratings",
|
|
|
name: "直播关注度",
|
|
|
},
|
|
|
- {
|
|
|
- key: "indicators_market_ratings",
|
|
|
- name: "市占率",
|
|
|
- },
|
|
|
- {
|
|
|
- key: "indicators_arrive",
|
|
|
- name: "到达率",
|
|
|
- },
|
|
|
];
|
|
|
- const v = this.tableData[i];
|
|
|
- if (obj[v.channel_2] === true) continue;
|
|
|
- obj[v.channel_2] = true;
|
|
|
+ const v = this.tableDate[i][0];
|
|
|
+ if (obj[v.channel] === true) continue;
|
|
|
+ obj[v.channel] = true;
|
|
|
li.push(
|
|
|
...b.map(k => {
|
|
|
- k.key = v.channel_2 + "_" + k.key;
|
|
|
- k.name = v.channel_2 + "_" + k.name;
|
|
|
+ k.name = v.channel + "_" + k.name;
|
|
|
return k;
|
|
|
})
|
|
|
);
|
|
@@ -226,25 +136,89 @@ export default {
|
|
|
console.log(li);
|
|
|
return li;
|
|
|
},
|
|
|
- cycle() {
|
|
|
- return config.cycle;
|
|
|
- },
|
|
|
region() {
|
|
|
return config.region;
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
- onExport() {},
|
|
|
+ handleSelect(item) {
|
|
|
+ this.form.tv_id = item.id || "";
|
|
|
+ },
|
|
|
+ querySearchAsync(queryString, cb) {
|
|
|
+ if (!queryString) {
|
|
|
+ cb([]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ overlapSearchTitle("kw=" + queryString).then(r => {
|
|
|
+ let li = (r || []).map(v => {
|
|
|
+ return {
|
|
|
+ value: v.name,
|
|
|
+ id: v.id,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ cb(li);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onExport() {
|
|
|
+ if (!this.form.date.length || !this.form.vs.length) return;
|
|
|
+ let vs = (this.form.vs || []).join(",");
|
|
|
+ this.loading1= true;
|
|
|
+ tvlistexport('start=' +
|
|
|
+ this.form.date[0] +'+00:00:00&end=' +
|
|
|
+ this.form.date[1] +'+00:00:00&tv_id=48&area_id=' +
|
|
|
+ this.form.tv_id +'&vs=' +
|
|
|
+ vs +'&domain=pro.eye.kuyun.com&download=csv', '平均频道点分钟.csv', ()=>{
|
|
|
+ this.loading1 = false
|
|
|
+ })
|
|
|
+ },
|
|
|
disabledDate(time) {
|
|
|
return time.getTime() > Date.now() - 86400000;
|
|
|
},
|
|
|
- onSubmit() {},
|
|
|
+ onSubmit() {
|
|
|
+ console.log(this.form);
|
|
|
+ if (!this.form.date.length || !this.form.vs.length) return;
|
|
|
+ let vs = (this.form.vs || []).join(",");
|
|
|
+ let vsname = [];
|
|
|
+ for (let i = 0; i < (this.form.vs || []).length; i++) {
|
|
|
+ const v = (this.form.vs || [])[i];
|
|
|
+ const item = this.tvList.filter(o => o.id === v);
|
|
|
+ vsname.push(...item);
|
|
|
+ }
|
|
|
+
|
|
|
+ tvvscountry(
|
|
|
+ "start=" +
|
|
|
+ this.form.date[0] +
|
|
|
+ "+00:00:00&end=" +
|
|
|
+ this.form.date[1] +
|
|
|
+ "+00:00:00&tv_id=" +
|
|
|
+ this.form.tv_id +
|
|
|
+ "&area_id=9&vs=" +
|
|
|
+ vs
|
|
|
+ ).then(r => {
|
|
|
+ const li = r || { list: [], vs: [] },
|
|
|
+ l = [];
|
|
|
+ l.push(
|
|
|
+ li.list.map(v => {
|
|
|
+ v.channel = this.form.program;
|
|
|
+ return v;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ vsname.map((v, i) => {
|
|
|
+ let list = li.vs[i] || [];
|
|
|
+ l.push(
|
|
|
+ list.map(item => {
|
|
|
+ item.channel = v.name;
|
|
|
+ return item;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ });
|
|
|
+ console.log(l);
|
|
|
+ this.tableDate = l;
|
|
|
+ });
|
|
|
+ },
|
|
|
matrer(row, column, cellValue) {
|
|
|
return (cellValue * 100).toFixed(4) - 0 + "%";
|
|
|
},
|
|
|
- channelSelect(a) {
|
|
|
- this.selectAll(a, "channel", 0);
|
|
|
- },
|
|
|
selectAll(a, key, val) {
|
|
|
if (!a.length) return;
|
|
|
let select = a[a.length - 1];
|
|
@@ -255,7 +229,6 @@ export default {
|
|
|
.replace(/,$/, "")
|
|
|
.split(",");
|
|
|
},
|
|
|
-
|
|
|
},
|
|
|
components: { lineCharts },
|
|
|
};
|