<style lang='scss'>
    .only-there .ant-tabs-bar{
        background: white;
    }
    #updateInfo .ant-modal-content,#updateInfo .ant-modal-body {
      
      width: 500px;
      position: relative;
      padding-top:10px;
      .updateBOX{
          height: 600px; 
          overflow: auto;
      }
    }
    .Updatecontent{       
        padding: 0 20px 40px;
        position: relative;
        .Updateitem{
          margin-bottom: 30px;
        }
    }
    .Updatetitle{
        text-align: center;
        font-size: 22px;
        font-weight: 500;
        color: #1890ff;
        margin-bottom: 20px;
        /* margin-top: 20px; */
      }
    .Updatetime{
      font-size: 16px;
      font-weight: 700;
      color: #000;
      margin-bottom: 15px;
    }
    .updateicon{
      font-size: 26px;
      position: relative;
      top: 4px;;
    }
    .updateSpan{
      margin-left: 10px;
    }
    .textTitle{
        font-weight: 600;
        font-size: 1.17em;
  
        font-family:Helvetica,Arial,"\5b8b\4f53",sans-serif;

      }
    .okBtn{
      position: absolute;
      right: 3%;
      bottom: 3%;
    }
    .updatelist{
      .circular{
        display: inline-block;
        width: 3px;
        height: 3px;
        border-radius: 50%;
        color: #999;
      }
    }

</style>
<template>
  <div class="page-header-index-wide">
    <div v-if="roleCode == 'operator'">
      <a-row :gutter="24">
        <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
          <chart-card :loading="loading" title="总销售额" total="￥126,560">
            <a-tooltip title="指标说明" slot="action">
              <a-icon type="info-circle-o" />
            </a-tooltip>
            <div>
              <trend flag="up" style="margin-right: 16px;">
                <span slot="term">周同比</span>
                12%
              </trend>
              <trend flag="down">
                <span slot="term">日同比</span>
                11%
              </trend>
            </div>
            <template slot="footer">
              日均销售额
              <span>￥ 234.56</span>
            </template>
          </chart-card>
        </a-col>
        <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
          <chart-card :loading="loading" title="访问量" :total="8846 | NumberFormat">
            <a-tooltip title="指标说明" slot="action">
              <a-icon type="info-circle-o" />
            </a-tooltip>
            <div>
              <mini-area />
            </div>
            <template slot="footer">
              日访问量
              <span>{{ '1234' | NumberFormat }}</span>
            </template>
          </chart-card>
        </a-col>
        <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
          <chart-card :loading="loading" title="支付笔数" :total="6560 | NumberFormat">
            <a-tooltip title="指标说明" slot="action">
              <a-icon type="info-circle-o" />
            </a-tooltip>
            <div>
              <mini-bar :height="40" />
            </div>
            <template slot="footer">
              转化率
              <span>60%</span>
            </template>
          </chart-card>
        </a-col>
        <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
          <chart-card :loading="loading" title="运营活动效果" total="78%">
            <a-tooltip title="指标说明" slot="action">
              <a-icon type="info-circle-o" />
            </a-tooltip>
            <div>
              <mini-progress color="rgb(19, 194, 194)" :target="80" :percentage="78" :height="8" />
            </div>
            <template slot="footer">
              <trend flag="down" style="margin-right: 16px;">
                <span slot="term">同周比</span>
                12%
              </trend>
              <trend flag="up">
                <span slot="term">日环比</span>
                80%
              </trend>
            </template>
          </chart-card>
        </a-col>
      </a-row>

      <a-card :loading="loading" :bordered="false" :body-style="{ padding: '0' }">
        <div class="salesCard">
          <a-tabs default-active-key="1" size="large" :tab-bar-style="{ marginBottom: '24px', paddingLeft: '16px' }">
            <div class="extra-wrapper" slot="tabBarExtraContent">
              <div class="extra-item">
                <a>今日</a>
                <a>本周</a>
                <a>本月</a>
                <a>本年</a>
              </div>
              <a-range-picker :style="{ width: '256px' }" />
            </div>
            <a-tab-pane loading="true" tab="销售额" key="1">
              <a-row>
                <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
                  <bar title="销售额排行" :dataSource="barData" />
                </a-col>
                <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
                  <rank-list title="门店销售排行榜" :list="rankList" />
                </a-col>
              </a-row>
            </a-tab-pane>
            <a-tab-pane tab="访问量" key="2">
              <a-row>
                <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
                  <bar title="销售额趋势" :dataSource="barData" />
                </a-col>
                <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
                  <rank-list title="门店销售排行榜" :list="rankList" />
                </a-col>
              </a-row>
            </a-tab-pane>
          </a-tabs>
        </div>
      </a-card>

      <a-row>
        <a-col :span="24">
          <a-card :loading="loading" :bordered="false" title="最近一周访问次数统计" :style="{ marginTop: '24px' }">
            <a-row>
              <a-col :span="6">
                <head-info title="今日访问IP数" :content="loginfo.todayIp"></head-info>
              </a-col>
              <a-col :span="2">
                <a-spin class="circle-cust">
                  <a-icon slot="indicator" type="environment" style="font-size: 24px" />
                </a-spin>
              </a-col>
              <a-col :span="6">
                <head-info title="今日访问次数" :content="loginfo.todayVisitCount"></head-info>
              </a-col>
              <a-col :span="2">
                <a-spin class="circle-cust">
                  <a-icon slot="indicator" type="team" style="font-size: 24px" />
                </a-spin>
              </a-col>
              <a-col :span="6">
                <head-info title="访问总次数" :content="loginfo.totalVisitCount"></head-info>
              </a-col>
              <a-col :span="2">
                <a-spin class="circle-cust">
                  <a-icon slot="indicator" type="rise" style="font-size: 24px" />
                </a-spin>
              </a-col>
            </a-row>
            <line-chart-multid :fields="visitFields" :dataSource="visitInfo"></line-chart-multid>
          </a-card>
        </a-col>
      </a-row>
    </div>
    
    <newHome v-else-if=" roleCode == 'touTiaoOperationManager'" />
    <statistics v-else-if="roleCode == 'kuaishouOperationManager'" />
    <statistics v-else-if="roleCode == 'sale'||roleCode=='saleDirector'" />

    <Workbench v-else-if="roleCode == 'clip'" />
    <Workbench v-else-if="roleCode == 'plane'" />

    <a-tabs default-active-key="1" v-else-if="roleCode == 'admin'" class="only-there">
      <a-tab-pane key="1" tab="快手">
        <statistics />
      </a-tab-pane>
      <a-tab-pane key="2" tab="头条">
        <newHome />
      </a-tab-pane>

    </a-tabs>
    <!-- 更新公告 -->
    <a-modal v-model="visible" title="" @ok="handleOk" :closable='false' :footer="null" id="updateInfo">
      <div class="updateBOX">
      <div class="Updatetitle">
         <a-icon type="notification" theme='twoTone'/> 更新通告
      </div>
      <div class="Updatecontent">
        <div class="Updateitem">
            <div class="Updatetime">
                 <a-icon type="dashboard" theme='twoTone' class="updateicon" />
                 <span class="updateSpan">{{updateTime[3]}}</span>
            </div>
            <div class="updateText">
              <div class="updateBox">
                <h3 class="textTitle">1.脚本库加word下载；</h3>
              </div>
              <div class="updateBox">
                <h3 class="textTitle">2.上线媒介报表；</h3>
                
              </div>
              <div class="updateBox">
                <h3 class="textTitle">3.快手批量工具更新：</h3>
                <ul class="updatelist">
                  <li> <span class="circular"></span>创建组时--商业兴趣加智能推荐</li>
                  <li><span class="circular"></span>在复制组时可选是否修改定向</li>
                  <li><span class="circular"></span>计划、组、创意列表页加id、名称模糊搜索</li>
                  <li><span class="circular"></span>复制组时连带组名一起复制，可对组名进行修改</li>
                </ul>
              </div>
                      
            </div>
        </div>
        <div class="Updateitem">
            <div class="Updatetime">
                 <a-icon type="dashboard" theme='twoTone' class="updateicon" />
                 <span class="updateSpan">{{updateTime[2]}}</span>
            </div>
            <div class="updateText">
              <div class="updateBox">
                <h3 class="textTitle">1.快手批量工具更新：</h3>
                <ul class="updatelist">
                  <li> <span class="circular"></span> 批量创建创意页面加入推荐文案，可根据关键词匹配文案；</li>
                  <li><span class="circular"></span>批量创建创意选择内部素材可根据时间排序、筛选（天维度）；</li>
                </ul>
              </div>
              <div class="updateBox">
                <h3 class="textTitle">2.脚本库重磅上线(位置：素材管理--脚本库)</h3>
                <ul class="updatelist">
                  <li> <span class="circular"></span> 脚本可在线编辑，并实时保存；</li>
                  <li><span class="circular"></span>可在线打印，支持导出脚本；</li>
                  <li><span class="circular"></span>可在线打印，支持导出脚本；</li>
                </ul>
              </div>
              <div class="updateBox">
                <h3 class="textTitle">3.支持飞书扫码登录助手</h3>
                
              </div>
                      
            </div>
        </div>
        <div class="Updateitem">
            <div class="Updatetime">
                 <a-icon type="dashboard" theme='twoTone' class="updateicon" />
                 <span class="updateSpan">{{updateTime[1]}}</span>
            </div>
            <div class="updateText">
              <div class="updateBox">
                <h3 class="textTitle">1.快手批量工具更新：</h3>
                <ul class="updatelist">
                  <li> <span class="circular"></span> 批量更改监测链接；</li>
                  <li><span class="circular"></span>素材审核驳回在企业微信发消息提醒；</li>
                  <li><span class="circular"></span>推送失败在企业微信发消息；</li>
                  <li><span class="circular"></span>广告语加入动态词包；</li>
                  <li><span class="circular"></span>屏蔽停投的账户；</li>
                </ul>
              </div>
              <div class="updateBox">
                <h3 class="textTitle">2.素材管理--视频素材-加素材名称搜索</h3>
              </div>
                      
            </div>
        </div>
        <div class="Updateitem">
            <div class="Updatetime">
                 <a-icon type="dashboard" theme='twoTone' class="updateicon" />
                 <span class="updateSpan">{{updateTime[0]}}</span>
            </div>
            <div class="updateText">
              <div class="updateBox">
                <h3 class="textTitle">1.头条-账户报表上线通知</h3>
                <ul class="updatelist">
                  <li><span class="circular"></span>点击“统计报表-头条报表-账户报表”查看模块</li>
                  <li><span class="circular"></span>可根据项目账户筛选查看数据，支持时间筛选</li>
                  <li><span class="circular"></span>支持报表导出</li>
                </ul>
              </div>
              <div class="updateBox">
                <h3 class="textTitle">2.快手批量工具更新</h3>
                <ul>
                  <li><span class="circular"></span>在创建创意模块加了时间维度筛选</li>
                </ul>
              </div>
              <div class="updateBox">
                <h3 class="textTitle">3.视频报表修改</h3>
                <ul>
                  <li><span class="circular"></span>添加了视频上传时间字段</li>
                </ul>
              </div>
            </div>
        </div>
         
      </div>
      <a-button type='primary' class="okBtn" @click="handleOk">知道了</a-button>
       </div>
    </a-modal>
  </div>
</template>

<script>
  import ChartCard from '@/components/ChartCard'
  import ACol from 'ant-design-vue/es/grid/Col'
  import ATooltip from 'ant-design-vue/es/tooltip/Tooltip'
  import MiniArea from '@/components/chart/MiniArea'
  import MiniBar from '@/components/chart/MiniBar'
  import MiniProgress from '@/components/chart/MiniProgress'
  import RankList from '@/components/chart/RankList'
  import Bar from '@/components/chart/Bar'
  import LineChartMultid from '@/components/chart/LineChartMultid'
  import HeadInfo from '@/components/tools/HeadInfo.vue'
  import { getAction, postAction, downFile, downFilePost } from '@/api/manage';
  import Trend from '@/components/Trend'
  import {
    getLoginfo,
    getVisitInfo
  } from '@/api/api'
  import newHome from '@/views/modules/Statistics/newHome.vue'
  import Workbench from '@/views/dashboard/Workbench.vue'
  import Statistics from '@/views/modules/Statistics/Statistics.vue'
  const rankList = []
  for (let i = 0; i < 7; i++) {
    rankList.push({
      name: '白鹭岛 ' + (i + 1) + ' 号店',
      total: 1234.56 - i * 100
    })
  }
  const barData = []
  for (let i = 0; i < 12; i += 1) {
    barData.push({
      x: `${i + 1}月`,
      y: Math.floor(Math.random() * 1000) + 200
    })
  }
  export default {
    name: 'Analysis',
    components: {
      ATooltip,
      ACol,
      ChartCard,
      MiniArea,
      MiniBar,
      MiniProgress,
      RankList,
      Bar,
      Trend,
      LineChartMultid,
      HeadInfo,
      newHome,
      Workbench,
      Statistics
    },
    data() {
      return {
        loading: true,
        center: null,
        rankList,
        barData,
        loginfo: {},
        visitFields: ['ip', 'visit'],
        visitInfo: [],
        indicator: <a-icon type="loading" style="font-size: 24px" spin />,
        roleCode: localStorage.getItem('roleCode'),
        visible:false,//更新通知消息提示框
        updateTime:['2020-06-10','2020-06-17','2020-06-24','2020-07-01'],
        versionId:0,//存储版本号 判断通知什么时候显示
      }
    },
    created() {
      setTimeout(() => {
        this.loading = !this.loading
      }, 1000)
      this.initLogInfo()
    },
    methods: {
      initLogInfo() {
        getLoginfo(null).then(res => {
          if (res.success) {
            Object.keys(res.result).forEach(key => {
              res.result[key] = res.result[key] + ''
            })
            this.loginfo = res.result
          }
        })
        getVisitInfo().then(res => {
          if (res.success) {
            console.log('aaaaaa', res.result)
            this.visitInfo = res.result
          }
        })

      },
      handleOk(e) {
        // console.log(e);
        this.visible = false;
        postAction('/ctop/releaseViewRecord/view', {
          versionId:this.versionId
        }).then(res => {
            console.log(res)
            if(res.success){
              //  this.visible=res.showPopup;
            }
           
        })
      },

    },
    mounted() {
         postAction('/ctop/releaseViewRecord/check', {}).then(res => {
            console.log(res)
            if(res.success){
               this.visible=res.showPopup;
               this.versionId=res.data.id;
            }
           
        })
    },
  }
</script>

<style lang="scss" scoped>
  .circle-cust {
    position: relative;
    top: 28px;
    left: -100%;
  }

  .extra-wrapper {
    line-height: 55px;
    padding-right: 24px;

    .extra-item {
      display: inline-block;
      margin-right: 24px;

      a {
        margin-left: 24px;
      }
    }
  }

  /* 首页访问量统计 */
  .head-info {
    position: relative;
    text-align: left;
    padding: 0 32px 0 0;
    min-width: 125px;

    &.center {
      text-align: center;
      padding: 0 32px;
    }

    span {
      color: rgba(0, 0, 0, 0.45);
      display: inline-block;
      font-size: 0.95rem;
      line-height: 42px;
      margin-bottom: 4px;
    }

    p {
      line-height: 42px;
      margin: 0;

      a {
        font-weight: 600;
        font-size: 1rem;
      }
    }
  }
</style>