浏览代码

添加考核

liyongli 1 月之前
父节点
当前提交
0fe4404384
共有 3 个文件被更改,包括 142 次插入7 次删除
  1. 18 7
      src/api/index.js
  2. 6 0
      src/router/index.js
  3. 118 0
      src/views/TraditionalAssessment/index.vue

+ 18 - 7
src/api/index.js

@@ -1345,10 +1345,21 @@ export function getAppColumn(data) {
  * 总编室需求
  * 总编室需求
  */
  */
 export function getUnionList(data) {
 export function getUnionList(data) {
-    return ajax({
-      urlType: 'url2',
-      url: '/union/list',
-      method: 'POST',
-      data
-    });
-  }
+  return ajax({
+    urlType: 'url2',
+    url: '/union/list',
+    method: 'POST',
+    data
+  });
+}
+
+/**
+ * 传统媒体考核
+ */
+export function getTraditionalAssessment(month) {
+  return ajax({
+    urlType: 'url2',
+    url: '/tv/evaluation?month=' + month,
+    method: 'GET'
+  });
+}

+ 6 - 0
src/router/index.js

@@ -56,6 +56,12 @@ const routes = [
     component: () =>
     component: () =>
       import(/* webpackChunkName: "jugou" */ "../views/Jugou/Jugou.vue"),
       import(/* webpackChunkName: "jugou" */ "../views/Jugou/Jugou.vue"),
   },
   },
+  {
+    path: "/traditionalassessment",
+    name: "TraditionalAssessment",
+    component: () =>
+      import(/* webpackChunkName: "TraditionalAssessment" */ "../views/TraditionalAssessment/index.vue"),
+  },
   {
   {
     path: "/jugouout",
     path: "/jugouout",
     name: "jugouout",
     name: "jugouout",

+ 118 - 0
src/views/TraditionalAssessment/index.vue

@@ -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>