|
@@ -0,0 +1,118 @@
|
|
|
|
+<template>
|
|
|
|
+ <el-card class="TraditionalAssessment">
|
|
|
|
+ <el-form size="small" inline label-width="120px">
|
|
|
|
+ <el-form-item label="日期">
|
|
|
|
+ <el-date-picker
|
|
|
|
+ style="width: 100%; height: 58px"
|
|
|
|
+ v-model="date"
|
|
|
|
+ type="month"
|
|
|
|
+ placeholder="请选择日期"
|
|
|
|
+ value-format="YYYYMM"
|
|
|
|
+ :disabled-date="pickerOptions"
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item style="float: right">
|
|
|
|
+ <el-button type="primary" @click="getData">查询</el-button>
|
|
|
|
+ <el-button type="primary" @click="exportFile">导出</el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-card>
|
|
|
|
+ <br />
|
|
|
|
+ <br />
|
|
|
|
+ <el-card>
|
|
|
|
+ <div v-for="item in list" :key="item.channelName">
|
|
|
|
+ <el-descriptions :title="item.channelName" border size="small" direction="vertical">
|
|
|
|
+ <el-descriptions-item label="收视率">
|
|
|
|
+ <el-tag size="small"> {{ round(item.watchrate, 4) }}% </el-tag>
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
+ <el-descriptions-item label="基础收视率">
|
|
|
|
+ <el-tag size="small">{{ round(item.baseWatchrate, 4) }}%</el-tag>
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
+ <el-descriptions-item label="收视率增长率">
|
|
|
|
+ <el-tag size="small">{{ round(item.compareWatchrate, 4) }}%</el-tag>
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
+ <el-descriptions-item label="市场份额">
|
|
|
|
+ <el-tag size="small" type="success">
|
|
|
|
+ {{ round(item.occrate, 4) }}%
|
|
|
|
+ </el-tag>
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
+ <el-descriptions-item label="基础市场份额">
|
|
|
|
+ <el-tag size="small" type="success"
|
|
|
|
+ >{{ round(item.baseOccrate, 4) }}%</el-tag
|
|
|
|
+ >
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
+ <el-descriptions-item label="市场份额增长率">
|
|
|
|
+ <el-tag size="small" type="success"
|
|
|
|
+ >{{ round(item.compareOccrate, 4) }}%</el-tag
|
|
|
|
+ >
|
|
|
|
+ </el-descriptions-item>
|
|
|
|
+ </el-descriptions>
|
|
|
|
+ <br />
|
|
|
|
+ </div>
|
|
|
|
+ </el-card>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup>
|
|
|
|
+import { getTraditionalAssessment } from '@/api/index';
|
|
|
|
+// import config from '@/config/index';
|
|
|
|
+import { ref } from 'vue';
|
|
|
|
+
|
|
|
|
+const getLastMonth = () => {
|
|
|
|
+ let now = new Date(Date.now() - 40 * 86400000);
|
|
|
|
+ let year = now.getFullYear();
|
|
|
|
+ let month = now.getMonth() + 1;
|
|
|
|
+ if (month < 10) month = '0' + month;
|
|
|
|
+ return year + '' + month;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const getData = value => {
|
|
|
|
+ getTraditionalAssessment(value).then(res => {
|
|
|
|
+ console.log(res);
|
|
|
|
+ list.value = res;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+function pickerOptions(d) {
|
|
|
|
+ let startDate = new Date('2022/04/11').getTime(),
|
|
|
|
+ nowDate = d.getTime();
|
|
|
|
+ startDate = startDate - (startDate % 86400000);
|
|
|
|
+ nowDate = nowDate - (nowDate % 86400000);
|
|
|
|
+ let out = nowDate < startDate || nowDate >= Date.now() - 172800000;
|
|
|
|
+ return out;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 四舍五入
|
|
|
|
+const round = (value, precision) => {
|
|
|
|
+ let multiplier = Math.pow(10, precision || 0);
|
|
|
|
+ return Math.round(value * multiplier) / multiplier;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// 将json导出成csv文件
|
|
|
|
+const exportFile = () => {
|
|
|
|
+ let data = list.value;
|
|
|
|
+ let csvData = [];
|
|
|
|
+ csvData.push('频道名称,收视率(%),基础收视率(%),收视率增长率(%),市场份额(%),基础市场份额(%),市场份额增长率(%)\n');
|
|
|
|
+ data.forEach(item => {
|
|
|
|
+ csvData.push(
|
|
|
|
+ `${item.channelName},${item.watchrate},${item.baseWatchrate},${item.compareWatchrate},${item.occrate},${item.baseOccrate},${item.compareOccrate}\n`
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ let csvFile = new Blob(csvData,{ type: 'text/csv' });
|
|
|
|
+ let link = document.createElement('a');
|
|
|
|
+ link.href = URL.createObjectURL(csvFile);
|
|
|
|
+ link.download = `${date.value}.csv`;
|
|
|
|
+ link.click();
|
|
|
|
+ URL.revokeObjectURL(link.href);
|
|
|
|
+ link.remove();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const date = ref(getLastMonth());
|
|
|
|
+const list = ref([]);
|
|
|
|
+
|
|
|
|
+getData(date.value);
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="scss">
|
|
|
|
+.TraditionalAssessment {
|
|
|
|
+}
|
|
|
|
+</style>
|