generated from liutk/owl-admin-base
agreement
parent
4f60ea8de8
commit
c39c3c3f3c
|
|
@ -84,7 +84,7 @@ class AgreementController extends AdminController
|
||||||
['label' => __('agreement.employee_id'), 'content' => '${employee.name}'],
|
['label' => __('agreement.employee_id'), 'content' => '${employee.name}'],
|
||||||
['label' => __('agreement.created_at'), 'content' => '${created_at}'],
|
['label' => __('agreement.created_at'), 'content' => '${created_at}'],
|
||||||
['label' => __('agreement.remarks'), 'content' => '${remarks}', 'span' => 3],
|
['label' => __('agreement.remarks'), 'content' => '${remarks}', 'span' => 3],
|
||||||
['label' => __('agreement.images'), 'content' => amisMake()->Images()->name('images')->enlargeAble(), 'span' => 3],
|
['label' => __('agreement.images'), 'content' => amisMake()->Images()->name('images')->src('${preview}')->enlargeAble(), 'span' => 3],
|
||||||
['label' => __('workflow_log.check_status'), 'content' => amisMake()->Mapping()->name('workflow.check_status')->map(CheckStatus::options())],
|
['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.checked_at'), 'content' => '${workflow.checked_at}'],
|
||||||
['label' => __('workflow_log.remarks'), 'content' => '${workflow.check_remarks}'],
|
['label' => __('workflow_log.remarks'), 'content' => '${workflow.check_remarks}'],
|
||||||
|
|
@ -111,10 +111,10 @@ class AgreementController extends AdminController
|
||||||
}
|
}
|
||||||
$baseUrl = Storage::url('');
|
$baseUrl = Storage::url('');
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$filename = time().'.zip';
|
$filename = Storage::path(time().'.zip');
|
||||||
$zip->open($filename, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
$zip->open($filename, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
|
||||||
foreach($model->images as $item) {
|
foreach($model->images as $item) {
|
||||||
$path = str_replace($baseUrl, '', $item);
|
$path = data_get($item, 'value');
|
||||||
$info = pathinfo($path);
|
$info = pathinfo($path);
|
||||||
$zip->addFile(Storage::path($path), data_get($info, 'basename'));
|
$zip->addFile(Storage::path($path), data_get($info, 'basename'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
namespace App\Admin\Services;
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Admin\Filters\AgreementFilter;
|
use App\Admin\Filters\AgreementFilter;
|
||||||
use App\Models\Agreement;
|
use App\Models\{Agreement, WorkflowCheck};
|
||||||
use Illuminate\Support\Facades\{Validator, Storage};
|
use Illuminate\Support\Facades\{Validator, Storage};
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
|
@ -20,9 +20,12 @@ class AgreementService extends BaseService
|
||||||
if (isset($data['images']) && $data['images']) {
|
if (isset($data['images']) && $data['images']) {
|
||||||
$images = [];
|
$images = [];
|
||||||
foreach ($data['images'] as $value) {
|
foreach ($data['images'] as $value) {
|
||||||
$image = is_array($value) ? data_get($value, 'value') : $value;
|
$image = data_get($value, 'value');
|
||||||
$url = Str::startsWith($image, ['http://', 'https://']) ? $image : Storage::url($image);
|
$url = Str::startsWith($image, ['http://', 'https://']) ? $image : Storage::url($image);
|
||||||
array_push($images, $url);
|
array_push($images, [
|
||||||
|
'value' => $image,
|
||||||
|
'preview' => $url,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
$data['images'] = $images;
|
$data['images'] = $images;
|
||||||
}
|
}
|
||||||
|
|
@ -43,4 +46,15 @@ class AgreementService extends BaseService
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(string $ids): mixed
|
||||||
|
{
|
||||||
|
$id = explode(',', $ids);
|
||||||
|
|
||||||
|
foreach (Agreement::whereIn('id', $id)->get() as $item) {
|
||||||
|
$item->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,13 @@ trait HasCheckable
|
||||||
'key' => $model->getCheckKey(),
|
'key' => $model->getCheckKey(),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static::deleting(function ($model) {
|
||||||
|
// 删除审核流水记录
|
||||||
|
$model->workflow->logs()->delete();
|
||||||
|
// 删除审核流程
|
||||||
|
$model->workflow->delete();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCheckKey(): string
|
public function getCheckKey(): string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue