From d037ec193d636570a91cbd6893aea618cce7fa46 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Tue, 1 Apr 2025 17:19:25 +0800 Subject: [PATCH] record --- .../admin/controller/orders/Dispatch2.php | 2 + .../controller/orders/Dispatchrecord.php | 145 ++++++++++++++++++ .../lang/zh-cn/orders/dispatchrecord.php | 19 +++ application/admin/model/OrderDispatch.php | 9 +- .../admin/model/OrderDispatchRecord.php | 64 ++++++++ .../admin/validate/OrderDispatchRecord.php | 27 ++++ .../admin/view/orders/dispatchrecord/add.html | 76 +++++++++ .../view/orders/dispatchrecord/edit.html | 69 +++++++++ .../view/orders/dispatchrecord/index.html | 46 ++++++ public/assets/js/backend/orders/dispatch2.js | 19 ++- .../js/backend/orders/dispatchrecord.js | 61 ++++++++ 11 files changed, 535 insertions(+), 2 deletions(-) create mode 100644 application/admin/controller/orders/Dispatchrecord.php create mode 100644 application/admin/lang/zh-cn/orders/dispatchrecord.php create mode 100644 application/admin/model/OrderDispatchRecord.php create mode 100644 application/admin/validate/OrderDispatchRecord.php create mode 100644 application/admin/view/orders/dispatchrecord/add.html create mode 100644 application/admin/view/orders/dispatchrecord/edit.html create mode 100644 application/admin/view/orders/dispatchrecord/index.html create mode 100644 public/assets/js/backend/orders/dispatchrecord.js diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index d65d820..3ac2732 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -81,6 +81,8 @@ class Dispatch2 extends Backend $row->btn_abnormal = (in_array($row->status, $this->model->btnActiveStatusList('btn_abnormal'))) ? true : false; $row->btn_finished = (in_array($row->status, $this->model->btnActiveStatusList('btn_finished'))) ? true : false; $row->is_disabled = (in_array($row->status, $this->model->btnActiveStatusList('disabled_status'))) ? true : false; + + $row->btn_record = (in_array($row->status, $this->model->btnActiveStatusList('btn_record'))) ? true : false; // $row->btn_income = (in_array($row->status, $this->model->btnActiveStatusList('btn_income')) && in_array($row->order->status, $orderModel->incomeBtnStatus())) ? true : false; } $result = array("total" => $list->total(), "rows" => $list->items()); diff --git a/application/admin/controller/orders/Dispatchrecord.php b/application/admin/controller/orders/Dispatchrecord.php new file mode 100644 index 0000000..39f47ed --- /dev/null +++ b/application/admin/controller/orders/Dispatchrecord.php @@ -0,0 +1,145 @@ +model = new \app\admin\model\OrderDispatchRecord; + $this->view->assign("needNoticeList", $this->model->getNeedNoticeList()); + $this->view->assign("statusList", $this->model->getStatusList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + + $dispatch_id = $this->request->get('dispatch_id'); + + + $list = $this->model->where('dispatch_id',$dispatch_id)->order('id','desc')->select(); + + $this->assign('dispatch_id',$dispatch_id); + + $this->assign('records',$list); + + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + + $params['admin_id'] = $this->auth->id; + + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } + + +} diff --git a/application/admin/lang/zh-cn/orders/dispatchrecord.php b/application/admin/lang/zh-cn/orders/dispatchrecord.php new file mode 100644 index 0000000..b5bde7d --- /dev/null +++ b/application/admin/lang/zh-cn/orders/dispatchrecord.php @@ -0,0 +1,19 @@ + '任务ID', + 'Worker_id' => '师傅ID', + 'Remark' => '备注', + 'Need_notice' => '提醒师傅', + 'Need_notice 0' => '不需要', + 'Need_notice 1' => '需要', + 'Status' => '通知状态', + 'Status 0' => '未通知', + 'Set status to 0'=> '设为未通知', + 'Status 1' => '已通知', + 'Set status to 1'=> '设为已通知', + 'Notice_time' => '通知时间', + 'Create_time' => '创建时间', + 'Update_time' => '更新时间', + 'Admin_id' => '管理员ID' +]; diff --git a/application/admin/model/OrderDispatch.php b/application/admin/model/OrderDispatch.php index 3207bcd..d133f6e 100644 --- a/application/admin/model/OrderDispatch.php +++ b/application/admin/model/OrderDispatch.php @@ -152,7 +152,14 @@ class OrderDispatch extends Model self::STATUS_CANCEL, self::STATUS_REFUSED, self::STATUS_MOVE - ] + ], + 'btn_record' => [ + self::STATUS_TOGET, + self::STATUS_GOTIT, + self::STATUS_PLANIT, + self::STATUS_OVERTIME, + self::STATUS_CLOCK, + ], ]; return $btns[$btn]??[]; diff --git a/application/admin/model/OrderDispatchRecord.php b/application/admin/model/OrderDispatchRecord.php new file mode 100644 index 0000000..4220935 --- /dev/null +++ b/application/admin/model/OrderDispatchRecord.php @@ -0,0 +1,64 @@ + __('Need_notice 0'), '1' => __('Need_notice 1')]; + } + + public function getStatusList() + { + return ['0' => __('Status 0'), '1' => __('Status 1')]; + } + + + public function getNeedNoticeTextAttr($value, $data) + { + $value = $value ?: ($data['need_notice'] ?? ''); + $list = $this->getNeedNoticeList(); + return $list[$value] ?? ''; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ?: ($data['status'] ?? ''); + $list = $this->getStatusList(); + return $list[$value] ?? ''; + } + + + + +} diff --git a/application/admin/validate/OrderDispatchRecord.php b/application/admin/validate/OrderDispatchRecord.php new file mode 100644 index 0000000..a3173c0 --- /dev/null +++ b/application/admin/validate/OrderDispatchRecord.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/orders/dispatchrecord/add.html b/application/admin/view/orders/dispatchrecord/add.html new file mode 100644 index 0000000..87e509c --- /dev/null +++ b/application/admin/view/orders/dispatchrecord/add.html @@ -0,0 +1,76 @@ +
diff --git a/application/admin/view/orders/dispatchrecord/edit.html b/application/admin/view/orders/dispatchrecord/edit.html new file mode 100644 index 0000000..c9efd9b --- /dev/null +++ b/application/admin/view/orders/dispatchrecord/edit.html @@ -0,0 +1,69 @@ + diff --git a/application/admin/view/orders/dispatchrecord/index.html b/application/admin/view/orders/dispatchrecord/index.html new file mode 100644 index 0000000..0dbc8d9 --- /dev/null +++ b/application/admin/view/orders/dispatchrecord/index.html @@ -0,0 +1,46 @@ +