<style lang='scss'>
.only-there .ant-tabs-bar {
    background: white;
    padding: 0 24px;
}

.ant-card-head .ant-tabs-bar {
    padding: 0;
}

#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 analysis">
        <!--  -->

        <operateStatistics v-if="roleCode == 'operator' || roleCode == 'operationAssistant'"/>
        <onlyOneDashboard
            v-else-if="userInfo().id == '228c45f913924639bf20c79ce5dadb16'||userInfo().id == 'b161b7d9793942f980dbfe8c931cd1b0' || userInfo().id == '16eab477cd7a43538c1049d9678753e0'|| userInfo().id == '1747433221403979778'   ||userInfoId"/>
        <managerStatistics v-else-if="userInfoId || roleCode == 'CompanyManager'"/>
        <groupKeepManage
            v-else-if="roleCode == 'kuaishouOperationManager'||roleCode == 'kuaishouDirector' || roleCode == 'touTiaoOperationManager'"/>
        <newHome v-else-if=" roleCode == 'bytedanceDirector'"/>
        <!-- <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'" /> -->
        <Design
            v-else-if="roleCode == 'designTeamLeader'||roleCode == 'plan'||roleCode == 'shot'||roleCode == 'clip'||userInfo().id == 'e9d527b2b6854a1ea0cc3167fc6a27d0'"/>
        <a-tabs default-active-key="1" v-else-if="roleCode == 'salesSupportManager'||roleCode == 'saleAm'||roleCode == 'saleDirector'||
    roleCode == 'sale'" 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[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>
                                    <li><span class="circular"></span>优化快手素材报表接口查询效率；</li>
                                </ul>
                            </div>
                            <!-- <div class="updateBox">
                              <h3 class="textTitle">2.功能优化：</h3>
                              <ul>
                                <li><span class="circular"></span>修复了相关BUG；</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 {mapActions, mapGetters} from 'vuex'
import Trend from '@/components/Trend'
import managerStatistics from './managerStatistics'
import operateStatistics from '@/views/modules/stockWatch/modules/new-keepManage/personal-keepManage.vue'
import groupKeepManage from '@/views/modules/stockWatch/modules/new-keepManage/group-keepManage.vue'
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'
import onlyOneDashboard from './onlyOneDashboard'
import Design from '@/views/modules/Statistics/designerReport/designIndex.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,
        Design,
        Statistics,
        managerStatistics,
        operateStatistics,
        groupKeepManage,
        onlyOneDashboard
    },
    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: ['2021-03-03'],
            versionId: 0,//存储版本号 判断通知什么时候显示
            userInfoId: false,
        }
    },
    created() {
        setTimeout(() => {
            this.loading = !this.loading
        }, 1000)
        this.initLogInfo()
        if (this.roleCode == 'operator' || this.roleCode == 'operationAssistant') {
            sessionStorage.setItem('personalUserId', this.userInfo().id)
        }
    },

    methods: {
        ...mapGetters(['userInfo']),
        getUserId() {
            if (this.userInfo().id == '4aba62011120ac565c7f2b9f8f4aa96b' || this.userInfo().id == 'e9ca23d68d884d4ebb19d07889727dae' || this.userInfo().id == 'db2d59e9b4a3b18629c838fd7f5b58d8' || this.userInfo().id == '00d630a129e4487cba5427788a1f08ce') {
                this.userInfoId = true;
            } else {
                this.userInfoId = false;
            }
        },
        // 跳转数据看板
        dataKanBan() {
            const a = document.createElement('a');
            document.body.appendChild(a);
            a.style.display = 'none';
            a.href = 'http://adsp.c-top.com.cn/boss-data-kanban';

            a.target = '_blank'
            a.click();
            document.body.removeChild(a);
        },
        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;
                if (res.data) {
                    this.versionId = res.data.id;
                }

            }

        })
        this.getUserId();
    },
}
</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>
<style lang="less">
.analysis .ant-tabs-bar {
    margin: 0 0 12px 0;
    /* height: 55px; */
    border-bottom: 1px solid #e8e8e8;
    outline: none;
    -webkit-transition: padding 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    transition: padding 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}
</style>