<template>
  <div>
    <el-breadcrumb separator="/" class="bread_crumb1">
      <el-breadcrumb-item :to="{ path: '/data_analysis' }">{{ $t("lang.dataAnalysis") }}</el-breadcrumb-item>
      <el-breadcrumb-item>{{ $t("lang.myApplicationDataAnalysis") }}</el-breadcrumb-item>
    </el-breadcrumb>
    <el-row class="in_analysis">
      <!-- 可横向铺满 -->
      <el-col :span="6" class="in_left">
        <el-row>
          <el-col :span="24" class="in_block">
            <block-radius :show_header="true" title="应用总体概况" class="block">
              <div class="left_1">
                <div class="left_block">
                  <div ref="left_1_l" class="left_1_l">
                    <img :src="require('@/assets/imgs/data_img_service.gif')" class="left_1_img" />
                    <div class="left_1_msg">
                      <div class="left_1_title">服务总数</div>
                      <div class="left_1_num">4</div>
                    </div>
                  </div>
                  <div class="chain">
                    月环比
                    <span
                      class="chain_mid"
                      :class="overview.month_chain >= 0 ? 'chain_up' : 'chain_down'"
                    >
                      {{ Math.abs(overview.month_chain) }}%
                      <img
                        :src="overview.month_chain >= 0 ? require('@/assets/imgs/icon_up.png') : require('@/assets/imgs/icon_down.png')"
                      />
                    </span>周环比
                    <span :class="overview.week_chain >= 0 ? 'chain_up' : 'chain_down'">
                      {{ Math.abs(overview.week_chain) }}%
                      <img
                        :src="overview.week_chain >= 0 ? require('@/assets/imgs/icon_up.png') : require('@/assets/imgs/icon_down.png')"
                      />
                    </span>
                  </div>
                  <div class="left_1_line"></div>
                  <div class="left_1_l_bottom">
                    日均被部署次数
                    <span class="left_1_l_bottom_msg">12432</span>（次）
                  </div>
                </div>
                <div class="left_1_right">
                  <WaterPolo class="water_polo" />
                </div>
              </div>
            </block-radius>
          </el-col>
          <el-col :span="24" class="in_block">
            <block-radius
              :show_header="true"
              title="应用调用次数分析"
              :buttons_arr="['近7天', '近30天']"
              @changeButton="changeServiceCellBtn"
              class="block"
            >
              <Graph :data="graph_arr" />
            </block-radius>
          </el-col>
          <el-col :span="24" class="in_block">
            <block-radius
              :show_header="true"
              title="应用类型分析"
              :buttons_arr="['构建的应用', '申请的应用 ']"
              @changeButton="changeServiceTypeBtn"
              class="block"
            >
              <multiple-circle class="block-radius-content" :data="mult_data" :text="text"></multiple-circle>
            </block-radius>
          </el-col>
        </el-row>
      </el-col>
      <el-col :span="12" class="in_center">
        <el-row>
          <el-col :span="24" class="in_block">
            <block-radius
              :show_header="true"
              title="应用使用领域统计"
              :buttons_arr="['构建的应用', '申请的应用']"
              @changeButton="changeServiceTypeBtn"
              class="block"
            >
              <BarChart
                :data="bar_data_org"
                :colors="['#1034eb', '#4274f8']"
                :bar_border_radius="[20, 20, 0, 0]"
                :bar_width="26"
                :show_split="true"
              />
            </block-radius>
          </el-col>
          <el-col :span="24" class="in_block">
            <block-radius :show_header="true" title="应用热门搜索" class="block">
              <div class="block-radius-content service-hot-search">
                <div class="left-content">
                  <div class="hot-line">
                    <p class="hot-line-title">搜索用户数</p>
                    <div class="hot-line-chart">
                      <!-- 折线图 -->
                    </div>
                  </div>
                  <div class="hot-line">
                    <p class="hot-line-title">搜索用户数</p>
                    <div class="hot-line-chart">
                      <!-- 折线图 -->
                    </div>
                  </div>
                </div>
                <div class="right-content apass_scroll">
                  <apass-table
                    class="hot-search-table"
                    :header="hotSearchHeader"
                    :data="hotSearchData"
                    :padding-left="0"
                    @sort-change="hotSearchSortChange"
                  ></apass-table>
                </div>
              </div>
            </block-radius>
          </el-col>
          <el-col :span="24" class="in_block">
            <block-radius
              class="block"
              :show_header="true"
              title="应用总数变化趋势"
              :buttons_arr="['近14天', '近30天']"
              @changeButton="changeAppTotalChangeBtn"
            >
              <line-chart class="block-radius-content" :data="line_data"></line-chart>
            </block-radius>
          </el-col>
        </el-row>
      </el-col>
      <el-col :span="6" class="in_right">
        <el-row>
          <el-col :span="24" class="in_block">
            <block-radius
              :show_header="true"
              title="应用部署排名分析"
              :buttons_arr="['被部署次数', '被部署次数']"
              @changeButton="changeServeiceApplyCountBtn"
              class="block"
            >
              <toplist
                class="block-radius-content"
                :options="toplistData"
                :target-value="toplistTargetValue"
              ></toplist>
            </block-radius>
          </el-col>
          <el-col :span="24" class="in_block">
            <block-radius
              :show_header="true"
              title="应用评价及评分"
              :buttons_arr="['应用评价', '应用评分']"
              @changeButton="changeAppInfoBtn"
              class="block"
            >
              <commentlist
                v-if="appInfoBtnIndex == 0"
                class="block-radius-content"
                :data="commentlistData"
              ></commentlist>
              <starlist
                v-else
                class="block-radius-content"
                :options="starlistData"
                :total="starlistTotal"
                style="margin-top: 30px;height: calc(100% - 51px);"
              ></starlist>
            </block-radius>
          </el-col>
          <el-col :span="24" class="in_block">
            <block-radius class="block" :show_header="true" title="应用在线状态统计">
              <single-circle class="block-radius-content" :data="single_data"></single-circle>
            </block-radius>
          </el-col>
        </el-row>
      </el-col>
      <!-- 不可横向铺满，一般为最后一行 -->
      <el-col :span="6" class="in_block">
        <block-radius :show_header="true" title="应用来源机构分析" class="block">
          <BarChart :data="bar_data_org" :colors="['#274fee', '#274fee']" :x_router="30" />
        </block-radius>
      </el-col>
      <el-col :span="18" class="in_block default">
        <block-radius class="block">
          <img :src="require('@/assets/imgs/data_img_default.gif')" class="default_img" />
        </block-radius>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import BlockRadius from "@/components/general/block-radius";
import multipleCircle from "@/components/e-charts/multiple_circle";
import singleCircle from "@/components/e-charts/single_circle";
import lineChart from "@/components/e-charts/line_chart";
import Toplist from "@/components/e-charts/toplist";
import Starlist from "@/components/e-charts/starlist";
import Commentlist from "@/components/e-charts/commentlist";
import BarChart from "@/components/e-charts/bar-chart";
import ApassTable from "@/components/apass-table";
import Graph from "@/components/e-charts/graph";
import WaterPolo from "@/components/e-charts/water-polo";
export default {
  components: {
    BlockRadius,
    multipleCircle,
    singleCircle,
    Toplist,
    Starlist,
    Commentlist,
    lineChart,
    BarChart,
    ApassTable,
    Graph,
    WaterPolo
  },
  data: () => ({
    overview: {
      month_chain: 14.5,
      week_chain: -14.2
    },
    mult_data: [
      { name: "基础工具", value: 40 },
      { name: "通用应用", value: 0 },
      { name: "业务应用", value: 2 }
    ],
    text: "应用总数",
    single_data: {
      num: 12,
      color: "#515fe7",
      text: "共享"
    },
    line_data: {
      xaxis: [
        "01-01",
        "01-02",
        "01-03",
        "01-04",
        "01-05",
        "01-06",
        "01-07",
        "01-08"
      ],
      data: [
        {
          name: "开发者应用",
          arr: [100, 120, 130, 150, 160, 120, 110, 100]
        },
        {
          name: "平台应用",
          arr: [120, 130, 140, 130, 140, 120, 100, 90]
        },
        {
          name: "未上架",
          arr: [80, 90, 100, 110, 100, 70, 80, 90]
        }
      ]
    },
    bar_data_org: {
      xaxis: [
        "01-01",
        "01-02",
        "01-03",
        "01-04",
        "01-05",
        "01-06",
        "01-07",
        "01-08"
      ],
      data: [100, 120, 130, 150, 160, 120, 110, 100]
    },
    graph_arr: {
      xaxis: [
        "01-01",
        "01-02",
        "01-03",
        "01-04",
        "01-05",
        "01-06",
        "01-07",
        "01-08"
      ],
      data: [
        [1010, 120, 130, 520, 160, 1120, 110, 100],
        [100, 1210, 130, 1530, 160, 120, 110, 1200]
      ],
      legend: ["被调用次数", "调用次数"]
    },
    toplistData: [
      {
        name: "mapvideos",
        value: 2302,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      },
      {
        name: "语音识别",
        value: 2213,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      },
      {
        name: "轨迹绘制",
        value: 1987,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      },
      {
        name: "postgresql",
        value: 1973,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      },
      {
        name: "易智瑞",
        value: 1872,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      },
      {
        name: "mapvideos",
        value: 1702,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      },
      {
        name: "语音识别",
        value: 1654,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      },
      {
        name: "轨迹绘制",
        value: 1623,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      },
      {
        name: "postgresql",
        value: 1598,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      },
      {
        name: "易智瑞",
        value: 1456,
        logo:
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
        unit: "次"
      }
    ], // 应用部署排名分析
    toplistTargetValue: 2400, // 应用部署排名分析 目标值
    appInfoBtnIndex: 0,
    commentlistData: [
      {
        add_time: "2020-07-14T16:35:40Z",
        content: "1111111111111111",
        id: 36,
        picture_path:
          "/apaas/static/docs/image/image/blob_cb30e7a3-3184-42dd-9e2f-7e6b69accb0c.blob",
        score: 5,
        service_id: 128,
        user_name: "普通用户lxy"
      },
      {
        add_time: "2020-07-14T16:35:40Z",
        content: "1111111111111111",
        id: 36,
        picture_path:
          "/apaas/static/docs/image/image/blob_cb30e7a3-3184-42dd-9e2f-7e6b69accb0c.blob",
        score: 4,
        service_id: 128,
        user_name: "普通用户lxy"
      },
      {
        add_time: "2020-07-14T16:35:40Z",
        content: "1111111111111111",
        id: 36,
        picture_path:
          "/apaas/static/docs/image/image/blob_cb30e7a3-3184-42dd-9e2f-7e6b69accb0c.blob",
        score: 3,
        service_id: 128,
        user_name: "普通用户lxy"
      },
      {
        add_time: "2020-07-14T16:35:40Z",
        content: "1111111111111111",
        id: 36,
        picture_path:
          "/apaas/static/docs/image/image/blob_cb30e7a3-3184-42dd-9e2f-7e6b69accb0c.blob",
        score: 2,
        service_id: 128,
        user_name: "普通用户lxy"
      }
    ], // 应用评价
    starlistData: [
      {
        star: 5,
        count: 5,
        unit: "个"
      },
      {
        star: 4,
        count: 4,
        unit: "个"
      },
      {
        star: 3,
        count: 3,
        unit: "个"
      },
      {
        star: 2,
        count: 2,
        unit: "个"
      },
      {
        star: 1,
        count: 1,
        unit: "个"
      }
    ], // 应用评分
    starlistTotal: 15,
    hotSearchHeader: [], // 热门搜索 表头
    hotSearchData: [
      {
        hotIndex: 1,
        name: "postgresql V11.1",
        count: 666,
        increases: 1.28
      },
      {
        hotIndex: 2,
        name: "钉钉 V1.0",
        count: 666,
        increases: 0.03
      },
      {
        hotIndex: 3,
        name: "易智瑞 V11.3",
        count: 666,
        increases: 0.58
      },
      {
        hotIndex: 4,
        name: "CAS单点登录 V1.0",
        count: 666,
        increases: -0.28
      },
      {
        hotIndex: 5,
        name: "mapvideos V1.0",
        count: 666,
        increases: -0.58
      }
    ] // 热门搜索 数据
  }),
  mounted() {
    this.hotSearchHeader = [
      {
        label: "排名",
        type: "hot-index",
        width: 100,
        align: "center"
      },
      {
        label: "应用名称",
        prop: "name",
        type: "button",
        callback: this.detailHotSearch
      },
      {
        label: "搜索次数",
        prop: "count",
        width: 100,
        align: "center"
      },
      {
        label: "日涨幅",
        prop: "increases",
        width: 100,
        sortType: "0", // 0：升序 1：降序
        sortable: true,
        align: "center"
      }
    ];
  },
  methods: {
    detailHotSearch(item) {
      console.log("查看热搜详情");
    },
    hotSearchSortChange(sortInfo) {
      console.log("应用热门搜索: " + sortInfo);
    },
    changeServiceTypeBtn(index) {
      console.log("应用类型分析: " + index);
    },
    changeApplicationFieldBtn(index) {
      console.log("xxx: " + index);
    },
    changeServiceCellBtn(index) {
      console.log("应用调用次数分析: " + index);
    },
    changeServeiceApplyCountBtn(index) {
      console.log("应用部署排名分析: " + index);
    },
    changeAppInfoBtn(index) {
      this.appInfoBtnIndex = index;

      console.log("应用评价及评分: " + index);
    },
    changeAppTotalChangeBtn(index) {
      console.log("应用总数变化趋势: " + index);
    }
  }
};
</script>
<style scoped>
.in_analysis {
  padding: 0 10px 10px;
  height: 100%;
  width: 100%;
  min-width: 1700px;
}
.in_l {
}
.in_r {
}
.in_c {
}
.in_block {
  height: 280px;
  padding: 10px;
}
.height_2x {
  height: 560px;
}
.block {
  width: 100%;
  height: 100%;
}
.left_1 {
  height: 100%;
  display: flex;
  justify-content: space-between;
}
.left_block {
  width: 280px;
  height: 100%;
  padding: 10px 0 0 0;
}
.left_1_l {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.left_1_title {
  width: 100%;
}
.left_1_num {
  font-size: 32px;
  color: #515fe7;
  width: 100%;
}
.left_1_img {
  width: 120px;
  height: 120px;
  display: inline-block;
}
.chain {
  color: #58617a;
  font-size: 14px;
  padding: 10px;
}
.chain_down {
  background-color: #fbe8e8;
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 12px;
  margin-left: 8px;
  color: #e15260;
}
.chain_up {
  background-color: #e7fdfc;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 12px;
  margin-left: 8px;
  color: #25bdb1;
}
.chain_mid {
  margin-right: 20px;
}
.left_1_l_bottom {
  color: #58617a;
  padding: 10px;
}
.left_1_l_bottom_msg {
  margin-left: 20px;
}
.left_1_msg {
  display: inline-block;
  width: 120px;
  padding-bottom: 10px;
}
.left_1_line {
  width: 90%;
  margin-left: 5%;
  height: 1px;
  background-color: #f2f2f2;
}
.left_1_right {
  width: 180px;
  height: 100%;
  display: inline-block;
}
.water_polo {
  width: 140px;
  margin: 0 auto 20px;
}
.default {
  text-align: center;
}
.default_img {
  width: 330px;
  height: 230px;
}
.block-radius-content {
  height: calc(100% - 36px);
  margin-top: 15px;
}
.service-hot-search {
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  height: calc(100% - 21px);
  margin-top: 0;
}
.service-hot-search > .left-content {
  width: 260px;
  flex-shrink: 0;
  padding: 0 20px;
  box-sizing: border-box;
  margin-right: 10px;
}
.service-hot-search > .right-content {
  flex-grow: 1;
  overflow-x: hidden;
  overflow-y: auto;
}
.hot-line {
  height: 50%;
}
.hot-line-title {
  font-size: 14px;
  line-height: 36px;
  color: #8890a7;
}
.hot-line-chart {
  height: calc(100% - 36px);
  background-color: pink;
}
</style>

<style>
.hot-search-table .el-table td,
.hot-search-table .el-table th {
  padding: 6px 0;
}
.hot-search-table .el-table div.row_action {
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  white-space: nowrap;
}
</style>