<style>
.businessInfoBox.drawer-box{
    height: 100%;
}
.businessInfoBox .drawer-header{
    height: 83px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}
.businessInfoBox .drawer-header .left{
    display: flex;
    align-items: center;
}
.businessInfoBox .drawer-header .left img{
    display: inline-block;
    margin-right: 10px;
    width: 26px;
    height: 26px;
}
.businessInfoBox .drawer-body{
    height: calc( 100% - 83px);
}
.businessInfoBox .drawer-body .top-info{
    height: 115px;
    padding: 30px;
    box-sizing: border-box;
    font-size: 12px;
    background-color: #F6F4FC;
}
.businessInfoBox .drawer-body .top-info .info-lable{
    display: inline-block;
    width: 100px;
    color: #999999;
}
.businessInfoBox .margin-bottom-25{
    margin-bottom: 25px;
}
.businessInfoBox .drawer-box .el-tabs__nav-wrap::after{
    height: 0;
}
.businessInfoBox .drawer-body .el-tabs__header{
    padding: 0 25px;
    margin-bottom: 0;
}
.businessInfoBox .drawer-body>.content{
    height: calc(100% - 115px);
}
.businessInfoBox .drawer-body .el-tabs{
    height: 100%;
    height: calc(100% - 84px);
}
.businessInfoBox .drawer-body .el-tabs__content{
    background-color: #F6F4FC;
    height: calc(100% - 40px);
    box-sizing: border-box;
}
.state-box{
    padding: 15px;
    border-top: 1px solid #e6e6e6;
    border-bottom: 1px solid #e6e6e6;
    background-color: #fff;
}
.busi-state {
    position: relative;
    padding-left: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 1;
    display: flex;
    align-items: center;
}
.busi-state-item{
    padding: 0 30px;
    height: 38px;
    position: relative;
    margin: 5px 5px 5px 0;
    border-top: 2px solid #ebebeb;
    border-bottom: 2px solid #ebebeb;
    line-height: 36px;
}
.state-suc .circle-left, .state-suc .circle-right{
    border-color: #00ca9d !important;
    background-color: #00ca9d !important;
}
.busi-state-item .state-circle{
    width: 37px;
    height: 38px;
    border-radius: 19px;
    background-color: #fff;
    -webkit-transform: rotate(45deg);
    transform: rotate(45deg);
    position: absolute;
    z-index: -1;
    top: -1px
}
.circle-left{
    border-left: 2px solid #ebebeb;
    border-bottom: 2px solid #ebebeb;
    top: -2px;
    left: -17px;
}
.state-suc{
    border-top: 1px solid #00ca9d;
    border-bottom: 1px solid #00ca9d;
    background-color: #00ca9d;
    color: #fff;
}
.state-suc .arrow-right{
    border-color: #00ca9d !important;
    background-color: #00ca9d !important;
}
.busi-state-item{
    cursor: pointer;
}
.busi-state-item .state-arrow{
    width: 38px;
    height: 38px;
    -webkit-transform: scale(.707) rotate(45deg);
    transform: scale(.707) rotate(45deg);
    border-top: 2px solid #ebebeb;
    border-right: 2px solid #ebebeb;
    background-color: #fff;
    position: absolute;
}
.state-doing{
    border-top: 2px solid #00ca9d;
    border-bottom: 2px solid #00ca9d;
    background-color: #fff;
    color: #00ca9d;
}
.arrow-right{
    z-index: 1;
    top: -1px;
    right: -20px;
}
.state-doing .arrow-left, .state-doing .arrow-right, .state-doing .circle-left, .state-doing .circle-right {
    border-color: #00ca9d  !important;
    background-color: #fff !important;
}
.arrow-left {
    top: -1px;
    left: -18px;
}
.state-undo{
    border-top: 2px solid #ebebeb;
    border-bottom: 2px solid #ebebeb;
    background-color: #fff;
    color: #666;
}
.circle-right{
    border-top: 2px solid #ebebeb;
    border-right: 2px solid #ebebeb;
    z-index: 1;
    top: -1px;
    right: -17.5px;
}
.busi-state-item .el-icon-arrow-down{
    padding-right: 10px;
}
.state-handel-cont>div{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    cursor: pointer;
}
.state-handel-cont>div:hover {
    background-color: #f7f8fa;
}
</style>
<template>
    <div class="businessInfoBox drawer-box" v-if="loading">
        <div class="drawer-header">
            <div class="left">
                <img src="../../assets/img/cust/shangji.png" alt="">
                <p>{{detailsData.BusinessName}}</p>
            </div>
            <div class="right">
                <el-button class="crm-btn query-btn" @click="editCustbusiness" v-if="detailsData.IsRead === 0">编辑</el-button>
                <el-button class="crm-btn easy-btn iconfont iconplus-transfer " v-if="detailsData.IsRead === 0">转移</el-button>
                <el-dropdown @command="handleCommand" style="top: 1px;" v-if="detailsData.IsRead === 0">
                    <el-button class="crm-btn crm-btn-more easy-btn margin-right0">
                        <i class="iconfont icongengduo"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="d"><i class="iconfont icondelete"></i> 删除</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div>
        </div>
        <div class="drawer-body">
            <div class="top-info">
                <el-row class="margin-bottom-25">
                    <el-col :span="12">
                        <span class="info-lable">所属客户：</span><span >{{detailsData.CustomerName}}</span>
                    </el-col>
                    <el-col :span="12">
                        <span class="info-lable">商机金额（元）：</span><span >{{detailsData.BudgetPrice}}</span>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <span class="info-lable">负责人：</span><span>{{detailsData.PersonChargeStr}}</span>
                    </el-col>
                    <el-col :span="12">
                        <span class="info-lable">创建时间：</span><span>{{detailsData.CreateTime}}</span>
                    </el-col>
                </el-row>
            </div>
            <div class="content">
                <div class="state-box"  v-show="false">
                    <div class="busi-state">
                        <el-popover
                            placement="bottom"
                            width="150"
                            title="验证客户"
                            trigger="hover">
                            <p>很好</p>
                            <div slot="reference" class="busi-state-item state-suc">
                                验证客户
                                <div class="state-circle circle-left"></div>
                                <div class="state-arrow arrow-right"></div>
                            </div>
                        </el-popover>
                        <el-popover
                            placement="bottom"
                            width="150"
                            title="需求分析"
                            trigger="hover">
                            <p>很好11</p>
                            <div slot="reference" class="busi-state-item state-doing">
                                需求分析
                                <div class="state-arrow arrow-left"></div>
                                <div class="state-arrow arrow-right"></div>
                            </div>
                        </el-popover>
                        <el-popover
                            placement="bottom"
                            width="150"
                            title="方案/报价"
                            trigger="hover">
                            <p>很好1122</p>
                            <div slot="reference" class="busi-state-item state-undo">
                                方案/报价
                                <div class="state-arrow arrow-left"></div>
                                <div class="state-arrow arrow-right"></div>
                            </div>
                        </el-popover>
                        <el-popover
                            placement="bottom"
                            width="150"
                            trigger="hover">
                            <div class="state-handel-cont">
                                <div @click="setBusinessState(1)">
                                    <div>赢单</div>
                                    <div>100%</div>
                                </div>
                                <div @click="setBusinessState(2)">
                                    <div>无效</div>
                                    <div>0%</div>
                                </div>
                                <div @click="setBusinessState(3)">
                                    <div>输单</div>
                                    <div>0%</div>
                                </div>
                            </div>
                            <div slot="reference" class="busi-state-item state-undo">
                                <i class="el-icon-arrow-down"></i>结束
                                <div class="state-arrow arrow-left"></div>
                                <div class="state-circle circle-right"></div>
                            </div>
                        </el-popover>
                    </div>
                </div>
                <el-tabs v-model="activeName" v-if="detailsData.CustomerId">
                    <el-tab-pane label="活动" name="1">
                        <Activity v-if="activeName === '1'" :BusinessId="BusinessId" :BusinessIdCustomerId="detailsData.CustomerId" />
                    </el-tab-pane>
                    <el-tab-pane label="详细资料" name="2">
                        <Details v-if="activeName === '2'" :detailsData="detailsData"/>
                    </el-tab-pane>
                    <el-tab-pane label="联系人" name="3">
                        <Contacts v-if="activeName === '3'" :BusinessId="BusinessId" :BusinessIdCustomerId="detailsData.CustomerId" :IsRead="detailsData.IsRead"/>
                    </el-tab-pane>
                    <el-tab-pane label="团队成员" name="4">
                        <TeamMembers v-if="activeName === '4'" :BusinessId="BusinessId" :IsRead="detailsData.IsRead"/>
                    </el-tab-pane>
                    <!-- <el-tab-pane label="回款" name="7">
                        <MoneyBack />
                    </el-tab-pane> -->
                    <el-tab-pane label="附件" name="8">
                        <Enclosure v-if="activeName === '8'"  :ID='BusinessId' :type='2' :IsRead="detailsData.IsRead"/>
                    </el-tab-pane>
                    <el-tab-pane  label="操作记录" name="9">
                        <Record v-if="activeName === '9'"  />
                    </el-tab-pane>
                </el-tabs>
            </div>
        </div>
    </div>
</template>
<script>
import Activity from "./Activity";
import Details from "./bsDetails";
import Contacts from "./Contacts";
import TeamMembers from "./TeamMembers";
import Business from "../assembly/Business";
import MoneyBack from "../assembly/MoneyBack";
import Enclosure from "../clueManagement/Enclosure";
import Record from "./Record";
export default {
    components: {
        Activity,
        Details,
        Contacts,
        TeamMembers,
        Business,
        MoneyBack,
        Enclosure,
        Record
    },
    props:{
        BusinessId: {
            type: Number,
            default: 0
        },
        BusinessIdCustomerId: {
            type: Number,
            default: 0
        },
        CustomerType: {
            type: Number,
            default: 0
        }
    },
    data() {
        return {
            detailsData: {},
            loading: true,
            activeName: '1',
        };
    },watch:{
        BusinessId: {
            handler(val, oldVal){
                this.init()
                this.activeName = '1'
            },
            deep:true
        },
        CustomerType: {
            handler(val, oldVal){
                
            },
            deep:true
        }
    },
    mounted() {
        let $this = this
        $this.init()
        // 监听修改更新界面
        this.MsgBus.$on('RefreshInfoBox', function () {
            $this.init()
        })
    },
    methods: {
        setBusinessState(){

        },
        init(){
            this.apipost('/api/Customer/GetAllBusinessModel', {BusinessId: this.BusinessId, CustomerType: this.CustomerType}, res=>{
                if (res.data.resultCode == 1) {
                    this.detailsData = res.data.data
                }
            })
        },
        handleCommand(command){
            if (command === 'z') {
                this.$emit('transferS', 3);
            } else if (command === 'g') {
                this.$emit('watersS', 1)
            }
        },
        handleClick(tab, event) {},
        editCustbusiness(){
            this.$emit('editCustbusiness', 1)
        },
        handleClose(done) {
            done();
        }
    }
}
</script>