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.
154 lines
4.6 KiB
154 lines
4.6 KiB
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\ImsCjdcMarket;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Controllers\AdminController;
|
|
use App\Models\LanzuMpInfo;
|
|
|
|
class ImsCjdcMarketController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new ImsCjdcMarket(), function (Grid $grid) {
|
|
$grid->id->sortable();
|
|
$grid->logo->image('', 50, 50);
|
|
$grid->name;
|
|
$grid->column('mp_id', '服务商')->display(function ($mid) {
|
|
if ($mid == 0) return '懒族自营';
|
|
$mp = LanzuMpInfo::find($mid);
|
|
if (!$mp) {
|
|
return '<span style="color: red">数据错误</span>';
|
|
}
|
|
return $mp->name;
|
|
});
|
|
$grid->column('status', '状态')->display(function ($status) {
|
|
if ($status == 0) {
|
|
return '禁用';
|
|
} else {
|
|
return '正常';
|
|
}
|
|
});
|
|
$grid->address;
|
|
$grid->column('addtime', '创建时间');
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->equal('id');
|
|
});
|
|
|
|
|
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
|
|
|
if (!\Admin::user()->isAdministrator() && $actions->row->mp_id == 0) {
|
|
$actions->disableDelete();
|
|
$actions->disableEdit();
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new ImsCjdcMarket(), function (Show $show) {
|
|
|
|
if (!\Admin::user()->isAdministrator() && $show->model()->mp_id == 0) {
|
|
$show->panel()
|
|
->tools(function ($tools) {
|
|
$tools->disableEdit();
|
|
$tools->disableList();
|
|
$tools->disableDelete();
|
|
// 显示快捷编辑按钮
|
|
$tools->showQuickEdit();
|
|
});
|
|
}
|
|
|
|
$show->id;
|
|
$show->name;
|
|
$show->logo->image();
|
|
$show->introduce;
|
|
$show->imgs->image();
|
|
$show->addtime('创建时间');
|
|
$show->sort;
|
|
$show->status;
|
|
$show->coordinates;
|
|
$show->remark;
|
|
$show->address;
|
|
$show->poundage;
|
|
$show->dn_poundage;
|
|
$show->dm_poundage;
|
|
$show->yd_poundage;
|
|
$show->dada_number;
|
|
$show->is_open_dada;
|
|
$show->loudspeaker_imei;
|
|
$show->dishes_menu_intro;
|
|
$show->create_time;
|
|
$show->created_at;
|
|
$show->updated_at;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new ImsCjdcMarket(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('name')->required();
|
|
$form->select('mp_id', '服务商')->options('/api/getMpInfo')->required();
|
|
$form->text('address')->required();
|
|
$form->text('coordinates')
|
|
->required()
|
|
->placeholder('输入 经纬度,如: 108.281552,22.83731')
|
|
->help("通过网址 <a href='https://lbs.amap.com/console/show/picker' target='_blank'>https://lbs.amap.com/console/show/picker</a> 获取经纬度");
|
|
|
|
$form->text('poundage');
|
|
$form->text('dn_poundage');
|
|
$form->text('dm_poundage');
|
|
$form->text('yd_poundage');
|
|
$form->text('loudspeaker_imei')->value(0);
|
|
$form->number('sort', '排序');
|
|
$form->switch('status', '状态');
|
|
$form->image('logo');
|
|
$form->multipleImage('imgs', '市场图片');
|
|
$form->textarea('introduce');
|
|
$form->textarea('remark');
|
|
$form->textarea('dishes_menu_intro')->value('菜谱简介');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 服务商信息
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
protected function getMpInfo()
|
|
{
|
|
$mps = LanzuMpInfo::all();
|
|
$ret = [];
|
|
foreach ($mps as $key => $value) {
|
|
$item = [];
|
|
$item['id'] = $value->id;
|
|
$item['text'] = $value->name;
|
|
$ret[] = $item;
|
|
}
|
|
return response()->json($ret);
|
|
}
|
|
}
|