<template>
  <div class="andon_info">
    <div class="divborder">
      <div class="list">
        <div class="clear" v-for="(lineItem,key) in machineStateList" :key="key" style="cursor:pointer;">
          <div class="title mb15 pl15">{{lineItem.line}}</div>
          <div class="clear">
            <div v-for="(machineItem,key) in lineItem.machine" :key="key" @click="showDetail($event,machineItem)" :class="['machineStateList','status'+machineItem.state]">
              <div class="t">
                <div style="height:25%;text-align:bottom">
                  {{machineItem.section_name}}
                </div>
                <div style="height:25%;text-align:bottom">
                  {{machineItem.name}}
                </div>
                <div style="height:50%;text-align:top;line-height: 40px;font-size:25px;">
                  <span v-if="machineItem.state === 0">{{$t(1135)}}</span>
                  <span v-else-if="machineItem.state === 1">{{$t(200032)}}</span>
                  <span v-else-if="machineItem.state === 2">{{$t(200033)}}</span>
                  <span v-else-if="machineItem.state === 3">{{$t(200034)}}</span>
                  <span v-else-if="machineItem.state === 4">{{$t(200035)}}</span>
                  <span v-else-if="machineItem.state === 5">{{$t(900704)}}</span>
                  <span v-else-if="machineItem.state === 6">{{$t(100200)}}</span>
                </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 {
            addModal: false,
            loading: false,
            total: 0,
            machineStateList: [],

            order: {
                location: '',
                status: 0,
                time: '',
                message: '',
                title: '',
                machinename: '',
                work_order: ''
            }

        }
    },
    created () {
        this.getStatus()
    },
    methods: {
        getStatus () {
            // 获取status相关数据
            axios.request({
                url: '/tpm/repair/GetMachineRepairState',
                method: 'get'
            }).then(res => {
                if (res.data.ret === 1) {
                    this.machineStateList = res.data.data
                }
            })
        },
        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>
  .andon_info .list {}

  .andon_info .list .title {
    font-size: 16px;
    font-weight: bold;
  }

  .andon_info .list .machineStateList {
    width: 100px;
    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: white;
    text-align: center;
    height: 80px;
    /* line-height: 80px; */
    overflow: hidden;

  }
  .andon_info .list .machineStateList .t div{
    font-size: 14px;
    /* font-weight: bold; */
    color: white;
    text-align: center;
    height: 40px;
    /* line-height: 40px; */
    overflow: hidden;
    word-wrap: break-word;
    word-break: normal;
    padding: 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>
