Browse Source

学校班级策略

gzb
guozhongbo 9 months ago
parent
commit
d087d4cb32
1 changed files with 171 additions and 30 deletions
  1. 171
    30
      src/views/schoolSection/strategy/publicStrategy.vue

+ 171
- 30
src/views/schoolSection/strategy/publicStrategy.vue View File

15
           >时间限制策略
15
           >时间限制策略
16
         </div>
16
         </div>
17
         <div>
17
         <div>
18
-          <Checkbox v-if="curState === 1" v-model="strategyInfo.hastime"
18
+          <Checkbox v-if="curState === 2" v-model="strategyInfo.hastime"
19
             >启用</Checkbox
19
             >启用</Checkbox
20
           >
20
           >
21
         </div>
21
         </div>
22
       </div>
22
       </div>
23
+      <div style="margin-bottom: 10px" v-if="strategyInfo.hastime">
24
+        <TimeStrategy
25
+          :times="strategyInfo.padTimes"
26
+          @timesChange="timesChange"
27
+        ></TimeStrategy>
28
+      </div>
29
+      <div class="nodata" v-else>未设置时间限制策略</div>
23
     </div>
30
     </div>
24
     <div class="strategy_list">
31
     <div class="strategy_list">
25
       <div class="strategy_title">
32
       <div class="strategy_title">
27
           <span class="ivu-icon iconfont icon-yingyongcelve"></span>应用策略
34
           <span class="ivu-icon iconfont icon-yingyongcelve"></span>应用策略
28
         </div>
35
         </div>
29
         <div>
36
         <div>
30
-          <Checkbox v-if="curState === 1" v-model="strategyInfo.hasapp"
37
+          <Checkbox v-if="curState === 2" v-model="strategyInfo.hasapp"
31
             >启用</Checkbox
38
             >启用</Checkbox
32
           >
39
           >
33
         </div>
40
         </div>
62
       <div class="strategy_title">
69
       <div class="strategy_title">
63
         <div><span class="ivu-icon iconfont icon-shezhi"></span>设备策略</div>
70
         <div><span class="ivu-icon iconfont icon-shezhi"></span>设备策略</div>
64
         <div>
71
         <div>
65
-          <Checkbox v-if="curState === 1" v-model="strategyInfo.hasdevice"
72
+          <Checkbox v-if="curState === 2" v-model="strategyInfo.hasdevice"
66
             >启用</Checkbox
73
             >启用</Checkbox
67
           >
74
           >
68
         </div>
75
         </div>
69
       </div>
76
       </div>
70
-      <div class="strategy_content">
77
+      <div class="strategy_content" v-if="strategyInfo.hasdevice">
71
         <div class="strategy_top">
78
         <div class="strategy_top">
72
-          <span>授权应用</span>
79
+          <span>设备功能管理</span>
73
         </div>
80
         </div>
74
         <div class="strategy_bottom" style="min-height: 160px">
81
         <div class="strategy_bottom" style="min-height: 160px">
75
           <div
82
           <div
94
           </div>
101
           </div>
95
         </div>
102
         </div>
96
       </div>
103
       </div>
104
+      <div class="nodata" v-else>未设置设备策略</div>
97
     </div>
105
     </div>
98
     <div class="strategy_list">
106
     <div class="strategy_list">
99
       <div class="strategy_title">
107
       <div class="strategy_title">
105
           >Wifi白名单策略
113
           >Wifi白名单策略
106
         </div>
114
         </div>
107
         <div>
115
         <div>
108
-          <Checkbox v-if="curState === 1" v-model="strategyInfo.haswifi"
116
+          <Checkbox v-if="curState === 2" v-model="strategyInfo.haswifi"
109
             >启用</Checkbox
117
             >启用</Checkbox
110
           >
118
           >
111
         </div>
119
         </div>
112
       </div>
120
       </div>
113
-      <div class="strategy_content">
121
+      <div class="strategy_content" v-if="strategyInfo.haswifi">
114
         <div class="strategy_top">
122
         <div class="strategy_top">
115
           <span>SSID</span>
123
           <span>SSID</span>
116
           <span v-if="curState === 2">
124
           <span v-if="curState === 2">
140
           </div>
148
           </div>
141
         </div>
149
         </div>
142
       </div>
150
       </div>
151
+      <div class="nodata" v-else>未设置Wifi白名单</div>
143
     </div>
152
     </div>
144
     <div class="strategy_list">
153
     <div class="strategy_list">
145
       <div class="strategy_title">
154
       <div class="strategy_title">
147
           <span class="ivu-icon iconfont icon-weiguiguanli"></span>违规处理
156
           <span class="ivu-icon iconfont icon-weiguiguanli"></span>违规处理
148
         </div>
157
         </div>
149
         <div>
158
         <div>
150
-          <Checkbox v-if="curState === 1" v-model="strategyInfo.hasviolate"
159
+          <Checkbox v-if="curState === 2" v-model="strategyInfo.hasviolate"
151
             >启用</Checkbox
160
             >启用</Checkbox
152
           >
161
           >
153
         </div>
162
         </div>
154
       </div>
163
       </div>
155
-      <Table class="table" :columns="columns" :data="strategyInfo.padViolates">
164
+      <Table
165
+        v-if="strategyInfo.hasviolate"
166
+        class="table"
167
+        :columns="columns"
168
+        :data="strategyInfo.padViolates"
169
+      >
156
         <template slot-scope="{ row }" slot="violationEvents">
170
         <template slot-scope="{ row }" slot="violationEvents">
157
           <Checkbox
171
           <Checkbox
158
             :disabled="curState === 1"
172
             :disabled="curState === 1"
165
           }}</span>
179
           }}</span>
166
         </template>
180
         </template>
167
         <template slot-scope="{ row }" slot="violationHandling">
181
         <template slot-scope="{ row }" slot="violationHandling">
168
-          <CheckboxGroup v-model="row.handleMethod">
182
+          <CheckboxGroup
183
+            @on-change="checkboxChange(row)"
184
+            v-model="row.handleMethod"
185
+          >
169
             <Checkbox :disabled="curState === 1" label="通知管理员"></Checkbox>
186
             <Checkbox :disabled="curState === 1" label="通知管理员"></Checkbox>
170
             <Checkbox
187
             <Checkbox
171
               :disabled="curState === 1"
188
               :disabled="curState === 1"
179
           </CheckboxGroup>
196
           </CheckboxGroup>
180
         </template>
197
         </template>
181
       </Table>
198
       </Table>
199
+      <div class="nodata" v-if="!strategyInfo.hasviolate">未设置违规处理</div>
182
       <div
200
       <div
183
         class="footer"
201
         class="footer"
184
         style="text-align: center; margin-top: 20px"
202
         style="text-align: center; margin-top: 20px"
202
 </template>
220
 </template>
203
 
221
 
204
 <script>
222
 <script>
205
-import { stApp_detail_obj } from "@/api/stPad";
223
+import {
224
+  stApp_add,
225
+  stApp_detail_obj,
226
+  stApp_edit,
227
+  stPad_add, stPad_detail_obj,
228
+  stPad_edit
229
+} from "@/api/stPad";
206
 import { app_list } from "@/api/appgroup";
230
 import { app_list } from "@/api/appgroup";
207
-
231
+import TimeStrategy from "@/components/TimeStrategy/TimeStrategy";
208
 export default {
232
 export default {
233
+  components: {
234
+    TimeStrategy
235
+  },
209
   props: ["curClass"],
236
   props: ["curClass"],
210
   data() {
237
   data() {
211
     return {
238
     return {
212
       showLoading: false,
239
       showLoading: false,
213
       curState: 1, //1查看/2编辑
240
       curState: 1, //1查看/2编辑
214
       strategyInfo: {
241
       strategyInfo: {
215
-        hastime: false, // 是否开启时间策略:0否 1是
242
+        hastime: true, // 是否开启时间策略:0否 1是
216
         padTimes: [], // 平板策略时间
243
         padTimes: [], // 平板策略时间
217
-        hasapp: false, //是否开启应用策略:0否 1是
244
+        hasapp: true, //是否开启应用策略:0否 1是
218
         padApps: [], //appid集合
245
         padApps: [], //appid集合
219
-        hasdevice: false, //是否开启设备策略:0否 1是
246
+        hasdevice: true, //是否开启设备策略:0否 1是
220
         padDevices: [
247
         padDevices: [
221
           {
248
           {
222
             id: 1,
249
             id: 1,
279
             icon: "ivu-icon iconfont icon-icon-OTG"
306
             icon: "ivu-icon iconfont icon-icon-OTG"
280
           }
307
           }
281
         ], //授权应用
308
         ], //授权应用
282
-        haswifi: false, //是否开启wifi白名单策略:0否 1是
283
-        padWifis: ["wifi白名单"], //wifi白名单
284
-        hasviolate: false, //是否开启违规通知:0否 1是
309
+        haswifi: true, //是否开启wifi白名单策略:0否 1是
310
+        padWifis: ["xhkjedu"], //wifi白名单
311
+        hasviolate: true, //是否开启违规通知:0否 1是
285
         padViolates: [
312
         padViolates: [
286
           {
313
           {
287
             title: "已ROOT",
314
             title: "已ROOT",
322
           align: "center"
349
           align: "center"
323
         }
350
         }
324
       ],
351
       ],
325
-      ssidName: ""
352
+      ssidName: "",
353
+      hasSave: null
326
     };
354
     };
327
   },
355
   },
328
   watch: {
356
   watch: {
339
     }
367
     }
340
   },
368
   },
341
   created() {
369
   created() {
342
-    this.curState = 1;
370
+    this.curState = 2;
343
     this.init();
371
     this.init();
344
   },
372
   },
345
   methods: {
373
   methods: {
346
-    save() {},
374
+    timesChange(times) {
375
+      this.strategyInfo.padTimes = times;
376
+      console.log(this.strategyInfo.padTimes);
377
+    },
378
+    save() {
379
+      console.log(this.strategyInfo);
380
+
381
+      let padDevices = [],
382
+        padViolates = [],
383
+        padApps = [];
384
+      //获取授权应用
385
+      for (let item of this.strategyInfo.padApps) {
386
+        if (item.checked) {
387
+          padApps.push(item.appid);
388
+        }
389
+      }
390
+      //获取设备
391
+      let pdorder = 0;
392
+      for (let item of this.strategyInfo.padDevices) {
393
+        if (item.enabled === 1) {
394
+          pdorder++;
395
+          padDevices.push({ pdtype: item.title, pdorder });
396
+        }
397
+      }
398
+
399
+      //获取违规处理
400
+      for (let item of this.strategyInfo.padViolates) {
401
+        if (item.checked) {
402
+          let handleMethod = item.handleMethod.join(";");
403
+          padViolates.push({ violateType: item.violateType, handleMethod });
404
+        }
405
+      }
406
+      if (this.strategyInfo.hastime) {
407
+        if (this.strategyInfo.padTimes.length === 0) {
408
+          this.$Message.error("请选择时间限制!");
409
+          return;
410
+        }
411
+      }
412
+      if (this.strategyInfo.hasapp) {
413
+        if (padApps.length === 0) {
414
+          this.$Message.error("请选择授权应用!");
415
+          return;
416
+        }
417
+      }
418
+      if (this.strategyInfo.hasdevice) {
419
+        if (padDevices.length === 0) {
420
+          this.$Message.error("请选择设备!");
421
+          return;
422
+        }
423
+      }
424
+      if (this.strategyInfo.haswifi) {
425
+        if (this.strategyInfo.padWifis.length === 0) {
426
+          this.$Message.error("请输入SSID!");
427
+          return;
428
+        }
429
+      }
430
+      if (this.strategyInfo.hasviolate) {
431
+        if (padViolates.length === 0) {
432
+          this.$Message.error("请选择违规事件!");
433
+          return;
434
+        }
435
+        //违规处理选项
436
+        for (let item of padViolates) {
437
+          if (item.handleMethod.length === 0) {
438
+            this.$Message.error("请选择违规处理!");
439
+            return;
440
+          }
441
+        }
442
+      }
443
+      let form = {
444
+        sttype: this.curClass.type, //1学校策略 2班级策略 3个人策略
445
+        objectid: this.curClass.id,
446
+        hastime: this.strategyInfo.hastime ? 1 : 0,
447
+        hasapp: this.strategyInfo.hasapp ? 1 : 0,
448
+        hasdevice: this.strategyInfo.hasdevice ? 1 : 0,
449
+        haswifi: this.strategyInfo.haswifi ? 1 : 0,
450
+        hasviolate: this.strategyInfo.hasviolate ? 1 : 0,
451
+        padTimes: this.strategyInfo.hastime ? this.strategyInfo.padTimes : [],
452
+        padDevices: this.strategyInfo.hasdevice ? padDevices : [],
453
+        padViolates: this.strategyInfo.hasviolate ? padViolates : [],
454
+        padWifis: this.strategyInfo.haswifi ? this.strategyInfo.padWifis : [],
455
+        padApps: this.strategyInfo.hasapp ? padApps : []
456
+      };
457
+      let api = this.hasSave ? stPad_edit : stPad_add;
458
+      console.log(form);
459
+      api(form).then((res) => {
460
+        if (res.code === 0) {
461
+          console.log(res.obj);
462
+          this.$Message.success(res.msg);
463
+          this.detail();
464
+        } else {
465
+          this.$Message.error(res.msg);
466
+        }
467
+      });
468
+    },
469
+    checkboxChange(row) {
470
+      row.checked = row.handleMethod.length > 0 ? true : false;
471
+      this.strategyInfo.padViolates.forEach((item) => {
472
+        if (item.violateType === row.violateType) {
473
+          item.checked = row.handleMethod.length > 0 ? true : false;
474
+          item.handleMethod = row.handleMethod;
475
+        }
476
+      });
477
+    },
347
     //违规事件
478
     //违规事件
348
     checkedChange(row) {
479
     checkedChange(row) {
349
-      if (!row.checked) {
350
-        //清空违规处理
351
-        row.handleMethod = [];
352
-      }
480
+      this.strategyInfo.padViolates.forEach((item) => {
481
+        if (item.violateType === row.violateType) {
482
+          if (!row.checked) {
483
+            //清空违规处理
484
+            item.handleMethod = [];
485
+          }
486
+        }
487
+      });
353
     },
488
     },
354
     delWifi(val) {
489
     delWifi(val) {
355
       //删除wifi白名单
490
       //删除wifi白名单
368
       );
503
       );
369
       console.log(this.strategyInfo.padWifis);
504
       console.log(this.strategyInfo.padWifis);
370
     },
505
     },
371
-    async init() {
372
-      console.log(this.curClass);
506
+    async detail(){
373
       this.showLoading = true;
507
       this.showLoading = true;
374
       //获取学校/班级策略详情
508
       //获取学校/班级策略详情
375
-      let res = await stApp_detail_obj({
509
+      let res = await stPad_detail_obj({
376
         rtype: this.powerParams.rtype,
510
         rtype: this.powerParams.rtype,
377
         objectid: this.curClass.id,
511
         objectid: this.curClass.id,
378
         sttype: this.curClass.type
512
         sttype: this.curClass.type
379
       });
513
       });
380
       this.showLoading = false;
514
       this.showLoading = false;
381
       if (res.code === 0) {
515
       if (res.code === 0) {
382
-        console.log(res.obj);
516
+        this.hasSave = res.obj;
517
+        if(this.hasSave){
518
+
519
+        }
520
+        console.log(this.hasSave);
383
       } else {
521
       } else {
384
         this.$Message.error(res.msg);
522
         this.$Message.error(res.msg);
385
       }
523
       }
524
+    },
525
+    async init() {
526
+       await this.detail();
386
       //获取应用列表
527
       //获取应用列表
387
       let res1 = await app_list({
528
       let res1 = await app_list({
388
         rtype: this.powerParams.rtype,
529
         rtype: this.powerParams.rtype,
533
         }
674
         }
534
       }
675
       }
535
     }
676
     }
536
-    .nodata{
677
+    .nodata {
537
       color: #798cb5;
678
       color: #798cb5;
538
       font-size: 16px;
679
       font-size: 16px;
539
       line-height: 30px;
680
       line-height: 30px;

Loading…
Cancel
Save