mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
clone contract UI
This commit is contained in:
@@ -45,4 +45,11 @@ class ContractController extends BaseController
|
||||
$contract = ContractModule::delete($request, $hash_id);
|
||||
return $contract;
|
||||
}
|
||||
|
||||
public function validCheck(Request $request, $hash_id = '')
|
||||
{
|
||||
$method = empty($hash_id) ? 'POST' :'PUT';
|
||||
$valid = ContractModule::validCheck($request, $hash_id, $method);
|
||||
return $valid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +230,14 @@ class ContractModule extends BaseController
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public static function validCheck(Request $request, $hash_id = '', $method = 'POST')
|
||||
{
|
||||
$id = $hash_id ? Hasher::decode('contracts', $hash_id) : '';
|
||||
$validation = ContractModule::validation($request, $id, $method);
|
||||
if (!$validation->status) {
|
||||
return response()->json($validation, 422);
|
||||
}
|
||||
}
|
||||
|
||||
private static function validation(Request $request, $id = '', $method = 'POST')
|
||||
{
|
||||
|
||||
+11
-1
@@ -11,7 +11,7 @@ class Contract extends Model
|
||||
{
|
||||
protected $table = 'contracts';
|
||||
|
||||
protected $appends = ['hash_id', 'contract_obligation_list'];
|
||||
protected $appends = ['hash_id', 'contract_obligation_list', 'contract_entity_list'];
|
||||
|
||||
protected $hidden = [
|
||||
'id', 'in_time_contract_template',
|
||||
@@ -22,6 +22,11 @@ class Contract extends Model
|
||||
return $this->hasMany('App\Models\ContractObligation', 'contract_id');
|
||||
}
|
||||
|
||||
public function contract_entity()
|
||||
{
|
||||
return $this->hasMany('App\Models\ContractEntity', 'contract_id');
|
||||
}
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('contracts', $this->id);
|
||||
@@ -32,6 +37,11 @@ class Contract extends Model
|
||||
return $this->contract_obligation()->get()->makeHidden(['contract_list']);
|
||||
}
|
||||
|
||||
public function getContractEntityListAttribute()
|
||||
{
|
||||
return $this->contract_entity()->get()->makeHidden(['contract_list']);
|
||||
}
|
||||
|
||||
public function getUpdatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
|
||||
@@ -2,10 +2,49 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Http\Helpers\Hasher;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ContractEntity extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'contract_entities';
|
||||
|
||||
protected $appends = ['hash_id', 'contract_list', 'entity_list'];
|
||||
|
||||
public function contract()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Contract', 'contract_id');
|
||||
}
|
||||
|
||||
public function entity()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Entity', 'entity_id');
|
||||
}
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('contract_entities', $this->id);
|
||||
}
|
||||
|
||||
public function getContractListAttribute()
|
||||
{
|
||||
return $this->contract()->get()->makeHidden(['contract_entity_list']);
|
||||
}
|
||||
|
||||
public function getEntityListAttribute()
|
||||
{
|
||||
return $this->entity()->get()->makeHidden(['entity_signature_list']);
|
||||
}
|
||||
|
||||
public function getUpdatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
|
||||
public function getCreatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ class ContractObligation extends Model
|
||||
'hash_id',
|
||||
'contract_list',
|
||||
'contract_obligation_dependency_list',
|
||||
'depend_contract_obligation_dependency_list'
|
||||
'depend_contract_obligation_dependency_list',
|
||||
'contract_entity_list'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@@ -37,6 +38,11 @@ class ContractObligation extends Model
|
||||
return $this->hasMany('App\Models\ContractObligationDependency', 'depend_contract_obligation_id');
|
||||
}
|
||||
|
||||
public function contract_entity()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ContractEntity', 'contract_entity_id');
|
||||
}
|
||||
|
||||
public function getHashIdAttribute()
|
||||
{
|
||||
return Hasher::encode('contract_obligations', $this->id);
|
||||
@@ -61,6 +67,11 @@ class ContractObligation extends Model
|
||||
->get()->makeHidden(['contract_obligation_list', 'depend_contract_obligation_list']);
|
||||
}
|
||||
|
||||
public function getContractEntityListAttribute()
|
||||
{
|
||||
return $this->contract_entity()->get()->makeHidden(['contract_list']);
|
||||
}
|
||||
|
||||
public function getUpdatedAtAttribute($date)
|
||||
{
|
||||
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';
|
||||
|
||||
@@ -31,8 +31,8 @@ class PlumberServiceContractEntitiesTableSeeder extends Seeder
|
||||
'id' => 202,
|
||||
'user_id' => 3,
|
||||
'contract_id' => 201,
|
||||
'entity_id' => 203,
|
||||
'entity_signature_id' => 203,
|
||||
'entity_id' => 202,
|
||||
'entity_signature_id' => 202,
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
|
||||
@@ -36,6 +36,7 @@ class PlumberServiceContractObligationsTableSeeder extends Seeder
|
||||
'contract_template_obligation_id' => 201,
|
||||
'contract_entity_id' => 201,
|
||||
'name' => 'mushroom kingdom request service from plumber hero company to rescue princess peach',
|
||||
'sequence' => 1.0,
|
||||
'reference' => null,
|
||||
'content' => null,
|
||||
'must_complete' => 1,
|
||||
@@ -59,6 +60,7 @@ class PlumberServiceContractObligationsTableSeeder extends Seeder
|
||||
'contract_template_obligation_id' => 202,
|
||||
'contract_entity_id' => 203,
|
||||
'name' => 'plumber hero company rescue princess peach',
|
||||
'sequence' => 2.0,
|
||||
'reference' => null,
|
||||
'content' => null,
|
||||
'must_complete' => 1,
|
||||
@@ -82,6 +84,7 @@ class PlumberServiceContractObligationsTableSeeder extends Seeder
|
||||
'contract_template_obligation_id' => 203,
|
||||
'contract_entity_id' => 203,
|
||||
'name' => 'plumber hero company get reward',
|
||||
'sequence' => 3.0,
|
||||
'reference' => null,
|
||||
'content' => null,
|
||||
'must_complete' => 1,
|
||||
@@ -105,6 +108,7 @@ class PlumberServiceContractObligationsTableSeeder extends Seeder
|
||||
'contract_template_obligation_id' => 204,
|
||||
'contract_entity_id' => 203,
|
||||
'name' => 'plumber hero company request plumber rescue mission service',
|
||||
'sequence' => 1.0,
|
||||
'reference' => null,
|
||||
'content' => null,
|
||||
'must_complete' => 1,
|
||||
@@ -128,6 +132,7 @@ class PlumberServiceContractObligationsTableSeeder extends Seeder
|
||||
'contract_template_obligation_id' => 205,
|
||||
'contract_entity_id' => 202,
|
||||
'name' => 'plumber hero accept rescue mission',
|
||||
'sequence' => 2.0,
|
||||
'reference' => null,
|
||||
'content' => null,
|
||||
'must_complete' => 1,
|
||||
@@ -151,6 +156,7 @@ class PlumberServiceContractObligationsTableSeeder extends Seeder
|
||||
'contract_template_obligation_id' => 206,
|
||||
'contract_entity_id' => 202,
|
||||
'name' => 'plumber hero complete castle level',
|
||||
'sequence' => 3.0,
|
||||
'reference' => null,
|
||||
'content' => null,
|
||||
'must_complete' => 1,
|
||||
@@ -174,6 +180,7 @@ class PlumberServiceContractObligationsTableSeeder extends Seeder
|
||||
'contract_template_obligation_id' => 207,
|
||||
'contract_entity_id' => 202,
|
||||
'name' => 'plumber hero defeat bowser',
|
||||
'sequence' => 4.0,
|
||||
'reference' => null,
|
||||
'content' => null,
|
||||
'must_complete' => 1,
|
||||
@@ -197,6 +204,7 @@ class PlumberServiceContractObligationsTableSeeder extends Seeder
|
||||
'contract_template_obligation_id' => 208,
|
||||
'contract_entity_id' => 202,
|
||||
'name' => 'plumber hero rescue princess peach',
|
||||
'sequence' => 5.0,
|
||||
'reference' => null,
|
||||
'content' => null,
|
||||
'must_complete' => 1,
|
||||
@@ -220,6 +228,7 @@ class PlumberServiceContractObligationsTableSeeder extends Seeder
|
||||
'contract_template_obligation_id' => 209,
|
||||
'contract_entity_id' => 202,
|
||||
'name' => 'plumber hero get reward',
|
||||
'sequence' => 6.0,
|
||||
'reference' => null,
|
||||
'content' => null,
|
||||
'must_complete' => 1,
|
||||
|
||||
Vendored
+2
@@ -6,6 +6,7 @@ const En = {
|
||||
'password': 'password',
|
||||
'complete_day_range': 'complete day range',
|
||||
'sequence': 'sequence',
|
||||
'contract_template_id': 'contract template',
|
||||
'depend_contract_template_id': 'depend contract template',
|
||||
|
||||
// Error
|
||||
@@ -23,6 +24,7 @@ const En = {
|
||||
'the_content_must_be_less_than_100': 'The %(att)s must be less than 100',
|
||||
'status_error': 'status not allow update',
|
||||
'obligation_depend_error': 'contract template obligation dependency error',
|
||||
'under_error': 'This %(att)s not belong to this user',
|
||||
|
||||
// toasted
|
||||
'have_been_successfully_created': '%(value[0].att)s ( %(value[1].att)s ) have been successfully created',
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
<breadcrumb
|
||||
:menu_item_list="menu_item_list"
|
||||
></breadcrumb>
|
||||
<admin-form
|
||||
<contract-form
|
||||
:mode="'create'"
|
||||
></admin-form>
|
||||
></contract-form>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import PageTitle from "../../components/titles/PageTitle";
|
||||
import Breadcrumb from "../../layouts/parts/Breadcrumb";
|
||||
import AdminForm from "./Form";
|
||||
import ContractForm from "./Form";
|
||||
|
||||
export default {
|
||||
metaInfo() {
|
||||
@@ -29,11 +29,11 @@
|
||||
components: {
|
||||
PageTitle,
|
||||
Breadcrumb,
|
||||
AdminForm
|
||||
ContractForm
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
heading: 'Create Admin',
|
||||
heading: 'Create Contract',
|
||||
icon: 'fa fa-plus',
|
||||
menu_item_list: [
|
||||
{
|
||||
@@ -42,14 +42,14 @@
|
||||
path: '/'
|
||||
},
|
||||
{
|
||||
title: 'Admin List',
|
||||
title: 'Contract List',
|
||||
active: false,
|
||||
path: '/admin/list'
|
||||
path: '/contract/list'
|
||||
},
|
||||
{
|
||||
title: 'Create Admin',
|
||||
title: 'Create Contract',
|
||||
active: true,
|
||||
path: '/admin/create'
|
||||
path: '/contract/create'
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<b-card class="main-card mb-3">
|
||||
<div v-if="!this_admin.data && mode == 'edit'" class="text-center">
|
||||
<div v-if="!this_contract.data && mode == 'edit'" class="text-center">
|
||||
<vue-element-loading :active="true" spinner="line-scale" color="var(--primary)"></vue-element-loading>
|
||||
</div>
|
||||
<div v-if="this_admin.data || mode == 'create'">
|
||||
<div v-if="this_contract.data || mode == 'create'">
|
||||
<form-wizard
|
||||
@on-complete="onComplete"
|
||||
title=""
|
||||
@@ -18,64 +18,18 @@
|
||||
ref="valid_one"
|
||||
icon="fa fa-info-circle"
|
||||
>
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
<image-input
|
||||
:input_name="'img'"
|
||||
:form="form"
|
||||
:label="'Profile Img'"
|
||||
:exist_img="exist_img"
|
||||
></image-input>
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
<text-input
|
||||
:input_name="'name'"
|
||||
:form="form"
|
||||
:label="'Name*'"
|
||||
></text-input>
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
<text-input
|
||||
:input_name="'email'"
|
||||
:form="form"
|
||||
:label="'Email*'"
|
||||
></text-input>
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
<password-input
|
||||
:input_name="'password'"
|
||||
:form="form"
|
||||
:label="'Password*'"
|
||||
></password-input>
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
<password-input
|
||||
:input_name="'password_confirmation'"
|
||||
:form="form"
|
||||
:label="'Confirm Password*'"
|
||||
></password-input>
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
<select-option-auto-complete-input
|
||||
v-if="mode != 'profile'"
|
||||
:input_name="'role_id'"
|
||||
:input_name="'contract_template_id'"
|
||||
:form="form"
|
||||
:exist_data="exist_admin_role"
|
||||
:placeholder="''"
|
||||
:label="'Role*'"
|
||||
:endpoint="'admin-role/list'"
|
||||
:label="'Clone Contract Template*'"
|
||||
:endpoint="'contract-template/list'"
|
||||
:search_field="'name'"
|
||||
:limit_tag="1"
|
||||
:return_key="'hash_id'"
|
||||
></select-option-auto-complete-input>
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
<text-read-only-input
|
||||
v-if="mode == 'profile'"
|
||||
:value="this_admin.data.role_list[0].name"
|
||||
:label="'Role'"
|
||||
>
|
||||
</text-read-only-input>
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
<switch-input
|
||||
:input_name="'status'"
|
||||
:form="form"
|
||||
:label="'Status'"
|
||||
></switch-input>
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
</tab-content>
|
||||
</form-wizard>
|
||||
</div>
|
||||
@@ -83,87 +37,61 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TextInput from '../../components/inputs/TextInput';
|
||||
import TextReadOnlyInput from '../../components/inputs/TextReadOnlyInput';
|
||||
import PasswordInput from '../../components/inputs/PasswordInput';
|
||||
import SwitchInput from '../../components/inputs/SwitchInput';
|
||||
import SelectOptionAutoCompleteInput from '../../components/inputs/SelectOptionAutoCompleteInput';
|
||||
import ImageInput from '../../components/inputs/ImageInput';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
mode: String
|
||||
},
|
||||
components: {
|
||||
TextInput,
|
||||
TextReadOnlyInput,
|
||||
PasswordInput,
|
||||
SelectOptionAutoCompleteInput,
|
||||
SwitchInput,
|
||||
ImageInput
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: new Form({
|
||||
img: [],
|
||||
name: '',
|
||||
email: '',
|
||||
password: '',
|
||||
password_confirmation: '',
|
||||
role_id: [],
|
||||
status: 1
|
||||
contract_template_id: [],
|
||||
}),
|
||||
this_admin: [],
|
||||
exist_img: [],
|
||||
exist_admin_role: []
|
||||
this_contract: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
validOne() {
|
||||
let vm = this;
|
||||
let ref_inputs = ['img', 'name', 'email', 'password', 'password_confirmation', 'role_id', 'status'];
|
||||
let url = vm.mode == 'create' ? 'admin/valid-check' : 'admin/valid-check/' + vm.this_admin.data.hash_id;
|
||||
let ref_inputs = ['contract_template_id'];
|
||||
let url = vm.mode == 'create' ? 'contract/valid-check' : 'contract/valid-check/' + vm.this_contract.data.hash_id;
|
||||
return General.validCheck(url, vm.form, ref_inputs);
|
||||
},
|
||||
onComplete() {
|
||||
let vm = this;
|
||||
let method = vm.mode == 'create' ? 'post' : 'put';
|
||||
let url = vm.mode == 'create' ? 'admin/store' : 'admin/update/' + vm.this_admin.data.hash_id;
|
||||
let url = vm.mode == 'create' ? 'contract/generate' : 'contract/update/' + vm.this_contract.data.hash_id;
|
||||
|
||||
return General.onComplete(url, vm.form, method)
|
||||
.then(data => {
|
||||
if (vm.mode != 'profile') {
|
||||
let pervious_query = data.pervious_query ? '?' + data.pervious_query : '';
|
||||
vm.$router.push('/admin/list' + pervious_query);
|
||||
}
|
||||
let pervious_query = data.pervious_query ? '?' + data.pervious_query : '';
|
||||
vm.$router.push('/contract/list' + pervious_query);
|
||||
|
||||
if (vm.mode == 'create') {
|
||||
General.toastedMessage('create', 'Admin', data.data.name);
|
||||
General.toastedMessage('create', 'Contract', data.data.hash_id);
|
||||
}
|
||||
else {
|
||||
General.toastedMessage('edit', 'Admin', data.data.name);
|
||||
General.toastedMessage('edit', 'Contract', data.data.hash_id);
|
||||
}
|
||||
});
|
||||
},
|
||||
loadThisAdmin() {
|
||||
loadThisContract() {
|
||||
let vm = this;
|
||||
let url = vm.mode == 'edit' ? 'admin/show/' + vm.$route.params.hash_id : 'admin/self';
|
||||
let url = 'contract/show/' + vm.$route.params.hash_id;
|
||||
let form = new Form({});
|
||||
General.getCall(url, form).then(data => {
|
||||
vm.this_admin = data;
|
||||
vm.exist_img = vm.this_admin.data.img;
|
||||
vm.form.name = vm.this_admin.data.name;
|
||||
vm.form.email = vm.this_admin.data.email;
|
||||
vm.form.status = vm.this_admin.data.status;
|
||||
vm.form.role_id = General.getKey(vm.this_admin.data.role_list, 'id');
|
||||
vm.exist_admin_role = General.autoCompleteKeyConvert(vm.this_admin.data.role_list);
|
||||
vm.this_contract = data;
|
||||
});
|
||||
}
|
||||
},
|
||||
created() {
|
||||
let vm = this;
|
||||
if (vm.mode == 'edit' || vm.mode == 'profile') {
|
||||
vm.loadThisAdmin();
|
||||
if (vm.mode == 'edit') {
|
||||
vm.loadThisContract();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<th>#</th>
|
||||
<th style="width: 25%">Details</th>
|
||||
<th>Obligation Template</th>
|
||||
<th>Contract Entity</th>
|
||||
<th>Status</th>
|
||||
<th>Created</th>
|
||||
<th>Actions</th>
|
||||
@@ -51,12 +52,24 @@
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="contract.contract_obligation_list" v-for="(obligation, $index) in contract.contract_obligation_list" :key="$index">
|
||||
<div>-{{ obligation.name }} <small>({{ obligation.sequence }})</small></div>
|
||||
<div>
|
||||
-{{ obligation.name }}
|
||||
<small>({{ obligation.sequence }})</small>
|
||||
<small>({{ obligation.contract_entity_list[0] ? obligation.contract_entity_list[0].entity_list[0].name : '-' }})</small>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!contract.contract_obligation_list[0]">
|
||||
-
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="contract.contract_entity_list" v-for="(entity, $index) in contract.contract_entity_list" :key="$index">
|
||||
<div>-{{ entity.entity_list[0].name }}</div>
|
||||
</div>
|
||||
<div v-if="!contract.contract_entity_list[0]">
|
||||
-
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span :class="'badge badge-' + contract.status[0].color">{{ contract.status[0].name }}</span>
|
||||
</td>
|
||||
@@ -116,7 +129,7 @@
|
||||
status: General.returnAray(General.getURLParam('status[]')),
|
||||
page: General.getURLParam('page')
|
||||
}),
|
||||
colspan: 6,
|
||||
colspan: 7,
|
||||
filter_status: false,
|
||||
loading: true,
|
||||
contract_list: [],
|
||||
|
||||
Vendored
+3
@@ -156,6 +156,9 @@ class Form {
|
||||
else if(code[i] == 'OBLIGATION_DEPEND_ERROR') {
|
||||
return_message.push(Sprintf(General.lang('obligation_depend_error'), value));
|
||||
}
|
||||
else if(code[i] == 'UNDER_ERROR') {
|
||||
return_message.push(Sprintf(General.lang('under_error'), value));
|
||||
}
|
||||
else {
|
||||
return_message.push(code[i]);
|
||||
}
|
||||
|
||||
@@ -302,6 +302,13 @@ Route::group(['namespace' => 'User', 'prefix' => 'user-backsys/api'], function (
|
||||
'middleware' => ['permission:add contract']
|
||||
]
|
||||
);
|
||||
Route::post('valid-check/{hash_id?}',
|
||||
[
|
||||
'as' => 'api.contract.valid-check',
|
||||
'uses' => 'ContractController@validCheck',
|
||||
'middleware' => ['permission:add contract']
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// contract generate
|
||||
|
||||
Reference in New Issue
Block a user