contract template obligation contract template dependency UI

This commit is contained in:
glovetleong
2021-07-18 17:29:45 +08:00
parent fca442fb7c
commit 175b99d6dc
20 changed files with 914 additions and 29 deletions
-3
View File
@@ -178,9 +178,6 @@ class ContractModule extends BaseController
$contract->complete_day_range = $complete_day_range ?? $contract->complete_day_range;
$contract->update();
// log
ContractModule::makeLog($contract->id, 'user (' . Auth::guard('user-api')->user()->id . ') updated');
@@ -11,7 +11,7 @@ use App\Http\Modules\User\ContractTemplateObligationModule;
use App\Http\Rules\User\UnderCheck;
use App\Http\Rules\User\ExistCheck;
use App\Http\Rules\User\ContractTemplateObligationDependencyCheck;
use App\Http\Rules\User\ContractTemplateObligationContractTemplateDependencyCheck;
use App\Http\Helpers\General;
use App\Http\Helpers\Hasher;
@@ -33,7 +33,9 @@ class ContractTemplateObligationContractTemplateDependencyModule extends BaseCon
public static function list(Request $request)
{
General::storeCachePerviousQuery($request->query(), 'contract_template_obligation_contract_template_dependency_query');
$contract_template_obligation_hash_id = $contract_template_obligation_id = $request->get('contract_template_obligation_id', []);
$name = $request->get('name', null);
$status = $request->get('status', []);
$page = $request->get('page', null);
@@ -41,7 +43,12 @@ class ContractTemplateObligationContractTemplateDependencyModule extends BaseCon
$query = ContractTemplateObligationContractTemplateDependency::query();
if (strlen($name) > 0) {
if (!empty($contract_template_obligation_id)) {
$contract_template_obligation_id = Hasher::decodeArray('contract_template_obligations', $contract_template_obligation_id);
$query->whereIn('contract_template_obligation_id', $contract_template_obligation_id);
}
if (strlen($name) > 0) {
$query->where('name', 'like', '%' . $name . '%');
}
@@ -54,6 +61,7 @@ class ContractTemplateObligationContractTemplateDependencyModule extends BaseCon
$query->orderBy('id', 'desc');
$params = [
'contract_template_obligation_id' => $contract_template_obligation_hash_id,
'name' => $name,
'status' => $status,
'page' => $page
@@ -155,12 +163,12 @@ class ContractTemplateObligationContractTemplateDependencyModule extends BaseCon
'required',
new UnderCheck('contract_template_obligation'),
new ExistCheck('contract_template_obligation'),
// new ContractTemplateObligationDependencyCheck($data['depend_contract_template_obligation_id'] ?? [])
],
'depend_contract_template_id' => [
'required',
new UnderCheck('contract_template'),
new ExistCheck('contract_template')
new ExistCheck('contract_template'),
// new ContractTemplateObligationContractTemplateDependencyCheck($data['contract_template_obligation_id'] ?? [])
],
];
}
@@ -32,7 +32,9 @@ class ContractTemplateObligationDependencyModule extends BaseController
public static function list(Request $request)
{
General::storeCachePerviousQuery($request->query(), 'contract_template_obligation_dependency_query');
$contract_template_obligation_hash_id = $contract_template_obligation_id = $request->get('contract_template_obligation_id', []);
$name = $request->get('name', null);
$status = $request->get('status', []);
$page = $request->get('page', null);
@@ -40,7 +42,12 @@ class ContractTemplateObligationDependencyModule extends BaseController
$query = ContractTemplateObligationDependency::query();
if (strlen($name) > 0) {
if (!empty($contract_template_obligation_id)) {
$contract_template_obligation_id = Hasher::decodeArray('contract_template_obligations', $contract_template_obligation_id);
$query->whereIn('contract_template_obligation_id', $contract_template_obligation_id);
}
if (strlen($name) > 0) {
$query->where('name', 'like', '%' . $name . '%');
}
@@ -53,6 +60,7 @@ class ContractTemplateObligationDependencyModule extends BaseController
$query->orderBy('id', 'desc');
$params = [
'contract_template_obligation_id' => $contract_template_obligation_hash_id,
'name' => $name,
'status' => $status,
'page' => $page
@@ -154,12 +162,12 @@ class ContractTemplateObligationDependencyModule extends BaseController
'required',
new UnderCheck('contract_template_obligation'),
new ExistCheck('contract_template_obligation'),
new ContractTemplateObligationDependencyCheck($data['depend_contract_template_obligation_id'] ?? [])
],
'depend_contract_template_obligation_id' => [
'required',
new UnderCheck('contract_template_obligation'),
new ExistCheck('contract_template_obligation')
new ExistCheck('contract_template_obligation'),
new ContractTemplateObligationDependencyCheck($data['contract_template_obligation_id'] ?? [])
],
];
}
@@ -31,6 +31,7 @@ class ContractTemplateObligationModule extends BaseController
{
General::storeCachePerviousQuery($request->query(), 'contract_template_obligation_query');
$not_hash_id = $not_id = $request->get('not_id', []);
$contract_template_hash_id = $contract_template_id = $request->get('contract_template_id', []);
$name = $request->get('name', null);
@@ -40,6 +41,11 @@ class ContractTemplateObligationModule extends BaseController
$query = ContractTemplateObligation::query();
if (!empty($not_id)) {
$not_id = Hasher::decodeArray('contract_template_obligations', $not_id);
$query->whereNotIn('id', $not_id);
}
if (!empty($contract_template_id)) {
$contract_template_id = Hasher::decodeArray('contract_templates', $contract_template_id);
$query->whereIn('contract_template_id', $contract_template_id);
@@ -17,11 +17,11 @@ class ContractTemplateObligationDependencyCheck implements Rule
* @return void
*/
private $depend_template_contract_obligation_id;
private $contract_template_obligation_id;
public function __construct($depend_template_contract_obligation_id = '')
public function __construct($contract_template_obligation_id = '')
{
$this->depend_template_contract_obligation_id = $depend_template_contract_obligation_id;
$this->contract_template_obligation_id = $contract_template_obligation_id;
}
/**
@@ -36,16 +36,17 @@ class ContractTemplateObligationDependencyCheck implements Rule
$this->attribute = $attribute;
$value = is_array($value) ? $value : [$value];
if ($value[0] != $this->depend_template_contract_obligation_id[0]) {
$contract_template_obligation_id = Hasher::decode('contract_template_obligations', $value[0]);
if ($value[0] != $this->contract_template_obligation_id[0]) {
$contract_template_obligation_id = Hasher::decode('contract_template_obligations', $this->contract_template_obligation_id[0]);
$contract_template_obligation = ContractTemplateObligation::find($contract_template_obligation_id);
$depend_contract_template_obligation_id = Hasher::decode('contract_template_obligations', $this->depend_template_contract_obligation_id[0]);
$depend_contract_template_obligation_id = Hasher::decode('contract_template_obligations', $value[0]);
$depend_contract_template_obligation = ContractTemplateObligation::find($depend_contract_template_obligation_id);
$contract_template_obligation_dependency_structure = $contract_template_obligation->getContractTemplateObligationDependencyStructure([$contract_template_obligation->hash_id]);
$contract_template_obligation_dependency_structure = $depend_contract_template_obligation->getContractTemplateObligationDependencyStructure([$depend_contract_template_obligation->hash_id]);
if (in_array($depend_contract_template_obligation->hash_id, $contract_template_obligation_dependency_structure)) {
// return false;
if (in_array($contract_template_obligation->hash_id, $contract_template_obligation_dependency_structure)) {
return false;
}
return true;