From 19d38802a90fdd1db9c05ea6ac89621fd9052826 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sun, 1 Dec 2024 16:56:00 +0800 Subject: [PATCH] Dept --- .../src/controller/Category.php | 2 - plugs/think-plugs-ticket/src/Service.php | 1 + .../src/controller/Dept.php | 47 +++++++++++ .../src/model/TicketDept.php | 10 +++ .../src/model/TicketTicket.php | 15 ++++ .../src/model/TicketTicketInter.php | 2 +- .../src/model/TicketTicketOuter.php | 2 +- .../src/view/dept/form.html | 33 ++++++++ .../src/view/dept/index.html | 82 +++++++++++++++++++ .../src/view/dept/index_search.html | 16 ++++ 10 files changed, 206 insertions(+), 4 deletions(-) create mode 100644 plugs/think-plugs-ticket/src/controller/Dept.php create mode 100644 plugs/think-plugs-ticket/src/model/TicketDept.php create mode 100644 plugs/think-plugs-ticket/src/view/dept/form.html create mode 100644 plugs/think-plugs-ticket/src/view/dept/index.html create mode 100644 plugs/think-plugs-ticket/src/view/dept/index_search.html diff --git a/plugs/think-plugs-cms/src/controller/Category.php b/plugs/think-plugs-cms/src/controller/Category.php index 72d9bb6..66294ba 100644 --- a/plugs/think-plugs-cms/src/controller/Category.php +++ b/plugs/think-plugs-cms/src/controller/Category.php @@ -38,7 +38,6 @@ class Category extends Controller public function add() { $this->title = '添加栏目'; - $this->_applyFormToken(); CmsCategory::mForm('form'); } @@ -53,7 +52,6 @@ class Category extends Controller { $this->title = '编辑栏目'; $this->id = $this->request->param('id', 0, 'intval'); //当前栏目ID - $this->_applyFormToken(); CmsCategory::mForm('form'); } diff --git a/plugs/think-plugs-ticket/src/Service.php b/plugs/think-plugs-ticket/src/Service.php index 9b7090e..16a4791 100644 --- a/plugs/think-plugs-ticket/src/Service.php +++ b/plugs/think-plugs-ticket/src/Service.php @@ -22,6 +22,7 @@ class Service extends Plugin 'name' => '工单管理', 'subs' => [ ['name' => '工单分类', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/type/index"], + ['name' => '部门管理', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/dept/index"], ['name' => '随手拍列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/user_share/index"], ['name' => '工单列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/ticket/index"], ['name' => '内部工单列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/ticket_inter/index"], diff --git a/plugs/think-plugs-ticket/src/controller/Dept.php b/plugs/think-plugs-ticket/src/controller/Dept.php new file mode 100644 index 0000000..9a53836 --- /dev/null +++ b/plugs/think-plugs-ticket/src/controller/Dept.php @@ -0,0 +1,47 @@ +title = '部门管理'; + TicketDept::mQuery()->layTable(function () { + + }, function (QueryHelper $query) { + $query->like('name')->equal('status'); + }); + } + + public function add() + { + $this->title = '添加部门'; + TicketDept::mForm('form'); + } + + public function edit() + { + $this->title = '编辑部门'; + TicketDept::mForm('form'); + } + + public function remove() + { + $this->_applyFormToken(); + TicketDept::mDelete('id'); + } + + public function status() + { + TicketDept::mSave($this->_vali([ + 'id.require' => '部门ID不能为空', + 'status.in:0,1' => '状态值范围异常!', + 'status.require' => '状态值不能为空!', + ]), 'id'); + } +} \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/model/TicketDept.php b/plugs/think-plugs-ticket/src/model/TicketDept.php new file mode 100644 index 0000000..ff8f72f --- /dev/null +++ b/plugs/think-plugs-ticket/src/model/TicketDept.php @@ -0,0 +1,10 @@ +dept()->find(); + if (!empty($dept)) { + return $dept['name']; + } else { + return '未知'; + } + } + private function getStatusList() { return [ @@ -88,6 +98,11 @@ class TicketTicket extends Model return $this->hasMany(TicketUserShare::class, 'linked_ticket_id'); } + public function dept() + { + return $this->belongsTo(TicketDept::class, 'dept_id'); + } + public function scopeUnConf($query) { return $query->where('state', '=', '0'); diff --git a/plugs/think-plugs-ticket/src/model/TicketTicketInter.php b/plugs/think-plugs-ticket/src/model/TicketTicketInter.php index c3566fd..a736f87 100644 --- a/plugs/think-plugs-ticket/src/model/TicketTicketInter.php +++ b/plugs/think-plugs-ticket/src/model/TicketTicketInter.php @@ -4,7 +4,7 @@ namespace plugin\ticket\model; class TicketTicketInter extends TicketTicket { - protected $append = ['status_text', 'type_name']; + protected $append = ['status_text', 'type_name', 'dept_name']; protected $globalScope = ['inter']; protected $table = 'ticket_ticket'; public function type() diff --git a/plugs/think-plugs-ticket/src/model/TicketTicketOuter.php b/plugs/think-plugs-ticket/src/model/TicketTicketOuter.php index 73dce1d..810e4a2 100644 --- a/plugs/think-plugs-ticket/src/model/TicketTicketOuter.php +++ b/plugs/think-plugs-ticket/src/model/TicketTicketOuter.php @@ -4,7 +4,7 @@ namespace plugin\ticket\model; class TicketTicketOuter extends TicketTicket { - protected $append = ['status_text', 'type_name']; + protected $append = ['status_text', 'type_name', 'dept_name']; protected $globalScope = ['outer']; protected $table = 'ticket_ticket'; public function type() diff --git a/plugs/think-plugs-ticket/src/view/dept/form.html b/plugs/think-plugs-ticket/src/view/dept/form.html new file mode 100644 index 0000000..bad18e6 --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/dept/form.html @@ -0,0 +1,33 @@ +
+ + + diff --git a/plugs/think-plugs-ticket/src/view/dept/index.html b/plugs/think-plugs-ticket/src/view/dept/index.html new file mode 100644 index 0000000..9fdc586 --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/dept/index.html @@ -0,0 +1,82 @@ +{extend name="table"} + +{block name="button"} + + + +{/block} + +{block name="content"} +