cqpCow 11 meses atrás
pai
commit
842d8eec56

+ 1 - 1
app/Http/Middleware/CheckLogin.php

@@ -90,7 +90,7 @@ class CheckLogin
 
         $menu2 = $query['is_list_search'] ?? [];
         if(in_array($url, $menu2)) {
-            if(! empty($data['is_list_search'])){//列表页呈现
+            if(! empty($query['is_list_search']) && ! empty($request->is_list_search)){//列表页呈现
                 $request->merge(['get_my_top_depart_data' => 0]);
             }else{//建单据选择
                 $request->merge(['get_my_top_depart_data' => 1]);

+ 1 - 1
app/Http/Middleware/CheckWx.php

@@ -109,7 +109,7 @@ class CheckWx
 
             $menu2 = $query['is_list_search'] ?? [];
             if(in_array($url, $menu2)) {
-                if(! empty($data['is_list_search'])){//列表页呈现
+                if(! empty($data['is_list_search']) && ! empty($request->is_list_search)){//列表页呈现
                     $request->merge(['get_my_top_depart_data' => 0]);
                 }else{//建单据选择
                     $request->merge(['get_my_top_depart_data' => 1]);

+ 59 - 0
app/Service/BasicTypeService.php

@@ -3,6 +3,8 @@
 namespace App\Service;
 
 use App\Model\BasicType;
+use App\Model\Depart;
+
 /**
  * 基础分类设置相关
  */
@@ -158,4 +160,61 @@ class BasicTypeService extends Service
 
         return $data;
     }
+
+    public function maked(){
+        $list = BasicType::where('del_time',0)
+            ->select('title','type','top_depart_id')
+            ->get()->toArray();
+        $basic_type2 = [];
+        $basic_other_type = [];
+        foreach ($list as $value){
+            if($value['top_depart_id'] == 2){
+                if(! in_array($value['type'], [28,23,24,22,8])){
+                    $basic_type2[] = $value['title'] . '|' . $value['type'];
+                }
+            }else{
+                $basic_other_type[$value['top_depart_id']][] = $value['title'] . '|' . $value['type'];
+            }
+        }dd($basic_type2);
+        $depart = Depart::where('del_time',0)
+            ->where('id','<>',2)
+            ->where('parent_id',0)
+//            ->whereIn('id',[139,49])
+            ->select('id')
+            ->orderBy('id','asc')
+            ->get()->toArray();
+        $depart = array_column($depart,'id');
+        $insert = [];
+        $time = time();
+        foreach ($depart as $value){
+            if(! empty($basic_other_type[$value])){
+                foreach ($basic_type2 as $val){
+                    if(! in_array($val,$basic_other_type[$value])) {
+                        $tmp = explode('|',$val);
+                        $insert[] = [
+                            'title' => $tmp[0],
+                            'type' => $tmp[1],
+                            'top_depart_id' => $value,
+                            'crt_time' => $time,
+                            'crt_id' => 1
+                        ];
+                    }
+                }
+            }else{
+                foreach ($basic_type2 as $val){
+                    $tmp = explode('|',$val);
+                    $insert[] = [
+                        'title' => $tmp[0],
+                        'type' => $tmp[1],
+                        'top_depart_id' => $value,
+                        'crt_time' => $time,
+                        'crt_id' => 1
+                    ];
+                }
+            }
+        }
+
+        if(! empty($insert)) BasicType::insert($insert);
+        dd('ok');
+    }
 }