|
@@ -5,7 +5,7 @@
|
|
|
* @Author: likang
|
|
|
* @Date: 2022-06-17 15:45:05
|
|
|
* @LastEditors: likang
|
|
|
- * @LastEditTime: 2022-06-29 15:45:03
|
|
|
+ * @LastEditTime: 2022-06-29 16:20:32
|
|
|
*/
|
|
|
|
|
|
namespace catchAdmin\equipment\controller;
|
|
@@ -14,6 +14,7 @@ use catcher\base\CatchRequest as Request;
|
|
|
use catcher\CatchResponse;
|
|
|
use catcher\base\CatchController;
|
|
|
use catchAdmin\equipment\model\EquipmentType as equipmentTypeModel;
|
|
|
+use catchAdmin\hydraulic\model\HydEquipment;
|
|
|
|
|
|
class EquipmentType extends CatchController
|
|
|
{
|
|
@@ -32,9 +33,9 @@ class EquipmentType extends CatchController
|
|
|
public function index(Request $request): \think\Response
|
|
|
{
|
|
|
$pch = null;
|
|
|
- $pch = $this->equipmentTypeModel->where('pid', 0)->order('order asc')->select()->toArray();
|
|
|
+ $pch = $this->equipmentTypeModel->where('pid', 0)->order('order desc')->select()->toArray();
|
|
|
foreach ($pch as $key => $value) {
|
|
|
- $list = $this->equipmentTypeModel->where('pid', $value['id'])->order('order asc')->select()->toArray();
|
|
|
+ $list = $this->equipmentTypeModel->where('pid', $value['id'])->order('order desc')->select()->toArray();
|
|
|
foreach ($list as $k => $v) {
|
|
|
$list[$k]['pid'] = intval($v['pid']);
|
|
|
$list[$k]['status'] = strval($v['status']);
|
|
@@ -89,6 +90,10 @@ class EquipmentType extends CatchController
|
|
|
if ($id <= 7) {
|
|
|
return CatchResponse::fail('该类型不能删除');
|
|
|
}
|
|
|
+ $data = HydEquipment::where('equipment_type', $id)->find();
|
|
|
+ if ($data) {
|
|
|
+ return CatchResponse::fail('该类型存在设备数据');
|
|
|
+ }
|
|
|
return CatchResponse::success($this->equipmentTypeModel->deleteBy($id, true));
|
|
|
}
|
|
|
/**
|
|
@@ -98,7 +103,7 @@ class EquipmentType extends CatchController
|
|
|
*/
|
|
|
public function findParentEquipmentType()
|
|
|
{
|
|
|
- $pch = $this->equipmentTypeModel->where('pid', 0)->order('order asc')->select();
|
|
|
+ $pch = $this->equipmentTypeModel->where('pid', 0)->order('order desc')->select();
|
|
|
return CatchResponse::success($pch);
|
|
|
}
|
|
|
/** 根据pid 获取所有的种类
|
|
@@ -110,8 +115,7 @@ class EquipmentType extends CatchController
|
|
|
{
|
|
|
$data = $request->get();
|
|
|
$pid = $data['id'];
|
|
|
- $ls = $this->equipmentTypeModel->where('pid', $pid)->select();
|
|
|
-
|
|
|
+ $ls = $this->equipmentTypeModel->where('pid', $pid)->order('order desc')->where('status', 1)->select();
|
|
|
return CatchResponse::success($ls);
|
|
|
}
|
|
|
}
|