<template>
    <div ref="pointStep" class="h100 saga-maintenance">
        <!-- <bread class="bread-view"></bread> -->
        <div class="saga-btns-view">
            <template v-for="(item,index) in jsonTitle">
                <div
                    :key="index"
                    @click="changeStep(index)"
                    class="saga-steps-btn pointer saga-size3"
                    :class="{
                        'active-steps': activeStep == index + 1
                    }"
                >
                    <div class="border-view">
                        <div class="point-step">{{index + 1}}</div>
                        <div class="jiao"></div>
                        <div class="point-title">{{item}}</div>
                    </div>
                </div>
            </template>
        </div>
        <div class="main-view">
        <step1 ref="step" v-if="activeStep == 1"></step1>
        <step2 ref="step" v-if="activeStep == 2"></step2>
        <step3 ref="step" v-if="activeStep == 3"></step3>
        <step4 ref="step" v-if="activeStep == 4"></step4>
        </div>
    </div>
</template>
<script>
    // import bread from "components/common/bread_crumb"
    import step1 from "./step1"
    import step2 from "./step2"
    import step3 from "./step3"
    import step4 from "./step4"
    export default {
        data() {
            return {
                activeStep: 1, //活跃的step
                jsonTitle: [
                    "原始点位表收集", "原始点位描述关键内容识别", "原始点位描述标准化", "点位表处理结果检查"
                ],
                activeHeight: 0
            }
        },
        created() {
            this.$store.dispatch('setBreadcrumb', [{
                label: '系统集成',
                path: '/point/pointsetting'
            }, {
                label: '点位表配置工具',
                path: '/point/pointsetting'
            }, {
                label: '点位收集'
            }])
        },
        mounted() {
            // console.log(this.$refs.pointStep.parentElement.parentElement.offsetHeight,'pointStep')
            this.resize()
            // document.addEventListener("resize",this.resize)
            window.onresize = this.resize
        },
        methods: {
            resize() {
                console.log(222)
                this.activeHeight = this.$refs.pointStep.parentElement.parentElement.parentElement.offsetHeight - 10
            },
            stepClick() {
                console.log("test")
            },
            changeStep(index) {
                console.log()
                let step = this.$refs.step
                let flag = step.hasOwnProperty('noSaveData') ? step.noSaveData() : false
                if (flag || this.activeStep == 4 || this.activeStep == 3) {
                    this.activeStep = index + 1
                } else {
                    this.$confirm('存在数据未保存, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.activeStep = index + 1
                    }).catch(() => {
                        return false
                    });
                }
            }
        },
        components: {
            // bread,
            step1,
            step2,
            step3,
            step4
        },
    }
</script>
<style lang="scss">
    .h100 {
        background-color: #fff; // padding: 0 10px;
        box-sizing: border-box;
        display: flex;
        flex-flow: column;
        .bread-view {
            height: 45px;
        }
        .main-view {
            flex: 1;
            display: flex;
            flex-flow: column;
        }
        .saga-btns-view {
            background-color: #fff; // display: flex;
            // justify-content: space-around;
            padding: 20px 0;
            box-sizing: border-box;
            height: 80px;
            text-align: center;
            .saga-steps-btn {
                display: inline-block;
                width: 250px;
                margin-right: 20px;
                height: 40px;
                background: #EEFAFF;
                box-shadow: 0 0 2px 0 #DDD;
                border-radius: 6px;
                font-size: 14px;
                line-height: 40px;
                color: #666;
                box-sizing: border-box;
                .border-view {
                    border: 1px solid #C2CEDB;
                    border-radius: 6px;
                    height: 34px;
                    line-height: 34px;
                    overflow: hidden;
                    margin: 2px 5px;
                    box-sizing: border-box;
                    position: relative;
                    flex: 1;
                    .jiao {
                        display: inline-block;
                        border-top: 17px solid transparent;
                        border-left: 17px solid #C2CEDB;
                        border-bottom: 17px solid transparent;
                        position: relative;
                        float: left;
                        &::after {
                            content: '';
                            position: absolute;
                            top: -17px;
                            left: -18px;
                            border-top: 17px solid transparent;
                            border-left: 17px solid #EEFAFF;
                            border-bottom: 17px solid transparent;
                        }
                    }
                    .point-step {
                        font-size: 24px;
                        padding: 0 9px;
                        float: left;
                    }
                    .point-title {
                        float: left; // padding-left: 10px;
                        // padding-right: 22px;
                        width: 168px;
                    }
                } // height: 80px;
                // text-align: center;
                // /*设置文本水平居中*/
                // display: table-cell;
                // vertical-align: middle;
                // padding: 0 30px;
            }
            .active-steps {
                background-color: rgb(179, 216, 255);
                .border-view {
                    border-color: #5BA7FF;
                    .point-step {
                        background-color: #5BA7FF;
                        color: #fff;
                    }
                    .jiao {
                        border-left-color: #5BA7FF;
                        &::after {
                            border-left-color: #5BA7FF;
                        }
                    }
                }
            }
        }
    }
</style>
