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.
86 lines
1.9 KiB
86 lines
1.9 KiB
<?php |
|
|
|
|
|
namespace App\Admin\Actions\Grid; |
|
|
|
|
|
use App\Admin\Actions\Form\Import; |
|
use App\Admin\Actions\Form\ImportExcelBedForm; |
|
use App\Admin\Actions\Form\ImportExcelStudentForm; |
|
use Dcat\Admin\Admin; |
|
use Dcat\Admin\Grid\Tools\AbstractTool; |
|
use Dcat\Admin\Traits\HasPermissions; |
|
use Dcat\Admin\Widgets\Form; |
|
use Illuminate\Contracts\Auth\Authenticatable; |
|
use Illuminate\Database\Eloquent\Model; |
|
|
|
|
|
|
|
class ImportExcelBed extends AbstractTool |
|
{ |
|
/** |
|
* @return string |
|
*/ |
|
protected $title = 'Title'; |
|
public function render() |
|
{ |
|
$id = "reset-pwd-{$this->getKey()}"; |
|
|
|
// 模态窗 |
|
$this->modal($id); |
|
|
|
return <<<HTML |
|
<span class="grid-expand" data-toggle="modal" data-target="#{$id}"> |
|
<a href="javascript:void(0)"><button class="btn btn-primary ">导入床位信息</button></a> |
|
</span> |
|
HTML; |
|
} |
|
|
|
protected function modal($id) |
|
{ |
|
$form = new ImportExcelBedForm(); |
|
|
|
Admin::script('Dcat.onPjaxComplete(function () { |
|
$(".modal-backdrop").remove(); |
|
$("body").removeClass("modal-open"); |
|
}, true)'); |
|
|
|
// 通过 Admin::html 方法设置模态窗HTML |
|
Admin::html( |
|
<<<HTML |
|
<div class="modal fade" id="{$id}"> |
|
<div class="modal-dialog modal-lg" role="document"> |
|
<div class="modal-content"> |
|
<div class="modal-header"> |
|
<h4 class="modal-title">导入数据</h4> |
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
|
</div> |
|
<div class="modal-body"> |
|
{$form->render()} |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
HTML |
|
); |
|
} |
|
|
|
/** |
|
* @param Model|Authenticatable|HasPermissions|null $user |
|
* |
|
* @return bool |
|
*/ |
|
protected function authorize($user): bool |
|
{ |
|
return true; |
|
} |
|
|
|
/** |
|
* @return array |
|
*/ |
|
protected function parameters() |
|
{ |
|
return []; |
|
} |
|
|
|
}
|
|
|