[Staff]Init

This commit is contained in:
2025-06-20 18:57:40 +08:00
parent c57ae846e3
commit 900e42f1db
8 changed files with 231 additions and 1 deletions

View File

@ -20,8 +20,15 @@
"zoujingli/think-install": true "zoujingli/think-install": true
} }
}, },
"repositories": {
"think-plug-staff": {
"type": "path",
"url": "plugs/think-plugs-staff"
}
},
"require": { "require": {
"php": ">=8.3", "php": ">=8.3",
"zoujingli/think-plugs-admin": "^1.0" "zoujingli/think-plugs-admin": "^1.0",
"jerryyan/think-plugs-staff": "dev-master"
} }
} }

View File

@ -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": {
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace jerryyan\staff;
use think\admin\Plugin;
class Service extends Plugin
{
protected $appCode = 'staff';
protected $appName = '部门员工';
public static function menu(): array
{
return [
[
'name' => '组织架构',
'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'],
]
]
];
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace jerryyan\staff\model;
use think\admin\Model;
use think\model\relation\HasMany;
use think\model\relation\HasOne;
class StaffDept extends Model
{
protected $createTime = 'create_at';
protected $updateTime = false;
protected $oplogName = '部门';
protected $oplogType = '部门管理';
public function staffs(): HasMany
{
return $this->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');
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace jerryyan\staff\model;
use think\admin\Model;
use think\model\relation\HasOne;
class StaffUser extends Model
{
protected $createTime = 'create_at';
protected $updateTime = false;
protected $oplogName = '部门员工';
protected $oplogType = '部门员工管理';
public function dept(): HasOne
{
return $this->hasOne(StaffDept::class, 'id', 'dept_id')->where([
'status' => 1, 'is_deleted' => 0,
]);
}
}

View File

@ -0,0 +1,23 @@
<div class="layui-card">
{block name='style'}{/block}
{block name='header'}
{notempty name='title'}
<div class="layui-card-header">
<span class="layui-icon font-s10 color-desc margin-right-5">&#xe65b;</span>{$title|lang}
<div class="pull-right">{block name='button'}{/block}</div>
</div>
{/notempty}
{/block}
<div class="layui-card-line"></div>
<div class="layui-card-body">
<div class="layui-card-html">
{notempty name='showErrorMessage'}
<div class="think-box-notify" type="error">
<b>{:lang('系统提示:')}</b><span>{$showErrorMessage|raw}</span>
</div>
{/notempty}
{block name='content'}{/block}
</div>
</div>
{block name='script'}{/block}
</div>

View File

@ -0,0 +1,23 @@
<div class="layui-card">
{block name='style'}{/block}
{block name='header'}
{notempty name='title'}
<div class="layui-card-header">
<span class="layui-icon font-s10 color-desc margin-right-5">&#xe65b;</span>{$title|lang}
<div class="pull-right">{block name='button'}{/block}</div>
</div>
{/notempty}
{/block}
<div class="layui-card-line"></div>
<div class="layui-card-body">
<div class="layui-card-table">
{notempty name='showErrorMessage'}
<div class="think-box-notify" type="error">
<b>{:lang('系统提示:')}</b><span>{$showErrorMessage|raw}</span>
</div>
{/notempty}
{block name='content'}{/block}
</div>
</div>
{block name='script'}{/block}
</div>

View File

@ -0,0 +1,54 @@
<?php
use jerryyan\staff\Service;
use think\admin\extend\PhinxExtend;
use think\migration\Migrator;
@set_time_limit(0);
@ini_set('memory_limit', -1);
/**
* 系统模块数据
*/
class InstallStaffMenu extends Migrator
{
/**
* 获取脚本名称
* @return string
*/
public function getName(): string
{
return 'StaffPlugin';
}
/**
* 创建数据库
*/
public function change()
{
$this->insertMenu();
}
/**
* 初始化系统菜单
* @return void
* @throws \Exception
*/
private function insertMenu()
{
// 初始化菜单数据
PhinxExtend::write2menu([
[
'name' => '组织架构',
'sort' => '101',
'subs' => Service::menu(),
],
], [
'url|node' => 'staff/user/index'
]);
}
}