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 @@ +
+ + {notempty name='records'} +
+ {/notempty} + + + + + +
+ +
+ +
+
+
+ +
+ + + +
+
+ +
+ +
+ +
+
+ {notempty name='records'} +
+ {/notempty} + + {notempty name='records'} +
+ + + + + + + + + + + + + {volist name="records" id="item"} + {$item.name} - {$item.age} + + + + + + + + {/volist} + +
ID备忘内容通知状态时间
{$item.id}{$item.remark}{$item.need_notice_text}{$item.status_text}{$item.create_time}
+
+ {/notempty} + + +
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 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + +
+
+
+ +
+ +
+ {foreach name="statusList" item="vo"} + + {/foreach} +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
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 @@ +
+ +
+ {:build_heading(null,FALSE)} + +
+ + +
+
+
+
+
+ + {:__('Add')} + {:__('Edit')} + {:__('Delete')} + + + + + +
+ +
+
+
+ +
+
+
diff --git a/public/assets/js/backend/orders/dispatch2.js b/public/assets/js/backend/orders/dispatch2.js index e92b561..088e2b1 100644 --- a/public/assets/js/backend/orders/dispatch2.js +++ b/public/assets/js/backend/orders/dispatch2.js @@ -111,7 +111,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($, text:"完成", title:"完成", icon: 'fa fa-check', - url: 'orders/dispatch2/finish', + url: function(row){ + return 'orders/dispatch2/finish?dispatch_id='+row.id; + }, extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-xs btn-success btn-dialog', visible:function(row){ @@ -121,6 +123,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($, return false; } }, + { + name: 'add-record', + text:"备忘", + title:"备忘", + icon: 'fa fa-record', + url: 'orders/dispatchrecord/add', + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-warning btn-dialog', + visible:function(row){ + if(row.btn_record){ + return true; + } + return false; + } + }, ], } diff --git a/public/assets/js/backend/orders/dispatchrecord.js b/public/assets/js/backend/orders/dispatchrecord.js new file mode 100644 index 0000000..1d81697 --- /dev/null +++ b/public/assets/js/backend/orders/dispatchrecord.js @@ -0,0 +1,61 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'orders/dispatchrecord/index' + location.search, + // add_url: 'orders/dispatchrecord/add', + edit_url: 'orders/dispatchrecord/edit', + del_url: 'orders/dispatchrecord/del', + multi_url: 'orders/dispatchrecord/multi', + import_url: 'orders/dispatchrecord/import', + table: 'order_dispatch_record', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + fixedColumns: true, + fixedRightNumber: 1, + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'dispatch_id', title: __('Dispatch_id')}, + {field: 'worker_id', title: __('Worker_id')}, + {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'need_notice', title: __('Need_notice'), searchList: {"0":__('Need_notice 0'),"1":__('Need_notice 1')}, formatter: Table.api.formatter.normal}, + {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status}, + {field: 'notice_time', title: __('Notice_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'admin_id', title: __('Admin_id')}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +});