| xqd
@@ -44,8 +44,9 @@ class InnerDeviceController extends BaseController
|
|
|
{
|
|
|
$options = $this->device_name->getNameSpecOptions();
|
|
|
$statuses = Option::get('inner_devices', 'status');
|
|
|
+ $project_id = Project::getOptions();
|
|
|
list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
|
|
|
- return view($this->view_path . 'index', compact('model', 'model_name','pre_uri', 'options', 'statuses'));
|
|
|
+ return view($this->view_path . 'index', compact('model', 'model_name','pre_uri', 'options', 'statuses','project_id'));
|
|
|
}
|
|
|
|
|
|
public function get(Request $request)
|
| xqd
@@ -59,7 +60,14 @@ class InnerDeviceController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $select_items = collect(['device_id', 'device_name_id', 'spec_id', 'status', 'work_point_id']);
|
|
|
+ $spec_items = collect(['spec_name']);
|
|
|
+ foreach($spec_items as $spec_item) {
|
|
|
+ if($request->has($spec_item) && !empty($request->input($spec_item))) {
|
|
|
+ $items = $items->where($spec_item, 'like', '%' . $request->input($spec_item) . '%');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $select_items = collect(['device_id', 'device_name_id', 'spec_id', 'status', 'work_point_id','project_id']);
|
|
|
foreach($select_items as $select_item) {
|
|
|
if($request->has($select_item) && !empty($request->input($select_item))) {
|
|
|
$items = $items->where($select_item, '=', $request->input($select_item));
|
| xqd
@@ -103,11 +111,10 @@ class InnerDeviceController extends BaseController
|
|
|
return back()->withErrors($validator)->withInput();
|
|
|
}
|
|
|
$data = $request->input('data');
|
|
|
-// dd($data);
|
|
|
$data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_name', 'project_id', 'work_point_id']));
|
|
|
$res = $this->model->create($data);
|
|
|
if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
|
|
|
- return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
|
|
|
+ return redirect($this->pre_uri . 'index')->with(['sg_success_info' => '创建成功']);
|
|
|
}
|
|
|
|
|
|
public function exportTemplate(Request $request)
|
| xqd
@@ -139,7 +146,7 @@ class InnerDeviceController extends BaseController
|
|
|
$data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_name', 'project_id', 'work_point_id']));
|
|
|
$res = $this->model->where('id', $request->input('id'))->update($data);
|
|
|
if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
|
|
|
- return back()->with(['sg_success_info' => '编辑成功']);
|
|
|
+ return redirect($this->pre_uri . 'index')->with(['sg_success_info' => '编辑成功']);
|
|
|
}
|
|
|
|
|
|
public function delete(Request $request)
|