Преглед изворни кода

细节优化,获取架构优化

wufeng пре 2 година
родитељ
комит
11dbf05b16
4 измењених фајлова са 37 додато и 0 уклоњено
  1. 21 0
      app/common.php
  2. 14 0
      app/controller/CustomerOrg.php
  3. 1 0
      app/controller/Headquarters.php
  4. 1 0
      route/app.php

+ 21 - 0
app/common.php

@@ -144,4 +144,25 @@ if (function_exists('makeNo') == false) {
         $msec = rand(1000, 9999);
         return $str . $date . $msec;
     }
+}
+
+//获取三级架构
+if (!function_exists('get_top_customer_org')) {
+    function get_top_customer_org($var, $data = [])
+    {
+        $str = Db::name('customer_org1')
+            ->field('id,name,pid,level')
+            ->where(['id' => $var])
+            ->findOrEmpty();
+        if (empty($str)) return [];
+
+        $vmn = [];
+        $vmn['id'] = $str['id'];
+        $vmn['name'] = $str['name'];
+        $vmn['level'] = $str['level'];
+        array_unshift($data, $vmn);
+        // $var['id']=made();
+        if ($str['pid'] == 0) return $data;
+        else return get_top_customer_org($str['pid'], $data);
+    }
 }

+ 14 - 0
app/controller/CustomerOrg.php

@@ -396,5 +396,19 @@ class CustomerOrg extends BaseController
         return $update ? json_show(0, "操作成功") : json_show(1004, "操作失败");
     }
 
+    //获取三级架构
+    public function getTopCustomerOrg()
+    {
+
+        $itemid = $this->request->filter('trim')->post('itemid');
+
+        $res = [];
+        foreach ($itemid as $val){
+            $res[$val] = get_top_customer_org($val);
+        }
+        return json_show(0, '获取架构成功', $res);
+
+    }
+
 
 }

+ 1 - 0
app/controller/Headquarters.php

@@ -844,6 +844,7 @@ class Headquarters extends BaseController
                 "middle" => "",
                 "country" => "",
                 "is_del" => 0,
+                "createrid" => $createrid,
                 "creater" => $creater,
                 "modifier" => "",
                 "addtime" => $date,

+ 1 - 0
route/app.php

@@ -77,6 +77,7 @@ Route::rule('customer_org_update', 'CustomerOrg/update');
 Route::rule('customer_org_info', 'CustomerOrg/info');
 Route::rule('customer_org_delete', 'CustomerOrg/delete');
 Route::rule('customer_org_status', 'CustomerOrg/status');
+Route::rule('get_top_customer_org', 'CustomerOrg/getTopCustomerOrg');
 
 //组织架构
 Route::rule('ulist', 'CompanyItem/getList');