Browse Source

设置壁纸获取设备型号

gzb
guozhongbo 9 months ago
parent
commit
89bb67a03a

+ 197
- 89
src/views/regionSection/setting/wallpaper.vue View File

23
             <img v-if="row.hpath" :src="$api.showImageUrl + row.hpath" />
23
             <img v-if="row.hpath" :src="$api.showImageUrl + row.hpath" />
24
           </div>
24
           </div>
25
         </template>
25
         </template>
26
+        <template slot-scope="{ row }" slot="vpath">
27
+          <div class="hpath">
28
+            <img v-if="row.vpath" :src="$api.showImageUrl + row.vpath" />
29
+          </div>
30
+        </template>
26
         <template slot-scope="{ row }" slot="actionSlot">
31
         <template slot-scope="{ row }" slot="actionSlot">
27
           <div class="action_list">
32
           <div class="action_list">
28
             <div @click="toView(row)">查看</div>
33
             <div @click="toView(row)">查看</div>
66
             placeholder="请输入壁纸名称"
71
             placeholder="请输入壁纸名称"
67
           ></Input>
72
           ></Input>
68
         </FormItem>
73
         </FormItem>
69
-        <FormItem label="壁纸" style="width: 100%">
70
-          <div class="up">
71
-            <Upload
72
-              class="Upload"
73
-              action
74
-              :show-upload-list="false"
75
-              :before-upload="
76
-                (file) => {
77
-                  upLoad(file);
78
-                  return false;
79
-                }
80
-              "
81
-              accept=".png,.jpeg,.jpg,.gif"
82
-            >
83
-              <div v-if="wallpaperInfo.hpath" class="hpath">
84
-                <img :src="$api.showImageUrl + wallpaperInfo.hpath" />
85
-              </div>
86
-              <div v-else class="icon">
87
-                <Icon type="ios-cloud-upload-outline" size="42"></Icon>
88
-                <div>横屏壁纸</div>
89
-              </div>
90
-            </Upload>
91
-            <span>支持图片格式:jpg、jgeg、gif、png</span>
74
+        <FormItem label="壁纸" class="require" style="width: 100%">
75
+          <div class="wallpaper_upload_box">
76
+            <div class="wallpaper_h">
77
+              <Upload
78
+                action
79
+                :show-upload-list="false"
80
+                class="wallpaper_upload"
81
+                :before-upload="
82
+                  (file) => {
83
+                    upLoad(file, 1);
84
+                    return false;
85
+                  }
86
+                "
87
+                accept=".png,.jpeg,.jpg,.gif"
88
+              >
89
+                <div class="wallpaper_img_box" v-if="wallpaperInfo.hpath">
90
+                  <img :src="$api.showImageUrl + wallpaperInfo.hpath" />
91
+                </div>
92
+                <div v-else class="upload_tip">
93
+                  <div>
94
+                    <Icon type="ios-cloud-upload-outline" size="42"></Icon>
95
+                    <div>横屏壁纸</div>
96
+                  </div>
97
+                </div>
98
+              </Upload>
99
+            </div>
100
+            <div class="wallpaper_v">
101
+              <Upload
102
+                action
103
+                :show-upload-list="false"
104
+                class="wallpaper_upload"
105
+                :before-upload="
106
+                  (file) => {
107
+                    upLoad(file, 2);
108
+                    return false;
109
+                  }
110
+                "
111
+                accept=".png,.jpeg,.jpg,.gif"
112
+              >
113
+                <div class="wallpaper_img_box" v-if="wallpaperInfo.vpath">
114
+                  <img :src="$api.showImageUrl + wallpaperInfo.vpath" />
115
+                </div>
116
+                <div v-else class="upload_tip">
117
+                  <div>
118
+                    <Icon type="ios-cloud-upload-outline" size="42"></Icon>
119
+                    <div>竖屏壁纸</div>
120
+                  </div>
121
+                </div>
122
+              </Upload>
123
+            </div>
124
+            <div class="wallpaper_tip">
125
+              <div>支持格式:jpg、jpeg、gif、png</div>
126
+              <div>最大限制:2MB</div>
127
+            </div>
92
           </div>
128
           </div>
93
         </FormItem>
129
         </FormItem>
94
         <FormItem label="适配类型" class="require" style="width: 100%">
130
         <FormItem label="适配类型" class="require" style="width: 100%">
121
       <div class="view_titles">{{ viewInfo.wname }}</div>
157
       <div class="view_titles">{{ viewInfo.wname }}</div>
122
       <div class="view_content">
158
       <div class="view_content">
123
         <div class="view_title">壁纸效果</div>
159
         <div class="view_title">壁纸效果</div>
124
-        <div class="hpath">
125
-          <img
126
-            v-if="viewInfo.hpath"
127
-            :src="$api.showImageUrl + viewInfo.hpath"
128
-          />
160
+        <div class="view_wallpaper_box">
161
+          <div class="view_img_box h" v-if="viewInfo.hpath">
162
+            <img :src="$api.showImageUrl + viewInfo.hpath" />
163
+          </div>
164
+          <div class="view_img_box v" v-if="viewInfo.vpath">
165
+            <img :src="$api.showImageUrl + viewInfo.vpath" />
166
+          </div>
129
         </div>
167
         </div>
130
       </div>
168
       </div>
131
       <div class="view_content" style="margin-top: 20px">
169
       <div class="view_content" style="margin-top: 20px">
169
   wallpaper_list_device,
207
   wallpaper_list_device,
170
   wallpaper_list_devicewp
208
   wallpaper_list_devicewp
171
 } from "@/api/setting";
209
 } from "@/api/setting";
172
-import { device_list } from "@/api/appgroup";
173
 export default {
210
 export default {
174
   components: {
211
   components: {
175
     CheckboxDevice
212
     CheckboxDevice
184
         list: [],
221
         list: [],
185
         total: 0
222
         total: 0
186
       },
223
       },
187
-      // 新建
224
+      // 新建/编辑
188
       wallpaperInfo: {
225
       wallpaperInfo: {
189
         show: false,
226
         show: false,
190
         id: null,
227
         id: null,
191
         wname: "",
228
         wname: "",
192
         hpath: "",
229
         hpath: "",
230
+        vpath: "",
193
         wlevel: "",
231
         wlevel: "",
194
         objectid: "",
232
         objectid: "",
195
         deviceids: []
233
         deviceids: []
196
       },
234
       },
197
-      // 编辑
198
-      modifyRegion: {
199
-        show: false,
200
-        regionid: null,
201
-        name: "",
202
-        regionCode: "",
203
-        comm: "",
204
-        rversion: null
205
-      },
206
       // 查看
235
       // 查看
207
       viewInfo: {
236
       viewInfo: {
208
         show: false,
237
         show: false,
240
           slot: "hpath",
269
           slot: "hpath",
241
           align: "center"
270
           align: "center"
242
         },
271
         },
272
+        {
273
+          title: "竖屏壁纸",
274
+          slot: "vpath",
275
+          align: "center"
276
+        },
243
         {
277
         {
244
           title: "壁纸名称",
278
           title: "壁纸名称",
245
           key: "wname",
279
           key: "wname",
295
         this.$Message.error(res.msg);
329
         this.$Message.error(res.msg);
296
       }
330
       }
297
     },
331
     },
298
-    upLoad(file) {
332
+    upLoad(file, type) {
333
+      //type 1横屏 2竖屏
299
       let str = file.name.split(".");
334
       let str = file.name.split(".");
335
+      let size = file.size / 1024 / 1024;
300
       let suffix = str[str.length - 1];
336
       let suffix = str[str.length - 1];
301
       suffix = suffix.toLowerCase();
337
       suffix = suffix.toLowerCase();
302
       if (suffix !== "png" && suffix !== "jpeg" && suffix !== "jpg") {
338
       if (suffix !== "png" && suffix !== "jpeg" && suffix !== "jpg") {
303
         this.$Message.warning("请上传png、jpeg、jpg类型的文件");
339
         this.$Message.warning("请上传png、jpeg、jpg类型的文件");
304
         return false;
340
         return false;
305
       }
341
       }
342
+      if (size > 2) {
343
+        this.$Message.error("图片太大,不能超过2M!");
344
+        return false;
345
+      }
306
       let formData = new FormData();
346
       let formData = new FormData();
307
       formData.append("file", file);
347
       formData.append("file", file);
308
-      formData.append("savefolder", "app");
348
+      formData.append("savefolder", "wallpaper");
309
       formData.append("isrename", "1");
349
       formData.append("isrename", "1");
310
       let Url = this.$api.baseImageUrl + "up/upfile";
350
       let Url = this.$api.baseImageUrl + "up/upfile";
311
       this.showLoading = true;
351
       this.showLoading = true;
316
         .then((res) => {
356
         .then((res) => {
317
           this.showLoading = false;
357
           this.showLoading = false;
318
           if (res.data.code === 0) {
358
           if (res.data.code === 0) {
319
-            this.wallpaperInfo.hpath = res.data.obj;
359
+            if (type === 1) {
360
+              this.wallpaperInfo.hpath = res.data.obj;
361
+            } else {
362
+              this.wallpaperInfo.vpath = res.data.obj;
363
+            }
320
             this.$Message.success(res.data.msg);
364
             this.$Message.success(res.data.msg);
321
           } else {
365
           } else {
322
             this.$Message.error(res.data.msg);
366
             this.$Message.error(res.data.msg);
324
         })
368
         })
325
         .catch(() => {
369
         .catch(() => {
326
           this.showLoading = false;
370
           this.showLoading = false;
327
-          this.$Message.error("图片上传失败");
371
+          this.$Message.error("壁纸上传失败");
328
         });
372
         });
329
     },
373
     },
330
     // 搜索
374
     // 搜索
377
             id: null,
421
             id: null,
378
             wname: "",
422
             wname: "",
379
             hpath: "",
423
             hpath: "",
424
+            vpath: "",
380
             wlevel: "",
425
             wlevel: "",
381
             objectid: "",
426
             objectid: "",
382
             deviceids: []
427
             deviceids: []
401
             this.$Message.error("请选择设备!");
446
             this.$Message.error("请选择设备!");
402
             return;
447
             return;
403
           }
448
           }
404
-          if (!this.wallpaperInfo.hpath) {
405
-            this.$Message.error("请上传横屏壁纸!");
449
+          if (!this.wallpaperInfo.hpath && !this.wallpaperInfo.vpath) {
450
+            this.$Message.error("请上传壁纸!");
406
             return;
451
             return;
407
           }
452
           }
408
           let api = this.wallpaperInfo.wallpaperid
453
           let api = this.wallpaperInfo.wallpaperid
411
           let form = {
456
           let form = {
412
             wname: this.wallpaperInfo.wname,
457
             wname: this.wallpaperInfo.wname,
413
             hpath: this.wallpaperInfo.hpath,
458
             hpath: this.wallpaperInfo.hpath,
459
+            vpath: this.wallpaperInfo.vpath,
414
             wlevel: 2,
460
             wlevel: 2,
415
             rtype: this.powerParams.rtype,
461
             rtype: this.powerParams.rtype,
416
             objectid: this.powerParams.objectid,
462
             objectid: this.powerParams.objectid,
426
             this.showLoading = false;
472
             this.showLoading = false;
427
             if (data.code === 0) {
473
             if (data.code === 0) {
428
               this.wallpaperInfo.show = false;
474
               this.wallpaperInfo.show = false;
475
+              this.init();
429
               this.searchList();
476
               this.searchList();
430
               this.$Message.success(data.msg);
477
               this.$Message.success(data.msg);
431
             } else {
478
             } else {
449
             show: true,
496
             show: true,
450
             wname: data.obj.wname,
497
             wname: data.obj.wname,
451
             hpath: data.obj.hpath,
498
             hpath: data.obj.hpath,
499
+            vpath: data.obj.vpath,
452
             devices: data.obj.devices
500
             devices: data.obj.devices
453
           };
501
           };
454
         } else {
502
         } else {
483
           wallpaperid: res.obj.wallpaperid,
531
           wallpaperid: res.obj.wallpaperid,
484
           wname: res.obj.wname,
532
           wname: res.obj.wname,
485
           hpath: res.obj.hpath,
533
           hpath: res.obj.hpath,
534
+          vpath: res.obj.vpath,
486
           wlevel: res.obj.wlevel,
535
           wlevel: res.obj.wlevel,
487
           objectid: res.obj.objectid,
536
           objectid: res.obj.objectid,
488
           deviceids: res.obj.devices,
537
           deviceids: res.obj.devices,
556
       flex: none;
605
       flex: none;
557
       margin: 0 10px;
606
       margin: 0 10px;
558
     }
607
     }
559
-    .hpath {
560
-      width: 180px;
561
-      height: 120px;
562
-      border-radius: 8px;
563
-      overflow: hidden;
564
-      border: 3px solid #333333;
565
-      background-color: #f0f6fc;
566
-      img {
567
-        width: 100%;
568
-        height: 100%;
569
-        object-fit: cover;
608
+    .view_wallpaper_box {
609
+      display: flex;
610
+      justify-content: flex-start;
611
+      align-items: flex-end;
612
+      .view_img_box {
613
+        position: relative;
614
+        margin-right: 20px;
615
+        border-radius: 6px;
616
+        border: 5px solid #333;
617
+        background: #f0f6fc;
618
+        &.h {
619
+          width: 180px;
620
+          height: 120px;
621
+          img {
622
+            width: 100%;
623
+            height: 100%;
624
+          }
625
+        }
626
+        &.v {
627
+          width: 120px;
628
+          height: 180px;
629
+          img {
630
+            width: 100%;
631
+            height: 100%;
632
+          }
633
+        }
570
       }
634
       }
571
     }
635
     }
572
     .view_devices {
636
     .view_devices {
590
 
654
 
591
 .table_wrap {
655
 .table_wrap {
592
   .hpath {
656
   .hpath {
593
-    width: 100px;
594
-    height: 60px;
657
+    max-width: 100px;
658
+    max-height: 60px;
595
     margin: 10px auto;
659
     margin: 10px auto;
596
     img {
660
     img {
597
-      width: 100%;
598
-      height: 100%;
599
-      object-fit: cover;
661
+      max-width: 100px;
662
+      max-height: 60px;
600
     }
663
     }
601
   }
664
   }
602
 }
665
 }
603
-.up {
666
+.wallpaper_upload_box {
604
   display: flex;
667
   display: flex;
605
-  .Upload {
606
-    width: 180px;
607
-    height: 120px;
608
-    border-radius: 8px;
609
-    border: 3px solid #333333;
610
-    background-color: #f0f6fc;
611
-    display: flex;
612
-    align-items: center;
613
-    justify-content: center;
614
-    cursor: pointer;
615
-    .icon {
616
-      color: #b8c2d9;
617
-      text-align: center;
618
-    }
668
+  justify-content: flex-start;
669
+  align-items: flex-start;
670
+  .wallpaper_h {
671
+    position: relative;
672
+    margin-top: 60px;
673
+    margin-right: 50px;
674
+    width: 190px;
675
+    height: 130px;
676
+    border-radius: 6px;
677
+    opacity: 1;
678
+    border: 5px solid #333;
679
+    background: #f0f6fc;
619
     &:hover {
680
     &:hover {
620
       background: #eaf5ff;
681
       background: #eaf5ff;
621
-      .icon {
622
-        color: #339cff;
682
+      .upload_tip {
683
+        color: #339cff !important;
623
       }
684
       }
624
     }
685
     }
625
-    .hpath {
686
+    .wallpaper_upload {
626
       width: 180px;
687
       width: 180px;
627
       height: 120px;
688
       height: 120px;
628
-      border-radius: 8px;
629
-      overflow: hidden;
630
-      padding: 3px;
631
-      img {
632
-        width: 100%;
633
-        height: 100%;
634
-        object-fit: cover;
689
+      cursor: pointer;
690
+      .wallpaper_img_box {
691
+        width: 180px;
692
+        height: 120px;
693
+        img {
694
+          width: 100%;
695
+          height: 100%;
696
+        }
697
+      }
698
+      .upload_tip {
699
+        display: flex;
700
+        justify-content: center;
701
+        align-items: center;
702
+        width: 180px;
703
+        height: 120px;
704
+        text-align: center;
705
+        color: #b8c2d9;
635
       }
706
       }
636
     }
707
     }
637
   }
708
   }
638
-  span {
639
-    margin-left: 20px;
640
-    color: #7c8db5;
709
+  .wallpaper_v {
710
+    position: relative;
711
+    margin-right: 20px;
712
+    width: 130px;
713
+    height: 190px;
714
+    border-radius: 6px;
715
+    opacity: 1;
716
+    border: 5px solid #333;
717
+    background: #f0f6fc;
718
+    &:hover {
719
+      background: #eaf5ff;
720
+      .upload_tip {
721
+        color: #339cff !important;
722
+      }
723
+    }
724
+    .wallpaper_upload {
725
+      width: 120px;
726
+      height: 180px;
727
+      cursor: pointer;
728
+      .wallpaper_img_box {
729
+        width: 120px;
730
+        height: 180px;
731
+        img {
732
+          width: 100%;
733
+          height: 100%;
734
+        }
735
+      }
736
+      .upload_tip {
737
+        display: flex;
738
+        justify-content: center;
739
+        align-items: center;
740
+        width: 120px;
741
+        height: 180px;
742
+        text-align: center;
743
+        color: #b8c2d9;
744
+      }
745
+    }
746
+  }
747
+  .wallpaper_tip {
641
     font-size: 16px;
748
     font-size: 16px;
749
+    color: #7c8db5;
642
   }
750
   }
643
 }
751
 }
644
 </style>
752
 </style>

+ 63
- 24
src/views/schoolSection/setting/wallpaper.vue View File

8
         @on-search="searchList()"
8
         @on-search="searchList()"
9
         style="width: 150px"
9
         style="width: 150px"
10
       />
10
       />
11
-      <Button type="primary" class="primary_btn" @click="toAdd()">新建</Button>
11
+      <Button
12
+        type="primary"
13
+        v-if="add_has === 1"
14
+        class="primary_btn"
15
+        @click="toAdd()"
16
+        >新建</Button
17
+      >
12
     </div>
18
     </div>
13
     <div class="table_wrap">
19
     <div class="table_wrap">
14
       <Table :columns="columns" :data="searchForm.list">
20
       <Table :columns="columns" :data="searchForm.list">
283
   wallpaper_add,
289
   wallpaper_add,
284
   wallpaper_edit,
290
   wallpaper_edit,
285
   wallpaper_detail,
291
   wallpaper_detail,
286
-  wallpaper_delete
292
+  wallpaper_delete,
293
+  wallpaper_list_device,
294
+  wallpaper_list_devicewp,
295
+  wallpaper_add_has
287
 } from "@/api/setting";
296
 } from "@/api/setting";
288
 import { device_list } from "@/api/appgroup";
297
 import { device_list } from "@/api/appgroup";
289
 export default {
298
 export default {
290
   data() {
299
   data() {
291
     return {
300
     return {
292
       userInfo: {},
301
       userInfo: {},
302
+      add_has: false,
293
       searchForm: {
303
       searchForm: {
294
         name: "",
304
         name: "",
295
         page: 1,
305
         page: 1,
385
     this.userInfo = JSON.parse(
395
     this.userInfo = JSON.parse(
386
       localStorage.getItem("xh_control_userInfo")
396
       localStorage.getItem("xh_control_userInfo")
387
     ).content;
397
     ).content;
398
+    this.init();
388
     this.searchList();
399
     this.searchList();
389
   },
400
   },
390
   computed: {
401
   computed: {
393
     }
404
     }
394
   },
405
   },
395
   methods: {
406
   methods: {
407
+    async init() {
408
+      //是否显示添加按钮
409
+      let res = await wallpaper_add_has({
410
+        wlevel: 3,
411
+        objectid: this.powerParams.objectid
412
+      });
413
+      if (res.code === 0) {
414
+        this.add_has = res.obj;
415
+      } else {
416
+        this.$Message.error(res.msg);
417
+      }
418
+    },
396
     // 搜索
419
     // 搜索
397
     searchList() {
420
     searchList() {
398
       this.searchForm.page = 1;
421
       this.searchForm.page = 1;
432
     },
455
     },
433
     // 新建
456
     // 新建
434
     toAdd() {
457
     toAdd() {
435
-      this.wallpaperInfo = {
436
-        show: true,
437
-        wallpaperid: null,
438
-        rversion: null,
439
-        wname: "",
440
-        hpath: "",
441
-        hLoading: false,
442
-        vpath: "",
443
-        vLoading: false,
444
-        // 2区域3学校
458
+      wallpaper_list_device({
445
         wlevel: 3,
459
         wlevel: 3,
446
-        // 对应的区域/学校ID
447
-        objectid: this.powerParams.objectid,
448
-        deviceids: [],
449
-        deviceList: []
450
-      };
451
-      this.getDeviceList().then((list) => {
452
-        this.wallpaperInfo.deviceList = list;
460
+        objectid: this.powerParams.objectid
461
+      }).then((res) => {
462
+        if (res.code === 0) {
463
+          this.wallpaperInfo = {
464
+            show: true,
465
+            wallpaperid: null,
466
+            rversion: null,
467
+            wname: "",
468
+            hpath: "",
469
+            hLoading: false,
470
+            vpath: "",
471
+            vLoading: false,
472
+            // 2区域3学校
473
+            wlevel: 3,
474
+            // 对应的区域/学校ID
475
+            objectid: this.powerParams.objectid,
476
+            deviceids: [],
477
+            deviceList: res.obj
478
+          };
479
+        } else {
480
+          this.$Message.error(res.msg);
481
+        }
453
       });
482
       });
454
     },
483
     },
455
     // 获取设备列表
484
     // 获取设备列表
603
             this.$Message.error("请上传壁纸");
632
             this.$Message.error("请上传壁纸");
604
             return;
633
             return;
605
           }
634
           }
635
+          if (this.wallpaperInfo.deviceids.length === 0) {
636
+            this.$Message.error("请选择设备!");
637
+          }
606
           this.wallpaperInfo.show = false;
638
           this.wallpaperInfo.show = false;
607
           let form = {
639
           let form = {
608
             rtype: this.powerParams.rtype,
640
             rtype: this.powerParams.rtype,
623
               : wallpaper_add;
655
               : wallpaper_add;
624
           api(form).then((data) => {
656
           api(form).then((data) => {
625
             if (data.code === 0) {
657
             if (data.code === 0) {
658
+              this.init();
626
               this.searchList();
659
               this.searchList();
627
               this.$Message.success(data.msg);
660
               this.$Message.success(data.msg);
628
             } else {
661
             } else {
658
       });
691
       });
659
     },
692
     },
660
     // 编辑
693
     // 编辑
661
-    toEdit(row) {
694
+    async toEdit(row) {
695
+      //获取选择设备包含自己
696
+      let res1 = await wallpaper_list_devicewp({
697
+        wlevel: this.powerParams.rtype,
698
+        objectid: this.powerParams.objectid,
699
+        wallpaperid: row.wallpaperid
700
+      });
701
+      if (res1.code != 0) {
702
+        this.$Message.error(res1.msg);
703
+      }
662
       this.wallpaperInfo = {
704
       this.wallpaperInfo = {
663
         show: true,
705
         show: true,
664
         wallpaperid: row.wallpaperid,
706
         wallpaperid: row.wallpaperid,
673
         // 对应的区域/学校ID
715
         // 对应的区域/学校ID
674
         objectid: row.objectid,
716
         objectid: row.objectid,
675
         deviceids: [],
717
         deviceids: [],
676
-        deviceList: []
718
+        deviceList: res1.obj
677
       };
719
       };
678
       this.getWallpaperDetail(row.wallpaperid).then((data) => {
720
       this.getWallpaperDetail(row.wallpaperid).then((data) => {
679
         if (data) {
721
         if (data) {
686
           this.wallpaperInfo.deviceids = _deviceids;
728
           this.wallpaperInfo.deviceids = _deviceids;
687
         }
729
         }
688
       });
730
       });
689
-      this.getDeviceList().then((list) => {
690
-        this.wallpaperInfo.deviceList = list;
691
-      });
692
     },
731
     },
693
     getWallpaperDetail(wallpaperid) {
732
     getWallpaperDetail(wallpaperid) {
694
       return new Promise((resolve) => {
733
       return new Promise((resolve) => {

Loading…
Cancel
Save