|
@@ -8,6 +8,8 @@ use App\Models\Device;
|
|
use App\Models\DeviceName;
|
|
use App\Models\DeviceName;
|
|
use App\Models\InnerDevice;
|
|
use App\Models\InnerDevice;
|
|
use App\Models\Option;
|
|
use App\Models\Option;
|
|
|
|
+use App\Models\Project;
|
|
|
|
+use App\Models\WorkPoint;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
|
|
@@ -82,7 +84,8 @@ class InnerDeviceController extends BaseController
|
|
list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
|
|
list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
|
|
$options = $this->device_name->getNameSpecOptions();
|
|
$options = $this->device_name->getNameSpecOptions();
|
|
$status_options = Option::get('inner_devices', 'status');
|
|
$status_options = Option::get('inner_devices', 'status');
|
|
- return view($this->view_path . 'create', compact('model', 'model_name','pre_uri', 'options', 'status_options'));
|
|
|
|
|
|
+ $project_work_point_options = (new Project())->getTwoLevelOptions();
|
|
|
|
+ return view($this->view_path . 'create', compact('model', 'model_name','pre_uri', 'options', 'status_options', 'project_work_point_options'));
|
|
}
|
|
}
|
|
|
|
|
|
public function transObject($items)
|
|
public function transObject($items)
|
|
@@ -98,9 +101,7 @@ class InnerDeviceController extends BaseController
|
|
return back()->withErrors($validator)->withInput();
|
|
return back()->withErrors($validator)->withInput();
|
|
}
|
|
}
|
|
$data = $request->input('data');
|
|
$data = $request->input('data');
|
|
- $data['device_id'] = $request->input('device_id');
|
|
|
|
- $data['device_name_id'] = $request->input('device_name_id');
|
|
|
|
- $data['spec_id'] = $request->input('spec_id');
|
|
|
|
|
|
+ $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_id', 'project_id', 'work_point_id']));
|
|
$res = $this->model->create($data);
|
|
$res = $this->model->create($data);
|
|
if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
|
|
if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
|
|
return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
|
|
return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
|
|
@@ -118,8 +119,9 @@ class InnerDeviceController extends BaseController
|
|
if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
|
|
if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
|
|
$options = $this->device_name->getNameSpecOptions();
|
|
$options = $this->device_name->getNameSpecOptions();
|
|
$status_options = Option::get('inner_devices', 'status');
|
|
$status_options = Option::get('inner_devices', 'status');
|
|
|
|
+ $project_work_point_options = (new Project())->getTwoLevelOptions();
|
|
list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
|
|
list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
|
|
- return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item', 'options', 'status_options'));
|
|
|
|
|
|
+ return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item', 'options', 'status_options', 'project_work_point_options'));
|
|
}
|
|
}
|
|
|
|
|
|
public function update(Request $request)
|
|
public function update(Request $request)
|
|
@@ -131,9 +133,7 @@ class InnerDeviceController extends BaseController
|
|
return back()->withErrors($validator)->withInput();
|
|
return back()->withErrors($validator)->withInput();
|
|
}
|
|
}
|
|
$data = $request->input('data');
|
|
$data = $request->input('data');
|
|
- $data['device_id'] = $request->input('device_id');
|
|
|
|
- $data['device_name_id'] = $request->input('device_name_id');
|
|
|
|
- $data['spec_id'] = $request->input('spec_id');
|
|
|
|
|
|
+ $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_id', 'project_id', 'work_point_id']));
|
|
$res = $this->model->where('id', $request->input('id'))->update($data);
|
|
$res = $this->model->where('id', $request->input('id'))->update($data);
|
|
if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
|
|
if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
|
|
return back()->with(['sg_success_info' => '编辑成功']);
|
|
return back()->with(['sg_success_info' => '编辑成功']);
|