liyongli 3 lat temu
rodzic
commit
cba8ff66d7

+ 29 - 0
src/api/kuyun.js

@@ -30,6 +30,20 @@ import fileDownload from "@/utils/download.js";
     });
   }
 
+  /**
+   *
+   * @param {*} data
+   * @returns {AxjxPromise}
+   */
+   export function tvselectDate(data) {
+    return ajax({
+      urlType: "kuyunApi",
+      url: "/api/evaluation/eye/performance/tv_filter",
+      method: "POST",
+      data,
+    });
+  }
+
 /**
  * 频道全天节目
  * 表格查询
@@ -226,3 +240,18 @@ export function realflow(data) {
       method: "GET",
     });
   }
+
+
+/**
+ * 频道分地区
+ * @props 
+ * @return {AxjxPromise}
+ */
+export function tvcountry(data) {
+    return ajax({
+      urlType: "kuyunApi",
+      url: "/api/evaluation/eye/performance/tvkpi",
+      method: "POST",
+      data,
+    });
+  }

+ 1 - 2
src/config/index.js

@@ -1,7 +1,6 @@
 let useApiUrl = "http://172.16.101.11:8899",
   useApiUrl1 = "http://172.16.101.11:9000",
-  kuyunApi = "http://114.117.161.191:9001/kuyun";
-//   kuyunApi = "http://172.16.101.11:9001/kuyun";
+  kuyunApi = "http://47.108.160.227:9001/kuyun";
 // let  isRelease = false; //是否是线上发布版本
 // if (process.env.NODE_ENV !== "development") {
 //   useApiUrl = "http://172.16.101.11:8899";

+ 1 - 1
src/views/Abstract/Abstract.vue

@@ -326,7 +326,7 @@ export default {
         }
       }
       fetch(
-        config.kuyunApi + "/kuyun/api/evaluation/eye/download/performance/epgkpi/download",
+        config.base.kuyunApi + "/kuyun/api/evaluation/eye/download/performance/epgkpi/download",
         {
           method: "post",
           responseType: "blob",

+ 1 - 2
src/views/AbstractProgram/AbstractProgram.vue

@@ -78,7 +78,6 @@
         <el-table-column
           align="center"
           show-overflow-tooltip
-          width="400px"
           prop="abs_epg"
           label="抽象节目"
           class-name="nowrap"
@@ -192,7 +191,7 @@ export default {
         }
       }
       fetch(
-        config.kuyunApi +
+        config.base.kuyunApi +
           "/kuyun/api/evaluation/eye/download/performance/epgkpi/download",
         {
           method: "post",

+ 1 - 1
src/views/AbstractProgramQuery/AbstractProgramQuery.vue

@@ -202,7 +202,7 @@ export default {
         }
       }
       fetch(
-        config.kuyunApi +
+        config.base.kuyunApi +
           "/kuyun/api/evaluation/eye/download/performance/epgkpi/download",
         {
           method: "post",

+ 0 - 1
src/views/ChannelEPG/Channel.vue

@@ -112,7 +112,6 @@
         <el-table-column
           align="center"
           show-overflow-tooltip
-          width="400px"
           prop="epg"
           label="具体节目"
           class-name="nowrap"

+ 0 - 1
src/views/ChannelList/ChannelList.vue

@@ -112,7 +112,6 @@
         <el-table-column
           align="center"
           show-overflow-tooltip
-          width="400px"
           prop="channel_2"
           label="省级卫视"
           class-name="nowrap"

+ 176 - 264
src/views/ChannelRegion/ChannelRegion.vue

@@ -1,8 +1,8 @@
 <template>
-  <div class="SingleDay">
+  <div class="AbstractProgram">
     <el-breadcrumb separator-class="el-icon-arrow-right">
       <el-breadcrumb-item>传统媒体</el-breadcrumb-item>
-      <el-breadcrumb-item>频道分地区收视</el-breadcrumb-item>
+      <el-breadcrumb-item>抽象节目剧目排行</el-breadcrumb-item>
     </el-breadcrumb>
     <el-card class="box-card">
       <el-form
@@ -24,97 +24,88 @@
           >
           </el-date-picker>
         </el-form-item>
-        <el-form-item label="频道">
+
+        <el-form-item :label="v.name" v-for="(v, i) in searchDate" :key="i">
           <el-select
-            v-model="form.channel"
-            placeholder="请选择频道"
+            v-model="form.filter[v.key]"
+            :placeholder="'请选择' + v.name"
             multiple
             collapse-tags
-            @change="channelSelect"
+            @change="se => select(v, se)"
           >
-            <el-option
-              v-for="item in channelList"
-              :key="item.label"
-              :label="item.label"
-              :value="item.label"
-              :disabled="item.disabled"
-            >
+            <el-option key="-1" v-if="v.id !== 'time'" label="全选" value="-1">
             </el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="时间">
-          <el-time-picker
-            v-model="form.rangeTime"
-            is-range
-            format="HH:mm"
-            @change="() => (form.rangeTimeRange = [])"
-            range-separator="-"
-            start-placeholder="开始时间"
-            end-placeholder="结束时间"
-          >
-          </el-time-picker>
-        </el-form-item>
-        <el-form-item label="时段">
-          <el-select
-            v-model="form.rangeTimeRange"
-            placeholder="请选择时段"
-            multiple
-            collapse-tags
-            clearable
-            @change="timeSelect"
-          >
             <el-option
-              v-for="item in cycle"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value"
-              :disabled="item.disabled"
+              v-for="item in v.list || []"
+              :key="item.id + ''"
+              :label="item.name"
+              :value="item.key + ''"
             >
             </el-option>
           </el-select>
         </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>
     <br />
     <el-card class="box-card">
       <line-charts
-        :list="tableDate"
+        :list="tableData"
+        v-if="tableData.length"
         xName="day"
         :keys="chartKeys"
       ></line-charts>
       <el-table
-        :data="tableDate"
+        :data="tableData"
         :header-cell-style="{ backgroundColor: '#f4f5f7', color: '#606266' }"
         style="width: 100%"
       >
         <el-table-column
           align="center"
           show-overflow-tooltip
-          width="400px"
-          prop="date"
-          label="日期"
+          prop="channel_0"
+          label="全部频道"
           class-name="nowrap"
         />
+        <el-table-column align="center" prop="day" label="日期" />
         <el-table-column
-          v-for="(item, i) in tableKeys"
-          :key="'table' + i"
-          align="center"
-          :prop="item.key"
+          prop="indicators_arrive"
+          :formatter="matrer"
+          label="到达率"
+        />
+        <el-table-column
+          prop="indicators_market_ratings_rank"
+          label="市占率排名"
+        />
+        <el-table-column
+          prop="indicators_tv_ratings"
           :formatter="matrer"
-          :label="item.name"
-        >
-          <el-table-column
-            v-for="(li, o) in item.children"
-            :key="i + '-' + o"
-            :prop="li.key"
-            :label="li.name"
-            :formatter="matrer"
-          />
-        </el-table-column>
+          label="直播关注度"
+        />
+        <el-table-column
+          prop="indicators_tv_ratings"
+          :formatter="matrer"
+          label="市占率"
+        />
+        <el-table-column
+          prop="indicators_tv_ratings_rank"
+          label="直播关注度排名"
+        />
+        <el-table-column
+          prop="indicators_arrive_rank"
+          label="到达率排名"
+        />
+        <el-table-column
+          prop="indicators_loyal_rank"
+          label="忠诚度排名"
+        />
       </el-table>
     </el-card>
   </div>
@@ -122,7 +113,7 @@
 
 <script>
 // @ is an alias to /src
-// import {  } from "@/api/index";
+import { tvselectDate, tvcountry } from "@/api/kuyun";
 
 import lineCharts from "@/views/Country/components/lineCharts";
 
@@ -131,229 +122,150 @@ export default {
   name: "Channel",
   data() {
     return {
-      form: {
-        channel: 0,
-        date: [
-          new Date(new Date() - 86400000),
-          new Date(new Date() - 86400000),
-        ],
-        rangeTime: [],
-      },
-      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,
-        },
+      searchDate: [],
+      chartKeys: [
         {
-          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,
+          key: "indicators_arrive",
+          name: "到达率",
         },
         {
-          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,
+          key: "indicators_market_ratings",
+          name: "市占率",
         },
         {
-          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,
+          key: "indicators_tv_ratings",
+          name: "直播关注度",
         },
       ],
+      form: {
+        filter: {},
+        date: [],
+        field: [
+          "channel_0",
+          "day",
+          "indicators_arrive",
+          "indicators_market_ratings_rank",
+          "indicators_tv_ratings",
+          "indicators_market_ratings",
+          "indicators_tv_ratings_rank",
+          "indicators_arrive_rank",
+          "indicators_loyal_rank",
+          "indicators_loyal",
+        ],
+        info: 1,
+        org_id: 20,
+      },
+      tableData: [],
+      loading: false,
+      loading1: false,
     };
   },
-  mounted() {},
-  computed: {
-    cycle() {
-      return config.cycle;
-    },
-    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];
-          });
+  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, M, D].join("-"), [Y, M, D].join("-")];
+    tvselectDate({
+      date: this.form.date,
+      key: "area_c_1,area_t_1",
+      org_id: 20,
+    }).then(r => {
+      let area = false;
+      this.searchDate = r || [];
+      for (let i = 0; i < this.searchDate.length; i++) {
+        const v = this.searchDate[i];
+        if (/area/.test(v.id)) {
+          if (area) continue;
+          area = true;
+          this.form.filter[v.id] = [v.list[0].key + ""];
+          continue;
         }
-        li.push({
-          date: dataLen[i],
-          ...p,
-        });
-      }
-      return li;
-    },
-    chartKeys() {
-      const obj = {},
-        li = [];
-      for (let i = 0; i < this.tableData.length; i++) {
-        const b = [
-          {
-            key: "indicators_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;
-        li.push(
-          ...b.map(k => {
-            k.key = v.channel_2 + "_" + k.key;
-            k.name = v.channel_2 + "_" + k.name;
-            return k;
-          })
-        );
+        this.form.filter[v.id] = [v.list[0].key + ""];
       }
-      console.log(li);
-      return li;
-    },
-    tableKeys() {
-      const obj = {},
-        li = [];
-      for (let i = 0; i < this.tableData.length; i++) {
-        const b = [
-          {
-            key: "indicators_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;
-        li.push({
-          name: v.channel_2,
-          children: b.map(k => {
-            k.key = v.channel_2 + "_" + k.key;
-            return k;
-          }),
+      tvcountry(this.form)
+        .then(r => {
+          this.tableData = r || [];
+          this.loading = false;
+        })
+        .catch(() => {
+          this.loading = false;
         });
-      }
-      return li;
-    },
+    });
   },
+  computed: {},
   methods: {
-    timeSelect(a) {
-      let end = (a || [])[(a || []).length - 1];
-      if (this.form.rangeTimeRange.length === config.cycle.length - 1) {
-        this.form.rangeTimeRange = ["0000_2400"];
-      } else {
-        let n = (this.form.rangeTimeRange || []).sort((a, b) => {
-          let aNum = a.split("_")[0];
-          let bNum = b.split("_")[0];
-          return aNum - bNum;
+    onExport() {
+      this.loading1 = true;
+      let form = JSON.parse(JSON.stringify(this.form));
+      console.log(config)
+      fetch(
+        config.base.kuyunApi +
+          "/kuyun/api/evaluation/eye/download/performance/tvkpi/download",
+        {
+          method: "post",
+          responseType: "blob",
+          body: JSON.stringify(form),
+        }
+      )
+        .then(res => {
+          return res.blob();
+        })
+        .then(blob => {
+          new Blob([blob]);
+          let fileName = "频道分地区收视.csv";
+          var link = document.createElement("a");
+          link.href = window.URL.createObjectURL(blob);
+          link.download = fileName;
+          link.click();
+          window.URL.revokeObjectURL(link.href);
+          this.loading1 = false;
         });
-        let isSelect = true;
-        for (let i = 0; i < n.length - 1; i++) {
-          let aNum = n[i].split("_")[1];
-          let bNum = n[i + 1].split("_")[0];
-          if (aNum !== bNum) {
-            isSelect = false;
+    },
+    disabledDate(time) {
+      return time.getTime() > Date.now() - 86400000;
+    },
+    onSubmit() {
+      this.loading = true;
+      let form = JSON.parse(JSON.stringify(this.form));
+      let keys = Object.keys(this.form.filter);
+      for (let i = 0; i < keys.length; i++) {
+        const v = keys[i];
+        if (form.filter[v] != -1) continue;
+        for (let o = 0; o < this.searchDate.length; o++) {
+          const item = this.searchDate[o];
+          if (v === item.key) {
+            form.filter[v] = item.list.map(v => v.key);
             break;
           }
         }
-        if (!isSelect) {
-          let arr = (n.join(",") + ",")
-            .replace(end + ",", "")
-            .replace(/,$/, "");
-          this.form.rangeTimeRange = arr.split(",");
-        }
       }
-      if (!this.form.rangeTimeRange.length) return;
-      let s = this.form.rangeTimeRange[0].split("_")[0];
-      let e = this.form.rangeTimeRange[
-        this.form.rangeTimeRange.length - 1
-      ].split("_");
-      e = e[e.length - 1];
-      if (e == "2400") e = "2359";
-      this.form.rangeTime = [
-        new Date(1970, 1, 1, s[0] + s[1] - 0, s[2] + s[3] - 0),
-        new Date(1970, 1, 1, e[0] + e[1] - 0, e[2] + e[3] - 0),
-      ];
-    },
-    onExport() {},
-    disabledDate(time) {
-      return time.getTime() > Date.now() - 86400000;
+      tvcountry(form)
+        .then(r => {
+          this.tableData = r || [];
+          this.loading = false;
+        })
+        .catch(() => {
+          this.loading = false;
+        });
     },
-    onSubmit() {},
     matrer(row, column, cellValue) {
+      if (typeof cellValue !== "number") return cellValue;
       return (cellValue * 100).toFixed(4) - 0 + "%";
     },
-    channelSelect(a) {
-      this.selectAll(a, "channel", 0);
+    select(v, se) {
+      if (v.id === "time") {
+        this.timeSelect(se, v.id, "0000_2400");
+      } else this.timeSelect(se, v.id, "-1");
     },
-    selectAll(a, key, val) {
-      if (!a.length) return;
-      let select = a[a.length - 1];
-      if (select === val) this.form[key] = [val];
-      else
-        this.form[key] = (a.join(",") + ",")
-          .replace(val + ",", "")
-          .replace(/,$/, "")
-          .split(",");
+    timeSelect(a, key, all) {
+      let ngx = new RegExp(all + ",?", "g");
+      let end = (a || [])[(a || []).length - 1],
+        s = (a || []).join(",").replace(ngx, "");
+      if (end !== all) this.form.filter[key] = s ? s.split(",") : [];
+      else this.form.filter[key] = [all];
     },
   },
   components: { lineCharts },
@@ -361,10 +273,10 @@ export default {
 </script>
 
 <style>
-.SingleDay {
+.AbstractProgram {
   margin: 10px 15px;
 }
-.SingleDay .nowrap .cell {
+.AbstractProgram .nowrap .cell {
   white-space: nowrap;
 }
 </style>

+ 1 - 1
src/views/Program/Program.vue

@@ -245,7 +245,7 @@ export default {
         }
       }
       fetch(
-        config.kuyunApi +
+        config.base.kuyunApi +
           "/api/evaluation/eye/download/performance/epgkpi/download",          
         {
           method: "post",

+ 0 - 1
src/views/SingleDay/SingleDay.vue

@@ -78,7 +78,6 @@
         <el-table-column
           align="center"
           show-overflow-tooltip
-          width="400px"
           prop="date"
           label="日期"
           class-name="nowrap"

+ 1 - 1
src/views/SpecificProgram/SpecificProgram.vue

@@ -247,7 +247,7 @@ export default {
         }
       }
       fetch(
-        config.kuyunApi +
+        config.base.kuyunApi +
           "/api/evaluation/eye/download/performance/epgkpi/download",          
         {
           method: "post",

+ 1 - 1
src/views/SpecificProgramQuery/SpecificProgramQuery.vue

@@ -252,7 +252,7 @@ export default {
         }
       }
       fetch(
-        config.kuyunApi +
+        config.base.kuyunApi +
           "/api/evaluation/eye/download/performance/epgkpi/download",          
         {
           method: "post",

+ 0 - 1
src/views/SubRegion/SubRegion.vue

@@ -111,7 +111,6 @@
         <el-table-column
           align="center"
           show-overflow-tooltip
-          width="400px"
           prop="channel_2"
           label="省级卫视"
           class-name="nowrap"