|
@@ -12,6 +12,7 @@ use App\Models\Project;
|
|
use App\Models\WorkPoint;
|
|
use App\Models\WorkPoint;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
+use phpDocumentor\Reflection\DocBlock;
|
|
|
|
|
|
class InnerDeviceController extends BaseController
|
|
class InnerDeviceController extends BaseController
|
|
{
|
|
{
|
|
@@ -43,13 +44,14 @@ class InnerDeviceController extends BaseController
|
|
{
|
|
{
|
|
$options = $this->device_name->getNameSpecOptions();
|
|
$options = $this->device_name->getNameSpecOptions();
|
|
$statuses = Option::get('inner_devices', 'status');
|
|
$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);
|
|
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)
|
|
public function get(Request $request)
|
|
{
|
|
{
|
|
- $items = $this->model->where('id', '>', 0)->with(['device', 'spec', 'device_name']);
|
|
|
|
|
|
+ $items = $this->model->where('id', '>', 0)->with(['device', 'spec', 'device_name','inner_device_names']);
|
|
|
|
|
|
$tmp_items = collect(['number']);
|
|
$tmp_items = collect(['number']);
|
|
foreach($tmp_items as $tmp_item) {
|
|
foreach($tmp_items as $tmp_item) {
|
|
@@ -58,19 +60,26 @@ 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) {
|
|
foreach($select_items as $select_item) {
|
|
if($request->has($select_item) && !empty($request->input($select_item))) {
|
|
if($request->has($select_item) && !empty($request->input($select_item))) {
|
|
$items = $items->where($select_item, '=', $request->input($select_item));
|
|
$items = $items->where($select_item, '=', $request->input($select_item));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //排序
|
|
$items = $items->orderBy('updated_at', 'desc')->paginate();
|
|
$items = $items->orderBy('updated_at', 'desc')->paginate();
|
|
-
|
|
|
|
|
|
+// dd($items);
|
|
foreach ($items as $item) {
|
|
foreach ($items as $item) {
|
|
$item->device_type = $item->device ? $item->device->name : '';
|
|
$item->device_type = $item->device ? $item->device->name : '';
|
|
- $item->device_name_name = $item->device_name ? $item->device_name->name : '';
|
|
|
|
- $item->spec_name = $item->spec ? $item->spec->name : '';
|
|
|
|
|
|
+ $item->device_name_name = $item->inner_device_names ? $item->inner_device_names->name : '';
|
|
|
|
+ $item->spec_name = $item->spec_name ? $item->spec_name : '';
|
|
$item->status = $item->getStatusLabel();
|
|
$item->status = $item->getStatusLabel();
|
|
$item->work_point_name = $item->workPoint ? $item->workPoint->name : '';
|
|
$item->work_point_name = $item->workPoint ? $item->workPoint->name : '';
|
|
$item->project_name = $item->project ? $item->project->name : '';
|
|
$item->project_name = $item->project ? $item->project->name : '';
|
|
@@ -102,10 +111,10 @@ class InnerDeviceController extends BaseController
|
|
return back()->withErrors($validator)->withInput();
|
|
return back()->withErrors($validator)->withInput();
|
|
}
|
|
}
|
|
$data = $request->input('data');
|
|
$data = $request->input('data');
|
|
- $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_id', 'project_id', 'work_point_id']));
|
|
|
|
|
|
+ $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_name', '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 . 'index')->with(['sg_success_info' => '创建成功']);
|
|
}
|
|
}
|
|
|
|
|
|
public function exportTemplate(Request $request)
|
|
public function exportTemplate(Request $request)
|
|
@@ -134,10 +143,10 @@ class InnerDeviceController extends BaseController
|
|
return back()->withErrors($validator)->withInput();
|
|
return back()->withErrors($validator)->withInput();
|
|
}
|
|
}
|
|
$data = $request->input('data');
|
|
$data = $request->input('data');
|
|
- $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_id', 'project_id', 'work_point_id']));
|
|
|
|
|
|
+ $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);
|
|
$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 redirect($this->pre_uri . 'index')->with(['sg_success_info' => '编辑成功']);
|
|
}
|
|
}
|
|
|
|
|
|
public function delete(Request $request)
|
|
public function delete(Request $request)
|