laiguoran 4 лет назад
Родитель
Сommit
b5e9b793e2
1 измененных файлов с 19 добавлено и 6 удалено
  1. 19 6
      app/public/js/shenpi.js

+ 19 - 6
app/public/js/shenpi.js

@@ -981,19 +981,32 @@ function setRightData(datas, coolist) {
     const newdatas = [];
     const reg = /(^GD([a-zA-Z0-9\-]+))|(^([0-9\-]+)$)/;
     for (const l of datas) {
+        console.log(l)
         if (reg.test(l.code) && l.level <= 4) {
             if(l.level === 4 && l.is_leaf === false) {
                 l.is_leaf = true;
             }
-            if(l.is_leaf) {
-                const coo = _.find(coolist, { 'ledger_id': l.ledger_id, 'user_id': cur_uid });
-                if(coo) {
-                    l.pwd = coo.pwd;
-                }
-            }
+            // if(l.is_leaf) {
+            //     const coo = _.find(coolist, { 'ledger_id': l.ledger_id, 'user_id': cur_uid });
+            //     if(coo) {
+            //         l.pwd = coo.pwd;
+            //     }
+            // }
             newdatas.push(l);
         }
     }
+    for (const nd of newdatas) {
+        const child = _.find(newdatas, { 'ledger_pid': nd.ledger_id });
+        if (!child && !nd.is_leaf) {
+            nd.is_leaf = true;
+        }
+        if(nd.is_leaf) {
+            const coo = _.find(coolist, { 'ledger_id': nd.ledger_id, 'user_id': cur_uid });
+            if(coo) {
+                nd.pwd = coo.pwd;
+            }
+        }
+    }
     return newdatas;
 }