From 49c0bbe837859f28aac27033e89ee937a76c9488 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Thu, 23 Nov 2023 17:26:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=9C=9F=E5=9C=B0=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/api/land_plant.ts | 1 - admin/src/api/land_plant_action.ts | 31 +++ admin/src/views/land/edit.vue | 2 +- admin/src/views/land_plant/edit.vue | 2 +- admin/src/views/land_plant/index.vue | 15 +- admin/src/views/land_plant_action/edit.vue | 178 ++++++++++++++++++ admin/src/views/land_plant_action/index.vue | 140 ++++++++++++++ .../land/LandPlantActionController.php | 108 +++++++++++ .../controller/land/LandPlantController.php | 6 +- .../lists/land/LandPlantActionLists.php | 77 ++++++++ app/adminapi/lists/land/LandPlantLists.php | 21 ++- .../logic/land/LandPlantActionLogic.php | 112 +++++++++++ .../validate/land/LandPlantActionValidate.php | 98 ++++++++++ app/common/model/land/LandPlantAction.php | 45 +++++ 14 files changed, 826 insertions(+), 10 deletions(-) create mode 100644 admin/src/api/land_plant_action.ts create mode 100644 admin/src/views/land_plant_action/edit.vue create mode 100644 admin/src/views/land_plant_action/index.vue create mode 100644 app/adminapi/controller/land/LandPlantActionController.php create mode 100644 app/adminapi/lists/land/LandPlantActionLists.php create mode 100644 app/adminapi/logic/land/LandPlantActionLogic.php create mode 100644 app/adminapi/validate/land/LandPlantActionValidate.php create mode 100644 app/common/model/land/LandPlantAction.php diff --git a/admin/src/api/land_plant.ts b/admin/src/api/land_plant.ts index 7e9138b6..725ec941 100644 --- a/admin/src/api/land_plant.ts +++ b/admin/src/api/land_plant.ts @@ -6,7 +6,6 @@ export function apiLandLists(params: any) { return request.get({ url: '/land.land/lists', params }) } - // 土地种植表列表 export function apiLandPlantLists(params: any) { return request.get({ url: '/land.land_plant/lists', params }) diff --git a/admin/src/api/land_plant_action.ts b/admin/src/api/land_plant_action.ts new file mode 100644 index 00000000..67721338 --- /dev/null +++ b/admin/src/api/land_plant_action.ts @@ -0,0 +1,31 @@ +import request from '@/utils/request' + +// 土地种植表列表 +export function apiLandPlantLists(params: any) { + return request.get({ url: '/land.land_plant/lists', params }) +} + +// 土地种植作物操作表列表 +export function apiLandPlantActionLists(params: any) { + return request.get({ url: '/land.land_plant_action/lists', params }) +} + +// 添加土地种植作物操作表 +export function apiLandPlantActionAdd(params: any) { + return request.post({ url: '/land.land_plant_action/add', params }) +} + +// 编辑土地种植作物操作表 +export function apiLandPlantActionEdit(params: any) { + return request.post({ url: '/land.land_plant_action/edit', params }) +} + +// 删除土地种植作物操作表 +export function apiLandPlantActionDelete(params: any) { + return request.post({ url: '/land.land_plant_action/delete', params }) +} + +// 土地种植作物操作表详情 +export function apiLandPlantActionDetail(params: any) { + return request.get({ url: '/land.land_plant_action/detail', params }) +} \ No newline at end of file diff --git a/admin/src/views/land/edit.vue b/admin/src/views/land/edit.vue index b31fc414..b0961914 100644 --- a/admin/src/views/land/edit.vue +++ b/admin/src/views/land/edit.vue @@ -111,7 +111,7 @@ const mode = ref('add') // 弹窗标题 const popupTitle = computed(() => { - return mode.value == 'edit' ? '编辑土地表' : '新增土地表' + return mode.value == 'edit' ? '编辑土地' : '新增土地' }) // 表单数据 diff --git a/admin/src/views/land_plant/edit.vue b/admin/src/views/land_plant/edit.vue index 2256112e..138b15f4 100644 --- a/admin/src/views/land_plant/edit.vue +++ b/admin/src/views/land_plant/edit.vue @@ -97,7 +97,7 @@ const mode = ref('add') // 弹窗标题 const popupTitle = computed(() => { - return mode.value == 'edit' ? '编辑土地种植表' : '新增土地种植表' + return mode.value == 'edit' ? '编辑土地种植' : '新增土地种植' }) // 表单数据 diff --git a/admin/src/views/land_plant/index.vue b/admin/src/views/land_plant/index.vue index 47181aca..18697da0 100644 --- a/admin/src/views/land_plant/index.vue +++ b/admin/src/views/land_plant/index.vue @@ -73,8 +73,20 @@ {{ row.plant_date ? timeFormat(row.plant_date, 'yyyy-mm-dd hh:MM:ss') : '' }} - + + + + 种植操作 + + import { usePaging } from '@/hooks/usePaging' +import { getRoutePath } from '@/router' import { useDictData } from '@/hooks/useDictOptions' import { apiLandPlantLists, apiLandPlantDelete } from '@/api/land_plant' import { timeFormat } from '@/utils/util' diff --git a/admin/src/views/land_plant_action/edit.vue b/admin/src/views/land_plant_action/edit.vue new file mode 100644 index 00000000..a3d7e163 --- /dev/null +++ b/admin/src/views/land_plant_action/edit.vue @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/admin/src/views/land_plant_action/index.vue b/admin/src/views/land_plant_action/index.vue new file mode 100644 index 00000000..ac569f81 --- /dev/null +++ b/admin/src/views/land_plant_action/index.vue @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + 查询 + 重置 + + + + + + + + + + + + + + + + + + + + + + + 编辑 + + + 删除 + + + + + + + + + + + + + + + diff --git a/app/adminapi/controller/land/LandPlantActionController.php b/app/adminapi/controller/land/LandPlantActionController.php new file mode 100644 index 00000000..d8963b91 --- /dev/null +++ b/app/adminapi/controller/land/LandPlantActionController.php @@ -0,0 +1,108 @@ +dataLists(new LandPlantActionLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function add() + { + $params = (new LandPlantActionValidate())->post()->goCheck('add'); + $result = LandPlantActionLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(LandPlantActionLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function edit() + { + $params = (new LandPlantActionValidate())->post()->goCheck('edit'); + $result = LandPlantActionLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(LandPlantActionLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function delete() + { + $params = (new LandPlantActionValidate())->post()->goCheck('delete'); + LandPlantActionLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function detail() + { + $params = (new LandPlantActionValidate())->goCheck('detail'); + $result = LandPlantActionLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/land/LandPlantController.php b/app/adminapi/controller/land/LandPlantController.php index e174c698..4be38ba0 100644 --- a/app/adminapi/controller/land/LandPlantController.php +++ b/app/adminapi/controller/land/LandPlantController.php @@ -16,9 +16,9 @@ namespace app\adminapi\controller\land; -use app\adminapi\controller\BaseAdminController; -use app\adminapi\lists\land\LandPlantLists; -use app\adminapi\logic\land\LandPlantLogic; +use app\adminapi\controller\BaseAdminController; +use app\adminapi\lists\land\LandPlantLists; +use app\adminapi\logic\land\LandPlantLogic; use app\adminapi\validate\land\LandPlantValidate; diff --git a/app/adminapi/lists/land/LandPlantActionLists.php b/app/adminapi/lists/land/LandPlantActionLists.php new file mode 100644 index 00000000..cdebc64f --- /dev/null +++ b/app/adminapi/lists/land/LandPlantActionLists.php @@ -0,0 +1,77 @@ + ['plant_id', 'type'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function lists(): array + { + return LandPlantAction::where($this->searchWhere)->with('landPlant') + ->field(['id', 'plant_id', 'type', 'type_text', 'detail']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function count(): int + { + return LandPlantAction::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/land/LandPlantLists.php b/app/adminapi/lists/land/LandPlantLists.php index d357ad05..212daad1 100644 --- a/app/adminapi/lists/land/LandPlantLists.php +++ b/app/adminapi/lists/land/LandPlantLists.php @@ -38,10 +38,25 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['land_id', 'kind', 'breed', 'user', 'status', 'plant_date'], + '%like%' => ['kind', 'breed'], + '=' => ['land_id', 'user', 'status', 'plant_date'], ]; } + /** + * @notes 搜索条件 + * @author 段誉 + * @date 2023/2/24 16:08 + */ + public function queryWhere() + { + $where = []; + if (!empty($this->params['keyword'])) { + $where[] = ['kind|breed', 'like', '%' . $this->params['keyword'] . '%']; + } + return $where; + } + /** * @notes 获取列表 @@ -54,7 +69,7 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { - return LandPlant::where($this->searchWhere)->with('land') + return LandPlant::where($this->queryWhere())->where($this->searchWhere)->with('land') ->field(['id', 'land_id', 'kind', 'breed', 'area', 'user', 'status', 'pic', 'qr_code', 'plant_date', 'remark']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) @@ -71,7 +86,7 @@ class LandPlantLists extends BaseAdminDataLists implements ListsSearchInterface */ public function count(): int { - return LandPlant::where($this->searchWhere)->count(); + return LandPlant::where($this->queryWhere())->where($this->searchWhere)->count(); } } \ No newline at end of file diff --git a/app/adminapi/logic/land/LandPlantActionLogic.php b/app/adminapi/logic/land/LandPlantActionLogic.php new file mode 100644 index 00000000..635627c6 --- /dev/null +++ b/app/adminapi/logic/land/LandPlantActionLogic.php @@ -0,0 +1,112 @@ + $params['plant_id'], + 'type' => $params['type'], + 'type_text' => $params['type_text'], + 'detail' => $params['detail'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + LandPlantAction::where('id', $params['id'])->update([ + 'plant_id' => $params['plant_id'], + 'type' => $params['type'], + 'type_text' => $params['type_text'], + 'detail' => $params['detail'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public static function delete(array $params): bool + { + return LandPlantAction::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public static function detail($params): array + { + return LandPlantAction::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/land/LandPlantActionValidate.php b/app/adminapi/validate/land/LandPlantActionValidate.php new file mode 100644 index 00000000..e0b8a485 --- /dev/null +++ b/app/adminapi/validate/land/LandPlantActionValidate.php @@ -0,0 +1,98 @@ + 'require', + 'plant_id' => 'require', + 'type' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'plant_id' => '种植ID', + 'type' => '操作类型', + ]; + + + /** + * @notes 添加场景 + * @return LandPlantActionValidate + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function sceneAdd() + { + return $this->only(['plant_id','type']); + } + + + /** + * @notes 编辑场景 + * @return LandPlantActionValidate + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function sceneEdit() + { + return $this->only(['id','plant_id','type']); + } + + + /** + * @notes 删除场景 + * @return LandPlantActionValidate + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return LandPlantActionValidate + * @author likeadmin + * @date 2023/11/23 14:53 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/land/LandPlantAction.php b/app/common/model/land/LandPlantAction.php new file mode 100644 index 00000000..33851dda --- /dev/null +++ b/app/common/model/land/LandPlantAction.php @@ -0,0 +1,45 @@ +hasOne(\app\common\model\land\LandPlant::class, 'id', 'plant_id'); + } + +} \ No newline at end of file