Kaynağa Gözat

Merge commit '44211739b99cc4dd4b03f67236fd02021d1ecfcf' into gzb

gzb
guozhongbo 8 ay önce
ebeveyn
işleme
1d0f540c26

BIN
public/doc/设备导入.xlsx Dosyayı Görüntüle


+ 40
- 1
src/utils/exportToExcel.js Dosyayı Görüntüle

@@ -57,6 +57,42 @@ const openDownloadDialog = (blob, fileName) => {
57 57
   }
58 58
   aLink.dispatchEvent(event);
59 59
 };
60
+// 列自适应宽度
61
+const setColFitWidth = (tableData, headerList, sheet) => {
62
+  function getCellWidth(value) {
63
+    // 判断是否为null或undefined
64
+    if (!value) {
65
+      return 10;
66
+    } else if (/.*[\u4e00-\u9fa5]+.*$/.test(value)) {
67
+      // 判断是否包含中文
68
+      return value.toString().length * 2.1;
69
+    } else {
70
+      return value.toString().length * 1.1;
71
+    }
72
+  }
73
+  let colWidths = []; // 所有列的名称数组
74
+  // 计算每一列的所有单元格宽度
75
+  // 先遍历行
76
+  tableData.forEach((row) => {
77
+    // 遍历列
78
+    for (const key in row) {
79
+      let index = headerList.findIndex((v) => v === key);
80
+      if (!colWidths[index]) {
81
+        colWidths[index] = [];
82
+      }
83
+      colWidths[index].push(getCellWidth(row[key]));
84
+    }
85
+  });
86
+  sheet["!cols"] = [];
87
+  // 每一列取最大值最为列宽
88
+  colWidths.forEach((widths, index) => {
89
+    // 计算列头的宽度
90
+    widths.push(getCellWidth(headerList[index]));
91
+    // 设置最大值为列宽
92
+    sheet["!cols"].push({ wch: Math.max(...widths, 10) });
93
+  });
94
+  return sheet;
95
+};
60 96
 /**
61 97
  * 导出Excel表格
62 98
  * @param sheetListInfo sheet列表信息 [{list:数组数据, name: sheet名称}]
@@ -65,12 +101,14 @@ const openDownloadDialog = (blob, fileName) => {
65 101
 export const exportToExcel = (sheetListInfo, excelName) => {
66 102
   const wb = XLSX2.utils.book_new();
67 103
   sheetListInfo.forEach((sheetItem, sheetIndex) => {
104
+    let headerList = [];
68 105
     sheetItem.list.forEach((item) => {
69 106
       for (const key in item) {
107
+        headerList.push(key);
70 108
         item[key] = item[key] || "";
71 109
       }
72 110
     });
73
-    const sheet = XLSX2.utils.json_to_sheet(sheetItem.list);
111
+    let sheet = XLSX2.utils.json_to_sheet(sheetItem.list);
74 112
     // 设置每个单元格的样式
75 113
     let range = XLSX.utils.decode_range(sheet["!ref"]);
76 114
     for (let R = range.s.r; R <= range.e.r; ++R) {
@@ -83,6 +121,7 @@ export const exportToExcel = (sheetListInfo, excelName) => {
83 121
         }
84 122
       }
85 123
     }
124
+    sheet = setColFitWidth(sheetItem.list, headerList, sheet);
86 125
     XLSX2.utils.book_append_sheet(
87 126
       wb,
88 127
       sheet,

+ 2
- 1
src/views/platformSection/deviceManage/deviceManageImport/detail.vue Dosyayı Görüntüle

@@ -305,7 +305,8 @@ export default {
305 305
         regionid: this.searchForm.regionid,
306 306
         page: this.searchForm.page,
307 307
         size: this.searchForm.size,
308
-        sn: this.searchForm.sn
308
+        sn: this.searchForm.sn,
309
+        snState: this.searchForm.snState
309 310
       }).then((data) => {
310 311
         if (data.code === 0) {
311 312
           this.searchForm.list = data.obj.data;

+ 3
- 1
src/views/platformSection/regionManage/adminManage.vue Dosyayı Görüntüle

@@ -346,6 +346,7 @@ export default {
346 346
         timer: null,
347 347
         second: 60,
348 348
         adminid: null,
349
+        atype: null,
349 350
         aname: "",
350 351
         loginname: "",
351 352
         loginpwd: "",
@@ -412,7 +413,6 @@ export default {
412 413
         {
413 414
           title: "最后登录IP",
414 415
           key: "lastip",
415
-          width: 150,
416 416
           align: "center"
417 417
         },
418 418
         {
@@ -492,6 +492,7 @@ export default {
492 492
         timer: null,
493 493
         second: 60,
494 494
         adminid: null,
495
+        atype: null,
495 496
         aname: "",
496 497
         loginname: "",
497 498
         loginpwd: generateRandomString(),
@@ -622,6 +623,7 @@ export default {
622 623
         timer: null,
623 624
         second: 60,
624 625
         adminid: row.adminid,
626
+        atype: row.atype,
625 627
         aname: row.aname,
626 628
         loginname: row.loginname,
627 629
         loginpwd: row.loginpwd,

+ 1
- 1
src/views/schoolSection/deviceManage/breakRuleDevice.vue Dosyayı Görüntüle

@@ -17,7 +17,7 @@
17 17
           placeholder="请输入设备号"
18 18
           search
19 19
           @on-search="searchList()"
20
-          style="width: 310px"
20
+          style="width: 200px"
21 21
         />
22 22
       </div>
23 23
       <div class="search_right">

+ 11
- 11
src/views/schoolSection/deviceManage/deviceManage.vue Dosyayı Görüntüle

@@ -37,7 +37,7 @@
37 37
           </Select>
38 38
           <Input
39 39
             v-model="searchForm.name"
40
-            placeholder="请输入名姓名、登录名、设备名、设备型号"
40
+            placeholder="请输入登录账号、姓名、设备型号、设备号"
41 41
             search
42 42
             @on-search="searchList()"
43 43
             style="width: 310px"
@@ -885,17 +885,17 @@ export default {
885 885
               value: params.value,
886 886
               unit: "B"
887 887
             };
888
-            if (memoryInfo.value / 1024 < 1024) {
888
+            if (memoryInfo.value / 1000 < 1000) {
889 889
               memoryInfo.value =
890
-                Math.floor((memoryInfo.value / 1024) * 100) / 100;
890
+                Math.floor((memoryInfo.value / 1000) * 100) / 100;
891 891
               memoryInfo.unit = "KB";
892
-            } else if (memoryInfo.value / 1024 / 1024 < 1024) {
892
+            } else if (memoryInfo.value / 1000 / 1000 < 1000) {
893 893
               memoryInfo.value =
894
-                Math.floor((memoryInfo.value / 1024 / 1024) * 100) / 100;
894
+                Math.floor((memoryInfo.value / 1000 / 1000) * 100) / 100;
895 895
               memoryInfo.unit = "MB";
896 896
             } else {
897 897
               memoryInfo.value =
898
-                Math.floor((memoryInfo.value / 1024 / 1024 / 1024) * 100) / 100;
898
+                Math.floor((memoryInfo.value / 1000 / 1000 / 1000) * 100) / 100;
899 899
               memoryInfo.unit = "GB";
900 900
             }
901 901
             return `${params.name}:${memoryInfo.value}${memoryInfo.unit}`;
@@ -927,17 +927,17 @@ export default {
927 927
                   value: params.value,
928 928
                   unit: "B"
929 929
                 };
930
-                if (memoryInfo.value / 1024 < 1024) {
930
+                if (memoryInfo.value / 1000 < 1000) {
931 931
                   memoryInfo.value =
932
-                    Math.floor((memoryInfo.value / 1024) * 100) / 100;
932
+                    Math.floor((memoryInfo.value / 1000) * 100) / 100;
933 933
                   memoryInfo.unit = "KB";
934
-                } else if (memoryInfo.value / 1024 / 1024 < 1024) {
934
+                } else if (memoryInfo.value / 1000 / 1000 < 1000) {
935 935
                   memoryInfo.value =
936
-                    Math.floor((memoryInfo.value / 1024 / 1024) * 100) / 100;
936
+                    Math.floor((memoryInfo.value / 1000 / 1000) * 100) / 100;
937 937
                   memoryInfo.unit = "MB";
938 938
                 } else {
939 939
                   memoryInfo.value =
940
-                    Math.floor((memoryInfo.value / 1024 / 1024 / 1024) * 100) /
940
+                    Math.floor((memoryInfo.value / 1000 / 1000 / 1000) * 100) /
941 941
                     100;
942 942
                   memoryInfo.unit = "GB";
943 943
                 }

+ 1
- 1
src/views/schoolSection/deviceManage/inLineDevice.vue Dosyayı Görüntüle

@@ -25,7 +25,7 @@
25 25
         </Select>
26 26
         <Input
27 27
           v-model="searchForm.name"
28
-          placeholder="请输入姓名、登录账号、设备号、设备号"
28
+          placeholder="请输入登录账号、姓名、设备号、设备号"
29 29
           search
30 30
           @on-search="searchList()"
31 31
           style="width: 310px"

+ 1
- 1
src/views/schoolSection/deviceManage/outControlDevice.vue Dosyayı Görüntüle

@@ -35,7 +35,7 @@
35 35
         </Select>
36 36
         <Input
37 37
           v-model="searchForm.name"
38
-          placeholder="请输入姓名、登录账号、设备号、设备号"
38
+          placeholder="请输入登录账号、姓名、设备号、设备号"
39 39
           search
40 40
           @on-search="searchList()"
41 41
           style="width: 310px"

+ 1
- 1
src/views/schoolSection/deviceManage/removeControlDevice.vue Dosyayı Görüntüle

@@ -4,7 +4,7 @@
4 4
       <div class="search_left">
5 5
         <Input
6 6
           v-model="searchForm.name"
7
-          placeholder="请输入姓名、登录账号、设备号、设备号"
7
+          placeholder="请输入登录账号、姓名、设备号、设备号"
8 8
           search
9 9
           @on-search="searchList()"
10 10
           style="width: 310px"

+ 2
- 3
src/views/schoolSection/log/deviceEvents.vue Dosyayı Görüntüle

@@ -42,7 +42,6 @@
42 42
     <div class="table_wrap">
43 43
       <Table :columns="columns" :data="searchForm.list">
44 44
         <template slot-scope="{ row }" slot="doEventSlot">
45
-          <!-- 1发送消息 2解除锁定 3锁定 4更新策略 5重启设备 6恢复出厂 -->
46 45
           <div>{{ doEventInfo[row.doEvent] }}</div>
47 46
         </template>
48 47
         <template slot-scope="{ row }" slot="violatedSlot">
@@ -237,9 +236,9 @@ export default {
237 236
                     // 0不违规1违规
238 237
                     违规:
239 238
                       item.violated === 1
240
-                        ? "违规"
239
+                        ? ""
241 240
                         : item.violated === 0
242
-                        ? "不违规"
241
+                        ? ""
243 242
                         : "",
244 243
                     时间: item.createtime
245 244
                   };

Loading…
İptal
Kaydet