Browse Source

学校应用策略管理

gzb
wangzhonglu 9 months ago
parent
commit
f271fee888

+ 3
- 3
public/iconfont/demo_index.html View File

@@ -234,9 +234,9 @@
234 234
 <pre><code class="language-css"
235 235
 >@font-face {
236 236
   font-family: 'iconfont';
237
-  src: url('iconfont.woff2?t=1712125751952') format('woff2'),
238
-       url('iconfont.woff?t=1712125751952') format('woff'),
239
-       url('iconfont.ttf?t=1712125751952') format('truetype');
237
+  src: url('iconfont.woff2?t=1712547599749') format('woff2'),
238
+       url('iconfont.woff?t=1712547599749') format('woff'),
239
+       url('iconfont.ttf?t=1712547599749') format('truetype');
240 240
 }
241 241
 </code></pre>
242 242
           <h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>

+ 3
- 3
public/iconfont/iconfont.css View File

@@ -1,8 +1,8 @@
1 1
 @font-face {
2 2
   font-family: "iconfont"; /* Project id 4468064 */
3
-  src: url('iconfont.woff2?t=1712125751952') format('woff2'),
4
-       url('iconfont.woff?t=1712125751952') format('woff'),
5
-       url('iconfont.ttf?t=1712125751952') format('truetype');
3
+  src: url('iconfont.woff2?t=1712547599749') format('woff2'),
4
+       url('iconfont.woff?t=1712547599749') format('woff'),
5
+       url('iconfont.ttf?t=1712547599749') format('truetype');
6 6
 }
7 7
 
8 8
 .iconfont {

BIN
public/iconfont/iconfont.ttf View File


BIN
public/iconfont/iconfont.woff View File


BIN
public/iconfont/iconfont.woff2 View File


+ 13
- 0
src/router/school.js View File

@@ -141,6 +141,19 @@ export default {
141 141
         title: "学校管控-应用策略管理"
142 142
       }
143 143
     },
144
+    {
145
+      path: "appStrategyManageEdit",
146
+      component: () =>
147
+        import(
148
+          "@/views/schoolSection/applicationStrategy/appStrategyManageEdit.vue"
149
+        ),
150
+      name: "appStrategyManageEdit",
151
+      meta: {
152
+        keepAlive: true,
153
+        isAuth: true,
154
+        title: "学校管控-应用策略管理编辑"
155
+      }
156
+    },
144 157
     {
145 158
       path: "deviceManage",
146 159
       component: () =>

+ 494
- 5
src/views/schoolSection/applicationStrategy/appStrategyManage.vue View File

@@ -1,20 +1,509 @@
1 1
 <template>
2
-  <div class="main_root">应用策略管理</div>
2
+  <div class="main_root">
3
+    <div class="main_left">
4
+      <div class="main_left_title">用户组</div>
5
+      <div class="class_list">
6
+        <div
7
+          :class="['class_item', !searchForm.classid ? 'selceted' : '']"
8
+          @click="classChange(null)"
9
+        >
10
+          {{ schoolInfo.schoolname }}
11
+        </div>
12
+        <div
13
+          :class="[
14
+            'class_item',
15
+            searchForm.classid === classItem.id ? 'selceted' : ''
16
+          ]"
17
+          v-for="classItem in schoolInfo.classList"
18
+          :key="classItem.id"
19
+          @click="classChange(classItem.id)"
20
+        >
21
+          {{ classItem.name }}
22
+        </div>
23
+      </div>
24
+    </div>
25
+    <div class="main_right">
26
+      <div class="right_header">
27
+        <div class="header_left">
28
+          <span v-if="appStrategyInfo.stappid"
29
+            >已引用“{{ appStrategyInfo.name }}”的应用策略</span
30
+          >
31
+        </div>
32
+        <div class="header_right">
33
+          <div @click="toEditAppStrategy(appStrategyInfo.stappid)">修改</div>
34
+          <div @click="toResetAppStrategy()">重置</div>
35
+          <div @click="toSelectAppStrategy()">引用</div>
36
+        </div>
37
+      </div>
38
+      <div
39
+        class="strategy_item"
40
+        v-for="(groupItem, groupIndex) in appStrategyInfo.groups"
41
+        :key="groupIndex"
42
+      >
43
+        <table class="my_table">
44
+          <tr>
45
+            <th colspan="7">
46
+              <div class="table_header">
47
+                <div class="table_header_title">
48
+                  应用策略{{ groupIndex + 1 }}
49
+                </div>
50
+                <div class="table_header_action"></div>
51
+              </div>
52
+            </th>
53
+          </tr>
54
+          <tr>
55
+            <td v-for="weekItem in weekDay" :key="weekItem.value">
56
+              {{ weekItem.label }}
57
+            </td>
58
+          </tr>
59
+          <tr>
60
+            <td v-for="weekItem in weekDay" :key="weekItem.value">
61
+              <div class="time_list">
62
+                <span
63
+                  v-for="(timeItem, timeIndex) in appStrategyGroupInfo[
64
+                    groupIndex
65
+                  ] && appStrategyGroupInfo[groupIndex][weekItem.value]"
66
+                  :key="timeIndex"
67
+                  >{{ timeItem.starttime }} - {{ timeItem.stoptime }}</span
68
+                >
69
+              </div>
70
+            </td>
71
+          </tr>
72
+          <tr>
73
+            <td colspan="7">
74
+              <div class="table_app_list">
75
+                <div
76
+                  class="table_app_item"
77
+                  v-for="appItem in groupItem.apps"
78
+                  :key="appItem.appid"
79
+                >
80
+                  <div class="app_top">
81
+                    <img :src="$api.showImageUrl + appItem.appIcon" />
82
+                  </div>
83
+                  <div class="app_name">
84
+                    {{ appItem.appName }}
85
+                  </div>
86
+                </div>
87
+              </div>
88
+            </td>
89
+          </tr>
90
+        </table>
91
+      </div>
92
+    </div>
93
+    <Modal
94
+      class="modal1"
95
+      :mask-closable="false"
96
+      v-model="useAppStrategyInfo.show"
97
+      title="引用"
98
+    >
99
+      <div class="table_wrap" v-if="useAppStrategyInfo.show">
100
+        <Table
101
+          :columns="useColumns"
102
+          :data="useAppStrategyInfo.list"
103
+          @on-row-click="useAppStrategyRowSelected"
104
+        >
105
+          <template slot-scope="{ row, index }" slot="actionSlot">
106
+            <Radio
107
+              :value="row.selected"
108
+              @on-change="useAppStrategyChange(index)"
109
+            ></Radio>
110
+          </template>
111
+        </Table>
112
+      </div>
113
+      <div slot="footer">
114
+        <Button @click="useAppStrategyInfo.show = false">取消</Button>
115
+        <Button
116
+          @click="saveUseAppStrategyInfo()"
117
+          type="primary"
118
+          class="primary_btn"
119
+          >保存</Button
120
+        >
121
+      </div>
122
+    </Modal>
123
+  </div>
3 124
 </template>
4 125
 
5 126
 <script>
127
+import { weekDay } from "@/utils";
128
+import { class_list } from "@/api/school";
129
+import { stApp_detail_obj, stApp_list_sel, stApp_delete } from "@/api/stPad";
6 130
 export default {
7 131
   data() {
8
-    return {};
132
+    return {
133
+      weekDay,
134
+      schoolInfo: {
135
+        schoolname: null,
136
+        classList: null
137
+      },
138
+      searchForm: {
139
+        classid: null
140
+      },
141
+      // 引用信息
142
+      useAppStrategyInfo: {
143
+        show: false,
144
+        stappid: null,
145
+        list: []
146
+      },
147
+      useColumns: [
148
+        {
149
+          title: "操作",
150
+          slot: "actionSlot",
151
+          width: 70,
152
+          align: "center"
153
+        },
154
+        {
155
+          title: "策略名称",
156
+          key: "name",
157
+          align: "center"
158
+        },
159
+        {
160
+          title: "更新时间",
161
+          key: "updatetime",
162
+          width: 190,
163
+          align: "center"
164
+        }
165
+      ],
166
+      appStrategyInfo: {
167
+        stappid: null,
168
+        rversion: null,
169
+        name: "",
170
+        groups: []
171
+      }
172
+    };
173
+  },
174
+  created() {
175
+    let search = this.$route.query.search;
176
+    if (search) {
177
+      search = JSON.parse(search);
178
+      this.searchForm.classid = search.classid;
179
+    }
180
+    this.getClassList();
181
+    this.getClassAppStrategyDetail();
9 182
   },
10
-  created() {},
11 183
   computed: {
12 184
     powerParams() {
13 185
       return this.$store.getters.powerParams;
186
+    },
187
+    appStrategyGroupInfo() {
188
+      let info = [];
189
+      this.appStrategyInfo.groups.forEach((groupItem) => {
190
+        let groupTimes = {};
191
+        groupItem.times.forEach((timeItem) => {
192
+          if (!groupTimes[timeItem.week]) {
193
+            groupTimes[timeItem.week] = [];
194
+          }
195
+          groupTimes[timeItem.week].push(timeItem);
196
+        });
197
+        info.push(groupTimes);
198
+      });
199
+      return info;
14 200
     }
15 201
   },
16
-  methods: {}
202
+  methods: {
203
+    toEditAppStrategy(stappid) {
204
+      this.$router.push({
205
+        path: "/school/appStrategyManageEdit",
206
+        query: {
207
+          stappid,
208
+          classid: this.searchForm.classid
209
+        }
210
+      });
211
+    },
212
+    useAppStrategyRowSelected(row, index) {
213
+      this.useAppStrategyChange(index);
214
+    },
215
+    useAppStrategyChange(index) {
216
+      this.useAppStrategyInfo.list.forEach((item) => {
217
+        item.selected = false;
218
+      });
219
+      this.useAppStrategyInfo.list[index].selected = true;
220
+    },
221
+    saveUseAppStrategyInfo() {
222
+      this.useAppStrategyInfo.list.forEach((item) => {
223
+        if (item.selected) {
224
+          this.useAppStrategyInfo.stappid = item.stappid;
225
+        }
226
+      });
227
+      if (!this.useAppStrategyInfo.stappid) {
228
+        this.$Message.error("请选择应用策略");
229
+        return;
230
+      }
231
+      this.useAppStrategyInfo.show = false;
232
+      this.toEditAppStrategy(this.useAppStrategyInfo.stappid);
233
+    },
234
+    toResetAppStrategy() {
235
+      this.$Modal.confirm({
236
+        title: "提示",
237
+        content: "确认之后会将当前应用策略恢复成默认状态,是否重置?",
238
+        onOk: () => {
239
+          stApp_delete({
240
+            stappid: this.appStrategyInfo.stappid,
241
+            rversion: this.appStrategyInfo.rversion
242
+          }).then((data) => {
243
+            if (data.code === 0) {
244
+              this.$Message.success(data.msg);
245
+              this.getClassAppStrategyDetail();
246
+            } else {
247
+              this.$Message.error(data.msg);
248
+            }
249
+          });
250
+        },
251
+        onCancel: () => {}
252
+      });
253
+    },
254
+    toSelectAppStrategy() {
255
+      this.useAppStrategyInfo.show = true;
256
+      this.useAppStrategyInfo.stappid = null;
257
+      this.useAppStrategyInfo.list = [];
258
+      stApp_list_sel({
259
+        schoolid: this.powerParams.objectid
260
+      }).then((data) => {
261
+        if (data.code === 0) {
262
+          this.useAppStrategyInfo.list = data.obj.map((item) => {
263
+            item.selected = false;
264
+            return item;
265
+          });
266
+        } else {
267
+          this.$Message.error(data.msg);
268
+        }
269
+      });
270
+    },
271
+    classChange(classid) {
272
+      this.searchForm.classid = classid;
273
+      this.getClassAppStrategyDetail();
274
+    },
275
+    // 获取班级列表
276
+    getClassList() {
277
+      class_list({
278
+        // rtype: this.powerParams.rtype,
279
+        // objectid: this.powerParams.objectid,
280
+        schoolid: this.powerParams.objectid
281
+      }).then((data) => {
282
+        if (data.code === 0) {
283
+          this.schoolInfo = {
284
+            schoolname: data.obj.name,
285
+            classList: data.obj.children
286
+          };
287
+        } else {
288
+          this.$Message.error(data.msg);
289
+        }
290
+      });
291
+    },
292
+    keepAlive() {
293
+      this.$router.replace({
294
+        path: this.$route.path,
295
+        query: {
296
+          search: JSON.stringify({
297
+            classid: this.searchForm.classid
298
+          })
299
+        }
300
+      });
301
+    },
302
+    getClassAppStrategyDetail() {
303
+      this.keepAlive();
304
+      this.appStrategyInfo = {
305
+        stappid: null,
306
+        rversion: null,
307
+        name: "",
308
+        groups: []
309
+      };
310
+      stApp_detail_obj({
311
+        objectid: this.searchForm.classid || this.powerParams.objectid,
312
+        // 0公共策略 1学校 2班级
313
+        sttype: this.searchForm.classid ? 2 : 1
314
+      }).then((data) => {
315
+        if (data.code === 0) {
316
+          if (data.obj) {
317
+            this.appStrategyInfo = data.obj;
318
+          }
319
+        } else {
320
+          this.$Message.error(data.msg);
321
+        }
322
+      });
323
+    }
324
+  }
17 325
 };
18 326
 </script>
19 327
 
20
-<style lang="less" scoped></style>
328
+<style lang="less" scoped>
329
+.main_root {
330
+  display: flex;
331
+  justify-content: space-between;
332
+  align-items: center;
333
+  height: calc(100% - 10px);
334
+  border-radius: 0;
335
+  border: none;
336
+  background-color: transparent;
337
+  .main_left {
338
+    margin-right: 10px;
339
+    width: 200px;
340
+    height: 100%;
341
+    border-radius: 15px;
342
+    border: 1px solid #e9f0f9;
343
+    background-color: #fff;
344
+    overflow: auto;
345
+    .main_left_title {
346
+      margin: 10px;
347
+      padding: 20px 0;
348
+      line-height: 20px;
349
+      font-size: 16px;
350
+      text-align: center;
351
+      color: #798cb5;
352
+      border-bottom: 1px solid #e9f0f9;
353
+    }
354
+    .class_list {
355
+      max-height: calc(100% - 82px);
356
+      font-size: 14px;
357
+      line-height: 32px;
358
+      text-align: center;
359
+      overflow: auto;
360
+      .class_item {
361
+        margin: 0 10px;
362
+        border-radius: 6px;
363
+        cursor: pointer;
364
+        &:hover,
365
+        &.selceted {
366
+          font-weight: bold;
367
+          color: #339dff;
368
+          background-color: #dbeeff;
369
+        }
370
+      }
371
+    }
372
+  }
373
+  .main_right {
374
+    width: calc(100% - 210px);
375
+    height: 100%;
376
+    border-radius: 15px;
377
+    border: 1px solid #e9f0f9;
378
+    background-color: #fff;
379
+    overflow: auto;
380
+    .right_header {
381
+      display: flex;
382
+      justify-content: space-between;
383
+      align-items: center;
384
+      margin: 16px;
385
+      font-size: 16px;
386
+      .header_left {
387
+        font-weight: bold;
388
+        color: #f0153f;
389
+      }
390
+      .header_right {
391
+        display: flex;
392
+        justify-content: flex-start;
393
+        align-items: center;
394
+        > div {
395
+          margin-left: 16px;
396
+          cursor: pointer;
397
+          &:hover {
398
+            color: #339dff;
399
+          }
400
+        }
401
+      }
402
+    }
403
+  }
404
+}
405
+.strategy_item {
406
+  margin: 16px;
407
+  .my_table {
408
+    width: 100%;
409
+    empty-cells: show;
410
+    border-collapse: collapse;
411
+    table-layout: fixed;
412
+    border: 1px solid #dcdee2;
413
+    border-spacing: 0;
414
+    box-sizing: border-box;
415
+    font-size: 12px;
416
+    th {
417
+      padding: 0;
418
+      line-height: 30px;
419
+      font-weight: normal;
420
+      text-align: center;
421
+      vertical-align: middle;
422
+      white-space: nowrap;
423
+      background-color: #fff;
424
+      border: 1px solid #ced9f2;
425
+    }
426
+    td {
427
+      position: relative;
428
+      padding: 0;
429
+      line-height: 30px;
430
+      text-align: center;
431
+      vertical-align: middle;
432
+      white-space: nowrap;
433
+      border: 1px solid #ced9f2;
434
+    }
435
+  }
436
+  .table_header {
437
+    display: flex;
438
+    justify-content: space-between;
439
+    align-items: center;
440
+    padding: 0 10px;
441
+    background-color: #edf3ff;
442
+    .table_header_title {
443
+      font-size: 12px;
444
+      font-weight: bold;
445
+    }
446
+    .table_header_action {
447
+      display: flex;
448
+      justify-content: flex-start;
449
+      align-items: center;
450
+      > div {
451
+        margin-left: 4px;
452
+        padding: 0 4px;
453
+        cursor: pointer;
454
+        &:hover {
455
+          color: #339dff;
456
+          &.del {
457
+            color: #f0153f;
458
+          }
459
+        }
460
+      }
461
+    }
462
+  }
463
+  .time_list {
464
+    display: flex;
465
+    justify-content: center;
466
+    align-items: center;
467
+    flex-wrap: wrap;
468
+    > span {
469
+      margin: 4px 6px;
470
+      line-height: 1;
471
+      white-space: nowrap;
472
+    }
473
+  }
474
+  .table_app_list {
475
+    display: flex;
476
+    justify-content: flex-start;
477
+    align-items: center;
478
+    flex-wrap: wrap;
479
+    .table_app_item {
480
+      margin: 10px;
481
+      .app_top {
482
+        display: flex;
483
+        justify-content: center;
484
+        align-items: center;
485
+        margin: 0 auto;
486
+        width: 56px;
487
+        height: 56px;
488
+        border-radius: 6px;
489
+        border: 1px solid #e5e5e5;
490
+        background: #ffffff;
491
+        img {
492
+          width: 38px;
493
+          height: 38px;
494
+        }
495
+      }
496
+      .app_name {
497
+        margin-top: 10px;
498
+        max-width: 100px;
499
+        line-height: 1;
500
+        font-size: 12px;
501
+        text-align: center;
502
+        overflow: hidden;
503
+        text-overflow: ellipsis;
504
+        white-space: nowrap;
505
+      }
506
+    }
507
+  }
508
+}
509
+</style>

+ 554
- 0
src/views/schoolSection/applicationStrategy/appStrategyManageEdit.vue View File

@@ -0,0 +1,554 @@
1
+<template>
2
+  <div class="main_root">
3
+    <div class="add_strategy_info">
4
+      <div class="add_strategy_left">
5
+        <div class="name_form">
6
+          <div class="name_form_item">名称</div>
7
+          <Input
8
+            placeholder="请输入名称"
9
+            v-model="appStrategyInfo.name"
10
+          ></Input>
11
+        </div>
12
+        <div class="time_strategy">
13
+          时间策略
14
+          <div class="time_tip">
15
+            (应用列表中选中的应用只能在限制的时间内使用)
16
+          </div>
17
+        </div>
18
+        <TimeStrategy
19
+          :times="tempStrategyInfo.times"
20
+          @timesChange="timesChange"
21
+        ></TimeStrategy>
22
+        <div class="action_btns">
23
+          <Button @click="toResetStrategy()">取消</Button>
24
+          <Button type="primary" class="primary_btn" @click="toAddStrategySet()"
25
+            >添加当前设置</Button
26
+          >
27
+        </div>
28
+      </div>
29
+      <div class="add_strategy_right">
30
+        <div class="optional_applications">
31
+          <div>可选应用</div>
32
+          <div>
33
+            <Checkbox
34
+              :disabled="appList.length === 0"
35
+              :value="appAllCheck"
36
+              @on-change="appAllCheckChange"
37
+              >全选</Checkbox
38
+            >
39
+          </div>
40
+        </div>
41
+        <div class="app_list">
42
+          <div
43
+            class="app_item"
44
+            :title="appItem.appName"
45
+            v-for="appItem in appList"
46
+            :key="appItem.appid"
47
+            @click="toSelectApp(appItem.appid)"
48
+          >
49
+            <div class="app_item_top">
50
+              <img :src="$api.showImageUrl + appItem.appIcon" />
51
+            </div>
52
+            <div class="app_item_name">
53
+              {{ appItem.appName }}
54
+            </div>
55
+            <div class="app_item_check">
56
+              <Checkbox
57
+                :value="tempStrategyInfo.apps.includes(appItem.appid)"
58
+              ></Checkbox>
59
+            </div>
60
+          </div>
61
+        </div>
62
+      </div>
63
+    </div>
64
+    <div class="strategy_list_title" v-if="appStrategyInfo.groups.length > 0">
65
+      应用策略列表
66
+    </div>
67
+    <div
68
+      class="strategy_item"
69
+      v-for="(groupItem, groupIndex) in appStrategyInfo.groups"
70
+      :key="groupIndex"
71
+    >
72
+      <table class="my_table">
73
+        <tr>
74
+          <th colspan="7">
75
+            <div class="table_header">
76
+              <div class="table_header_title">应用策略{{ groupIndex + 1 }}</div>
77
+              <div class="table_header_action">
78
+                <div @click="toEditeGroupItem(groupItem, groupIndex)">编辑</div>
79
+                <div class="del" @click="toDelGroupItem(groupIndex)">删除</div>
80
+              </div>
81
+            </div>
82
+          </th>
83
+        </tr>
84
+        <tr>
85
+          <td v-for="weekItem in weekDay" :key="weekItem.value">
86
+            {{ weekItem.label }}
87
+          </td>
88
+        </tr>
89
+        <tr>
90
+          <td v-for="weekItem in weekDay" :key="weekItem.value">
91
+            <div class="time_list">
92
+              <span
93
+                v-for="(timeItem, timeIndex) in appStrategyGroupInfo[
94
+                  groupIndex
95
+                ] && appStrategyGroupInfo[groupIndex][weekItem.value]"
96
+                :key="timeIndex"
97
+                >{{ timeItem.starttime }} - {{ timeItem.stoptime }}</span
98
+              >
99
+            </div>
100
+          </td>
101
+        </tr>
102
+        <tr>
103
+          <td colspan="7">
104
+            <div class="table_app_list">
105
+              <div
106
+                class="table_app_item"
107
+                v-for="appid in groupItem.apps"
108
+                :key="appid"
109
+              >
110
+                <div class="app_top">
111
+                  <img
112
+                    v-if="appsInfo[appid]"
113
+                    :src="$api.showImageUrl + appsInfo[appid].appIcon"
114
+                  />
115
+                </div>
116
+                <div class="app_name">
117
+                  {{ appsInfo[appid] && appsInfo[appid].appName }}
118
+                </div>
119
+              </div>
120
+            </div>
121
+          </td>
122
+        </tr>
123
+      </table>
124
+    </div>
125
+    <div class="bottom_btns">
126
+      <Button @click="toGoBack()">返回</Button>
127
+      <Button type="primary" class="primary_btn" @click="toSaveAppStrategy()"
128
+        >确定</Button
129
+      >
130
+    </div>
131
+  </div>
132
+</template>
133
+
134
+<script>
135
+import { weekDay } from "@/utils";
136
+import TimeStrategy from "@/components/TimeStrategy/TimeStrategy";
137
+import { app_list_sel } from "@/api/appgroup";
138
+import { stApp_add, stApp_detail } from "@/api/stPad";
139
+export default {
140
+  components: {
141
+    TimeStrategy
142
+  },
143
+  data() {
144
+    return {
145
+      weekDay,
146
+      appList: [],
147
+      // 应用策略信息
148
+      appStrategyInfo: {
149
+        stappid: null,
150
+        rversion: null,
151
+        name: "",
152
+        // {apps[appid], times[{week, starttime, stoptime}]}
153
+        groups: []
154
+      },
155
+      // 临时保存策略
156
+      tempStrategyInfo: {
157
+        apps: [],
158
+        times: []
159
+      }
160
+    };
161
+  },
162
+  created() {
163
+    this.getAppList();
164
+    this.getAppStrategyDetail();
165
+  },
166
+  computed: {
167
+    powerParams() {
168
+      return this.$store.getters.powerParams;
169
+    },
170
+    appAllCheck() {
171
+      let allAppids = this.appList.map((appItem) => appItem.appid);
172
+      let isCheck = true;
173
+      for (const appid of allAppids) {
174
+        if (!this.tempStrategyInfo.apps.includes(appid)) {
175
+          isCheck = false;
176
+        }
177
+      }
178
+      return allAppids.length > 0 ? isCheck : false;
179
+    },
180
+    appsInfo() {
181
+      let info = {};
182
+      this.appList.forEach((item) => {
183
+        info[item.appid] = item;
184
+      });
185
+      return info;
186
+    },
187
+    appStrategyGroupInfo() {
188
+      let info = [];
189
+      this.appStrategyInfo.groups.forEach((groupItem) => {
190
+        let groupTimes = {};
191
+        groupItem.times.forEach((timeItem) => {
192
+          if (!groupTimes[timeItem.week]) {
193
+            groupTimes[timeItem.week] = [];
194
+          }
195
+          groupTimes[timeItem.week].push(timeItem);
196
+        });
197
+        info.push(groupTimes);
198
+      });
199
+      return info;
200
+    }
201
+  },
202
+  methods: {
203
+    getAppStrategyDetail() {
204
+      stApp_detail({
205
+        rtype: this.powerParams.rtype,
206
+        objectid: this.powerParams.objectid,
207
+        stappid: this.$route.query.stappid
208
+      }).then((data) => {
209
+        if (data.code === 0) {
210
+          this.appStrategyInfo.name = data.obj.name;
211
+          this.appStrategyInfo.groups = data.obj.groups.map((groupItem) => {
212
+            groupItem.apps = groupItem.apps.map((appItem) => appItem.appid);
213
+            return groupItem;
214
+          });
215
+          this.appStrategyInfo.stappid = data.obj.stappid;
216
+          this.appStrategyInfo.rversion = data.obj.rversion;
217
+        } else {
218
+          this.$Message.error(data.msg);
219
+        }
220
+      });
221
+    },
222
+    toGoBack() {
223
+      this.$router.go(-1);
224
+    },
225
+    toSaveAppStrategy() {
226
+      if (!this.appStrategyInfo.name) {
227
+        this.$Message.error("请输入名称");
228
+        return;
229
+      }
230
+      if (this.appStrategyInfo.groups.length === 0) {
231
+        this.$Message.error("请添加应用策略");
232
+        return;
233
+      }
234
+      let _groups = this.appStrategyInfo.groups.map((groupItem) => {
235
+        groupItem = JSON.parse(JSON.stringify(groupItem));
236
+        groupItem.apps = groupItem.apps.map((appid) => {
237
+          return { appid };
238
+        });
239
+        return groupItem;
240
+      });
241
+      stApp_add({
242
+        objectid: this.$route.query.classid || this.powerParams.objectid,
243
+        name: this.appStrategyInfo.name,
244
+        groups: _groups,
245
+        // 0公共策略 1学校 2班级
246
+        sttype: this.$route.query.classid ? 2 : 1
247
+      }).then((data) => {
248
+        if (data.code === 0) {
249
+          this.toGoBack();
250
+        } else {
251
+          this.$Message.error(data.msg);
252
+        }
253
+      });
254
+    },
255
+    toEditeGroupItem(groupItem, groupIndex) {
256
+      this.tempStrategyInfo = JSON.parse(JSON.stringify(groupItem));
257
+      this.appStrategyInfo.groups.splice(groupIndex, 1);
258
+    },
259
+    toDelGroupItem(groupIndex) {
260
+      this.$Modal.confirm({
261
+        title: "提示",
262
+        content: "您确定删除选中数据吗?",
263
+        onOk: () => {
264
+          this.appStrategyInfo.groups.splice(groupIndex, 1);
265
+        },
266
+        onCancel: () => {}
267
+      });
268
+    },
269
+    appAllCheckChange(selected) {
270
+      if (selected) {
271
+        this.tempStrategyInfo.apps = this.appList.map(
272
+          (appItem) => appItem.appid
273
+        );
274
+      } else {
275
+        this.tempStrategyInfo.apps = [];
276
+      }
277
+    },
278
+    toSelectApp(appid) {
279
+      if (this.tempStrategyInfo.apps.includes(appid)) {
280
+        this.tempStrategyInfo.apps = this.tempStrategyInfo.apps.filter(
281
+          (id) => id !== appid
282
+        );
283
+      } else {
284
+        this.tempStrategyInfo.apps.push(appid);
285
+      }
286
+    },
287
+    getAppList() {
288
+      app_list_sel({
289
+        rtype: this.powerParams.rtype,
290
+        objectid: this.powerParams.objectid
291
+      }).then((data) => {
292
+        if (data.code === 0) {
293
+          this.appList = data.obj;
294
+        } else {
295
+          this.appList = [];
296
+          this.$Message.error(data.msg);
297
+        }
298
+      });
299
+    },
300
+    timesChange(times) {
301
+      this.tempStrategyInfo.times = times;
302
+    },
303
+    toResetStrategy() {
304
+      this.tempStrategyInfo = {
305
+        apps: [],
306
+        times: []
307
+      };
308
+    },
309
+    toAddStrategySet() {
310
+      let _tempStrategyInfo = JSON.parse(JSON.stringify(this.tempStrategyInfo));
311
+      if (_tempStrategyInfo.times.length === 0) {
312
+        this.$Message.error("请选择时间范围");
313
+        return;
314
+      }
315
+      if (_tempStrategyInfo.apps.length === 0) {
316
+        this.$Message.error("请选择应用");
317
+        return;
318
+      }
319
+      this.appStrategyInfo.groups.push(_tempStrategyInfo);
320
+      this.toResetStrategy();
321
+    }
322
+  }
323
+};
324
+</script>
325
+
326
+<style lang="less" scoped>
327
+.add_strategy_info {
328
+  display: flex;
329
+  justify-content: space-between;
330
+  margin: 16px 16px 0;
331
+  .add_strategy_left {
332
+    width: calc(50% - 20px);
333
+    .name_form {
334
+      display: flex;
335
+      justify-content: flex-start;
336
+      align-items: center;
337
+      margin-bottom: 16px;
338
+      font-size: 16px;
339
+      font-weight: bold;
340
+      .name_form_item {
341
+        margin-right: 16px;
342
+        white-space: nowrap;
343
+      }
344
+    }
345
+    .time_strategy {
346
+      display: flex;
347
+      justify-content: flex-start;
348
+      align-items: center;
349
+      margin-bottom: 16px;
350
+      font-size: 16px;
351
+      font-weight: bold;
352
+      .time_tip {
353
+        margin-left: 10px;
354
+        font-size: 12px;
355
+        font-weight: normal;
356
+        color: #f0153f;
357
+      }
358
+    }
359
+    .action_btns {
360
+      display: flex;
361
+      justify-content: flex-start;
362
+      align-items: center;
363
+      margin-top: 40px;
364
+      .primary_btn {
365
+        margin-left: 16px;
366
+      }
367
+    }
368
+  }
369
+  .add_strategy_right {
370
+    width: 50%;
371
+    // max-height: 400px;
372
+    overflow: auto;
373
+    .optional_applications {
374
+      display: flex;
375
+      justify-content: space-between;
376
+      align-items: center;
377
+      font-size: 16px;
378
+      line-height: 30px;
379
+      font-weight: bold;
380
+    }
381
+    .app_list {
382
+      display: flex;
383
+      justify-content: flex-start;
384
+      flex-wrap: wrap;
385
+      width: 100%;
386
+      // max-height: calc(100% - 33px);
387
+      overflow: auto;
388
+      .app_item {
389
+        position: relative;
390
+        margin: 8px;
391
+        width: 100px;
392
+        height: 100px;
393
+        border-radius: 10px;
394
+        border: 1px solid #798cb51a;
395
+        background: #ffffff;
396
+        cursor: pointer;
397
+        &:hover {
398
+          box-shadow: 4px 4px 8px 0 #339dff26;
399
+        }
400
+        .app_item_top {
401
+          display: flex;
402
+          justify-content: center;
403
+          align-items: center;
404
+          margin-top: 10px;
405
+          padding-top: 10px;
406
+          height: calc(100% - 44px);
407
+          img {
408
+            width: 38px;
409
+            height: 38px;
410
+          }
411
+        }
412
+        .app_item_name {
413
+          margin: 10px 0;
414
+          line-height: 1;
415
+          font-size: 14px;
416
+          text-align: center;
417
+          overflow: hidden;
418
+          text-overflow: ellipsis;
419
+          white-space: nowrap;
420
+        }
421
+        .app_item_check {
422
+          position: absolute;
423
+          right: 8px;
424
+          top: 8px;
425
+          /deep/.ivu-checkbox-wrapper {
426
+            margin-right: 0;
427
+            .ivu-checkbox-inner {
428
+              border-radius: 50%;
429
+            }
430
+          }
431
+        }
432
+      }
433
+    }
434
+  }
435
+}
436
+.strategy_list_title {
437
+  margin: 16px;
438
+  font-size: 16px;
439
+  font-weight: bold;
440
+}
441
+.strategy_item {
442
+  margin: 16px;
443
+  .my_table {
444
+    width: 100%;
445
+    empty-cells: show;
446
+    border-collapse: collapse;
447
+    table-layout: fixed;
448
+    border: 1px solid #dcdee2;
449
+    border-spacing: 0;
450
+    box-sizing: border-box;
451
+    font-size: 12px;
452
+    th {
453
+      padding: 0;
454
+      line-height: 30px;
455
+      font-weight: normal;
456
+      text-align: center;
457
+      vertical-align: middle;
458
+      white-space: nowrap;
459
+      background-color: #fff;
460
+      border: 1px solid #ced9f2;
461
+    }
462
+    td {
463
+      position: relative;
464
+      padding: 0;
465
+      line-height: 30px;
466
+      text-align: center;
467
+      vertical-align: middle;
468
+      white-space: nowrap;
469
+      border: 1px solid #ced9f2;
470
+    }
471
+  }
472
+  .table_header {
473
+    display: flex;
474
+    justify-content: space-between;
475
+    align-items: center;
476
+    padding: 0 10px;
477
+    background-color: #edf3ff;
478
+    .table_header_title {
479
+      font-size: 12px;
480
+      font-weight: bold;
481
+    }
482
+    .table_header_action {
483
+      display: flex;
484
+      justify-content: flex-start;
485
+      align-items: center;
486
+      > div {
487
+        margin-left: 4px;
488
+        padding: 0 4px;
489
+        cursor: pointer;
490
+        &:hover {
491
+          color: #339dff;
492
+          &.del {
493
+            color: #f0153f;
494
+          }
495
+        }
496
+      }
497
+    }
498
+  }
499
+  .time_list {
500
+    display: flex;
501
+    justify-content: center;
502
+    align-items: center;
503
+    flex-wrap: wrap;
504
+    > span {
505
+      margin: 4px 6px;
506
+      line-height: 1;
507
+      white-space: nowrap;
508
+    }
509
+  }
510
+  .table_app_list {
511
+    display: flex;
512
+    justify-content: flex-start;
513
+    align-items: center;
514
+    flex-wrap: wrap;
515
+    .table_app_item {
516
+      margin: 10px;
517
+      .app_top {
518
+        display: flex;
519
+        justify-content: center;
520
+        align-items: center;
521
+        margin: 0 auto;
522
+        width: 56px;
523
+        height: 56px;
524
+        border-radius: 6px;
525
+        border: 1px solid #e5e5e5;
526
+        background: #ffffff;
527
+        img {
528
+          width: 38px;
529
+          height: 38px;
530
+        }
531
+      }
532
+      .app_name {
533
+        margin-top: 10px;
534
+        max-width: 100px;
535
+        line-height: 1;
536
+        font-size: 12px;
537
+        text-align: center;
538
+        overflow: hidden;
539
+        text-overflow: ellipsis;
540
+        white-space: nowrap;
541
+      }
542
+    }
543
+  }
544
+}
545
+.bottom_btns {
546
+  display: flex;
547
+  justify-content: flex-end;
548
+  align-items: center;
549
+  margin: 16px;
550
+  .primary_btn {
551
+    margin-left: 16px;
552
+  }
553
+}
554
+</style>

+ 3
- 3
src/views/schoolSection/applicationStrategy/appStrategyTemplate.vue View File

@@ -274,9 +274,9 @@ export default {
274 274
         return;
275 275
       }
276 276
       stApp_add_empower({
277
-        rtype: this.powerParams.rtype,
278
-        objectid: this.powerParams.objectid,
279
-        schoolid: this.powerParams.objectid,
277
+        // rtype: this.powerParams.rtype,
278
+        // objectid: this.powerParams.objectid,
279
+        // schoolid: this.powerParams.objectid,
280 280
         stappid: this.empowerInfo.stappid,
281 281
         classids: this.empowerInfo.classids
282 282
       }).then((data) => {

Loading…
Cancel
Save