<template>
    <div class="content">
        <div class="tabs">
            <ul>
                <li v-for="(tab,i) in tabs" @click="goTab(tab.url)" :class="{'active':tabIndex == i}">
                    {{tab.name}}
                </li>
            </ul>
        </div>
        <div class="panel">
            <div class="panel-body">
                <div class="panel_row">
                    <div class="panel_title">
                        <i></i>
                        基本信息
                    </div>
                </div>
                <div class=" panel_control">
                    <div class="pline">
                        <em>策略名称:</em>
                        <el-input v-model="panel.name" placeholder=""></el-input>
                    </div>
                    <div class="pline">
                        <em>持续时间:</em>
                        <el-input v-model="panel.duration" type="number" placeholder="单位 秒"></el-input>
                    </div>
                    <div class="pline">
                        <em class="label_checked" @click="turnRecord">
                            <img src="../assets/img/main/true.png" height="15" width="15" v-if="recordState"/>
                            <img src="../assets/img/main/false.png" height="15" width="15" v-else/>
                            信号录制
                        </em>
                    </div>
                </div>
                <div class="panel_row">
                    <div class="panel_title">
                        <i></i>
                        扫描选项
                    </div>
                </div>
                <div class="panel_row control_row">
                    <div class="pline pull-right">
                        <el-button size="medium" type="primary" @click="addList">添加</el-button>
                        <el-button size="medium" type="primary" @click="editList">修改</el-button>
                        <el-button size="medium" type="primary" @click="delList">删除</el-button>
                    </div>
                </div>
            </div>
        </div>
        <el-table
                :data="tableData"
                is-horizontal-resize
                :default-sort="{prop: 'date', order: 'descending'}"
                v-loading="loading"
                element-loading-background="rgba(0, 0, 0, 0.8)"
                class=""
                @selection-change="handleSelectionChange"
                stripe
                ref="multipleTable"
                @row-click="handle"
        >
            <el-table-column
                    type="selection"
                    width="55">
            </el-table-column>
            <el-table-column
                    type="index"
                    label="序号"
                    width="60"
                    sortable
            >
            </el-table-column>
            <el-table-column
                    prop="agreement"
                    label="无线协议"
                    :formatter="filterWirelessTypeName"
            >
            </el-table-column>
            <el-table-column
                    prop="begin"
                    label="起始频率"
                    sortable
            >
            </el-table-column>
            <el-table-column
                    prop="end"
                    label="截止频率"
                    sortable
            >
            </el-table-column>
            <el-table-column
                    prop="distance"
                    label="扫描距离"
                    :formatter="filterDistanceName"
                    sortable
            >
            </el-table-column>
        </el-table>
        <br>
        <div class="btm_control">
            <el-button size="medium" type="primary" @click="cancleTactics">取消</el-button>
            <el-button size="medium" type="primary" @click="confirmTactics">确定</el-button>
        </div>

        <dialog_referrer_list
                :show="dialog_state"
                :title="dialog_title"
                :large="true"
                @dialog_cancel="dialog_cancel"
                @dialog_ok="dialog_ok"
        >
            <div class="dialogContent">
                <el-row :gutter="24">
                    <el-col :span="12">
                        <label>
                            无线协议
                        </label>
                        <!--单条添加与首页逻辑不同-->
                        <el-select v-model="scan.agreement" placeholder="请选择">
                            <el-option
                                    v-for="item in agreement_options"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-col>
                    <el-col :span="12">
                        <label>
                            扫描距离
                        </label>
                        <el-select v-model="scan.distance" placeholder="请选择">
                            <el-option
                                    v-for="item in distance_options"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-col>
                </el-row>
                <el-row :gutter="24" v-if="scopeState">
                    <el-col :span="12">
                        <label>
                            起始频率
                        </label>
                        <el-input v-model="scan.begin" type="number" placeholder="单位100K"></el-input>
                    </el-col>
                    <el-col :span="12">
                        <label>
                            截止频率
                        </label>
                        <el-input v-model="scan.end" placeholder="单位100K"></el-input>
                    </el-col>
                </el-row>
            </div>
        </dialog_referrer_list>
    </div>
</template>

<script>
    import Global from '../Global.js'
    import dialog_referrer_list from '../components/dialog_referrer_list'
    import {
        RegionList,
        DetectorList,
        ScanStrategyAdd,
        ScanStrategyEdit,
    } from '../api/getApiRes.js'

    let qs = require('qs');
    export default {
        data() {
            return {
                tid: 0,
                dialog_state: false,
                checked: false,
                dialog_title: '',
                dialog_type: '',//类型，1是添加，2是修改
                dialog: {
                    mac: '',
                    comId: 1,
                    regionlevelOneId: 0,
                    regionId: 0,
                    tagname: '',
                    longitude: 0,
                    latitude: 0,
                    HardwareVersion: '',
                    FirmwareVersion: '',
                    FirmwareScanM4Version: '',
                    FirmwareScanM0Version: '',
                    purchasesrc: '',
                    location: '',
                    coords_memo: '',
                    memo: '',
                    plateImgSrc: '',
                    regionlevelOneIdOptions: [],
                    regionIdRoomOptions: [],
                    points: [],
                    CoordsId: 0,
                    status: 0,
                },
                scan: {
                    tactics: 0,
                    agreement: "",
                    begin: 0,
                    end: 0,
                    distance: 1,
                    cycle: 0,
                    duration: 0,
                },
                scopeState: false,
                agreement_options: WirelessType(),
                distance_options: WirelessRange(),
                recordState: true,
                tabIndex: 0,
                tabs: [
                    {name: '扫描策略新增', url: 'addTactics'},
                ],
                // panel 配置项目
                panel: {
                    name: '',
                    usercode: '',
                    username: '',
                    compname: '',
                    keyword: '',
                    USERCODE: '',
                    taskstatus: 99,
                    isRecording: true,
                    regionid: 0,
                    regionid2: '',
                    regionidOptions: [],
                    regionidOptions2: [],
                    options: [
                        {value: 99, label: '全部'},
                        {value: 1, label: '进行中'},
                        {value: 2, label: '已完成'},
                    ],
                    time1: globalBt3(2),
                    duration: 0,
                },
                pageination: {
                    pageItem: 100,
                    pageoptions: pageOptions(),
                    total: 500,
                    pageIndex: 1,
                },
                draw: 1,
                start: 0,
                recordsTotal: 0,
                tableData: [],
                allTableData: [],
                limit: '10',
                multipleSort: false,
                loading: true,
                fileList: [],
                multipleSelection: [],
                detectedmac: '',
            }
        },
        mounted() {
            if (this.$route.query.tid != 0) {
                // 有tid是修改
                this.readTacticsInfo();
            }
            this.loading = false;
        },
        watch: {
            '$route': function (val) {
                if (val.path == '/addtactics') {
                    console.log(123);
                    this.readTacticsInfo();
                }
            },
            panel: {
                handler(newName, oldName) {
                    if (parseInt(newName.duration) < 0) {
                        this.$notify.error({
                            title: '错误',
                            message: '持续时间不能小于0'
                        });
                        return false
                    }
                    if (parseInt(newName.duration) > 86400) {
                        this.$notify.error({
                            title: '错误',
                            message: '持续时间不能超过86400秒（24小时）'
                        });
                        return false
                    }
                },
                deep: true,
                immediate: true
            },
            scan: {
                handler(newName, oldName) {
                    if (parseInt(newName.begin) > 6000) {
                        this.$notify.error({
                            title: '错误',
                            message: '起始频率不能大于6000'
                        });
                        return false
                    }
                    if (parseInt(newName.begin) < 0) {
                        this.$notify.error({
                            title: '错误',
                            message: '起始频率不能小于0'
                        });
                        return false
                    }
                    if (parseInt(newName.end) > 6000) {
                        this.$notify.error({
                            title: '错误',
                            message: '截止频率不能大于6000'
                        });
                        return false
                    }
                    if (parseInt(newName.end) < 0) {
                        this.$notify.error({
                            title: '错误',
                            message: '截止频率不能小于0'
                        });
                        return false
                    }
                    if (parseInt(newName.end) < parseInt(newName.begin)) {
                        this.$notify.error({
                            title: '错误',
                            message: '截止频率不能小于起始频率'
                        });
                        return false
                    }
                    if (parseInt(newName.duration) < 0) {
                        this.$notify.error({
                            title: '错误',
                            message: '持续时间不能小于0'
                        });
                        return false
                    }
                    if (parseInt(newName.duration) > 86400) {
                        this.$notify.error({
                            title: '错误',
                            message: '持续时间不能超过86400秒（24小时）'
                        });
                        return false
                    }

                    // 0-6G现实范围
                    if (newName.agreement == "13") {
                        this.scopeState = true
                    } else {
                        this.scopeState = false
                    }

                },
                deep: true,
                immediate: true
            }
        },
        methods: {
            // 读取信息
            readTacticsInfo() {
                let row = this.$route.query;
                let rowVal = JSON.parse(row.Value);
                this.tid = row.tid;
                this.panel.name = row.name;
                this.panel.duration = rowVal.Duration;
                this.recordState = rowVal.IsRecording;
                this.tableData = [];
                let signalList = {};
                let signAttr = '';
                for (var i = 0; i < rowVal.SignalList.length; i++) {
                    signAttr = rowVal.SignalList[i];
                    signalList = {
                        agreement: signAttr.Type,
                        distance: signAttr.Range,
                        begin: 0,
                        end: 0,
                    };
                    this.tableData.push(signalList)
                }
                this.loading = false;
            },
            turnRecord() {
                this.recordState = !this.recordState
            },
            handle(row, column, event) {
                this.$refs.multipleTable.toggleRowSelection(row);
            },
            // 取消
            cancleTactics() {
                this.$confirm('是否取消当前扫描策略？', '取消操作', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$router.push({path: '/tactics'});
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });
            },
            confirmTactics() {
                let tid = this.$route.query.tid;
                if (tid == 0) {
                    // 新增
                    this.addTactitcs();
                } else {
                    // 编辑
                    this.editTactitcs();
                }
            },
            // 新增
            addTactitcs() {
                let that = this;
                // 校验数据
                if (!this.panel.name) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，策略名称不能为空',
                        type: 'error'
                    });
                    return false
                }
                if (this.panel.length > 8) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，策略名称不能超过8个字',
                        type: 'error'
                    });
                    return false
                }

                if (this.tableData.length == 0) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，扫描选项不能为空',
                        type: 'error'
                    });
                    return false
                }

                if (parseInt(this.panel.duration) < 0) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，持续时间不能小于0',
                        type: 'error'
                    });
                    return false
                }
                if (parseInt(this.panel.duration) > 86400) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，持续时间不能超过86400秒（24小时）',
                        type: 'error'
                    });
                    return false
                }

                let freq06G = [];
                let signalList = [];

                // 有0-6g
                let begin = 0;
                let end = 0;
                that.tableData.map(function (item) {
                    if (item.agreement == 13) {
                        freq06G = [
                            {
                                begin: parseInt(item.begin),
                                end: parseInt(item.end)
                            }
                        ];
                    }
                });

                if (that.tableData.length == 0) {
                    that.$message({
                        showClose: true,
                        message: '无线协议不能为空！',
                        type: 'error'
                    });
                    return false
                }

                for (var i = 0; i < that.tableData.length; i++) {
                    signalList[i] = {
                        "range": that.tableData[i].distance,
                        "type": that.tableData[i].agreement
                    }
                }

                // 拼装value
                let tacticsValue = {
                    duration: parseInt(this.panel.duration),
                    freq06G: freq06G,
                    isRecording: this.recordState,
                    signalList: signalList,
                };
                tacticsValue = JSON.stringify(tacticsValue);
                let param = {
                    token: localStorage.token,
                    name: this.panel.name,
                    memo: '',
                    value: tacticsValue
                };
                let postdata = qs.stringify(param);
                ScanStrategyAdd(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        that.$message({
                            showClose: true,
                            message: '扫描策略已新增！',
                            type: 'success'
                        });

                        this.$router.push({path: '/tactics'});

                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            editTactitcs() {
                let that = this;
                // 校验数据
                if (!this.panel.name) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，策略名称不能为空',
                        type: 'error'
                    });
                    return false
                }
                if (this.panel.length > 8) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，策略名称不能超过8个字',
                        type: 'error'
                    });
                    return false
                }

                if (this.tableData.length == 0) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，扫描选项不能为空',
                        type: 'error'
                    });
                    return false
                }

                let freq06G = [];
                let signalList = [];

                // 有0-6g
                let begin = 0;
                let end = 0;
                that.tableData.map(function (item) {
                    if (item.agreement == 13) {
                        freq06G = [
                            {
                                begin: parseInt(item.begin),
                                end: parseInt(item.end)
                            }
                        ];
                    }
                });

                if (that.tableData.length == 0) {
                    that.$message({
                        showClose: true,
                        message: '无线协议不能为空！',
                        type: 'error'
                    });
                    return false
                }

                for (var i = 0; i < that.tableData.length; i++) {
                    signalList[i] = {
                        "range": that.tableData[i].distance,
                        "type": that.tableData[i].agreement
                    }
                }

                // 拼装value
                let tacticsValue = {
                    duration: parseInt(this.panel.duration),
                    freq06G: freq06G,
                    isRecording: this.recordState,
                    signalList: signalList,
                };
                tacticsValue = JSON.stringify(tacticsValue);
                let param = {
                    token: localStorage.token,
                    id: this.tid,
                    name: this.panel.name,
                    memo: '',
                    value: tacticsValue
                };
                let postdata = qs.stringify(param);
                ScanStrategyEdit(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        that.$message({
                            showClose: true,
                            message: '扫描策略已修改！',
                            type: 'success'
                        });

                        this.$router.push({path: '/tactics'});

                    } else {
                        that.$message.error(json.Memo);
                    }
                })
            },
            // 页面数据查询
            getTableQuery() {
                let that = this;
                // this.getGetChildRegionSelect(0, 1);
                this.getGeFullRegionSelect();
                that.loading = true;
                // 查询检测设备。上级区域id，区域id必传。regionid传0，查询supregionid对应所有子区域的检测设备。 如果supregionid，regionid都传0，默认查询企业ID下所有检测设备
                let param = {
                    token: localStorage.token,
                    mac: this.panel.mac,//
                    regionId: that.panel.regionId,//
                    name: that.panel.tagname,//标签名
                    comid: 1,//
                    start: 1,//
                    tableMax: 9999,//
                };
                let postdata = qs.stringify(param);
                DetectorList(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        that.loading = false;
                        if (json.Rs) {
                            that.allTableData = json.Rs;
                            that.recordsTotal = json.Rs.length;
                        } else {
                            that.allTableData = [];
                            that.recordsTotal = 0;
                        }
                        // 设置分页数据
                        that.setPaginations();
                    } else {
                        that.$message.error(json.Memo + '，错误代码：' + json.Code);
                    }
                })
            },
            // 获取下级列表
            getGeFullRegionSelect() {
                let that = this;
                let param = {
                    token: localStorage.token,
                };
                let postdata = qs.stringify(param);
                RegionList(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        if (!json.Rs) {
                            that.$message.error('区域列表为空，请先添加有效区域');
                            return false
                        }
                        that.panel.regionidOptions = json.Rs;
                        that.panel.regionidOptions.unshift({Id: 0, Name: "全部", DisplayName: "全部"});
                    } else {
                        that.$message.error(json.Memo + '，错误代码：' + json.Code);
                    }
                })
            },
            // dialog获取下级列表
            dialoggetGeFullRegionSelect() {
                let that = this;
                let param = {
                    token: localStorage.token,
                };
                let postdata = qs.stringify(param);
                RegionList(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        that.dialog.regionlevelOneIdOptions = json.Rs;
                        that.dialog.regionId = json.Rs[0].Id;
                    } else {
                        that.$message.error(json.Memo + '，错误代码：' + json.Code);
                    }
                })
            },
            // dialog获取区域下级菜单
            dialogGetGetChildRegionSelect(regionId, level) {
                let that = this;
                let param = {
                    token: localStorage.token,
                    regionId: regionId,
                };
                let postdata = qs.stringify(param);
                RegionList(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        that.dialog.regionlevelOneIdOptions = json.Rs;
                        that.dialog.regionlevelOneId = regionId;
                        // if (level == 1) {
                        //     console.log(json.Rs);
                        //     that.dialog.regionlevelOneIdOptions = json.Rs;
                        //     that.dialog.regionlevelOneId = regionId;
                        // } else {
                        //     if (json.Rs) {
                        //         console.log(123);
                        //         that.dialog.regionIdRoomOptions = json.Rs;
                        //         that.dialog.regionId = regionId;
                        //     } else {
                        //         that.dialog.regionIdRoomOptions = [];
                        //         that.dialog.regionId = '';
                        //     }
                        // }
                    } else {
                        that.$message.error(json.Memo + '，错误代码：' + json.Code);
                    }
                })
            },
            // 跳转tab页面
            goTab(url) {
                this.$router.push({path: url});
            },
            // 查询按钮
            query() {
                this.getTableQuery();
                this.$message.success('查询完毕');
            },

            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            // 设置分页数据
            setPaginations() {
                // 分页属性
                let that = this;
                that.pageination.total = that.recordsTotal;
                // 默认分页
                that.tableData = that.allTableData.filter((item, index) => {
                    return index < that.pageination.pageItem;
                });
            },
            // 每页显示数量
            handleSizeChange() {
                let that = this;
                that.tableData = that.allTableData.filter((item, index) => {
                    return index < that.pageination.pageItem;
                });
                that.draw = that.pageination.pageItem;
                // that.getTableQuery();
            },
            // 翻页
            pageChange(pageIndex) {
                let that = this;
                // 获取当前页
                let index = that.pageination.pageItem * (pageIndex - 1);
                // 数据总数
                let nums = that.pageination.pageItem * pageIndex;
                // 容器
                let tables = [];
                for (var i = index; i < nums; i++) {
                    if (that.allTableData[i]) {
                        tables.push(that.allTableData[i])
                    }
                    this.tableData = tables;
                }
                that.start = index * that.draw;
                // that.getTableQuery();
            },
            // 自动排序
            sortChange(params) {
                console.log(params)
            },
            // 过滤时间
            filterFmtDate(value, row, column) {
                return globalfmtDate(column, 11);
            },
            addList() {
                this.dialog_state = true;
                this.dialog_title = '添加扫描选项';
                this.dialog_type = 1;

                // clear dialog
                this.scan.tactics = '';
                this.scan.agreement = "";
                this.scan.begin = 0;
                this.scan.end = 0;
                this.scan.distance = 1;
                this.scan.cycle = 0;

                // 加载默认的平面图
                // this.dialogGetGetChildRegionSelect(0, 1);
                this.dialoggetGeFullRegionSelect()
            },
            delList() {
                let that = this;
                // checkNum
                if (!this.multipleSelection.length) {
                    that.$message({
                        showClose: true,
                        message: '错了哦，需要先选中至少一条记录',
                        type: 'error'
                    });
                    return false
                }
                let current = this.multipleSelection[0];
                this.$confirm('是否删除选中的无线协议？', '删除操作', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    // 从列表删掉
                    var index = that.tableData.indexOf(current);
                    that.tableData.splice(index, 1);
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });

            },
            editList() {
                let that = this;
                // checkNum
                if (!this.multipleSelection.length) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，需要先选中一条记录',
                        type: 'error'
                    });
                    return false
                }
                if (this.multipleSelection.length > 1) {
                    this.$message({
                        showClose: true,
                        message: '错了哦，只能选中一条记录',
                        type: 'error'
                    });
                    return false
                }
                this.dialog_state = true;
                this.dialog_title = '修改扫描选项';
                this.dialog_type = 2;

                // 读取本条记录
                let row = this.multipleSelection[0];
                this.scan.agreement = row.agreement;
                this.scan.distance = row.distance;
                this.scan.begin = row.begin;
                this.scan.end = row.end;
            },
            // 自动补全MAC
            autoCompleteMac() {
                let text = this.dialog.mac;
                if (text.length == 2 || text.length == 5 || text.length == 8 || text.length == 11 || text.length == 14) {
                    this.dialog.mac = this.dialog.mac.toUpperCase() + ":"
                }
                if (text.length > 14) {
                    this.dialog.mac = this.dialog.mac.toUpperCase()
                }
            },
            dialog_cancel() {
                let that = this;
                that.dialog_state = false;
            },
            dialog_ok() {
                if (this.dialog_type == 1) {
                    this.confirmAddEquip();
                } else {
                    this.confirmEditEquip();
                }
            },
            // 提交增加新设备
            confirmAddEquip() {
                let that = this;
                // checkVal
                if (!that.scan.agreement) {
                    this.$message.error('错了哦，无线协议不能为空');
                    return false
                }

                if (parseInt(that.scan.begin) < 0) {
                    this.$message.error('错了哦，起始频率不能小于0');
                    return false
                }
                if (parseInt(that.scan.end) > 6000) {
                    this.$message.error('错了哦，截止频率不能大于6000');
                    return false
                }
                if (parseInt(that.scan.end) < 0) {
                    this.$message.error('错了哦，截止频率不能小于0');
                    return false
                }
                if (parseInt(that.scan.end) < parseInt(that.scan.begin)) {
                    this.$message.error('错了哦，截止频率不能小于起始频率');
                    return false
                }

                // 去掉已有的
                let hasSelected = [];
                that.allTableData.map(function (item) {
                    hasSelected.push(item.agreement)
                });
                if (!hasSelected.includes(that.scan.agreement)) {
                    let row = {
                        agreement: that.scan.agreement,
                        distance: that.scan.distance,
                        begin: that.scan.begin,
                        end: that.scan.end,
                    };
                    that.allTableData.push(row)
                } else {
                    this.$message.error('当前协议已添加，请不要重复添加');
                    return false
                }
                that.recordsTotal = that.recordsTotal + 1;
                // 设置分页数据
                that.setPaginations();
                that.dialog_state = false;
            },
            // 提交修改设备信息
            confirmEditEquip() {
                let that = this;
                if (!that.scan.agreement) {
                    this.$message.error('错了哦，无线协议不能为空');
                    return false
                }
                if (parseInt(that.scan.begin) < 0) {
                    this.$message.error('错了哦，起始频率不能小于0');
                    return false
                }
                if (parseInt(that.scan.end) > 6000) {
                    this.$message.error('错了哦，截止频率不能大于6000');
                    return false
                }
                if (parseInt(that.scan.end) < 0) {
                    this.$message.error('错了哦，截止频率不能小于0');
                    return false
                }
                if (parseInt(that.scan.end) < parseInt(that.scan.begin)) {
                    this.$message.error('错了哦，截止频率不能小于起始频率');
                    return false
                }

                // 去掉已有的
                let hasSelected = [];
                that.tableData.map(function (item) {
                    hasSelected.push(item.agreement)
                });
                if (!hasSelected.includes(that.scan.agreement)) {
                    let row = {
                        agreement: that.scan.agreement,
                        distance: that.scan.distance,
                        begin: that.scan.begin,
                        end: that.scan.end,
                    };
                    that.tableData.push(row);

                    // 当前编辑的那条再从列表删掉
                    let current = this.multipleSelection[0];
                    var index = that.tableData.indexOf(current);
                    that.tableData.splice(index, 1);

                } else {
                    this.$message.error('当前协议已添加，请不要重复添加');
                    return false
                }
                that.recordsTotal = that.recordsTotal + 1;
                // 设置分页数据
                // that.setPaginations();
                that.dialog_state = false;
            },
            // 修改设备状态
            getDetectorEditStatus(detectorid, status, text) {
                let that = this;
                let param = {
                    token: localStorage.token,
                    detectorid: detectorid,
                    status: status,
                };
                let postdata = qs.stringify(param);
                DetectorEditStatus(postdata).then(res => {
                    let json = res;
                    if (json.Code == 0) {
                        that.$message({
                            showClose: true,
                            message: text + '成功！',
                            type: 'success'
                        });
                        // table 重载
                        that.getTableQuery();
                    } else {
                        that.$message.error(json.Memo + '，错误代码：' + json.Code);
                    }
                })
            },
            // 过滤设备类型
            filterWirelessTypeName(value, row, column) {
                return filterWirelessType(column);
            },
            filterDistanceName(value, row, column) {
                return filterWirelessRangeText(column)
            },
            filterTime(val, row, column) {
                return nonTfmtDate(column, 10);
            }
        },

        components: {
            dialog_referrer_list
        }
    }
</script>

<style scoped>
    @import "../assets/css/panel.css";
    @import "../assets/css/dialog.css";

    .tabs ul {
        width: 168px;
        float: left;
    }

    table span {
        cursor: pointer;
    }

    .down_btn {
        float: left;
    }

    .content {
        width: 98%;
        overflow: hidden;
        display: block;
        margin: 0 auto;
        padding-left: 20px;
    }

    .selectStyle {
        width: 100%;
        color: #005EA2;
    }

    .selectStyle ::placeholder {
        color: #005EA2;
    }

    /deep/ .modal .el-select .el-input .el-select__caret {
        position: relative;
        top: 35px;
    }

    .imgContianer {
        width: 100%;
        height: 340px;
        overflow: hidden;
        display: block;
        margin: 0 auto;
    }

    .imgContianer img {
        width: 100%;
        height: 100%;
        overflow: hidden;
        display: block;
        margin: 0 auto;
    }

    .pointers {
        position: relative;
        bottom: 340px;
        width: 100%;
        height: 100%;
        overflow: hidden;
        display: block;
        margin: 0 auto;
    }

    .imgContianer i {
        position: relative;
        width: 10px;
        height: 10px;
        float: left;
        border-radius: 250px;
        background: #FFDD00;
    }

    /deep/ .modal-dialog {
        height: 80px;
        margin-top: 20px;
    }

    /deep/ textarea {
        color: #6DC1FF;
    }

    /deep/ .el-table__empty-text {
        color: #015B9E;
    }

    /deep/ .el-input.is-disabled .el-input__inner {
        background-color: #015B9E;
    }

    .red {
        color: red;
    }

    .yellow {
        color: #fd0;
    }

    .panel_title {
        width: 180px;
        float: left;
        text-align: left;
        color: #00FEFF;
        font-size: 14px;
        line-height: 14px;
        margin-left: 30px;
    }

    .panel_title i {
        width: 3px;
        height: 14px;
        float: left;
        background: #00FEFF;
        margin-right: 10px;
    }

    .panel_row {
        width: 100%;
        overflow: hidden;
        display: block;
        margin: 0 auto;
        padding-top: 20px;
        padding-bottom: 10px;
        background: rgba(27, 86, 200, 0.14)
    }

    .pline {
        color: #fff;
    }

    /deep/ .el-checkbox__label {
        color: #fff;
    }

    .panel {
        background: none;
    }

    .panel_control {
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .control_row {
        background: rgba(27, 86, 200, 0.4)
    }

    /deep/ .modal-body {
        position: relative;
        z-index: 1989;
    }

    /deep/ .el-checkbox__inner {
        z-index: 0 !important;
    }

    /deep/ .modal-dialog {
        margin-top: 10%;
        min-height: 340px;
    }

    /deep/ .modal-body .el-select {
        width: 100%;
        /*height: 40px;*/
    }

    /deep/ .modal .el-input__inner {
        height: 40px;
        /*height: 30px!important;*/
    }

    /deep/ .el-popper {
        z-index: 6666;
    }

    .label_checked {
        width: 140px !important;
    }
</style>
