Browse Source

学校-应用策略

gzb
wangzhonglu 9 months ago
parent
commit
7d3cf410b3

+ 6
- 2
src/api/appgroup.js View File

@@ -30,7 +30,10 @@ export const appgroup_list_app = (data) =>
30 30
  * 5.2.1 应用-列表
31 31
  */
32 32
 export const app_list = (data) => setRequest("app/list", data);
33
-
33
+/**
34
+ * 5.2.1.1 应用-选择列表
35
+ */
36
+export const app_list_sel = (data) => setRequest("app/list_sel", data);
34 37
 /**
35 38
  * 5.2.2 应用-添加
36 39
  */
@@ -80,7 +83,8 @@ export const app_edit_enable = (data) => setRequest("app/edit_enable", data);
80 83
 /**
81 84
  * 5.2.11 应用-禁用
82 85
  */
83
-export const app_edit_unenable = (data) => setRequest("app/edit_unenable", data);
86
+export const app_edit_unenable = (data) =>
87
+  setRequest("app/edit_unenable", data);
84 88
 /**
85 89
  * 5.3 设备-列表(分组下设备)
86 90
  */

+ 258
- 13
src/views/schoolSection/applicationStrategy/appStrategyTemplateAdd.vue View File

@@ -4,7 +4,10 @@
4 4
       <div class="add_strategy_left">
5 5
         <div class="name_form">
6 6
           <div class="name_form_item">名称</div>
7
-          <Input placeholder="请输入名称"></Input>
7
+          <Input
8
+            placeholder="请输入名称"
9
+            v-model="appStrategyInfo.name"
10
+          ></Input>
8 11
         </div>
9 12
         <div class="time_strategy">
10 13
           时间策略
@@ -26,28 +29,94 @@
26 29
       <div class="add_strategy_right">
27 30
         <div class="optional_applications">
28 31
           <div>可选应用</div>
29
-          <div><Checkbox>全选</Checkbox></div>
32
+          <div>
33
+            <Checkbox
34
+              :disabled="appList.length === 0"
35
+              :value="appAllCheck"
36
+              @on-change="appAllCheckChange"
37
+              >全选</Checkbox
38
+            >
39
+          </div>
30 40
         </div>
31 41
         <div class="app_list">
32
-          <div class="app_item">
33
-            <div><img src="" /></div>
34
-            <div>洋葱学院</div>
35
-            <div><Checkbox></Checkbox></div>
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>
36 60
           </div>
37 61
         </div>
38 62
       </div>
39 63
     </div>
64
+    <div class="strategy_list_title">应用策略列表</div>
65
+    <div
66
+      class="strategy_item"
67
+      v-for="(groupItem, groupIndex) in appStrategyInfo.groups"
68
+      :key="groupIndex"
69
+    >
70
+      <table class="my_table">
71
+        <tr>
72
+          <th colspan="7">
73
+            <div class="table_header">
74
+              <div class="table_header_title">应用策略列表</div>
75
+              <div class="table_header_action">
76
+                <div>编辑</div>
77
+                <div class="del">删除</div>
78
+              </div>
79
+            </div>
80
+          </th>
81
+        </tr>
82
+        <tr>
83
+          <td v-for="weekItem in weekDay" :key="weekItem.value">
84
+            {{ weekItem.label }}
85
+          </td>
86
+        </tr>
87
+        <tr>
88
+          <td colspan="7">
89
+            <div class="table_app_list">
90
+              <div
91
+                class="table_app_item"
92
+                v-for="appItem in groupItem.apps"
93
+                :key="appItem.appid"
94
+              >
95
+                <div class="app_top"></div>
96
+                <div class="app_name">
97
+                  {{ appsInfo[appItem.appid].appName }}
98
+                </div>
99
+              </div>
100
+            </div>
101
+          </td>
102
+        </tr>
103
+      </table>
104
+    </div>
40 105
   </div>
41 106
 </template>
42 107
 
43 108
 <script>
109
+import { weekDay } from "@/utils";
44 110
 import TimeStrategy from "@/components/TimeStrategy/TimeStrategy";
111
+import { app_list_sel } from "@/api/appgroup";
45 112
 export default {
46 113
   components: {
47 114
     TimeStrategy
48 115
   },
49 116
   data() {
50 117
     return {
118
+      weekDay,
119
+      appList: [],
51 120
       // 应用策略信息
52 121
       appStrategyInfo: {
53 122
         name: "",
@@ -61,13 +130,63 @@ export default {
61 130
       }
62 131
     };
63 132
   },
64
-  created() {},
133
+  created() {
134
+    this.getAppList();
135
+  },
65 136
   computed: {
66 137
     powerParams() {
67 138
       return this.$store.getters.powerParams;
139
+    },
140
+    appAllCheck() {
141
+      let allAppids = this.appList.map((appItem) => appItem.appid);
142
+      let isCheck = true;
143
+      for (const appid of allAppids) {
144
+        if (!this.tempStrategyInfo.apps.includes(appid)) {
145
+          isCheck = false;
146
+        }
147
+      }
148
+      return allAppids.length > 0 ? isCheck : false;
149
+    },
150
+    appsInfo() {
151
+      let info = {};
152
+      this.appList.forEach((item) => {
153
+        info[item.appid] = item;
154
+      });
155
+      return info;
68 156
     }
69 157
   },
70 158
   methods: {
159
+    appAllCheckChange(selected) {
160
+      if (selected) {
161
+        this.tempStrategyInfo.apps = this.appList.map(
162
+          (appItem) => appItem.appid
163
+        );
164
+      } else {
165
+        this.tempStrategyInfo.apps = [];
166
+      }
167
+    },
168
+    toSelectApp(appid) {
169
+      if (this.tempStrategyInfo.apps.includes(appid)) {
170
+        this.tempStrategyInfo.apps = this.tempStrategyInfo.apps.filter(
171
+          (id) => id !== appid
172
+        );
173
+      } else {
174
+        this.tempStrategyInfo.apps.push(appid);
175
+      }
176
+    },
177
+    getAppList() {
178
+      app_list_sel({
179
+        rtype: this.powerParams.rtype,
180
+        objectid: this.powerParams.objectid
181
+      }).then((data) => {
182
+        if (data.code === 0) {
183
+          this.appList = data.obj;
184
+        } else {
185
+          this.appList = [];
186
+          this.$Message.error(data.msg);
187
+        }
188
+      });
189
+    },
71 190
     timesChange(times) {
72 191
       this.tempStrategyInfo.times = times;
73 192
     },
@@ -100,7 +219,6 @@ export default {
100 219
   margin: 16px 16px 0;
101 220
   .add_strategy_left {
102 221
     width: calc(50% - 20px);
103
-    height: 500px;
104 222
     .name_form {
105 223
       display: flex;
106 224
       justify-content: flex-start;
@@ -139,7 +257,8 @@ export default {
139 257
   }
140 258
   .add_strategy_right {
141 259
     width: 50%;
142
-    height: 500px;
260
+    // max-height: 400px;
261
+    overflow: auto;
143 262
     .optional_applications {
144 263
       display: flex;
145 264
       justify-content: space-between;
@@ -153,17 +272,143 @@ export default {
153 272
       justify-content: flex-start;
154 273
       flex-wrap: wrap;
155 274
       width: 100%;
156
-      min-height: calc(100% - 33px);
275
+      // max-height: calc(100% - 33px);
157 276
       overflow: auto;
158 277
       .app_item {
159
-        margin-top: 16px;
160
-        margin-right: 16px;
278
+        position: relative;
279
+        margin: 8px;
161 280
         width: 100px;
162
-        height: 110px;
281
+        height: 100px;
163 282
         border-radius: 10px;
164 283
         border: 1px solid #798cb51a;
165 284
         background: #ffffff;
166 285
         cursor: pointer;
286
+        &:hover {
287
+          box-shadow: 4px 4px 8px 0 #339dff26;
288
+        }
289
+        .app_item_top {
290
+          display: flex;
291
+          justify-content: center;
292
+          align-items: center;
293
+          margin-top: 10px;
294
+          padding-top: 10px;
295
+          height: calc(100% - 44px);
296
+          img {
297
+            width: 38px;
298
+            height: 38px;
299
+          }
300
+        }
301
+        .app_item_name {
302
+          margin: 10px 0;
303
+          line-height: 1;
304
+          font-size: 14px;
305
+          text-align: center;
306
+          overflow: hidden;
307
+          text-overflow: ellipsis;
308
+          white-space: nowrap;
309
+        }
310
+        .app_item_check {
311
+          position: absolute;
312
+          right: 8px;
313
+          top: 8px;
314
+          /deep/.ivu-checkbox-wrapper {
315
+            margin-right: 0;
316
+            .ivu-checkbox-inner {
317
+              border-radius: 50%;
318
+            }
319
+          }
320
+        }
321
+      }
322
+    }
323
+  }
324
+}
325
+.strategy_list_title {
326
+  margin: 16px;
327
+  font-size: 16px;
328
+  font-weight: bold;
329
+}
330
+.strategy_item {
331
+  margin: 16px;
332
+  .my_table {
333
+    width: 100%;
334
+    empty-cells: show;
335
+    border-collapse: collapse;
336
+    table-layout: fixed;
337
+    border: 1px solid #dcdee2;
338
+    border-spacing: 0;
339
+    box-sizing: border-box;
340
+    font-size: 12px;
341
+    th {
342
+      padding: 0;
343
+      line-height: 30px;
344
+      font-weight: normal;
345
+      text-align: center;
346
+      vertical-align: middle;
347
+      white-space: nowrap;
348
+      background-color: #fff;
349
+      border: 1px solid #ced9f2;
350
+    }
351
+    td {
352
+      position: relative;
353
+      padding: 0;
354
+      line-height: 30px;
355
+      text-align: center;
356
+      vertical-align: middle;
357
+      white-space: nowrap;
358
+      border: 1px solid #ced9f2;
359
+    }
360
+  }
361
+  .table_header {
362
+    display: flex;
363
+    justify-content: space-between;
364
+    align-items: center;
365
+    padding: 0 10px;
366
+    background-color: #edf3ff;
367
+    .table_header_title {
368
+      font-size: 12px;
369
+      font-weight: bold;
370
+    }
371
+    .table_header_action {
372
+      display: flex;
373
+      justify-content: flex-start;
374
+      align-items: center;
375
+      > div {
376
+        margin-left: 4px;
377
+        padding: 0 4px;
378
+        cursor: pointer;
379
+        &:hover {
380
+          color: #339dff;
381
+        }
382
+        &.del {
383
+          color: #f0153f;
384
+        }
385
+      }
386
+    }
387
+  }
388
+  .table_app_list {
389
+    display: flex;
390
+    justify-content: flex-start;
391
+    align-items: center;
392
+    flex-wrap: wrap;
393
+    .table_app_item {
394
+      margin: 10px;
395
+      .app_top {
396
+        margin: 0 auto;
397
+        width: 56px;
398
+        height: 56px;
399
+        border-radius: 6px;
400
+        border: 1px solid #e5e5e5;
401
+        background: #ffffff;
402
+      }
403
+      .app_name {
404
+        margin-top: 10px;
405
+        max-width: 100px;
406
+        line-height: 1;
407
+        font-size: 14px;
408
+        text-align: center;
409
+        overflow: hidden;
410
+        text-overflow: ellipsis;
411
+        white-space: nowrap;
167 412
       }
168 413
     }
169 414
   }

Loading…
Cancel
Save