wenhongquan 2 лет назад
Родитель
Сommit
63816c1fb4
1 измененных файлов с 19 добавлено и 10 удалено
  1. 19 10
      src/views/statics/index.vue

+ 19 - 10
src/views/statics/index.vue

@@ -34,7 +34,7 @@
             v-model="filterText"
             placeholder="输入关键字"
           />
-          <div style="max-height: 80vh;overflow-y: scroll">
+          <div style="max-height: 80vh; overflow-y: scroll">
             <lay-tree
               :data="data"
               ref="treeRef"
@@ -169,16 +169,22 @@ const initData = async () => {
     var index = 0;
     var all = 0;
     var zx = 0;
-
-    deptOptions.value[0].children.forEach((p) => {
+    var depts = [];
+    if (deptOptions.value[0].children == undefined) {
+      depts = deptOptions.value;
+    } else {
+      depts = deptOptions.value[0].children;
+    }
+    depts.forEach((p) => {
       p["children"] = (p.children ?? []).concat(
         carlist.value
           .filter((i) => JSON.parse(i.ext1).deptId == p.id)
           .map((i) => {
             keyp.push(p.id);
-            let ll = i.lastCountTime == null
-              ? "离线"
-              : moment().unix() - moment(i.lastCountTime).unix() > 60 * 5
+            let ll =
+              i.lastCountTime == null
+                ? "离线"
+                : moment().unix() - moment(i.lastCountTime).unix() > 60 * 5
                 ? "离线"
                 : "在线";
             if (ll == "在线") {
@@ -189,14 +195,17 @@ const initData = async () => {
               id: `car_${++index}`,
               title: i.carNum,
               deviceInfos: i.deviceInfos,
-              time:
-                ll,
+              time: ll,
             };
           })
       );
-      p["title"] = p.label+` [ ${p["children"].filter(i=>i.time.indexOf("在线")!=-1).length}/${p["children"].length}]`;
+      p["title"] =
+        p.label +
+        ` [ ${p["children"].filter((i) => i.time.indexOf("在线") != -1).length}/${
+          p["children"].length
+        }]`;
     });
-    deptOptions.value[0]["title"] = deptOptions.value[0]["label"] +` [ ${zx}/${all}]`;
+    deptOptions.value[0]["title"] = deptOptions.value[0]["label"] + ` [ ${zx}/${all}]`;
     data.value = deptOptions.value;
     keys.value = keyp;
     setTimeout(() => {