diff --git a/composer.json b/composer.json index 9e23cf3..7c5bf77 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,15 @@ "zoujingli/think-install": true } }, + "repositories": { + "think-plug-staff": { + "type": "path", + "url": "plugs/think-plugs-staff" + } + }, "require": { "php": ">=8.3", - "zoujingli/think-plugs-admin": "^1.0" + "zoujingli/think-plugs-admin": "^1.0", + "jerryyan/think-plugs-staff": "dev-master" } } \ No newline at end of file diff --git a/plugs/think-plugs-staff/composer.json b/plugs/think-plugs-staff/composer.json new file mode 100644 index 0000000..0e52426 --- /dev/null +++ b/plugs/think-plugs-staff/composer.json @@ -0,0 +1,39 @@ +{ + "name": "jerryyan/think-plugs-staff", + "description": "ThinkAdmin Plugin: Staff with Dept Support", + "version": "dev-master", + "minimum-stability": "dev", + "license": "WTFPL", + "authors": [ + { + "name": "Jerry Yan", + "email": "792602257@qq.com" + } + ], + "extra": { + "config": { + "type": "module", + "name": "员工及组织架构模块", + "platforms": ["h5web"], + "description": "员工及组织架构模块" + }, + "plugin": { + "copy": { + "stc/database": "database/migrations" + } + }, + "think": { + "services": [ + "jerryyan\\staff\\Service" + ] + } + }, + "autoload": { + "psr-4": { + "jerryyan\\staff\\": "src" + } + }, + "require": { + + } +} \ No newline at end of file diff --git a/plugs/think-plugs-staff/src/Service.php b/plugs/think-plugs-staff/src/Service.php new file mode 100644 index 0000000..e7f57b3 --- /dev/null +++ b/plugs/think-plugs-staff/src/Service.php @@ -0,0 +1,24 @@ + '组织架构', + 'subs' => [ + ['name' => '员工管理', 'icon' => 'layui-icon layui-icon-group', 'url' => 'staff/user/index'], + ['name' => '部门管理', 'icon' => 'layui-icon layui-icon-cols', 'url' => 'staff/dept/index'], + ['name' => '角色管理', 'icon' => 'layui-icon layui-icon-auz', 'url' => 'staff/role/index'], + ] + ] + ]; + } +} \ No newline at end of file diff --git a/plugs/think-plugs-staff/src/model/StaffDept.php b/plugs/think-plugs-staff/src/model/StaffDept.php new file mode 100644 index 0000000..99b3e5b --- /dev/null +++ b/plugs/think-plugs-staff/src/model/StaffDept.php @@ -0,0 +1,39 @@ +hasMany(StaffUser::class, 'dept_id', 'id')->where([ + 'status' => 1, 'is_deleted' => 0, + ]); + } + + public function headman(): HasOne + { + return $this->hasOne(StaffUser::class, 'id', 'headman_id')->where([ + 'status' => 1, 'is_deleted' => 0, + ]); + } + + public function children(): HasMany + { + return $this->hasMany(StaffDept::class, 'pid', 'id'); + } + + public function parent(): HasOne + { + return $this->hasOne(StaffDept::class, 'id', 'pid'); + } +} \ No newline at end of file diff --git a/plugs/think-plugs-staff/src/model/StaffUser.php b/plugs/think-plugs-staff/src/model/StaffUser.php new file mode 100644 index 0000000..75329f8 --- /dev/null +++ b/plugs/think-plugs-staff/src/model/StaffUser.php @@ -0,0 +1,21 @@ +hasOne(StaffDept::class, 'id', 'dept_id')->where([ + 'status' => 1, 'is_deleted' => 0, + ]); + } +} \ No newline at end of file diff --git a/plugs/think-plugs-staff/src/view/main.html b/plugs/think-plugs-staff/src/view/main.html new file mode 100644 index 0000000..a698dd7 --- /dev/null +++ b/plugs/think-plugs-staff/src/view/main.html @@ -0,0 +1,23 @@ +
+ {block name='style'}{/block} + {block name='header'} + {notempty name='title'} +
+ {$title|lang} +
{block name='button'}{/block}
+
+ {/notempty} + {/block} +
+
+
+ {notempty name='showErrorMessage'} +
+ {:lang('系统提示:')}{$showErrorMessage|raw} +
+ {/notempty} + {block name='content'}{/block} +
+
+ {block name='script'}{/block} +
\ No newline at end of file diff --git a/plugs/think-plugs-staff/src/view/table.html b/plugs/think-plugs-staff/src/view/table.html new file mode 100644 index 0000000..fef73fe --- /dev/null +++ b/plugs/think-plugs-staff/src/view/table.html @@ -0,0 +1,23 @@ +
+ {block name='style'}{/block} + {block name='header'} + {notempty name='title'} +
+ {$title|lang} +
{block name='button'}{/block}
+
+ {/notempty} + {/block} +
+
+
+ {notempty name='showErrorMessage'} +
+ {:lang('系统提示:')}{$showErrorMessage|raw} +
+ {/notempty} + {block name='content'}{/block} +
+
+ {block name='script'}{/block} +
\ No newline at end of file diff --git a/plugs/think-plugs-staff/stc/database/20250621000000_install_staff_menu.php b/plugs/think-plugs-staff/stc/database/20250621000000_install_staff_menu.php new file mode 100644 index 0000000..b14ccbe --- /dev/null +++ b/plugs/think-plugs-staff/stc/database/20250621000000_install_staff_menu.php @@ -0,0 +1,54 @@ +insertMenu(); + } + + /** + * 初始化系统菜单 + * @return void + * @throws \Exception + */ + private function insertMenu() + { + + // 初始化菜单数据 + PhinxExtend::write2menu([ + [ + 'name' => '组织架构', + 'sort' => '101', + 'subs' => Service::menu(), + ], + ], [ + 'url|node' => 'staff/user/index' + ]); + } +} \ No newline at end of file