You've already forked jianlizaojia
82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace app\xzgl\controller;
|
|
|
|
use app\xzgl\model\XzglProfile;
|
|
use think\admin\Controller;
|
|
use think\admin\helper\QueryHelper;
|
|
use think\admin\model\SystemUser;
|
|
|
|
/**
|
|
* 用户档案管理
|
|
*/
|
|
class User extends Controller
|
|
{
|
|
/**
|
|
* 用户档案管理
|
|
* @auth true
|
|
* @menu true
|
|
* @return void
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->title = '用户档案管理';
|
|
XzglProfile::mQuery()->layTable(function () {
|
|
|
|
}, static function (QueryHelper $query) {
|
|
$query->rightJoin('jl_staff_user', 'jl_staff_user.id = jl_xzgl_profile.id')
|
|
->field('jl_staff_user.id as staff_id, jl_staff_user.*, jl_xzgl_profile.*')
|
|
->with('user');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 编辑用户档案
|
|
* @auth true
|
|
* @return void
|
|
*/
|
|
public function edit()
|
|
{
|
|
$data = $this->_vali([
|
|
'id.require' => '用户ID不能为空',
|
|
]);
|
|
$sys_user = SystemUser::mk()->findOrEmpty($data['id']);
|
|
if ($sys_user->isEmpty()) $this->error('用户不存在!');
|
|
XzglProfile::mForm('form');
|
|
}
|
|
|
|
protected function _form_filter(&$data) {
|
|
if ($this->request->isPost()) {
|
|
if (empty($data['lz_date'])) {
|
|
unset($data['lz_date']);
|
|
}
|
|
if (empty($data['rz_date'])) {
|
|
unset($data['rz_date']);
|
|
}
|
|
if (empty($data['zz_date'])) {
|
|
unset($data['zz_date']);
|
|
}
|
|
if (empty($data['birthday'])) {
|
|
unset($data['birthday']);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 清空用户档案
|
|
* @auth true
|
|
* @return void
|
|
*/
|
|
public function clear()
|
|
{
|
|
$data = $this->_vali([
|
|
'id.require' => '用户ID不能为空',
|
|
]);
|
|
$sys_user = SystemUser::mk()->findOrEmpty($data['id']);
|
|
if ($sys_user->isEmpty()) $this->error('用户不存在!');
|
|
if ($this->request->isPost()) {
|
|
XzglProfile::mk()->where(['id' => $data['id']])->delete();
|
|
}
|
|
$this->success('清空成功!');
|
|
}
|
|
} |