z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.15k stars 2.82k forks source link

自定义批量上传按钮时,js报错$(...).fileinput is not a function #5650

Open aoeng opened 2 years ago

aoeng commented 2 years ago

版本是最新

class ImportEnglish extends Action
{
    protected $selector = '.import-english';

    public function handle(Request $request)
    {
        $res = Excel::import(new EnglishImport(), $request->file('file'));

        if ($res['code'] != 0) {
            return $this->response()->error($res['message']);
        }
        return $this->response()->success('上传成功')->refresh();
    }

    public function form()
    {
        $this->file('file', '请选择文件')->required()->help('表头: [编号],年级,[一级分类],[二级分类],[三级分类],原文,翻译,类型');
    }

    public function html()
    {
        return <<<HTML
        <a class="btn btn-sm btn-default import-english">导入数据</a>
HTML;
    }
}
 $grid->tools(function (Grid\Tools $tools) {
            $tools->append(new ImportEnglish());
        });

image image