浏览代码

更新导入

ChenWuJie 4 年之前
父节点
当前提交
903cb8fd04

+ 11 - 10
app/Imports/InnerDeviceImport.php

xqd xqd
@@ -83,21 +83,22 @@ class InnerDeviceImport implements ToCollection
             //项目
             if($row[7]) {
                 $project = Project::firstOrCreate([
-                    'name' => $row[7]
-                ]);
-            }
-            //工点
-            if($project && $row[8]) {
-                $work_point = WorkPoint::firstOrCreate([
-                    'project_id' => $project->id,
-                    'name' => $row[8]
+                    'name' => $row[7],
+                    'active' => 1
                 ]);
             }
+//            //工点
+//            if($project && $row[8]) {
+//                $work_point = WorkPoint::firstOrCreate([
+//                    'project_id' => $project->id,
+//                    'name' => $row[8]
+//                ]);
+//            }
 
             $status = Option::where([
                 ['table', '=', 'inner_devices'],
                 ['column', '=', 'status'],
-                ['name', '=', $row[9]]
+                ['name', '=', $row[8]]
             ])->first();
 
             $data = [
@@ -109,7 +110,7 @@ class InnerDeviceImport implements ToCollection
                 'manufacturer' => $row[5],
                 'shape' => $row[6],
                 'project_id' => $project ? $project->id : '',
-                'work_point_id' => $work_point ? $work_point->id : '',
+//                'work_point_id' => $work_point ? $work_point->id : '',
                 'status' => $status ? $status->id : ''
             ];
             $this->model->create($data);

+ 19 - 22
app/Imports/SpecImport.php

xqd
@@ -48,46 +48,43 @@ class SpecImport implements ToCollection
                 break;
             }
             //设备类型
+            if ($row[1] == "项目自填(必须填写)" || $row[2] == "项目自填(必须填写)")
+            {
+                continue;
+            }
             $device_id = null;
             $device_name_id = null;
-            if ($row[1])
+            //设备类型
+            if ($row[0])
             {
                 $device_id = Device::firstOrCreate([
-                    'name' => $row[1],
+                    'name' => $row[0],
                     'sort' => 1,
                 ]);
             }
             //设备名称
-            if ($row[2] == "项目自填(必须填写)")
-            {
-                continue;
-            }else
+            if ($row[1])
             {
-                if($device_id && $row[2]) {
+                if($device_id && $row[1]) {
                     $device_name_id = DeviceName::firstOrCreate([
                         'device_id' => $device_id->id,
-                        'name' => $row[2],
+                        'name' => $row[1],
                         'sort' => 1,
                         'status' => 1
                     ]);
                 }
             }
-
-            $name = null;
-            if ($row[3] == "项目自填(必须填写)")
+            //规格型号
+            if ($row[2])
             {
-                $name = '';
-            }
-            else{
-                $name = $row[3];
+                $data = [
+                    'name' => $row[2],
+                    'device_name_id' => $device_name_id ? $device_name_id->id : '',
+                    'device_id' => $device_id ? $device_id->id : '',
+                    'sort' => 1
+                ];
+                $this->model->create($data);
             }
-            $data = [
-                'name' => $name,
-                'device_name_id' => $device_name_id ? $device_name_id->id : '',
-                'device_id' => $device_id ? $device_id->id : '',
-                'sort' => 1
-            ];
-            $this->model->create($data);
         }
         return true;
     }

二进制
public/内部设备导入模板.xlsx


二进制
public/租赁设备导入模板.xlsx


+ 1 - 1
resources/views/admin/inner-devices/index.blade.php

xqd
@@ -222,7 +222,7 @@
                         { field: 'shape', title: '外形尺寸', align: 'center' },
                         // { field: 'quantity', title: '数量', align: 'center' },
                         { field: 'project_name', title: '在用项目', align: 'center' },
-                        { field: 'work_point_name', title: '目前工点', align: 'center' },
+                        // { field: 'work_point_name', title: '目前工点', align: 'center' },
                         { field: 'status', title: '状态', align: 'center' },
                         { title: '操作', align:'center', toolbar: '#sg-table-bar', width: '200' },
                     ]],