You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
4.0 KiB
143 lines
4.0 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\adminapi\controller\contract_sign;
|
|
|
|
use core\base\BaseAdminController;
|
|
use app\service\admin\contract_sign\ContractSignService;
|
|
|
|
|
|
/**
|
|
* 合同关系控制器
|
|
* Class ContractSign
|
|
* @package app\adminapi\controller\contract_sign
|
|
*/
|
|
class ContractSign extends BaseAdminController
|
|
{
|
|
/**
|
|
* 获取合同关系列表
|
|
* @return \think\Response
|
|
*/
|
|
public function lists(){
|
|
$data = $this->request->params([
|
|
["contract_id",""],
|
|
["personnel_id",0],
|
|
["status",""],
|
|
["created_at",["",""]],
|
|
["sign_time",["",""]]
|
|
]);
|
|
|
|
// 过滤掉空字符串参数,避免不必要的搜索条件
|
|
$filtered_data = array_filter($data, function($value) {
|
|
return $value !== "" && $value !== [];
|
|
});
|
|
|
|
// 确保personnel_id总是有数值类型
|
|
if (!isset($filtered_data['personnel_id'])) {
|
|
$filtered_data['personnel_id'] = 0;
|
|
}
|
|
|
|
return success((new ContractSignService())->getPage($filtered_data));
|
|
}
|
|
|
|
/**
|
|
* 合同关系详情
|
|
* @param int $id
|
|
* @return \think\Response
|
|
*/
|
|
public function info(int $id){
|
|
return success((new ContractSignService())->getInfo($id));
|
|
}
|
|
|
|
/**
|
|
* 添加合同关系
|
|
* @return \think\Response
|
|
*/
|
|
public function add(){
|
|
$data = $this->request->params([
|
|
["contract_id",0],
|
|
["personnel_id",0],
|
|
|
|
]);
|
|
$this->validate($data, 'app\validate\contract_sign\ContractSign.add');
|
|
$id = (new ContractSignService())->add($data);
|
|
return success('ADD_SUCCESS', ['id' => $id]);
|
|
}
|
|
|
|
/**
|
|
* 合同关系编辑
|
|
* @param $id 合同关系id
|
|
* @return \think\Response
|
|
*/
|
|
public function edit(int $id){
|
|
$data = $this->request->params([
|
|
["contract_id",0],
|
|
["personnel_id",0],
|
|
|
|
]);
|
|
$this->validate($data, 'app\validate\contract_sign\ContractSign.edit');
|
|
(new ContractSignService())->edit($id, $data);
|
|
return success('EDIT_SUCCESS');
|
|
}
|
|
|
|
/**
|
|
* 合同关系删除
|
|
* @param $id 合同关系id
|
|
* @return \think\Response
|
|
*/
|
|
public function del(int $id){
|
|
(new ContractSignService())->del($id);
|
|
return success('DELETE_SUCCESS');
|
|
}
|
|
|
|
|
|
public function getContractAll(){
|
|
return success(( new ContractSignService())->getContractAll());
|
|
}
|
|
|
|
public function getPersonnelAll(){
|
|
return success(( new ContractSignService())->getPersonnelAll());
|
|
}
|
|
|
|
/**
|
|
* 获取员工所有合同(包括未签署的)
|
|
* @return \think\Response
|
|
*/
|
|
public function getPersonnelContracts(){
|
|
$data = $this->request->params([
|
|
["personnel_id", 0]
|
|
]);
|
|
return success((new ContractSignService())->getPersonnelContracts($data));
|
|
}
|
|
|
|
/**
|
|
* 更新合同签署状态
|
|
* @return \think\Response
|
|
*/
|
|
public function updateStatus(){
|
|
$data = $this->request->params([
|
|
["id", 0],
|
|
["contract_id", 0],
|
|
["personnel_id", 0],
|
|
["status", 1],
|
|
["signature_image", ""],
|
|
["sign_time", ""],
|
|
["fill_data", ""]
|
|
]);
|
|
|
|
$id = $data['id'];
|
|
unset($data['id']);
|
|
|
|
(new ContractSignService())->edit($id, $data);
|
|
return success('UPDATE_SUCCESS');
|
|
}
|
|
|
|
}
|
|
|