浏览代码

策略 增删改查

Changpeng Duan 4 年之前
父节点
当前提交
7ff64a3602
共有 7 个文件被更改,包括 634 次插入470 次删除
  1. 26 0
      src/Global.js
  2. 20 0
      src/api/getApiRes.js
  3. 3 0
      src/assets/css/dialog.css
  4. 2 2
      src/components/DetcotrRecord.vue
  5. 0 2
      src/components/Task.vue
  6. 499 334
      src/views/addTactics.vue
  7. 84 132
      src/views/tactics.vue

+ 26 - 0
src/Global.js

@@ -272,6 +272,9 @@ filterWirelessType = function (value) {
         case 12:
             return "800M";
             break;
+        case 13:
+            return "0-6G";
+            break;
     }
 };
 
@@ -316,6 +319,9 @@ filterAllType = function (value) {
         case 12:
             return "800M";
             break;
+        case 13:
+            return "0-6G";
+            break;
         case 20:
             return "其他";
             break
@@ -357,6 +363,26 @@ WirelessRange = function () {
     return option
 };
 
+filterWirelessRangeText = function (value) {
+    switch (parseInt(value)) {
+        case 1:
+            return "20cm";
+            break;
+        case 2:
+            return "50cm";
+            break;
+        case 3:
+            return "1M";
+            break;
+        case 4:
+            return "3M";
+            break;
+        case 5:
+            return "5M";
+            break;
+    }
+};
+
 filterDetctorType = function (value) {
     switch (parseInt(value)) {
         case 0:

+ 20 - 0
src/api/getApiRes.js

@@ -176,3 +176,23 @@ export function ScanStrategyDetail(postdata) {
     let url = headapi + 'v1/ScanStrategy/Detail';
     return getApiBasic(url, postdata);
 }
+// 策略列表带详情
+export function ScanStrategyListDetail(postdata) {
+    let url = headapi + 'v1/ScanStrategy/ListDetail';
+    return getApiBasic(url, postdata);
+}
+// 策略列表带详情
+export function ScanStrategyAdd(postdata) {
+    let url = headapi + 'v1/ScanStrategy/Add';
+    return getApiBasic(url, postdata);
+}
+// 策略删除
+export function ScanStrategyDel(postdata) {
+    let url = headapi + 'v1/ScanStrategy/Del';
+    return getApiBasic(url, postdata);
+}
+// 策略修改
+export function ScanStrategyEdit(postdata) {
+    let url = headapi + 'v1/ScanStrategy/Edit';
+    return getApiBasic(url, postdata);
+}

+ 3 - 0
src/assets/css/dialog.css

@@ -59,3 +59,6 @@
 .el-dialog__body {
     color:#6DC1FF!important;
 }
+.el-icon-close {
+    cursor: pointer;
+}

+ 2 - 2
src/components/DetcotrRecord.vue

@@ -139,10 +139,10 @@
             },
             // 过滤设备类型
             filterWirelessTypeName(value, row, column) {
-                return filterWirelessType(value.WirelessType);
+                return filterWirelessType(column);
             },
             filterTime(value, row, column) {
-                return filterTimeToString(value.UpdateAtMilleSec);
+                return filterTimeToString(column);
             }
         }
         ,

+ 0 - 2
src/components/Task.vue

@@ -119,7 +119,6 @@
                     end: 0,
                     distance: 1,
                     cycle: 0,
-
                 },
                 tactics_options: [
                     {
@@ -218,7 +217,6 @@
         },
         methods: {
             turnRecord(){
-                console.log(123);
                 this.recordState = !this.recordState
             },
             // 扫描开始

+ 499 - 334
src/views/addTactics.vue

@@ -18,27 +18,14 @@
                 <div class=" panel_control">
                     <div class="pline">
                         <em>策略名称:</em>
-                        <el-input v-model="panel.tagname" placeholder=""></el-input>
+                        <el-input v-model="panel.name" placeholder=""></el-input>
                     </div>
                     <div class="pline">
-                        <em>持续时间:</em>
-                        <el-input v-model="panel.tagname" placeholder=""></el-input>
-                    </div>
-                    <div class="pline">
-                        <em>所属区域:</em>
-                        <el-select v-model="panel.regionid">
-                            <el-option
-                                    v-for="item in panel.regionidOptions"
-                                    :key="item.Id"
-                                    :label="item.Name"
-                                    :value="item.Id">
-                            </el-option>
-                        </el-select>
-                    </div>
-                    <div class="pline">
-                        <el-col :span="6"><em class="label_checked">
-                            <el-checkbox v-model="checked">信号录制</el-checkbox>
-                        </em></el-col>
+                        <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">
@@ -47,7 +34,7 @@
                         扫描选项
                     </div>
                 </div>
-                <div class="panel_row">
+                <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>
@@ -80,36 +67,35 @@
             >
             </el-table-column>
             <el-table-column
-                    prop="Mac"
+                    prop="agreement"
                     label="无线协议"
+                    :formatter="filterWirelessTypeName"
             >
             </el-table-column>
             <el-table-column
-                    prop="Xmax"
+                    prop="begin"
                     label="起始频率"
+                    sortable
             >
             </el-table-column>
             <el-table-column
-                    prop="Ymax"
+                    prop="end"
                     label="截止频率"
+                    sortable
             >
             </el-table-column>
             <el-table-column
-                    prop="Memo"
+                    prop="distance"
                     label="扫描距离"
+                    :formatter="filterDistanceName"
+                    sortable
             >
             </el-table-column>
         </el-table>
         <br>
-        <!--<el-pagination-->
-        <!--background-->
-        <!--:total="pageination.total"-->
-        <!--:page-size="pageination.pageItem"-->
-        <!--@current-change="pageChange"-->
-        <!--&gt;</el-pagination>-->
         <div class="btm_control">
-            <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="cancleTactics">取消</el-button>
+            <el-button size="medium" type="primary" @click="confirmTactics">确定</el-button>
         </div>
 
         <dialog_referrer_list
@@ -121,31 +107,46 @@
         >
             <div class="dialogContent">
                 <el-row :gutter="24">
-                    <el-col :span="24">
+                    <el-col :span="12">
                         <label>
                             无线协议
                         </label>
-                        <el-input v-model="dialog.mac" @keyup.native="autoCompleteMac"
-                                  :disabled="dialog_type == 2"></el-input>
+                        <!--单条添加与首页逻辑不同-->
+                        <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="24">
+                    <el-col :span="12">
                         <label>
                             扫描距离
                         </label>
-                        <el-input v-model="dialog.mac" @keyup.native="autoCompleteMac"
-                                  :disabled="dialog_type == 2"></el-input>
+                        <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="dialog.tagname" type="number"></el-input>
+                        <el-input v-model="scan.begin" type="number" placeholder="单位100K"></el-input>
                     </el-col>
                     <el-col :span="12">
                         <label>
                             截止频率
                         </label>
-                        <el-input v-model="dialog.tagname" type="number"></el-input>
+                        <el-input v-model="scan.end" placeholder="单位100K"></el-input>
                     </el-col>
                 </el-row>
             </div>
@@ -157,24 +158,19 @@
     import Global from '../Global.js'
     import dialog_referrer_list from '../components/dialog_referrer_list'
     import {
-        DetectorQuery,
-        GetChildRegionSelect,
-        DetectorEditStatus,
-        RegionPictureGetByRegionId,
-        DetectorAdd,
         RegionList,
         DetectorList,
-        DetectorEdit,
-        GetDetectorCoords,
-        GeFullRegionSelect,
+        ScanStrategyAdd,
+        ScanStrategyEdit,
     } from '../api/getApiRes.js'
 
     let qs = require('qs');
     export default {
         data() {
             return {
-                // dialog
+                tid: 0,
                 dialog_state: false,
+                checked: false,
                 dialog_title: '',
                 dialog_type: '',//类型,1是添加,2是修改
                 dialog: {
@@ -200,18 +196,32 @@
                     CoordsId: 0,
                     status: 0,
                 },
+                scan: {
+                    tactics: 0,
+                    agreement: "",
+                    begin: 0,
+                    end: 0,
+                    distance: 1,
+                    cycle: 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: [],
@@ -243,17 +253,308 @@
             }
         },
         mounted() {
-            if (this.$route.query.RegionId) {
-                this.panel.regionid = this.$route.query.RegionId;
-                this.panel.tagname = this.$route.query.TagName;
+            if (this.$route.query.tid != 0) {
+                // 有tid是修改
+                this.readTacticsInfo();
             }
 
-            this.getTableQuery();
+            this.loading = false;
+        },
+        watch: {
+            '$route': function (val) {
+                if (val.path == '/addtactics') {
+                    this.readTacticsInfo();
+                }
+            },
+            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
+                    }
+
+                    // 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.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
+                }
+
+                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 = {
+                    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 = {
+                    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;
@@ -277,7 +578,6 @@
                         that.loading = false;
                         if (json.Rs) {
                             that.allTableData = json.Rs;
-                            console.log(json.Rs);
                             that.recordsTotal = json.Rs.length;
                         } else {
                             that.allTableData = [];
@@ -423,22 +723,13 @@
                 this.dialog_title = '添加扫描选项';
                 this.dialog_type = 1;
 
-                // 重载地区列表
-                this.getGeFullRegionSelect();
-
                 // clear dialog
-                this.dialog.mac = '';
-                this.dialog.regionId = '';
-                this.dialog.tagname = '';
-                this.dialog.HardwareVersion = '';
-                this.dialog.FirmwareVersion = '';
-                this.dialog.FirmwareScanM4Version = '';
-                this.dialog.FirmwareScanM0Version = '';
-                this.dialog.location = '';
-                this.dialog.purchasesrc = '';
-                this.dialog.memo = '';
-                this.dialog.coords_memo = '';
-                this.dialog.points = [{}];
+                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);
@@ -455,41 +746,22 @@
                     });
                     return false
                 }
-                let detectorid = that.multipleSelection[0].Id;
-
-                let param = {
-                    token: localStorage.token,
-                    detectorid: detectorid,
-                    status: 9,//0禁用1启用9删除
-                };
-                let postdata = qs.stringify(param);
-
-                this.$confirm('此操作将永久删除该设备, 是否继续?', '提示', {
+                let current = this.multipleSelection[0];
+                this.$confirm('是否删除选中的无线协议?', '删除操作', {
                     confirmButtonText: '确定',
                     cancelButtonText: '取消',
                     type: 'warning'
                 }).then(() => {
-                    DetectorEditStatus(postdata).then(res => {
-                        let json = res;
-                        if (json.Code == 0) {
-                            that.$message({
-                                showClose: true,
-                                message: '选中的设备已删除!',
-                                type: 'success'
-                            });
-                            // 重载列表
-                            that.getTableQuery();
-                            that.dialog_state = false;
-                        } else {
-                            that.$message.error(json.Memo + ',错误代码:' + json.Code);
-                        }
-                    });
+                    // 从列表删掉
+                    var index = that.tableData.indexOf(current);
+                    that.tableData.splice(index, 1);
                 }).catch(() => {
                     this.$message({
                         type: 'info',
                         message: '已取消删除'
                     });
                 });
+
             },
             editList() {
                 let that = this;
@@ -511,53 +783,15 @@
                     return false
                 }
                 this.dialog_state = true;
-                this.dialog_title = '修改设备信息';
+                this.dialog_title = '修改扫描选项';
                 this.dialog_type = 2;
 
                 // 读取本条记录
                 let row = this.multipleSelection[0];
-                this.dialog.eqId = row.Id;
-                this.dialog.mac = row.Mac;
-                this.dialog.regionId = row.RegionId;
-                this.dialog.tagname = row.TagName;
-                this.dialog.HardwareVersion = row.HardwareVersion;
-                this.dialog.FirmwareVersion = row.FirmwareVersion;
-                this.dialog.FirmwareScanM4Version = row.FirmwareScanM4Version;
-                this.dialog.FirmwareScanM0Version = row.FirmwareScanM0Version;
-                this.dialog.location = row.Location;
-                this.dialog.purchasesrc = row.PurchaseSrc;
-                this.dialog.memo = row.Memo;
-                this.dialog.regionlevelOneId = row.RegionId;
-                this.dialog.status = row.Status;
-                // this.dialog.coords_memo = row.coords_memo;
-
-                // 重载地区列表
-                this.getGeFullRegionSelect();
-
-                that.dialog.points = [{x: row.X, y: row.Y}];
-
-                // let param = {
-                //     token: localStorage.token,
-                //     detectorId: row.Id,
-                // };
-                // let postdata = qs.stringify(param);
-                // GetDetectorCoords(postdata).then(res => {
-                //     let json = res;
-                //     if (json.Code == 0) {
-                //         if (json.Rs.length != 0) {
-                //             console.log(json.Rs[0]);
-                //             // that.dialog.points = [{x: json.Rs[0].X, y: json.Rs[0].Y}];
-                //             that.dialog.points = [{x: json.Rs.X, y: json.Rs.Y}];
-                //             // that.dialog.CoordsId = json.Rs[0].CoordsId;
-                //             // that.dialog.coords_memo = json.Rs[0].Memo;
-                //         } else {
-                //             that.dialog.points = [{x: 0, y: 0}];
-                //             that.dialog.CoordsId = 0;
-                //         }
-                //     } else {
-                //         that.$message.error(json.Memo + ',错误代码:' + json.Code);
-                //     }
-                // })
+                this.scan.agreement = row.agreement;
+                this.scan.distance = row.distance;
+                this.scan.begin = row.begin;
+                this.scan.end = row.end;
             },
             // 自动补全MAC
             autoCompleteMac() {
@@ -569,30 +803,6 @@
                     this.dialog.mac = this.dialog.mac.toUpperCase()
                 }
             },
-            // 探测记录
-            goPhoneRecord(row) {
-                this.$router.push({
-                    path: '/phoneSign',
-                    query:
-                        {
-                            detectorid: row.Id,
-                            comId: 1,
-                            regionId: row.RegionId,
-                        }
-                });
-            },
-            // 探测记录
-            goWifiRecord(row) {
-                this.$router.push({
-                    path: '/wifiSign',
-                    query:
-                        {
-                            detectorid: row.Id,
-                            comId: 1,
-                            regionId: row.RegionId,
-                        }
-                });
-            },
             dialog_cancel() {
                 let that = this;
                 that.dialog_state = false;
@@ -608,127 +818,101 @@
             confirmAddEquip() {
                 let that = this;
                 // checkVal
-                if (!that.dialog.mac) {
-                    this.$message.error('错了哦,mac不能为空');
+                if (!that.scan.agreement) {
+                    this.$message.error('错了哦,无线协议不能为空');
                     return false
                 }
-                if (!checkMac(that.dialog.mac)) {
-                    this.$message.error('错了哦,mac格式不正确');
+
+                if (parseInt(that.scan.begin) < 0) {
+                    this.$message.error('错了哦,起始频率不能小于0');
                     return false
                 }
-                if (!that.dialog.regionId) {
-                    this.$message.error('错了哦,所属区域不能为空');
+                if (parseInt(that.scan.end) > 6000) {
+                    this.$message.error('错了哦,截止频率不能大于6000');
                     return false
                 }
-                if (!that.dialog.tagname) {
-                    this.$message.error('错了哦,标签名不能为空');
+                if (parseInt(that.scan.end) < 0) {
+                    this.$message.error('错了哦,截止频率不能小于0');
                     return false
                 }
-                if (that.dialog.tagname.length > 20) {
-                    this.$message.error('错了哦,标签名不能超过20个字符');
+                if (parseInt(that.scan.end) < parseInt(that.scan.begin)) {
+                    this.$message.error('错了哦,截止频率不能小于起始频率');
                     return false
                 }
-                this.selectRegionLabel(that.dialog.regionId);
-                let param = {
-                    token: localStorage.token,
-                    mac: that.dialog.mac,
-                    comId: 1,
-                    regionId: that.dialog.regionId,
-                    name: that.dialog.tagname,
-                    HardwareVersion: that.dialog.HardwareVersion,
-                    FirmwareVersion: that.dialog.FirmwareVersion,
-                    FirmwareScanM4Version: that.dialog.FirmwareScanM4Version,
-                    FirmwareScanM0Version: that.dialog.FirmwareScanM0Version,
-                    location: that.dialog.location,
-                    purchasesrc: that.dialog.purchasesrc,
-                    x: that.dialog.points[0].x,
-                    y: that.dialog.points[0].y,
-                    // coords_memo: that.dialog.coords_memo,
-                    memo: that.dialog.memo,
-                };
-                let postdata = qs.stringify(param);
-                DetectorAdd(postdata).then(res => {
-                    let json = res;
-                    if (json.Code == 0) {
-                        that.$message({
-                            showClose: true,
-                            message: '设备添加成功!',
-                            type: 'success'
-                        });
-                        // 重载列表
-                        that.getTableQuery();
-                        that.dialog_state = false;
 
-                    } else {
-                        that.$message.error(json.Memo + ',错误代码:' + json.Code);
-                    }
+                // 去掉已有的
+                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;
-                // checkVal
-                if (!that.dialog.mac) {
-                    this.$message.error('错了哦,mac不能为空');
+                if (!that.scan.agreement) {
+                    this.$message.error('错了哦,无线协议不能为空');
                     return false
                 }
-                if (!checkMac(that.dialog.mac)) {
-                    this.$message.error('错了哦,mac格式不正确');
+                if (parseInt(that.scan.begin) < 0) {
+                    this.$message.error('错了哦,起始频率不能小于0');
                     return false
                 }
-
-                if (!that.dialog.regionId) {
-                    this.$message.error('错了哦,所属区域不能为空');
+                if (parseInt(that.scan.end) > 6000) {
+                    this.$message.error('错了哦,截止频率不能大于6000');
                     return false
                 }
-                if (!that.dialog.tagname) {
-                    this.$message.error('错了哦,标签名不能为空');
+                if (parseInt(that.scan.end) < 0) {
+                    this.$message.error('错了哦,截止频率不能小于0');
                     return false
                 }
-                if (that.dialog.tagname.length > 20) {
-                    this.$message.error('错了哦,标签名不能超过20个字符');
+                if (parseInt(that.scan.end) < parseInt(that.scan.begin)) {
+                    this.$message.error('错了哦,截止频率不能小于起始频率');
                     return false
                 }
-                this.selectRegionLabel(that.dialog.regionId);
-                let param = {
-                    token: localStorage.token,
-                    id: that.dialog.eqId,
-                    mac: that.dialog.mac,
-                    comId: 1,
-                    regionId: that.dialog.regionId,
-                    name: that.dialog.tagname,
-                    HardwareVersion: that.dialog.HardwareVersion,
-                    FirmwareVersion: that.dialog.FirmwareVersion,
-                    FirmwareScanM4Version: that.dialog.FirmwareScanM4Version,
-                    FirmwareScanM0Version: that.dialog.FirmwareScanM0Version,
-                    location: that.dialog.location,
-                    purchasesrc: that.dialog.purchasesrc,
-                    x: that.dialog.points[0].x,
-                    y: that.dialog.points[0].y,
-                    coords_memo: that.dialog.coords_memo,
-                    memo: that.dialog.memo,
-                    coordsType: 1,//坐标状态 0:禁用, 1:启用, 9:删除,没有就传0
-                    coordsID: that.dialog.CoordsId,
-                    status: that.dialog.status,
-                };
-
-                let postdata = qs.stringify(param);
-                DetectorEdit(postdata).then(res => {
-                    let json = res;
-                    if (json.Code == 0) {
-                        that.$message({
-                            showClose: true,
-                            message: '设备添加成功!',
-                            type: 'success'
-                        });
-                        // 重载列表
-                        that.getTableQuery();
-                        that.dialog_state = false;
 
-                    } else {
-                        that.$message.error(json.Memo + ',错误代码:' + json.Code);
-                    }
+                // 去掉已有的
+                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) {
@@ -754,91 +938,18 @@
                     }
                 })
             },
-            // 禁用
-            pauseRow(row) {
-                let that = this;
-                this.$confirm('是否禁用' + row.TagName + '设备?', '禁用操作', {
-                    confirmButtonText: '确定',
-                    cancelButtonText: '取消',
-                    type: 'warning'
-                }).then(() => {
-                    that.getDetectorEditStatus(row.Id, 0, '禁用');
-                }).catch(() => {
-                    this.$message({
-                        type: 'info',
-                        message: '已取消禁用'
-                    });
-                });
+            // 过滤设备类型
+            filterWirelessTypeName(value, row, column) {
+                return filterWirelessType(column);
             },
-            // 获取区域位置的平面图
-            getRegionPictureGetByRegionId(regionID) {
-                let that = this;
-                let param = {
-                    token: localStorage.token,
-                    regionID: regionID,
-                    regionId: regionID,
-                };
-                let postdata = qs.stringify(param);
-                that.dialog.plateImgSrc = '../assets/img/main/grid.png'
-                // RegionPictureGetByRegionId(postdata).then(res => {
-                //     let json = res;
-                //     that.dialog.plateImgSrc = '';
-                //     if (json.Code == 0) {
-                //         that.dialog.plateImgSrc = json.EncodeString;
-                //     } else {
-                //         that.$message.error(json.Memo + ',错误代码:' + json.Code);
-                //     }
-                // })
-            },
-            // 启用
-            runRow(row) {
-                console.log(row);
-                let that = this;
-                this.$confirm('是否启用' + row.TagName + '设备?', '启用操作', {
-                    confirmButtonText: '确定',
-                    cancelButtonText: '取消',
-                    type: 'warning'
-                }).then(() => {
-                    that.getDetectorEditStatus(row.Id, 1, '启用');
-                }).catch(() => {
-                    this.$message({
-                        type: 'info',
-                        message: '已取消启用'
-                    });
-                });
-            },
-            // 添加探测器位置的点坐标
-            addPoint(e) {
-                let x = e.offsetX;
-                let y = e.offsetY;
-                this.dialog.points = [{x: x, y: y}];
-            },
-            // 获取位置的文字内容
-            selectRegionLabel(id) {
-                let that = this;
-                let selectedWorkName = {};
-                // selectedWorkName = that.dialog.regionIdRoomOptions.filter(item => {
-                selectedWorkName = that.dialog.regionlevelOneIdOptions.filter(item => {
-                    if (item.Id === id) {
-                        console.log(item.Name);
-                        that.dialog.location = item.Name;
-                    }
-                });
+            filterDistanceName(value, row, column) {
+                return filterWirelessRangeText(column)
             },
             filterTime(val, row, column) {
                 return nonTfmtDate(column, 10);
             }
         },
-        watch: {
-            // 'dialog.regionlevelOneId': function (val) {
-            //     this.dialogGetGetChildRegionSelect(val, 2)
-            // },
-            'dialog.regionId': function (val) {
-                if (val) {
-                    this.getRegionPictureGetByRegionId(val);
-                }
-            },
-        },
+
         components: {
             dialog_referrer_list
         }
@@ -961,6 +1072,7 @@
         background: #00FEFF;
         margin-right: 10px;
     }
+
     .panel_row {
         width: 100%;
         overflow: hidden;
@@ -968,6 +1080,59 @@
         margin: 0 auto;
         padding-top: 20px;
         padding-bottom: 10px;
-        background: rgba(27,86,200,0.14)
+        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>

+ 84 - 132
src/views/tactics.vue

@@ -49,60 +49,60 @@
             >
             </el-table-column>
             <el-table-column
-                    prop="Mac"
-                    label="区域名称"
+                    prop="Name"
+                    label="策略名称"
             >
             </el-table-column>
             <el-table-column type="expand">
                 <template slot-scope="props">
                     <el-table
-                            :data="props.row"
+                            :data="props.row.Value.SignalList"
                             style="width: 100%">
                         <el-table-column
-                                prop="date"
-                                label="日期"
-                                width="180">
+                                prop="Type"
+                                label="无线协议"
+                                :formatter="filterWirelessTypeName"
+
+                        >
+                        </el-table-column>
+                        <el-table-column
+                                prop="Range"
+                                label="扫描距离"
+                                :formatter="filterDistanceName"
+                                sortable
+                        >
                         </el-table-column>
                         <el-table-column
-                                prop="name"
-                                label="姓名"
-                                width="180">
+                                prop="begin"
+                                label="起始频率"
+                                sortable
+                        >
                         </el-table-column>
                         <el-table-column
-                                prop="address"
-                                label="地址">
+                                prop="end"
+                                label="截止频率"
+                                sortable
+                        >
                         </el-table-column>
                     </el-table>
                 </template>
             </el-table-column>
             <el-table-column
-                    prop="Xmax"
-                    label="长/m"
-            >
-            </el-table-column>
-            <el-table-column
-                    prop="Ymax"
-                    label="宽/m"
-            >
-            </el-table-column>
-            <el-table-column
-                    prop="Memo"
-                    label="备注"
+                    prop="Value.IsRecording"
+                    label="信号录制"
             >
+                <template slot-scope="scope">
+                    <span class="red" v-if="scope.row.Value.IsRecording" style="color: #72FF99">已启用</span>
+                    <span v-else style="color: red">已禁用</span>
+                </template>
             </el-table-column>
             <el-table-column
-                    prop="address"
-                    label="操作记录"
-                    width="220"
+                    prop="CreateAt"
+                    label="创建时间"
+                    sortable
+                    :formatter="filterTime"
+
             >
-                <template slot-scope="scope">
-                    <!--<el-button class="" type="text" @click="goPhoneRecord(scope.row)">手机信号记录</el-button>-->
-                    <el-button class="" type="primary" size="small" @click="goWifiRecord(scope.row)">监测记录</el-button>
-                    <!--<el-button v-if="scope.row.Status == 1" class="yellow" type="text" @click="pauseRow(scope.row)">禁用-->
-                    <!--</el-button>-->
-                    <!--<el-button v-if="scope.row.Status == 0" class="green" type="text" @click="runRow(scope.row)">启用-->
-                    <!--</el-button>-->
-                </template>
             </el-table-column>
         </el-table>
         <br>
@@ -112,44 +112,6 @@
                 :page-size="pageination.pageItem"
                 @current-change="pageChange"
         ></el-pagination>
-
-        <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="24">
-                        <label>
-                            区域名称
-                        </label>
-                        <el-input v-model="dialog.mac" @keyup.native="autoCompleteMac"
-                                  :disabled="dialog_type == 2"></el-input>
-                    </el-col>
-                    <el-col :span="12">
-                        <label>
-                            长/m
-                        </label>
-                        <el-input v-model="dialog.tagname"></el-input>
-                    </el-col>
-                    <el-col :span="12">
-                        <label>
-                            宽/m
-                        </label>
-                        <el-input v-model="dialog.tagname"></el-input>
-                    </el-col>
-                    <el-col :span="24">
-                        <label>
-                            备注
-                        </label>
-                        <el-input v-model="dialog.memo" type="textarea"></el-input>
-                    </el-col>
-                </el-row>
-            </div>
-        </dialog_referrer_list>
     </div>
 </template>
 
@@ -167,6 +129,8 @@
         DetectorEdit,
         GetDetectorCoords,
         GeFullRegionSelect,
+        ScanStrategyListDetail,
+        ScanStrategyDel
     } from '../api/getApiRes.js'
 
     let qs = require('qs');
@@ -250,6 +214,13 @@
 
             this.getTableQuery();
         },
+        watch: {
+            '$route': function (val) {
+                if (val.path == '/tactics') {
+                    this.getTableQuery();
+                }
+            },
+        },
         methods: {
             handle(row, column, event) {
                 this.$refs.multipleTable.toggleRowSelection(row);
@@ -260,24 +231,29 @@
                 // this.getGetChildRegionSelect(0, 1);
                 this.getGeFullRegionSelect();
                 that.loading = true;
-                // 查询检测设备。上级区域id,区域id必传。regionid传0,查询supregionid对应所有子区域的检测设备。 如果supregionid,regionid都传0,默认查询企业ID下所有检测设备
+                // 查询检测策略。上级区域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 => {
+                ScanStrategyListDetail(postdata).then(res => {
                     let json = res;
                     if (json.Code == 0) {
                         that.loading = false;
                         if (json.Rs) {
+
+                            // 把起始频率回填
+                            json.Rs.map(function (item) {
+                                item.Value.SignalList.map(function (row) {
+                                    if (row.Type == 13) {
+                                        row.begin = item.Value.Freq06G[0].Begin;
+                                        row.end = item.Value.Freq06G[0].End;
+                                    }
+                                })
+                            });
+
                             that.allTableData = json.Rs;
-                            console.log(json.Rs);
                             that.recordsTotal = json.Rs.length;
                         } else {
                             that.allTableData = [];
@@ -436,26 +412,33 @@
                     });
                     return false
                 }
-                let detectorid = that.multipleSelection[0].Id;
+                if (this.multipleSelection.length > 1) {
+                    this.$message({
+                        showClose: true,
+                        message: '错了哦,只能选中一条记录',
+                        type: 'error'
+                    });
+                    return false
+                }
+                let Id = that.multipleSelection[0].Id;
 
                 let param = {
                     token: localStorage.token,
-                    detectorid: detectorid,
-                    status: 9,//0禁用1启用9删除
+                    id: Id,
                 };
                 let postdata = qs.stringify(param);
 
-                this.$confirm('此操作将永久删除该设备, 是否继续?', '提示', {
+                this.$confirm('此操作将永久删除该策略, 是否继续?', '提示', {
                     confirmButtonText: '确定',
                     cancelButtonText: '取消',
                     type: 'warning'
                 }).then(() => {
-                    DetectorEditStatus(postdata).then(res => {
+                    ScanStrategyDel(postdata).then(res => {
                         let json = res;
                         if (json.Code == 0) {
                             that.$message({
                                 showClose: true,
-                                message: '选中的设备已删除!',
+                                message: '选中的策略已删除!',
                                 type: 'success'
                             });
                             // 重载列表
@@ -491,34 +474,10 @@
                     });
                     return false
                 }
-                this.dialog_state = true;
-                this.dialog_title = '修改设备信息';
-                this.dialog_type = 2;
-
-                // 读取本条记录
                 let row = this.multipleSelection[0];
-                this.dialog.eqId = row.Id;
-                this.dialog.mac = row.Mac;
-                this.dialog.regionId = row.RegionId;
-                this.dialog.tagname = row.TagName;
-                this.dialog.HardwareVersion = row.HardwareVersion;
-                this.dialog.FirmwareVersion = row.FirmwareVersion;
-                this.dialog.FirmwareScanM4Version = row.FirmwareScanM4Version;
-                this.dialog.FirmwareScanM0Version = row.FirmwareScanM0Version;
-                this.dialog.location = row.Location;
-                this.dialog.purchasesrc = row.PurchaseSrc;
-                this.dialog.memo = row.Memo;
-                this.dialog.regionlevelOneId = row.RegionId;
-                this.dialog.status = row.Status;
-                // this.dialog.coords_memo = row.coords_memo;
-
-                // 重载地区列表
-                this.getGeFullRegionSelect();
-
-                that.dialog.points = [{x: row.X, y: row.Y}];
                 this.$router.push(
                     {
-                        path: '/addtactics', query: {tid: row.id}
+                        path: '/addtactics', query: {tid: row.Id, name: row.Name, Value: JSON.stringify(row.Value)}
                     }
                 );
             },
@@ -567,7 +526,7 @@
                     this.confirmEditEquip();
                 }
             },
-            // 提交增加新设备
+            // 提交增加新策略
             confirmAddEquip() {
                 let that = this;
                 // checkVal
@@ -615,7 +574,7 @@
                     if (json.Code == 0) {
                         that.$message({
                             showClose: true,
-                            message: '设备添加成功!',
+                            message: '策略添加成功!',
                             type: 'success'
                         });
                         // 重载列表
@@ -627,7 +586,7 @@
                     }
                 });
             },
-            // 提交修改设备信息
+            // 提交修改策略信息
             confirmEditEquip() {
                 let that = this;
                 // checkVal
@@ -681,7 +640,7 @@
                     if (json.Code == 0) {
                         that.$message({
                             showClose: true,
-                            message: '设备添加成功!',
+                            message: '策略添加成功!',
                             type: 'success'
                         });
                         // 重载列表
@@ -693,7 +652,7 @@
                     }
                 });
             },
-            // 修改设备状态
+            // 修改策略状态
             getDetectorEditStatus(detectorid, status, text) {
                 let that = this;
                 let param = {
@@ -720,7 +679,7 @@
             // 禁用
             pauseRow(row) {
                 let that = this;
-                this.$confirm('是否禁用' + row.TagName + '设备?', '禁用操作', {
+                this.$confirm('是否禁用' + row.TagName + '策略?', '禁用操作', {
                     confirmButtonText: '确定',
                     cancelButtonText: '取消',
                     type: 'warning'
@@ -757,7 +716,7 @@
             runRow(row) {
                 console.log(row);
                 let that = this;
-                this.$confirm('是否启用' + row.TagName + '设备?', '启用操作', {
+                this.$confirm('是否启用' + row.TagName + '策略?', '启用操作', {
                     confirmButtonText: '确定',
                     cancelButtonText: '取消',
                     type: 'warning'
@@ -788,25 +747,18 @@
                     }
                 });
             },
+            // 过滤设备类型
+            filterWirelessTypeName(value, row, column) {
+                return filterWirelessType(column);
+            },
+            filterDistanceName(value, row, column) {
+                return filterWirelessRangeText(column)
+            },
             filterTime(val, row, column) {
                 return nonTfmtDate(column, 10);
             }
         }
-        ,
-        watch: {
-            // 'dialog.regionlevelOneId': function (val) {
-            //     this.dialogGetGetChildRegionSelect(val, 2)
-            // },
-            'dialog.regionId':
-
-                function (val) {
-                    if (val) {
-                        this.getRegionPictureGetByRegionId(val);
-                    }
-                }
 
-            ,
-        }
         ,
         components: {
             dialog_referrer_list