<template>
    <div class="andon_info">
        <!-- <Spin size="large" v-if="loading"></Spin> -->
        <!-- <Spin size="large"></Spin> -->
        <div class="divborder newSearchDiv">
            <div class="filter">
                <label>{{ $t("1132") }}：</label>
                <Cascader
                    class="searchInput"
                    :data="datalevel"
                    :value="leveldata"
                    trigger="click"
                    @on-change="handlelevelchange"
                ></Cascader>
            </div>
           
                <Button
                    type="primary"
                    class="twoWord"
                    icon="ios-search"
                    @click="search()"
                    >{{ $t("1001") }}</Button
                >
           
        </div>
        <div class="">
            <div class="list1">
                <!-- <Spin size="large" fix v-if="loading"></Spin> -->

                <!-- <div class="clear" v-for="(lineItem,key) in machineStateList" :key="key" style="cursor:pointer;"> -->
                <div class="boardItem" v-for="i in 10" >
                    <div style="display: flex">
                        <div class="circle1">
                            <i-circle
                                :percent="80"
                                style="width: 90px; height: 90px"
                            >
                                <span class="demo-Circle-inner title"
                                    >剩余寿命</span
                                >
                                <span class="demo-Circle-inner" style="font-size:16px">10000min</span>
                            </i-circle>
                        </div>
                        <div class="rightBox">
                            <p class="name">设备名称</p>
                            <p>主轴：<span class="f16">222</span></p>
                            <p>刀位：<span class="f16">333</span></p>
                        </div>
                    </div>
                    <div class="bottomBox">
                        <p class="title">预计换刀时间</p>
                        <p class="time">2020/09/21 2020/09/21</p>
                    </div>
                </div>
                <div
                    class="clear"
                    v-for="(value, name) in allData"
                    :key="name"
                    style="cursor: pointer"
                >
                    <div class="title mb15 pl15">{{ name }}</div>
                    <div class="clear1">
                        <div
                            v-for="(machineItem, i) in value"
                            :key="i"
                            class="machineStateList"
                            :style="{ backgroundColor: machineItem.bk_color }"
                        >
                            <!-- @click="showDetail($event,machineItem)" -->
                            <div class="t">
                                <div style="height: 25%; text-align: bottom">
                                    设备：{{ machineItem.machine_name }}
                                </div>
                                <div style="height: 25%; text-align: bottom">
                                    主轴：{{ machineItem.spindle_name }}
                                </div>
                                <div style="height: 25%; text-align: bottom">
                                    刀位：{{ machineItem.cutter_location_name }}
                                </div>
                                <div style="height: 25%; text-align: bottom">
                                    剩余寿命：{{ machineItem.surplus_life }}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- <Modal v-model="addModal" :loading="loading" footer-hide :styles="{top: '60px',width:'380px'}">
      <div class="modal_body" style="width:100%!important;padding:0 20px;">
        <div class="p1" style="margin-bottom: 5px;">{{ order.location}}</div>
        <p class="p2" style="margin-bottom: 50px;">{{order.machinename}}</p>
        <div class="p3" style="margin-bottom: 15px;">
          <div class="clear pr" style="border-bottom: 1px dashed #DCDEE2;height: 15px;">
            <em  :class="['round', order.status<=1?'active':'past']" style="left: 0px;"></em><em :class="['point', order.status<=1?'':'hide']" style="left: 5px;"></em>
            <em :class="['round', order.status===2?'active':(order.status>2?'past':'')]" style="left: 74px;"></em><em :class="['point', order.status===2?'':'hide']" style="left: 79px;"></em>
            <em :class="['round', order.status===3?'active':(order.status>3?'past':'')]" style="left: 146px;"></em><em :class="['point', order.status===3?'':'hide']" style="left: 151px;"></em>
            <em :class="['round', order.status===4?'active':(order.status>4?'past':'')]" style="left: 221px;"></em><em :class="['point', order.status===4?'':'hide']" style="left: 226px;"></em>
            <em :class="['round', order.status===5?'active':'']" style="left: 297px;"></em><em :class="['point', order.status===5?'':'hide']" style="left: 302px;"></em>
          </div>
          <div class="clear mt15 des">
            <span style="left: 32px;">{{$t(1590001)}}</span>
            <span style="left: 104px;">{{$t(1590002)}}</span>
            <span style="left: 176px;">{{$t(1590003)}}</span>
            <span style="left: 253px;">{{$t(1590004)}}</span>
            <span style="left: 329px;">{{$t(1590005)}}</span>
          </div>
        </div>
        <div class="p4" style="margin-bottom: 5px;">{{order.location}} {{order.message}}</div>
        <div class="p5">{{order.work_order+$t(order.title)}}</div>
      </div>
        </Modal>-->
    </div>
</template>
<script>
import axios from "@/libs/api.request";
import myTrees from "_c/tpm-status/status2.vue";
export default {
    components: {
        myTrees,
    },
    data() {
        return {
            datalevel: [],
            leveldata: [],
            addModal: false,
            total: 0,
            machineStateList: [],
            allData: {},
            order: {
                location: "",
                status: 0,
                time: "",
                message: "",
                title: "",
                machinename: "",
                work_order: "",
            },
            alarmCount: {},
            isClick: false,
            loading: false,
        };
    },
    created() {
        // this.getStatus(0);
        this.initlevel();
    },
    methods: {
        initlevel() {
            // 初始化产线层级
            this.axios
                .request({
                    url: "config/ProjectLevelSection/GetSectionTree",
                    method: "get",
                })
                .then((res) => {
                    const arr = [];
                    if (res.data.data.length > 0) {
                        this.datalevel = res.data.data;
                    }
                });
        },
        handlelevelchange(val) {
            this.leveldata = val;
            // this.getMachine();
        },
        search() {},
        getStatus(machine_type) {
            // 获取status相关数据
            axios
                .request({
                    url: "/tools/ToolMoniter/getAllToolMonitorData",
                    // url: "/tools/ToolMoniter/DashboardData",
                    data: { machine_type: machine_type },
                    method: "post",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.$Spin.hide();
                        this.loading = false;
                        this.alarmCount = res.data.data.alarmCount;
                        this.allData = res.data.data.data;
                        //   this.machineStateList = res.data.data.data
                    } else {
                        this.$Spin.hide();
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        changeState(type) {
            // console.log(type);
            this.$Spin.show();
            // this.loading = true
            this.getStatus(type);
        },
        // showDetail (e, item) {
        //   if (item.id) {
        //     let params = {
        //       machineid: item.id
        //     }
        //     axios.request({
        //       url: '/tpm/Repair/GetMachineRepairInfo',
        //       params,
        //       method: 'get'
        //     }).then(res => {
        //       if (res.data.ret === 1) {
        //         let item = res.data.data
        //         this.order.location = item.location
        //         this.order.status = item.status
        //         this.order.time = item.time
        //         this.order.message = item.message
        //         this.order.title = item.title
        //         this.order.machinename = item.machinename
        //         this.order.work_order = item.work_order
        //         this.addModal = true
        //       } else {
        //         this.order.location = ''
        //         this.order.status = ''
        //         this.order.time = ''
        //         this.order.message = ''
        //         this.order.title = ''
        //         this.order.machinename = ''
        //         this.order.work_order = ''
        //         // this.addModal = false
        //         this.$Message.error(this.$t(1095))
        //       }
        //     })
        //   }
        // }
    }, // end method
};
</script>
<style lang="less" scoped>
.list1 {
    display: flex;
    flex-wrap: wrap;
    margin: 10px;
    width: 100%;
    .boardItem {
        background-color: #fff;
        width: 240px;
        height: 180px;
        // border: 1px solid #333;
        box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.04);
        opacity: 1;
        border-radius: 4px;
        margin: 20px;
        .circle1 {
            width: 90px;
            height: 90px;
            margin: 16px 16px 8px;
            .title {
                font-size: 10px;
                color: #bfbfbf;
            }
        }
        .rightBox {
            width: 105px;
            height: 122px;
            padding: 25px 5px;
            .name {
                font-size: 14px;
                color: #515a6e;
                margin-bottom: 5px;
            }
            p {
                color: #bfbfbf;

                .f16 {
                    font-size: 16px;
                    color: #515a6e;
                }
            }
        }
        .bottomBox {
            text-align: center;
            .title {
                color: #bfbfbf;
            }
            .time {
                font-size: 16px;
                color: #515a6e;
            }
        }
    }
}
.stateItem {
    flex: 1;
    height: 100px;
    margin: 10px;
    font-size: 25px;
    text-align: center;
    line-height: 50px;
}
.border {
    border: 1px solid #333;
    /* border-radius: 2px; */
}
.andon_info .list {
    position: relative;
}

.andon_info .list .title {
    font-size: 16px;
    font-weight: bold;
}
.clear1 {
    display: flex;
    flex-wrap: wrap;
}
.andon_info .list .machineStateList {
    width: 150px;
    height: 80px;
    float: left;
    margin-left: 15px;
    margin-bottom: 15px;
}

.andon_info .list .machineStateList.status0 {
    background-color: #23343c;
}

.andon_info .list .machineStateList.status1 {
    background-color: #d9534f;
}

.andon_info .list .machineStateList.status2 {
    background-color: #f0ad4e;
}
.andon_info .list .machineStateList.status3 {
    background-color: #103981;
}
.andon_info .list .machineStateList.status4 {
    background-color: #337ab7;
}
.andon_info .list .machineStateList.status5 {
    background-color: #2caf8c;
}
.andon_info .list .machineStateList.status6 {
    background-color: #5cb85c;
}
.andon_info .list .machineStateList .status7 {
    background-color: #5cb85c;
}
.andon_info .list .machineStateList .status8 {
    background-color: #5cb85c;
}

.andon_info .list .machineStateList .t {
    font-size: 14px;
    /* font-weight: bold; */
    color: #000;
    text-align: left;
    height: 80px;
    padding: 0;
    margin: 0;
    /* line-height: 80px; */
    /* overflow: hidden; */
}
.andon_info .list .machineStateList .t div {
    font-size: 14px;
    /* font-weight: bold; */
    color: #000;
    text-align: center;
    /* height: 40px; */
    line-height: 20px;

    /* line-height: 40px; */
    overflow: hidden;
    word-wrap: break-word;
    word-break: normal;
    padding: 0 3px;
}
/* .andon_info .list .machineStateList .state {
    font-size: 30px;
    font-weight: bold;
    color: white;
    text-align: center;
    height: 50px;
    line-height: 50px;
    overflow: hidden;
  } */

.p1 {
    font-family: "Arial Bold Oblique", "Arial Bold", "Arial Normal", "Arial";
    font-weight: 700;
    font-style: oblique;
    font-size: 15px;
    color: #103981;
    text-align: center;
}

.p2 {
    font-family: "Arial Bold Oblique", "Arial Bold", "Arial Normal", "Arial";
    font-weight: 700;
    font-style: oblique;
    font-size: 15px;
    color: #103981;
    text-align: center;
}

.p3 {
    height: 50px;
}

.p3 .round {
    width: 20px;
    height: 20px;
    border-radius: 10px;
    background-color: #dcdee2;
    display: block;
    float: left;
    position: absolute;
    top: 5px;
}

.p3 .round.past {
    background-color: lightgreen;
}

.p3 .round.active {
    width: 16px;
    height: 16px;
    margin: 0px 0 0 0px;
    border-radius: 50%;
    position: absolute;
    -webkit-box-shadow: 0 0 0 3px orange;
    box-shadow: 0 0 0 6px orange;
    z-index: 10;
    background-color: white;
    top: 6px;
}

.p3 .point {
    width: 6px;
    height: 6px;
    border-radius: 3px;
    position: absolute;
    top: 11px;
    background-color: orange;
    z-index: 20;
}

.p3 .des span {
    font-size: 14px;
    position: absolute;
}

.p4 {
    font-family: "Arial Bold Oblique", "Arial Bold", "Arial Normal", "Arial";
    font-weight: 700;
    font-style: oblique;
    font-size: 12px;
    color: #103981;
    text-align: center;
}

.p5 {
    font-family: "Arial Bold Oblique", "Arial Bold", "Arial Normal", "Arial";
    font-weight: 700;
    font-style: oblique;
    font-size: 12px;
    color: #103981;
    text-align: center;
}
</style>
