Browse Source

Merge commit '44211739b99cc4dd4b03f67236fd02021d1ecfcf' into gzb

gzb
guozhongbo 8 months ago
parent
commit
1d0f540c26

BIN
public/doc/设备导入.xlsx View File


+ 40
- 1
src/utils/exportToExcel.js View File

57
   }
57
   }
58
   aLink.dispatchEvent(event);
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
  * 导出Excel表格
97
  * 导出Excel表格
62
  * @param sheetListInfo sheet列表信息 [{list:数组数据, name: sheet名称}]
98
  * @param sheetListInfo sheet列表信息 [{list:数组数据, name: sheet名称}]
65
 export const exportToExcel = (sheetListInfo, excelName) => {
101
 export const exportToExcel = (sheetListInfo, excelName) => {
66
   const wb = XLSX2.utils.book_new();
102
   const wb = XLSX2.utils.book_new();
67
   sheetListInfo.forEach((sheetItem, sheetIndex) => {
103
   sheetListInfo.forEach((sheetItem, sheetIndex) => {
104
+    let headerList = [];
68
     sheetItem.list.forEach((item) => {
105
     sheetItem.list.forEach((item) => {
69
       for (const key in item) {
106
       for (const key in item) {
107
+        headerList.push(key);
70
         item[key] = item[key] || "";
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
     let range = XLSX.utils.decode_range(sheet["!ref"]);
113
     let range = XLSX.utils.decode_range(sheet["!ref"]);
76
     for (let R = range.s.r; R <= range.e.r; ++R) {
114
     for (let R = range.s.r; R <= range.e.r; ++R) {
83
         }
121
         }
84
       }
122
       }
85
     }
123
     }
124
+    sheet = setColFitWidth(sheetItem.list, headerList, sheet);
86
     XLSX2.utils.book_append_sheet(
125
     XLSX2.utils.book_append_sheet(
87
       wb,
126
       wb,
88
       sheet,
127
       sheet,

+ 2
- 1
src/views/platformSection/deviceManage/deviceManageImport/detail.vue View File

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

+ 3
- 1
src/views/platformSection/regionManage/adminManage.vue View File

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

+ 1
- 1
src/views/schoolSection/deviceManage/breakRuleDevice.vue View File

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

+ 11
- 11
src/views/schoolSection/deviceManage/deviceManage.vue View File

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

+ 1
- 1
src/views/schoolSection/deviceManage/inLineDevice.vue View File

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

+ 1
- 1
src/views/schoolSection/deviceManage/outControlDevice.vue View File

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

+ 1
- 1
src/views/schoolSection/deviceManage/removeControlDevice.vue View File

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

+ 2
- 3
src/views/schoolSection/log/deviceEvents.vue View File

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

Loading…
Cancel
Save