<template>
  <div class="andon_info">

    <div class="divborder newSearchDiv"  style="margin:0px;">
      <div class="filter">
        <label>{{$t(1132)}}：</label>
        <Cascader :data="datalevel" v-model="leveldata" change-on-select trigger="hover" class="searchSelect"
          @on-change="changelevel"></Cascader>
      </div>
      <div class="searchBtn">
      <Button type="primary" class="twoWord" icon="ios-search" @click="search(1,10)">{{$t('1001')}}</Button>
      </div>
    </div>
    <div class="divborder">
      <div class="list">
        <div class="clear" v-for="(lineItem,index) in machineStateList" :key="index">
          <div class="title mb15 pl15">{{lineItem.line}}</div>
          <div class="clear">
            <div v-for="(machineItem,index) in lineItem.machine" :key="index" @click="clickMachine(machineItem)" :class="['machineStateList',machineItem.state===0?'running':(machineItem.state===1?'alarm':'close')]">
              <div class="t">
                <div style="height:50%;text-align:bottom">
                  {{machineItem.station}}
                </div>
                <div style="height:30%;text-align:top;line-height: 24px;">
                  {{machineItem.name}}
                </div>
              </div>
              <!-- <div class="t"></div> -->
              <!-- <div class="state">{{machineItem.state===0?this.$t(100200):(machineItem.state===1?'预警':'安灯')}}</div> -->
              <!-- <div class="state">{{machineItem.state}}</div> -->

            </div>
          </div>
        </div>
      </div>
    </div>
    <Modal class="newModalClass" :title="$t(950420)" v-model="optModal" footer-hide :loading="loading" :styles="{width:'900px',overflow: 'visible'}">
      <div class="modal_body" style="padding-right:40px;min-height: 500px;overflow: visible;">
        <Form ref="optObj" :model="optObj" label-position="left" :label-width="80">
          <Tabs type="card" style="overflow: hidden !important;" v-model="tab" @on-click="changeTab($event)">
            <TabPane :label="$t(960428)">
              <Row type="flex" justify="space-between" class="code-row-bg" style="height:400px">
                <Col span="15">
                <FormItem :label="$t(7000000)" style="margin-bottom:10px;">
                  <Cascader :data="expectionLevel" :value="expectionLeveldata" trigger="click" change-on-select class="searchSelect MaxWidth"
                    @on-change="handleExpectionlevelchange"></Cascader>
                </FormItem>
                <FormItem v-show="shutdownTime" :label="$t(960577)" style="margin-bottom:10px;">
                  <DatePicker
                    type="datetime"
                    v-model="shutdownstime"
                    placeholder
                    class="searchInput MaxWidth"
                  ></DatePicker>
                </FormItem>
                <FormItem v-show="shutdownTime" :label="$t(960578)" style="margin-bottom:10px;">
                  <DatePicker
                    type="datetime"
                    v-model="shutdownetime"
                    placeholder
                    class="searchInput MaxWidth"
                  ></DatePicker>
                </FormItem>
                <FormItem :label="$t(1030)" style="margin-bottom:10px;">
                  <Input v-model="remark" type="text" class="searchInput MaxWidth"/>
                </FormItem>
                </Col>
                <Col span="9" style="border-left: 1px solid #808080;padding-left:20px ;">
                <h2>{{$t(7000022)}}</h2>
                <ul class="pl15" style="line-height: 30px;">
                  <li style="font-weight: normal;">
                    <span>{{$t(7000023)}}：{{optObj.alarmReason}}</span>
                  </li>
                  <li style="font-weight: normal;">
                    {{$t(1049)}}：{{optObj.startTime}}
                  </li>
                  <li style="font-weight: normal;">
                    {{$t(500083)}}：{{optObj.costTime}}
                  </li>
                </ul>
                </Col>
              </Row>
              <div style="width: 100%;" class="center">
                <Button type="primary" @click="triggerAndon()">{{$t(7000024)}}</Button>
              </div>
            </TabPane>
            <TabPane :label="$t(7000025)">
              <Table style="margin-top:10px;overflow:visible;" width='100%' :data="tableData1" :columns="tableColumns1"></Table>
              <div style="margin: 10px;overflow: hidden">
                <div style="float: right;">
                  <Page :total="total1" :current="page1" @on-change="changePage1" show-elevator show-sizer show-total
                    @on-page-size-change="handlePageSize1" :page-size-opts="[10,20,30,40,100]"></Page>
                </div>
              </div>
            </TabPane>
            <TabPane :label="$t(8000004)">
              <Table style="margin-top:10px;overflow:visible;" width='100%' :data="tableData2" :columns="tableColumns2"></Table>
              <div style="margin: 10px;overflow: hidden">
                <div style="float: right;">
                  <Page :total="total2" :current="page2" @on-change="changePage2" show-elevator show-sizer show-total
                    @on-page-size-change="handlePageSize2" :page-size-opts="[10,20,30,40,100]"></Page>
                </div>
              </div>
            </TabPane>
            <TabPane :label="$t(7000026)">
              <Table style="margin-top:10px;overflow:visible;" width='100%' :data="tableData4" :columns="tableColumns4"></Table>
              <div style="margin: 10px;overflow: hidden">
                <div style="float: right;">
                  <Page :total="total4" :current="page4" @on-change="changePage4" show-elevator show-sizer show-total
                    @on-page-size-change="handlePageSize4" :page-size-opts="[10,20,30,40,100]"></Page>
                </div>
              </div>
            </TabPane>
            <TabPane :label="$t(7000027)">
              <Table style="margin-top:10px;overflow:visible;" width='100%' :data="tableData3" :columns="tableColumns3"></Table>
              <div style="margin: 10px;overflow: hidden">
                <div style="float: right;">
                  <Page :total="total3" :current="page3" @on-change="changePage3" show-elevator show-sizer show-total
                    @on-page-size-change="handlePageSize3" :page-size-opts="[10,20,30,40,100]"></Page>
                </div>
              </div>
              <Row type="flex" justify="space-between" class="code-row-bg">
                <Col span="11">
                <span>{{$t(7000028)}}:</span><span class="fs20 pl10 pr10">{{optObj.andonCount}}</span><span>{{$t(200163)}}</span><span class="pl20">{{$t(7000029)}}：</span><span
                  class="fs20 pl10 pr10">{{optObj.andonTime}}</span><span>{{$t(200028)}}</span>
                </Col>
                <Col span="13">

                </Col>
              </Row>
            </TabPane>
          </Tabs>
        </Form>
      </div>
    </Modal>
    <!-- 异常解除 -->
    <Modal class="newModalClass" v-model="translateModel" draggable scrollable :title="$t(8000004)">
        <div>
          <label v-text="$t(1030)">备注</label>
          <Input
          v-model="translate_remark"
          type="textarea"
          class="searchInput MaxWidth"
          :autosize="{minRows: 2,maxRows: 2}"
          />
        </div>
        <div slot="footer">
          <Button type="text" size="large" @click="translateModel = false">{{$t("1033")}}</Button>
          <Button type="primary" size="large" @click="relievingAbnormal()">{{$t("900552")}}</Button>
      </div>
    </Modal>
  </div>
</template>
<script>
import axios from '@/libs/api.request'
import moment from 'moment'
export default {
    name: 'tpm-andon-info',
    components: {},
    data () {
        return {
            leveldata: [], // 产线层级插件所需数据
            datalevel: [], // 产线层级选中数据
            levelid: 0, // 产线层级选中的section_id
            translateModel: false, // 异常解除
            translate_remark: '', // 异常解除备注
            translate_data: {}, // 异常解除数据
            shutdownstime: '', // 停机开始时间
            shutdownetime: '', // 停机结束时间
            shutdownTime: false, // 停机时间
            filterObj: {
                index_time: [
                    moment(new Date().getTime()).format('YYYY-MM-DD ') + '00:00:00',
                    moment(new Date().getTime()).format('YYYY-MM-DD ') + '23:59:59'
                ]
            },

            initPageData: {

            },
            machineStateList: [],
            optModal: false, // 添加Modal的开关
            loading: true,
            optObj: {
                machineid: 0, // 点击的设备
                status: 0,
                alarmReason: '', // 报警原因
                startTime: '', // 安灯开始时间
                costTime: '', // 安灯持续时间

                handleTime: '', // 处理时间

                andonCount: 0, // 今日安灯次数
                andonTime: 0 // 累计安灯时长(分钟)

            },
            tab: 0,
            remark: '',
            expectionLevel: [], // 异常级别全部数据
            expectionLeveldata: [], // 产线层级value [1,2,4]

            tableData1: [],
            total1: 0,
            page1: 1,
            pagesize1: 10,
            tableColumns1: [{
                title: this.$t(7000030),
                key: 'andonType1',
                width: 140
            },
            {
                title: this.$t(7000031),
                key: 'andonType2',
                width: 140
            },
            {
                title: this.$t(7000032),
                key: 'andonType3',
                width: 140
            },
            {
                title: this.$t(7000033),
                key: 'startTime',
                width: 160
            },
            {
                title: this.$t(7000034),
                key: 'costTime',
                width: 160
            },
            {
                title: this.$t(1038),
                key: 'action',
                align: 'center',
                render: (h, params) => {
                    return h('div', [
                        h('Button', {
                            props: {
                                type: 'primary',
                                size: 'small'
                            },
                            style: {
                                marginRight: '5px'
                            },
                            on: {
                                click: (row) => {
                                    this.andonSign(params)
                                }
                            }
                        }, this.$t(200049))
                    ])
                } // end render
            }
            ],

            tableData2: [],
            total2: 0,
            page2: 1,
            pagesize2: 10,
            isshutdown: 0,
            tableColumns2: [
                {
                    title: this.$t(1038),
                    key: 'action',
                    width: 120,
                    align: 'center',
                    render: (h, params) => {
                        return h('div', [
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: (row) => {
                                        this.translate_remark = ''
                                        this.translateModel = true
                                        this.translate_data = params
                                        // this.relievingAbnormal(params)
                                    }
                                }
                            }, this.$t(7000036))
                        ])
                    } // end render
                },
                {
                    title: this.$t(7000030),
                    key: 'andonType1',
                    width: 140
                },
                {
                    title: this.$t(7000031),
                    key: 'andonType2',
                    width: 140
                },
                {
                    title: this.$t(7000032),
                    key: 'andonType3',
                    width: 160
                },
                {
                    title: this.$t(7000033),
                    key: 'startTime',
                    width: 160
                },
                {
                    title: this.$t(7000034),
                    key: 'costTime',
                    width: 120
                },
                {
                    title: this.$t(7000035),
                    key: 'handleTime',
                    width: 120
                }
            ],

            tableData3: [],
            total3: 0,
            page3: 1,
            pagesize3: 10,
            tableColumns3: [{
                title: this.$t(200054),
                key: 'status',
                width: 80
            },
            {
                title: this.$t(950312),
                key: 'expection3',
                width: 180
            },
            {
                title: this.$t(960409),
                key: 'create_time',
                width: 165
            },
            {
                title: this.$t(7000037),
                key: 'complete_time',
                width: 165
            },
            {
                title: this.$t(7000038),
                key: 'andon_cost_time',
                width: 140
            },
            {
                title: this.$t(960408),
                key: 'creator_name',
                width: 120
            },
            {
                title: this.$t(200049),
                key: 'handler_name',
                width: 120
            }
            ],
            tableData4: [],
            total4: 0,
            page4: 1,
            pagesize4: 10,
            tableColumns4: [
                {
                    title: this.$t(1038),
                    key: 'action',
                    width: 240,
                    align: 'center',
                    render: (h, params) => {
                        return h('span', [
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: (row) => {
                                        this.Double_track(6, params.row.id)
                                        // this.translate_remark = ''
                                        // this.translateModel = true
                                        // this.translate_data = params
                                        // this.relievingAbnormal(params)
                                    }
                                }
                            }, this.$t(200024)),
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: (row) => {
                                        this.Double_track(7, params.row.id)
                                        // this.translate_remark = ''
                                        // this.translateModel = true
                                        // this.translate_data = params
                                        // this.relievingAbnormal(params)
                                    }
                                }
                            }, this.$t(7000039)),
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: (row) => {
                                        this.Double_track(8, params.row.id)
                                        // this.translate_remark = ''
                                        // this.translateModel = true
                                        // this.translate_data = params
                                        // this.relievingAbnormal(params)
                                    }
                                }
                            }, this.$t(200089))
                        ])
                    } // end render
                },
                {
                    title: this.$t(7000030),
                    key: 'andonType1',
                    width: 140
                },
                {
                    title: this.$t(7000031),
                    key: 'andonType2',
                    width: 140
                },
                {
                    title: this.$t(7000032),
                    key: 'andonType3',
                    width: 160
                },
                {
                    title: this.$t(7000033),
                    key: 'startTime',
                    width: 160
                },
                {
                    title: this.$t(7000034),
                    key: 'costTime',
                    width: 120
                },
                {
                    title: this.$t(7000035),
                    key: 'handleTime',
                    width: 120
                }
            ]
        }
    },
    created () {
        this.defaultPageData()
        this.search()
    },
    methods: {
        relievingAbnormal () { // 解除异常
            var params = this.translate_data
            let data = {
                id: params.row.id,
                expection: params.row.expection_type, // --异常类型id（处理完成后填写）
                type: 4, // 3：签到/4：处理完成/5：确认
                remark: this.translate_remark
            }
            axios.request({
                url: '/tpm/Andon/HandleAndon',
                data,
                method: 'post'
            }).then(res => {
                if (res.data.ret === 1) {
                    this.$Message.success(this.$t(7000040))
                    this.search()
                    this.optModal = false
                    this.translateModel = false
                } else {
                    // this.$Message.error('解除异常失败')
                    this.$Message.error(this.$t(res.data.msg))
                }
            })
        },
        andonSign (params) { // 安灯签到
            let data = {
                id: params.row.id,
                expection: 0, // --异常类型id（处理完成后填写）
                type: 3, // 3：签到/4：处理完成/5：确认
                remark: ''
            }
            axios.request({
                url: '/tpm/Andon/HandleAndon',
                data,
                method: 'post'
            }).then(res => {
                if (res.data.ret === 1) {
                    this.$Message.success(this.$t(7000041))
                    this.search()
                    this.optModal = false
                } else {
                    // this.$Message.error('安灯签到失败')
                    this.$Message.error(this.$t(res.data.msg))
                }
            })
        },
        triggerAndon () { // 触发安灯
            if (!this.expectionLeveldata[this.expectionLeveldata.length - 1]) {
                window_warning(this.$t(7000042))
                return false
            }

            var params = {
                id: this.expectionLeveldata[this.expectionLeveldata.length - 1]
            }
            this.axios.request({
                url: '/tpm/AndonBaseSetting/GetExpectionInfoByid',
                params,
                method: 'get'
            }).then(res => {
                if (res.data.ret === 1) {
                    if (res.data.data.is_passprocess === 1) {
                        this.andonbegin()
                    } else {
                        if (this.expectionLeveldata[1] === undefined || this.expectionLeveldata[1] === 0) {
                            this.$Message.error(this.$t(7000043))
                            return false
                        }
                        this.andonbegin()
                    }
                    // console.log(res.data)
                    // return false
                } else {
                    this.$Message.error(this.$t(res.data.msg))
                }
            })
        },
        andonbegin () {
            // 计划停机
            let stime = 0
            let etime = 0
            if (this.shutdownTime) {
                if (this.shutdownstime == '' || this.shutdownetime == '') {
                    this.$Message.error(this.$t(930012))
                    return false
                }
                stime = moment(this.shutdownstime).valueOf() / 1000;
                etime = moment(this.shutdownetime).valueOf() / 1000;
                if (stime >= etime) {
                    this.$Message.error(this.$t(930013))
                    return false
                }
            }
            let data = {
                machine: this.optObj.machineid,
                expection: this.expectionLeveldata[this.expectionLeveldata.length - 1],
                remark: this.remark,
                is_shutdown: this.optObj.status === 0 ? 1 : 0,
                start: stime,
                end: etime
            }

            axios.request({
                url: 'tpm/andon/AndonTrigger',
                data,
                method: 'post'
            }).then(res => {
                if (res.data.ret === 1) {
                    this.$Message.success(this.$t(7000044))
                    this.search()
                    this.optModal = false
                    this.remark = ''
                    this.shutdownTime = false
                    this.shutdownstime = ''
                    this.shutdownetime = ''
                } else {
                    this.$Message.error(this.$t(res.data.msg))
                }
            })
        },
        changeTab (tab) {
            // console.log(tab)
            let status, page = 1,
                pagesize = 10
            switch (tab) {
            case 0:
                status = 1
                break
            case 1:
                status = 2
                page = this.page1
                pagesize = this.pagesize1
                break
            case 2:
                status = 3
                page = this.page2
                pagesize = this.pagesize2
                break
            case 3:
                status = 4
                page = this.page4
                pagesize = this.pagesize
                break
            case 4:
                status = 0
                page = this.page3
                pagesize = this.pagesize3
                break
            }

            let data = {
                page: page,
                pagesize: pagesize,
                machine: this.optObj.machineid,
                starttime: moment(this.filterObj.index_time[0]) / 1000, // moment(this.filterObj.index_time[0]) / 1000   1581955200--18
                endtime: moment(this.filterObj.index_time[1]) / 1000 // moment(this.filterObj.index_time[1]) / 1000    1582041599--18
            }
            if (status != 0) { // 切换到今日安灯记录时，不需要传递status参数
                data.status = status
            }
            axios.request({
                url: '/tpm/andon/GetAndonInfo',
                data,
                method: 'post'
            }).then(res => {
                this.tableData1 = this.tableData2 = this.tableData3 = data = []

                if (res.data.ret === 1 && res.data.data) {
                    if (status === 1) { // 触发安灯-获取显示信息
                        // console.log(res.data.data)
                        if (res.data.data.length > 0) {
                            this.optObj.id = res.data.data[0].id
                            this.optObj.alarmReason = res.data.data[0].handle_cost_time
                            this.optObj.costTime = res.data.data[0].andon_cost_time === null ? moment(new Date().getTime() - res.data
                                .data[0].handle_time).format('YYYY-MM-DD HH-MM-SS') : res.data.data[0].andon_cost_time
                            this.optObj.startTime = this.changeDate(res.data.data[0].create_time * 1000)
                        }
                    } else if (status === 2) { // 获取待签到列表
                        this.total1 = res.data.total
                        res.data.data.forEach(item => {
                            data.push({
                                andonType1: item.expection1,
                                andonType2: item.expection2,
                                andonType3: item.expection3,
                                startTime: this.changeDate(item.create_time * 1000),
                                costTime: item.andon_cost_time === null ? Math.floor((new Date().getTime() - item.create_time *
                    1000) / (60 * 1000)) + this.$t(200028) : item.andon_cost_time,
                                id: item.id
                            })
                        })
                        this.tableData1 = data
                    } else if (status === 3) { // 获取待解除异常列表
                        this.total2 = res.data.total
                        res.data.data.forEach(item => {
                            data.push({
                                andonType1: item.expection1,
                                andonType2: item.expection2,
                                andonType3: item.expection3,
                                startTime: this.changeDate(item.create_time * 1000),
                                costTime: Math.floor(item.cost_time / 60) + this.$t(200028),
                                handleTime: Math.floor((new Date().getTime() - item.handle_time *
                    1000) / (60 * 1000)) + this.$t(200028),
                                id: item.id,
                                expection_type: item.expection_type
                            })
                        })
                        this.tableData2 = data
                    } else if (status === 4) { // 获取待解除异常列表
                        this.total4 = res.data.total
                        res.data.data.forEach(item => {
                            data.push({
                                andonType1: item.expection1,
                                andonType2: item.expection2,
                                andonType3: item.expection3,
                                startTime: this.changeDate(item.create_time * 1000),
                                costTime: Math.floor((new Date().getTime() - item.create_time *
                    1000) / (60 * 1000)) + this.$t(200028),
                                handleTime: Math.floor((new Date().getTime() - item.handle_time *
                    1000) / (60 * 1000)) + this.$t(200028),
                                id: item.id,
                                expection_type: item.expection_type
                            })
                        })
                        this.tableData4 = data
                    } else {
                        this.total3 = res.data.total
                        this.mockTableData3(res.data.data)
                    }
                }
                if (status === 0) {
                    let data = {
                        machine: this.optObj.machineid,
                        starttime: moment(this.filterObj.index_time[0]) / 1000, // moment(this.filterObj.index_time[0]) / 1000,    1581955200--18
                        endtime: moment(this.filterObj.index_time[1]) / 1000 // moment(this.filterObj.index_time[1]) / 1000       1582041599--18
                    }
                    axios.request({
                        url: '/tpm/andon/GetCostTimeByMachineid',
                        data,
                        method: 'post'
                    }).then(result => {
                        if (result.data.ret === 1) {
                            this.optObj.andonCount = parseInt(result.data.data.andon_count)
                            this.optObj.andonTime = result.data.data.cost_time === undefined || result.data.data.cost_time ===
                  null || result.data.data.cost_time === '' ? 0 : parseInt(result.data.data.cost_time)
                        }
                    })
                }
            })
        },
        mockTableData3 (tablelist) { // 转换数据，并赋值给列表数据容器tableData1
            let data = []
            tablelist.forEach(item => {
                if (item) {
                    let status = ''
                    switch (item.status) {
                    case 0:
                        status = this.$t(100200)
                        break
                    case 1:
                        status = this.$t(930014)
                        break
                    case 2:
                        status = this.$t(200033)
                        break
                    case 3:
                        status = this.$t(950378)
                        break
                    case 4:
                        status = this.$t(930015)
                        break
                    default:
                        status = this.$t(1028)
                        break
                    }
                    if (item.complete_time == 0) {
                        item.complete_time = new Date().getTime() / 1000
                    }
                    data.push({
                        id: item.id,
                        status: status,
                        expection_type: item.expection_type,
                        expection3: item.expection2 == '' ? item.expection1 : item.expection2,
                        create_time: this.changeDate(item.create_time * 1000),
                        creator: item.creator,
                        creator_name: item.creator_name,
                        handler: item.handler,
                        handler_name: item.handler_name,
                        handle_time: this.changeDate(item.handle_time * 1000),
                        complete_time: item.complete_time != 0 ? this.changeDate(item.complete_time * 1000) : '',
                        machine: item.machine,
                        station: item.station,
                        station_name: item.station_name,
                        process_code: item.process_code,
                        projectid: item.projectid,
                        is_shutdown: item.is_shutdown,
                        approve_time: item.approve_time,
                        andon_cost_time: item.status < 4 ? Math.floor((new Date().getTime() - item.create_time *
                    1000) / (60 * 1000)) + this.$t(200028) : Math.floor((item.complete_time * 1000 - item.create_time *
                    1000) / (60 * 1000)) + this.$t(200028),
                        handle_cost_time: item.handle_cost_time
                    })
                }
            })
            this.tableData3 = data
        },
        clickMachine (machineItem) {
            this.expectionLeveldata = []
            this.optModal = true
            this.tab = 0
            this.optObj.machineid = machineItem.id
            this.optObj.status = machineItem.state
            this.changeTab(this.tab)
        },
        search () {
            var params = {
                line: this.levelid
            }
            axios.request({
                url: '/tpm/Andon/GetAndonData',
                params,
                method: 'get'
            }).then(res => {
                if (res.data.ret === 1) {
                    this.total = res.data.total
                    this.machineStateList = res.data.data.state
                    // console.log(res.data.data)
                }
            })
        },
        defaultPageData () {
            this.initlevel() // 初始化产线层级
            this.initExpectionType()
        },
        initExpectionType () {
            axios.request({
                url: '/tpm/AndonBaseSetting/GetExpectionTypeTree',
                method: 'get'
            }).then(res => {
                this.expectionLevel = res.data.data
            })
        },
        handleExpectionlevelchange (value, selectedData) {
            this.shutdownstime = ''
            this.shutdownetime = ''
            let is_passprocess = ''
            let is_caloee = ''
            if (selectedData.length > 0) {
                is_passprocess = selectedData[0].is_passprocess
                is_caloee = selectedData[0].is_caloee
            }
            if (is_passprocess == 1 && is_caloee == 0) {
                this.shutdownTime = true
            } else {
                this.shutdownTime = false
            }
            this.expectionLeveldata = value
        },
        initlevel () { // 初始化产线层级
            axios.request({
                url: 'config/ProjectLevelSection/GetSectionTree',
                method: 'get'
            }).then(res => {
                const arr = []
                this.datalevel = res.data.data
                this.leveldata = arr
            })
        },
        changelevel (data) { // 切换产线层级，触发事件
            this.levelid = data[data.length - 1]
        },
        changeDate (dateA) {
            var dateee = new Date(dateA).toJSON()
            var date = new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(
                /\.[\d]{3}Z/,
                '').replace(/\//g, '-')
            return date
        },

        changePage1 (value) { // 换页事件
            this.page1 = value
            this.tableData1 = this.changeTab(this.tab)
        },
        handlePageSize1 (value) { // 切换分页页数，触发事件
            this.pagesize1 = value
            this.tableData1 = this.changeTab(this.tab)
        },

        changePage2 (value) { // 换页事件
            this.page2 = value
            this.tableData1 = this.changeTab(this.tab)
        },
        handlePageSize2 (value) { // 切换分页页数，触发事件
            this.pagesize2 = value
            this.tableData2 = this.changeTab(this.tab)
        },

        changePage3 (value) { // 换页事件
            this.page3 = value
            this.tableData3 = this.changeTab(this.tab)
        },
        handlePageSize3 (value) { // 切换分页页数，触发事件
            this.pagesize3 = value
            this.tableData3 = this.changeTab(this.tab)
        },
        changePage4 (value) { // 换页事件
            this.page4 = value
            this.tableData1 = this.changeTab(this.tab)
        },
        handlePageSize4 (value) { // 切换分页页数，触发事件
            this.pagesize4 = value
            this.tableData4 = this.changeTab(this.tab)
        },
        Double_track (num, id) {
            var data = {
                type: num,
                id: id,
                is_shutdown: this.isshutdown
            }
            axios.request({
                url: '/tpm/andon/HandleAndon',
                data,
                method: 'post'
            }).then(res => {
                if (res.data.ret === 1) {
                    this.$Message.success(this.$t(1064))
                    this.search()
                    this.changeTab(3)
                } else {
                    // this.$Message.error('安灯签到失败')
                    this.$Message.error(this.$t(res.data.msg))
                }
            })
        }

    }
}
</script>
<style lang="less" scoped>

  .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.running {
    background-color: #5CB85C;
  }

  .andon_info .list .machineStateList.alarm {
    background-color: orange;
  }

  .andon_info .list .machineStateList.close {
    background-color: #FF0000;
  }

  .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;
  }
  .andon_info .list .machineStateList .state {
    font-size: 30px;
    font-weight: bold;
    color: white;
    text-align: center;
    height: 50px;
    line-height: 50px;
    overflow: hidden;
  }

</style>
