<template>
    <div class="fullHeight">
        <div class="searchBox whiteBlock">
            <el-button type="warning" plain size="medium" @click="refresh">{{$t('message.alarmValueSet.refresh')}}</el-button>
        </div>
        <div class="table_wrap whiteBlock">
        <el-table class="tables" :data="List">
            <el-table-column prop="laboratoryName" align="center"
                             :label="$t('message.markRoomOverview.laboratoryName')"
            ></el-table-column>

            <!-- <el-table-column prop="devSn" :label="$t('message.alarmValueSet.deviceId')"
                             align="center"></el-table-column> -->
            <!-- <el-table-column prop="isClosed" :label="$t('message.alarmValueSet.isClosed')" align="center">
                <template slot-scope="scope">{{$t('message.deviceManage.isClosedArr')[scope.row.isClosed-1]}}</template>
            </el-table-column> -->
            <el-table-column prop="laboratoryAddr" :label="$t('message.markRoomOverview.laboratoryAddress')"
                             align="center"></el-table-column>
            <el-table-column prop="laboratoryDirector" :label="$t('message.markRoomOverview.laboratoryHead')"
                             align="center"></el-table-column>
            <el-table-column prop="businessName" :label="$t('message.markRoomOverview.companyName')"
                             align="center"></el-table-column>
             <el-table-column
                prop="isEnable"
                :label="$t('message.alarmValueSet.dialog_edit.isEnable')"
                align="center"
                >
                <template slot-scope="scope">{{
                    $t("message.alarmValueSet.dialog_edit.isEnableArr")[scope.row.isEnable]
                }}</template>
                </el-table-column>
            <!-- <el-table-column prop="realTime" width="200"
                             :label="$t('message.alarmValueSet.createTime')"
                             align="center"></el-table-column> -->
            <el-table-column :label="$t('message.alarmValueSet.operation')" align="center">
                <template slot-scope="scope">
                    <div class="tableBtns">
                        <div @click="yu(scope.row)" class="operationText"><img src="@/assets/images/yu.png" alt="">{{$t('message.alarmValueSet.yjz')}}
                        </div>
                        <!-- <div @click="bao(scope.row)" class="operationText"><img src="@/assets/images/bao.png" alt="">{{$t('message.alarmValueSet.bjz')}}
                        </div> -->
                        <div @click="edit(scope.row)" class="operationText">
                            <img src="@/assets/images/icon-edit.png" width="15px" height="15px"/>
                            <span>{{$t('message.alarmValueSet.edit')}}</span>
                        </div>
                    </div>
                </template>
            </el-table-column>
        </el-table>
        </div>
        <el-dialog
                :modal-append-to-body="false"
                :title="$t('message.alarmValueSet.Popup_title')[Popup.type]"
                :visible.sync="Popup.show"
                width="967px">
            <div class="dialog_content">
                <el-form v-show="Popup.type === 'edit'" size="medium"
                         ref="addEditForm" :model="addEditForm" :rules="addEditRules"
                         label-width="130px" class="dialogFormBox">
                         <div class="dialogFormInner">
                    <div class="left">
                        <!-- <el-form-item :label="$t('message.alarmValueSet.dialog_edit.deviceId')" prop="deviceId">
                            <el-input v-model="addEditForm.deviceId" disabled
                                    :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                        </el-form-item> -->
                    
                        <el-form-item :label="$t('message.markRoomOverview.laboratoryName')" prop="laboratoryName">
                            <el-input v-model="addEditForm.laboratoryName"
                                    :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                        </el-form-item>
                        <!-- '设备SN' -->
                        <el-form-item :label="$t('message.projectManage.devSN')" prop="devSn">
                            <!-- 不填则后台自动生成 -->
                            <el-input v-model="addEditForm.devSn"
                                    :placeholder="$t('message.projectManage.placeholderText')" :disabled="Popup.type=='edit'"></el-input>
                        </el-form-item>
                        <el-form-item :label="$t('message.markRoomOverview.companyName')">
                            <el-input v-model="addEditForm.businessName"
                                    :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                        </el-form-item>
                        <el-form-item :label="$t('message.markRoomOverview.laboratoryAddress')">
                            <el-input v-model="addEditForm.laboratoryAddr"
                                    :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                        </el-form-item>
                        <el-form-item :label="$t('message.markRoomOverview.laboratoryHead')">
                            <el-input v-model="addEditForm.laboratoryDirector"
                                    :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                        </el-form-item>
                        <el-form-item :label="$t('message.markRoomOverview.laboratoryPhone')">
                            <el-input v-model="addEditForm.lxPhone"
                                    :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                        </el-form-item>
                        <!-- 摄像头 -->
                        <el-form-item :label="$t('message.projectManage.camera')" prop="recordNumber">
                            <el-select
                            v-model="addEditForm.videoList"
                            multiple
                            collapse-tags
                            style="width: 100%"
                            :placeholder="$t('message.projectManage.pleaseChoose')"
                            >
                            <el-option
                                v-for="item in videoList"
                                :key="item.itemId"
                                :label="item.videoName"
                                :value="item.itemId"
                            >
                            </el-option>
                            </el-select>
                        </el-form-item>
                        <!-- 是否接收报警通知 -->
                        <el-form-item
                            :label="$t('message.projectManage.isAcceptAlarm')"
                            prop="isEnable"
                        >
                            <el-radio-group v-model="addEditForm.isEnable" :disabled="!canEditAlarm">
                                <el-radio :label="0">{{
                                    $t("message.alarmValueSet.dialog_edit.isEnableArr")[0]
                                }}</el-radio>
                                <el-radio :label="1">{{
                                    $t("message.alarmValueSet.dialog_edit.isEnableArr")[1]
                                }}</el-radio>
                            </el-radio-group>
                        </el-form-item>
                        <!-- '不接收通知原因' -->
                        <el-form-item :label="$t('message.projectManage.notAcceptreason')" prop="reason" v-if="addEditForm.isEnable==1" :rules="[
                            { required: true, message: $t('message.projectManage.require'), trigger: 'blur' },{ min: 1, max: 20, message:$t('message.projectManage.errorTipText') , trigger: 'blur' }
                            ]">
                            <el-input v-model="addEditForm.reason" :disabled="!canEditAlarm"
                                    :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                        </el-form-item>
                        <!-- <el-form-item :label="$t('message.alarmValueSet.dialog_edit.pusher')">
                            <el-select v-model="addEditForm.alarmPushWorkerId" multiple
                                    :placeholder="$t('message.alarmValueSet.placeholder_select')">
                                <el-option
                                        v-for="item in options"
                                        :key="item.id"
                                        :label="item.workerName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item> -->
                    </div>
                    <div class="right">
                        <!-- '1小时报警推送人' -->
                        <el-form-item :label="$t('message.projectManage.houersPushAlarm[0]')">
                            <!-- 从项目内选择人员 -->
                            <el-select
                                v-model="addEditForm.oneHourPushWorkerId"
                                multiple
                                collapse-tags
                                style="width: 100%"
                                :placeholder="$t('message.projectManage.fromProjectSelectProple')"
                                >
                                <el-option
                                    v-for="item in workerList"
                                    :key="item.workerId"
                                    :label="item.workerName"
                                    :value="item.workerId+''"
                                >
                                </el-option>
                            </el-select>
                            <div v-for="(item,index) in addEditForm.oneHourPushPhone" :key="index" class="personItem">
                                <el-input v-model="item.phone" :placeholder="$t('message.projectManage.pleasePlaceholderPhone')" class="phone"></el-input>
                                <el-input v-model="item.name" :placeholder="$t('message.projectManage.pleasePlaceholderName')" class="name"></el-input>
                                <i class="redText el-icon-remove" @click="operateAddPerson(1,false,index)"></i>
                            </div>
                            <el-button plain type="primary" size="mini" style="margin: 10px 0" @click="operateAddPerson(1,true)"><!-- 新增人员 -->{{$t('message.projectManage.addNewPeople')}}</el-button>
                        </el-form-item>
                         <el-form-item :label="$t('message.projectManage.houersPushAlarm[1]')">
                            <el-select
                                v-model="addEditForm.twoHourPushWorkerId"
                                multiple
                                collapse-tags
                                style="width: 100%"
                                :placeholder="$t('message.projectManage.fromProjectSelectProple')"
                                >
                                <el-option
                                    v-for="item in workerList"
                                    :key="item.workerId"
                                    :label="item.workerName"
                                    :value="item.workerId+''"
                                >
                                </el-option>
                            </el-select>
                            <div v-for="(item,index) in addEditForm.twoHourPushPhone" :key="index" class="personItem">
                                <!-- 请输入手机号 -->
                                <el-input v-model="item.phone" :placeholder="$t('message.projectManage.pleasePlaceholderPhone')" class="phone"></el-input>
                                <el-input v-model="item.name" :placeholder="$t('message.projectManage.pleasePlaceholderName')" class="name"></el-input>
                                <i class="redText el-icon-remove" @click="operateAddPerson(2,false,index)"></i>
                            </div>
                            <el-button plain type="primary" size="mini" style="margin: 10px 0" @click="operateAddPerson(2,true)"><!-- 新增人员 -->{{$t('message.projectManage.addNewPeople')}}</el-button>
                        </el-form-item>
                         <el-form-item :label="$t('message.projectManage.houersPushAlarm[2]')">
                            <el-select
                                v-model="addEditForm.threeHourPushWorkerId"
                                multiple
                                collapse-tags
                                style="width: 100%"
                                :placeholder="$t('message.projectManage.fromProjectSelectProple')"
                                >
                                <el-option
                                    v-for="item in workerList"
                                    :key="item.workerId"
                                    :label="item.workerName"
                                    :value="item.workerId+''"
                                >
                                </el-option>
                            </el-select>
                            <div v-for="(item,index) in addEditForm.threeHourPushPhone" :key="index" class="personItem">
                                <el-input v-model="item.phone" :placeholder="$t('message.projectManage.pleasePlaceholderPhone')" class="phone"></el-input>
                                <el-input v-model="item.name" :placeholder="$t('message.projectManage.pleasePlaceholderName')" class="name"></el-input>
                                <i class="redText el-icon-remove" @click="operateAddPerson(3,false,index)"></i>
                            </div>
                            <el-button plain type="primary" size="mini" style="margin: 10px 0" @click="operateAddPerson(3,true)"><!-- 新增人员 -->{{$t('message.projectManage.addNewPeople')}}</el-button>
                        </el-form-item>
                         <el-form-item :label="$t('message.projectManage.houersPushAlarm[3]')">
                            <el-select
                                v-model="addEditForm.sixHourPushWorkerId"
                                multiple
                                collapse-tags
                                style="width: 100%"
                                :placeholder="$t('message.projectManage.fromProjectSelectProple')"
                                >
                                <el-option
                                    v-for="item in workerList"
                                    :key="item.workerId"
                                    :label="item.workerName"
                                    :value="item.workerId+''"
                                >
                                </el-option>
                            </el-select>
                            <div v-for="(item,index) in addEditForm.sixHourPushPhone" :key="index" class="personItem">
                                <el-input v-model="item.phone" :placeholder="$t('message.projectManage.pleasePlaceholderPhone')" class="phone"></el-input>
                                <el-input v-model="item.name" :placeholder="$t('message.projectManage.pleasePlaceholderName')" class="name"></el-input>
                                <i class="redText el-icon-remove" @click="operateAddPerson(6,false,index)"></i>
                            </div>
                            <el-button plain type="primary" size="mini" style="margin: 10px 0" @click="operateAddPerson(6,true)"><!-- 新增人员 -->{{$t('message.projectManage.addNewPeople')}}</el-button>
                        </el-form-item>
                         <el-form-item :label="$t('message.projectManage.houersPushAlarm[4]')">
                            <el-select
                                v-model="addEditForm.twelveHourPushWorkerId"
                                multiple
                                collapse-tags
                                style="width: 100%"
                                :placeholder="$t('message.projectManage.fromProjectSelectProple')"
                                >
                                <el-option
                                    v-for="item in workerList"
                                    :key="item.workerId"
                                    :label="item.workerName"
                                    :value="item.workerId+''"
                                >
                                </el-option>
                            </el-select>
                            <div v-for="(item,index) in addEditForm.twelveHourPushPhone" :key="index" class="personItem">
                                <el-input v-model="item.phone" :placeholder="$t('message.projectManage.pleasePlaceholderPhone')" class="phone"></el-input>
                                <el-input v-model="item.name" :placeholder="$t('message.projectManage.pleasePlaceholderName')" class="name"></el-input>
                                <i class="redText el-icon-remove" @click="operateAddPerson(12,false,index)"></i>
                            </div>
                            <el-button plain type="primary" size="mini" style="margin: 10px 0" @click="operateAddPerson(12,true)"><!-- 新增人员 -->{{$t('message.projectManage.addNewPeople')}}</el-button>
                        </el-form-item>
                         <el-form-item :label="$t('message.projectManage.houersPushAlarm[5]')">
                            <el-select
                                v-model="addEditForm.twelveFourHourPushWorkerId"
                                multiple
                                collapse-tags
                                style="width: 100%"
                                :placeholder="$t('message.projectManage.fromProjectSelectProple')"
                                >
                                <el-option
                                    v-for="item in workerList"
                                    :key="item.workerId"
                                    :label="item.workerName"
                                    :value="item.workerId+''"
                                >
                                </el-option>
                            </el-select>
                            <div v-for="(item,index) in addEditForm.twelveFourHourPushPhone" :key="index" class="personItem">
                                <el-input v-model="item.phone" :placeholder="$t('message.projectManage.pleasePlaceholderPhone')" class="phone"></el-input>
                                <el-input v-model="item.name" :placeholder="$t('message.projectManage.pleasePlaceholderName')" class="name"></el-input>
                                <i class="redText el-icon-remove" @click="operateAddPerson(24,false,index)"></i>
                            </div>
                            <el-button plain type="primary" size="mini" style="margin: 10px 0" @click="operateAddPerson(24,true)"><!-- 新增人员 -->{{$t('message.projectManage.addNewPeople')}}</el-button>
                        </el-form-item>
                    </div>
                    </div>
                    <div class="dialog-footer">
                        <el-button
                                class="cancleBtn"
                                @click="Popup.show = false"
                                icon="el-icon-circle-close"
                                size="medium"
                        >{{$t('message.alarmValueSet.cancel')}}
                        </el-button>
                        <el-button
                                type="primary"
                                icon="el-icon-circle-check"
                                @click="submit"
                                size="medium"
                        >{{$t('message.alarmValueSet.save')}}
                        </el-button>
                    </div>
                </el-form>
                <el-form v-if="Popup.type === 'ybj'||Popup.type === 'bjz'" size="medium" ref="warningForm"
                         label-width="140px" class="dialogFormBox yj-dialogFormBox">
                    <el-form-item :label="$t('message.markRoomOverview.tempSet.start1')" prop="maxTemperature">
                        <el-input v-model="warningInfo.maxTemperature" disabled
                                  :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                                  <!-- <el-input value="没有限制" disabled
                                  :placeholder="$t('message.alarmValueSet.placeholder')"></el-input> -->
                    </el-form-item>
                    <el-form-item :label="$t('message.markRoomOverview.tempSet.end1')" prop="minTemperature">
                        <el-input v-model="warningInfo.minTemperature" disabled
                                  :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                    </el-form-item>
                    
                    <el-form-item :label="$t('message.markRoomOverview.tempSet.start3')" prop="maxHumidity">
                        <!-- <el-input v-model="warningInfo.maxHumidity" disabled
                                  :placeholder="$t('message.alarmValueSet.placeholder')"></el-input> -->

                                  <!-- 没有限制 -->
                                  <el-input :value="$t('message.alarmValueSet.noRestrictions')" disabled
                                  :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                    </el-form-item>
                    <el-form-item :label="$t('message.markRoomOverview.tempSet.end3')" prop="minHumidity">
                        <el-input v-model="warningInfo.minHumidity" disabled
                                  :placeholder="$t('message.alarmValueSet.placeholder')"></el-input>
                    </el-form-item>
                   
                    <div class="dialog-footer">
                        <el-button
                                class="cancleBtn"
                                @click="Popup.show = false"
                                icon="el-icon-circle-close"
                                size="medium"
                        >{{$t('message.alarmValueSet.cancel')}}
                        </el-button>
                        <el-button
                                type="primary"
                                icon="el-icon-circle-check"
                                @click="submit"
                                size="medium"
                        >{{$t('message.alarmValueSet.save')}}
                        </el-button>
                    </div>
                </el-form>
            </div>
        </el-dialog>
    </div>
</template>
<script>
    import {
        editstandardDevApi,
        getstandardDevListApi,
        editstandardWarningInfoApi,
        getstandardWarningInfoApi,
        // getLaborManagementInfoList
    } from "@/assets/js/api/markingRoom";

  import {
  getProjectChilderSystemUserListApi
} from "@/assets/js/api/configManage";
import {
  getVideoItemListApi

} from "@/assets/js/api/lifter";

    export default {
        mounted() {
            if(this.$store.state.userInfo.accountType==5||this.$store.state.userInfo.accountType==6){
                this.canEditAlarm=false
            }else{
                this.canEditAlarm=true
            }
            this.getVideoItemList()
            this.getList();
            this.getWorkerInfoList();
        },
        data() {
            return {
                canEditAlarm:false,
                props: {
                    multiple: true
                },
                addEditRules: {
                    laboratoryName: [
                        {required: true, message: this.$t('message.deviceManage.rules.devName'), trigger: "blur"},
                        { min: 1, max: 20, message:this.$t('message.projectManage.errorTipText')/*  '长度在 1 到 20 个字符' */, trigger: 'blur' }
                    ]
                },
                // options: [],
                warningInfo: {
                    "devSn": "",
                    "maxHumidity": "",
                    "maxTemperature": "",
                    "minHumidity": "",
                    "minTemperature": "",
                    "projectSn": "",
                },
                addEditForm: {
                    "businessName": "",
                    "devSn": "",
                    "laboratoryAddr": "",
                    "laboratoryDirector": "",
                    "laboratoryName": "",
                    "lxPhone": "",
                    "projectSn": "",
                    videoList:[],
                    oneHourPushPhone:[],
                    oneHourPushWorkerId:[],
                    "sixHourPushPhone": [],
                    "sixHourPushWorkerId": [],
                    "threeHourPushPhone": [],
                    "threeHourPushWorkerId": [],
                    "twelveFourHourPushPhone": [],
                    "twelveFourHourPushWorkerId": [],
                    "twelveHourPushPhone": [],
                    "twelveHourPushWorkerId": [],
                    "twoHourPushPhone": [],
                    "twoHourPushWorkerId": [],
                    isEnable:0,
                    reason:""
                },
                List: [],
                Popup: {
                    type: 'edit',
                    show: false
                },
                videoList:[],
                workerList:[]
            }
        },
        methods: {
            //操作人员的添加和删除
            operateAddPerson(hour,isAdd,index){
                let json = {
                                name:'',phone:''
                            }
                if(isAdd){
                    switch (hour) {
                        case 1:
                            this.addEditForm.oneHourPushPhone.push(json)
                            break;
                        case 2:
                            this.addEditForm.twoHourPushPhone.push(json)
                            break;
                        case 3:
                            this.addEditForm.threeHourPushPhone.push(json)
                            break;
                        case 6:
                            this.addEditForm.sixHourPushPhone.push(json)
                            break;
                        case 12:
                            this.addEditForm.twelveHourPushPhone.push(json)
                            break;
                        case 24:
                            this.addEditForm.twelveFourHourPushPhone.push(json)
                            break;
                    }
                }else{
                    switch (hour) {
                        case 1:
                            this.addEditForm.oneHourPushPhone.splice(index,1)
                            break;
                        case 2:
                            this.addEditForm.twoHourPushPhone.splice(index,1)
                            break;
                        case 3:
                            this.addEditForm.threeHourPushPhone.splice(index,1)
                            break;
                        case 6:
                            this.addEditForm.sixHourPushPhone.splice(index,1)
                            break;
                        case 12:
                            this.addEditForm.twelveHourPushPhone.splice(index,1)
                            break;
                        case 24:
                            this.addEditForm.twelveFourHourPushPhone.splice(index,1)
                            break;
                    }
                }
                
            },
            //获取人员账号列表
            getWorkerInfoList() {
                let data = {
                    projectSn: this.$store.state.projectSn,
                };
                getProjectChilderSystemUserListApi(data).then((res) => {
                    if (res.code == 200) {
                        this.workerList = res.result;
                    }
                });
            },
            //获取摄像机列表
            getVideoItemList() {
                let data = {
                    projectSn: this.$store.state.projectSn,
                };
                getVideoItemListApi(data).then((res) => {
                    if (res.code == 200) {
                        this.videoList = res.result.list;
                    }
                });
            },
            handle(type, show) {//打开弹窗前的统一处理
                this.Popup = {
                    type: type,
                    show: show
                }
            },
            setWarningType(warningType) {
                // this.warningInfo.warningType = warningType;
                editstandardWarningInfoApi(this.warningInfo).then(result => {
                    if (result.success) {
                        this.$message.success(result.message);
                        console.log('预警值/报警值设置成功', result);
                    }
                })
            },
            submit() {
                if (this.Popup.type === 'ybj') {
                    console.log('打印预警设置', this.warningInfo)
                    this.setWarningType(2);
                    this.Popup.show = false;
                } else if (this.Popup.type === 'bjz') {
                    this.setWarningType(1);
                    this.Popup.show = false;
                } else if (this.Popup.type === 'edit') {
                    this.$refs.addEditForm.validate((valid) => {
                        if (valid) {
                            if(this.addEditForm.isEnable==0){
                                this.addEditForm.reason=''
                            }else{
                                // if(this.addEditForm.reason==''){
                                //     this.$message.error('请输入不接收通知原因');
                                //     return
                                // }
                            }
                            let params = this.addEditForm;
                            // 
                            // params.alarmPushWorkerId = this.addEditForm.alarmPushWorkerId.join(',');
                            params.oneHourPushWorkerId = this.addEditForm.oneHourPushWorkerId?this.addEditForm.oneHourPushWorkerId.join(','):'';
                            params.sixHourPushWorkerId = this.addEditForm.sixHourPushWorkerId?this.addEditForm.sixHourPushWorkerId.join(','):'';
                            params.threeHourPushWorkerId = this.addEditForm.threeHourPushWorkerId?this.addEditForm.threeHourPushWorkerId.join(','):'';
                            params.twelveFourHourPushWorkerId = this.addEditForm.twelveFourHourPushWorkerId?this.addEditForm.twelveFourHourPushWorkerId.join(','):'';
                            params.twelveHourPushWorkerId = this.addEditForm.twelveHourPushWorkerId?this.addEditForm.twelveHourPushWorkerId.join(','):"";
                            params.twoHourPushWorkerId = this.addEditForm.twoHourPushWorkerId?this.addEditForm.twoHourPushWorkerId.join(','):'';

                            params.oneHourPushPhone = JSON.stringify(this.addEditForm.oneHourPushPhone);
                            params.sixHourPushPhone = JSON.stringify(this.addEditForm.sixHourPushPhone);
                            params.threeHourPushPhone = JSON.stringify(this.addEditForm.threeHourPushPhone);
                            params.twelveFourHourPushPhone = JSON.stringify(this.addEditForm.twelveFourHourPushPhone);
                            params.twelveHourPushPhone = JSON.stringify(this.addEditForm.twelveHourPushPhone);
                            params.twoHourPushPhone = JSON.stringify(this.addEditForm.twoHourPushPhone);

                            params.projectSn = this.$store.state.projectSn;
                            delete params.realTime
                            //循环选中的摄像头
                            let videoArr = [];
                            for (let i = 0; i < this.addEditForm.videoList.length; i++) {
                                let obj = { videoItemId: this.addEditForm.videoList[i] };
                                videoArr.push(obj);
                            }
                            params.videoList = videoArr;
                            console.log('编辑信息', this.addEditForm)
                            
                            editstandardDevApi(params).then(result => {
                                if (result.success) {
                                    // console.log('信息编辑成功', result);
                                    this.$message.success(result.message);
                                    this.getList();
                                    this.Popup.show = false;
                                }
                            })
                        } else {
                            return false;
                        }
                    });
                }
            },
            yu(obj) {
                console.log('预警', obj);
                this.handle('ybj', true);
                // obj.warningType = 2;
                this.getWarningInfo(obj);
                // this.warningInfo.id = obj.id;
                this.warningInfo.devSn = obj.devSn;
                this.warningInfo.projectSn = obj.projectSn;

            },
            bao(obj) {
                console.log('报警', obj);
                // this.warningInfo.id = obj.id;
                /*this.warningInfo.deviceId = obj.deviceId;
                this.warningInfo.projectSn = obj.projectSn;*/
                this.handle('bjz', true);
                obj.warningType = 1;
                this.getWarningInfo(obj);
            },
            edit(obj) {
                console.log('编辑', obj);
                this.addEditForm = JSON.parse(JSON.stringify(obj));
                if (typeof obj.alarmPushWorkerId === 'string'&& obj.alarmPushWorkerId != '') {
                    this.addEditForm.alarmPushWorkerId = obj.alarmPushWorkerId.split(',');
                }
                if (typeof obj.oneHourPushWorkerId === 'string'&& obj.oneHourPushWorkerId != '') {
                    this.addEditForm.oneHourPushWorkerId = obj.oneHourPushWorkerId.split(',');
                }
                if (typeof obj.twoHourPushWorkerId === 'string'&& obj.twoHourPushWorkerId != '') {
                    this.addEditForm.twoHourPushWorkerId = obj.twoHourPushWorkerId.split(',');
                }
                if (typeof obj.threeHourPushWorkerId === 'string'&& obj.threeHourPushWorkerId != '') {
                    this.addEditForm.threeHourPushWorkerId = obj.threeHourPushWorkerId.split(',');
                }
                if (typeof obj.sixHourPushWorkerId === 'string'&& obj.sixHourPushWorkerId != '') {
                    this.addEditForm.sixHourPushWorkerId = obj.sixHourPushWorkerId.split(',');
                }
                if (typeof obj.twelveHourPushWorkerId === 'string'&& obj.twelveHourPushWorkerId != '') {
                    this.addEditForm.twelveHourPushWorkerId = obj.twelveHourPushWorkerId.split(',');
                }
                if (typeof obj.twelveFourHourPushWorkerId === 'string'&& obj.twelveFourHourPushWorkerId != '') {
                    this.addEditForm.twelveFourHourPushWorkerId = obj.twelveFourHourPushWorkerId.split(',');
                }
                if (obj.oneHourPushPhone == '') {
                    this.addEditForm.oneHourPushPhone = [];
                }else{
                    this.addEditForm.oneHourPushPhone=JSON.parse(this.addEditForm.oneHourPushPhone)
                }
                if (obj.twoHourPushPhone == '') {
                    this.addEditForm.twoHourPushPhone = [];
                }else{
                    this.addEditForm.twoHourPushPhone=JSON.parse(this.addEditForm.twoHourPushPhone)
                }
                if (obj.threeHourPushPhone == '') {
                    this.addEditForm.threeHourPushPhone = [];
                }else{
                    this.addEditForm.threeHourPushPhone=JSON.parse(this.addEditForm.threeHourPushPhone)
                }
                if (obj.sixHourPushPhone == '') {
                    this.addEditForm.sixHourPushPhone = [];
                }else{
                    this.addEditForm.sixHourPushPhone=JSON.parse(this.addEditForm.sixHourPushPhone)
                }
                if (obj.twelveHourPushPhone == '') {
                    this.addEditForm.twelveHourPushPhone = [];
                }else{
                    this.addEditForm.twelveHourPushPhone=JSON.parse(this.addEditForm.twelveHourPushPhone)
                }
                if (obj.twelveFourHourPushPhone == '') {
                    this.addEditForm.twelveFourHourPushPhone = [];
                }else{
                    this.addEditForm.twelveFourHourPushPhone=JSON.parse(this.addEditForm.twelveFourHourPushPhone)
                }
                if(obj.videoList){
                    let videoItemIdArr = [];
                    for (let i = 0; i < obj.videoList.length; i++) {
                        videoItemIdArr.push(obj.videoList[i].itemId);
                    }
                    this.addEditForm.videoList = videoItemIdArr;
                }
                this.handle('edit', true);
            },
            getList() {
                getstandardDevListApi({projectSn: this.$store.state.projectSn}).then(result => {
                    if (result.success) {
                        this.List = result.result;
                        console.log('列表', result);
                    }
                })
            },
            refresh() {
                this.getList();
            },
            getWarningInfo(obj) {
                let {devSn, projectSn} = obj;
                getstandardWarningInfoApi({
                    devSn: devSn,
                    projectSn: projectSn
                }).then(result => {
                    if (result.result) {
                        this.warningInfo = result.result;
                        console.log('预警信息', result);
                    }else{
                        this.warningInfo.maxHumidity=""
                        this.warningInfo.maxTemperature=""
                        this.warningInfo.minHumidity=""
                        this.warningInfo.minTemperature=""
                    }
                })
            },
            // getLaborManagementList() {
            //     getLaborManagementInfoList({projectSn: this.$store.state.projectSn, workerName: ''}).then(result => {
            //         if (result.success) {
            //             console.log('施工人员', result);
            //             this.options = result.result;
            //         }
            //     })
            // }
        }
    }
</script>
<style lang="less">
    .tableBtns {
        display: flex;
        justify-content: center;
    }

    .yj-dialogFormBox {
        width: 462px;
    }
    
    .dialogFormBox{
        overflow: hidden;
        width: 100%;
        .dialogFormInner{
            overflow: hidden;
        width: 100%;
        }
        .el-input{
            width: 260px!important;
        }
        .left{
            float: left;
            width: 50%;
        }
        .right{
            float: left;
            width: 50%;
        }
    }
    .personItem{
        margin-top: 10px;
        .phone{
            width: 150px!important;
            margin-right: 10px;
        }
        .name{
            width: 100px!important;
        }
    }
    .el-icon-remove{
        font-size: 22px;
        margin-left: 10px;
        margin-top: 7px;
        vertical-align: top;
        cursor: pointer;
    }
</style>