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.
152 lines
4.1 KiB
152 lines
4.1 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\model\contract_sign;
|
|
|
|
use core\base\BaseModel;
|
|
use think\model\concern\SoftDelete;
|
|
use think\model\relation\HasMany;
|
|
use think\model\relation\HasOne;
|
|
|
|
use app\model\contract\Contract;
|
|
|
|
use app\model\personnel\Personnel;
|
|
|
|
/**
|
|
* 合同关系模型
|
|
* Class ContractSign
|
|
* @package app\model\contract_sign
|
|
*/
|
|
class ContractSign extends BaseModel
|
|
{
|
|
|
|
use SoftDelete;
|
|
|
|
/**
|
|
* 数据表主键
|
|
* @var string
|
|
*/
|
|
protected $pk = 'id';
|
|
|
|
/**
|
|
* 模型名称
|
|
* @var string
|
|
*/
|
|
protected $name = 'contract_sign';
|
|
|
|
/**
|
|
* 定义软删除标记字段.
|
|
* @var string
|
|
*/
|
|
protected $deleteTime = 'deleted_at';
|
|
|
|
/**
|
|
* 定义软删除字段的默认值.
|
|
* @var int
|
|
*/
|
|
protected $defaultSoftDelete = 0;
|
|
|
|
/**
|
|
* 搜索器:合同ID
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchContractIdAttr($query, $value, $data)
|
|
{
|
|
if ($value && $value != 0) {
|
|
$query->where("contract_id", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:合同关系人员ID
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchPersonnelIdAttr($query, $value, $data)
|
|
{
|
|
if ($value && $value != 0) {
|
|
$query->where("personnel_id", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:合同关系签署状态
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchStatusAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("status", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:合同关系创建时间
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchCreatedAtAttr($query, $value, $data)
|
|
{
|
|
$start = empty($value[0]) ? 0 : strtotime($value[0]);
|
|
$end = empty($value[1]) ? 0 : strtotime($value[1]);
|
|
if ($start > 0 && $end > 0) {
|
|
$query->where([["created_at", "between", [$start, $end]]]);
|
|
} else if ($start > 0 && $end == 0) {
|
|
$query->where([["created_at", ">=", $start]]);
|
|
} else if ($start == 0 && $end > 0) {
|
|
$query->where([["created_at", "<=", $end]]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:合同关系签署时间
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchSignTimeAttr($query, $value, $data)
|
|
{
|
|
$start = empty($value[0]) ? 0 : strtotime($value[0]);
|
|
$end = empty($value[1]) ? 0 : strtotime($value[1]);
|
|
if ($start > 0 && $end > 0) {
|
|
$query->where([["sign_time", "between", [$start, $end]]]);
|
|
} else if ($start > 0 && $end == 0) {
|
|
$query->where([["sign_time", ">=", $start]]);
|
|
} else if ($start == 0 && $end > 0) {
|
|
$query->where([["sign_time", "<=", $end]]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function contract(){
|
|
return $this->hasOne(Contract::class, 'id', 'contract_id')->joinType('left')
|
|
->withField('contract_name,contract_type,remarks,original_filename,file_size,contract_content,placeholder_config,id')
|
|
->bind([
|
|
'contract_id_name'=>'contract_name',
|
|
'contract_type'=>'contract_type',
|
|
'remarks'=>'remarks',
|
|
'original_filename'=>'original_filename',
|
|
'file_size'=>'file_size',
|
|
'contract_content'=>'contract_content',
|
|
'placeholder_config'=>'placeholder_config'
|
|
]);
|
|
}
|
|
|
|
public function personnel(){
|
|
return $this->hasOne(Personnel::class, 'id', 'personnel_id')->joinType('left')->withField('name,id')->bind(['personnel_id_name'=>'name']);
|
|
}
|
|
|
|
}
|
|
|