generated from liutk/owl-admin-base
admin 合同管理-审核
parent
816ac52eb5
commit
4f60ea8de8
|
|
@ -6,17 +6,20 @@ use App\Admin\Services\AgreementService;
|
|||
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use App\Enums\EmployeeStatus;
|
||||
use App\Enums\{EmployeeStatus, CheckStatus};
|
||||
use App\Models\Agreement;
|
||||
use Illuminate\Support\{Arr};
|
||||
use Illuminate\Support\Facades\{Storage};
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\HasCheckActions;
|
||||
|
||||
/**
|
||||
* 合同管理
|
||||
*/
|
||||
class AgreementController extends AdminController
|
||||
{
|
||||
use HasCheckActions;
|
||||
|
||||
protected string $serviceName = AgreementService::class;
|
||||
|
||||
public function list(): Page
|
||||
|
|
@ -34,15 +37,19 @@ class AgreementController extends AdminController
|
|||
amisMake()->TableColumn()->name('name')->label(__('agreement.name')),
|
||||
amisMake()->TableColumn()->name('employee.name')->label(__('agreement.employee_id')),
|
||||
amisMake()->TableColumn()->name('created_at')->label(__('agreement.created_at')),
|
||||
amisMake()->TableColumn()->name('workflow.check_status')->label(__('workflow_log.check_status'))->set('type', 'mapping')->map(CheckStatus::options()),
|
||||
amisMake()->Operation()->label(__('admin.actions'))->buttons([
|
||||
$this->rowShowTypeButton('drawer', 'xl')->visible($user->can('admin.agreement.view')),
|
||||
$this->rowEditTypeButton('drawer', 'xl')->visible($user->can('admin.agreement.update')),
|
||||
$this->rowDeleteButton()->visible($user->can('admin.agreement.delete')),
|
||||
$this->applyAction(),
|
||||
$this->cancelAction(),
|
||||
amisMake()->AjaxAction()
|
||||
->level('link')
|
||||
->label('打包下载')
|
||||
->api('post:'.admin_url('agreement/download?id=${id}'))
|
||||
->visible($user->can('admin.agreement.download')),
|
||||
->visible($user->can('admin.agreement.download'))
|
||||
->visibleOn('${workflow.check_status == '.CheckStatus::Success->value.'}'),
|
||||
]),
|
||||
]);
|
||||
|
||||
|
|
@ -69,25 +76,44 @@ class AgreementController extends AdminController
|
|||
|
||||
public function detail(): Form
|
||||
{
|
||||
return $this->baseDetail()->title('')->body(amisMake()->Property()->items([
|
||||
$detailId = 'agreement-detail';
|
||||
$serviceId = 'agreement-checklog-service';
|
||||
|
||||
$detail = amisMake()->Property()->items([
|
||||
['label' => __('agreement.name'), 'content' => '${name}'],
|
||||
['label' => __('agreement.employee_id'), 'content' => '${employee.name}'],
|
||||
['label' => __('agreement.created_at'), 'content' => '${created_at}'],
|
||||
['label' => __('agreement.remarks'), 'content' => '${remarks}', 'span' => 3],
|
||||
['label' => __('agreement.images'), 'content' => amisMake()->Images()->name('images')->enlargeAble(), 'span' => 3],
|
||||
]));
|
||||
['label' => __('workflow_log.check_status'), 'content' => amisMake()->Mapping()->name('workflow.check_status')->map(CheckStatus::options())],
|
||||
['label' => __('workflow_log.checked_at'), 'content' => '${workflow.checked_at}'],
|
||||
['label' => __('workflow_log.remarks'), 'content' => '${workflow.check_remarks}'],
|
||||
]);
|
||||
|
||||
return $this->baseDetail()->id($detailId)->title('')->onEvent([
|
||||
'inited' => [
|
||||
'actions' => [
|
||||
['actionType' => 'reload', 'componentId' => $serviceId],
|
||||
],
|
||||
],
|
||||
])->body([
|
||||
$detail,
|
||||
amisMake()->Divider(),
|
||||
$this->baseWorkflowLogService($detailId)->id($serviceId),
|
||||
]);
|
||||
}
|
||||
|
||||
public function download(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$images = Agreement::whereIn('id', is_array($id) ? $id : explode(',', $id))->pluck('images');
|
||||
$list = Arr::flatten($images);
|
||||
$model = Agreement::findOrFail($request->input('id'));
|
||||
if (!$model->images || count($model->images) == 0) {
|
||||
return $this->response()->fail('没有图片下载');
|
||||
}
|
||||
$baseUrl = Storage::url('');
|
||||
$zip = new \ZipArchive();
|
||||
$filename = time().'.zip';
|
||||
$zip->open($filename, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||
foreach($list as $item) {
|
||||
foreach($model->images as $item) {
|
||||
$path = str_replace($baseUrl, '', $item);
|
||||
$info = pathinfo($path);
|
||||
$zip->addFile(Storage::path($path), data_get($info, 'basename'));
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Illuminate\Support\Str;
|
|||
|
||||
class AgreementService extends BaseService
|
||||
{
|
||||
protected array $withRelationships = ['employee'];
|
||||
protected array $withRelationships = ['employee', 'workflow'];
|
||||
|
||||
protected string $modelName = Agreement::class;
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ class AgreementService extends BaseService
|
|||
|
||||
public function resloveData($data, $model = null)
|
||||
{
|
||||
if (isset($data['images'])) {
|
||||
if (isset($data['images']) && $data['images']) {
|
||||
$images = [];
|
||||
foreach ($data['images'] as $value) {
|
||||
$image = is_array($value) ? data_get($value, 'value') : $value;
|
||||
|
|
|
|||
|
|
@ -6,13 +6,14 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
use App\Traits\HasCheckable;
|
||||
|
||||
/**
|
||||
* 合同
|
||||
*/
|
||||
class Agreement extends Model
|
||||
{
|
||||
use HasDateTimeFormatter, Filterable;
|
||||
use HasDateTimeFormatter, Filterable, HasCheckable;
|
||||
|
||||
protected $fillable = ['name', 'employee_id', 'images', 'remarks'];
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\{CheckStatus};
|
||||
use App\Traits\HasCheckable;
|
||||
use App\Traits\HasDateTimeFormatter;
|
||||
use EloquentFilter\Filterable;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
\App\Models\Reimbursement::class,
|
||||
\App\Models\StoreMasterCommission::class,
|
||||
\App\Models\EmployeePromotion::class,
|
||||
\App\Models\Agreement::class,
|
||||
])->mapWithKeys(fn ($model) => [(new $model)->getTable() => $model])->all()
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ trait HasCheckActions
|
|||
->level('link')
|
||||
->api('post:'.admin_url('api/workflow/success?id=${id}'))
|
||||
->confirmText(__('admin.confirm'))
|
||||
->visibleOn('${workflow.check_status == '.CheckStatus::Processing->value.'}');
|
||||
->visibleOn('${check_status == '.CheckStatus::Processing->value.'}');
|
||||
}
|
||||
|
||||
public function failAction()
|
||||
|
|
@ -57,7 +57,7 @@ trait HasCheckActions
|
|||
amisMake()->TextControl()->name('remarks')->label(__('workflow_log.remarks'))->required(),
|
||||
])
|
||||
))
|
||||
->visibleOn('${workflow.check_status == '.CheckStatus::Processing->value.'}');
|
||||
->visibleOn('${check_status == '.CheckStatus::Processing->value.'}');
|
||||
}
|
||||
|
||||
public function baseWorkflowLogService($reload = null): Service
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class WorkflowSeeder extends Seeder
|
|||
['key' => 'reimbursement', 'name' => '收支报销', 'config' => $config, 'created_at' => now(), 'updated_at' => now()],
|
||||
['key' => 'store_master_commission', 'name' => '店长提成', 'config' => $config, 'created_at' => now(), 'updated_at' => now()],
|
||||
['key' => 'employee_promotion', 'name' => '升职申请', 'config' => $config, 'created_at' => now(), 'updated_at' => now()],
|
||||
['key' => 'agreement', 'name' => '合同审核', 'config' => $config, 'created_at' => now(), 'updated_at' => now()],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ return [
|
|||
'subject_data' => '基本信息',
|
||||
'check_user_id' => '实际审核人',
|
||||
'checked_at' => '审核时间',
|
||||
'remarks' => '备注',
|
||||
'remarks' => '未通过原因',
|
||||
'check_status' => '审核状态',
|
||||
'sort' => '顺序号',
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue