http://103.39.211.179:8080/admin/with-border
异步表单demo地址
https://learnku.com/docs/dcat-admin/2.x/use-of-fields/8107#f3f55c
dcat 表单字段map使用
1.配置
申请地图key
需要在 .env 内加入 BAIDU_MAP_API_KEY=XXXXXXXXXXXXXX
2.下载demo,仿照官方demo使用异步表单
protected function form()
{
return Form::make(new DeviceManage(), function (Form $form) {
$form->display('id');
$form->text('car_name');
$form->text('car_id');
$form->text('gps_id');
$form->text('gps_name');
$form->text('location_description');
$form->map('latitude','longitude','经纬度')
//latitude 翻译纬度 longitude 翻译经度
$form->text('battery_status');
$form->display('created_at');
$form->display('updated_at');
});
}
protected function grid()
{
return Grid::make(new DeviceManage(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('car_name');
$grid->column('car_id');
$grid->column('gps_id');
$grid->column('gps_name');
$grid->column('location_description');
$grid->column('longitude');
$grid->column('latitude');
//latitude 翻译纬度 longitude 翻译经度
$grid->column('map','位置')->display('查看位置')->modal(function (Grid\Displayers\Modal $modal) { //异步表单
// 标题
$modal->title('查看位置');
// 自定义图标
$modal->icon('feather icon-edit');
// 传递当前行字段值
return UserProfile::make()->payload(['car_name' => $this->car_name,'longitude' => $this->longitude,'latitude' => $this->latitude]);
});
$grid->battery_status->progressBar('danger', 'sm', 100);
});
app\Admin\Forms\UserProfile.php
<?php
namespace App\Admin\Forms;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
class UserProfile extends Form implements LazyRenderable
{
use LazyWidget;
public function handle(array $input)
{
//return $this->success('保存成功');
}
public function default()
{
return [
// 展示上个页面传递过来的值
'car_name' => $this->payload['car_name'] ?? '',
'longitude' => $this->payload['longitude'] ?? '',
'latitude' => $this->payload['latitude'] ?? '',
];
}
public function form()
{
$this->text('car_name','车辆名称')->help('车辆名称')->disable();
$this->map('latitude','longitude','经纬度');
$this->disableSubmitButton();
$this->disableResetButton();
}
}