6
0
Fork 0

添加砍价订单备注功能

release
vine_liutk 2022-04-12 16:43:24 +08:00
parent 0b1b44af27
commit e56ff82385
4 changed files with 100 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
namespace App\Admin\Actions\Show;
use App\Admin\Forms\BargainOrderRemark as BargainOrderRemarkForm;
use Dcat\Admin\Show\AbstractTool;
use Dcat\Admin\Widgets\Modal;
class BargainOrderRemark extends AbstractTool
{
/**
* @return string
*/
protected $title = '<i class="feather icon-file-text"></i>&nbsp;备注';
/**
* 按钮样式定义,默认 btn btn-white waves-effect
*
* @var string
*/
protected $style = 'btn-success';
public function render()
{
$form = BargainOrderRemarkForm::make()->payload(['id'=>$this->getKey()]);
return Modal::make()
->lg()
->title($this->title)
->body($form)
->button("<a href=\"javascript:void(0)\" class=\"btn btn-sm {$this->style}\">{$this->title}</a>&nbsp;&nbsp;");
}
}

View File

@ -2,6 +2,7 @@
namespace App\Admin\Controllers;
use App\Admin\Actions\Show\BargainOrderRemark;
use App\Admin\Renderable\Grid\Filter\BargainOrderSnIn;
use App\Admin\Repositories\BargainOrder;
use App\Models\BargainOrder as BargainOrderModel;
@ -130,11 +131,14 @@ class BargainOrderController extends AdminController
$show->field('expire_at');
$show->field('created_at');
$show->width(12)->field('remark')->width(10, 1);
});
$show->panel()
->tools(function (Show\Tools $tools) {
$tools->disableEdit();
$tools->disableDelete();
$tools->prepend(new BargainOrderRemark());
});
}));
});

View File

@ -0,0 +1,61 @@
<?php
namespace App\Admin\Forms;
use App\Models\BargainOrder;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
class BargainOrderRemark extends Form implements LazyRenderable
{
use LazyWidget;
/**
* 权限判断,如不需要可以删除此方法
*
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return $user->can('dcat.admin.bargain_orders.remark');
}
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$orderId = $this->payload['id'] ?? 0;
$order = BargainOrder::findOrFail($orderId);
$remark = $input['remark'] ?? '';
$order->update([
'remark'=>$remark,
]);
return $this->response()
->success(__('admin.update_succeeded'))
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$orderId = $this->payload['id'] ?? 0;
$order = BargainOrder::findOrFail($orderId);
$this->text('remark')->value($order->remark);
$this->disableResetButton();
}
}

View File

@ -426,6 +426,9 @@ class AdminPermissionSeeder extends Seeder
'bargain_orders'=>[
'name' =>'砍价活动记录',
'curd' => ['index', 'show'],
'children'=>[
'remark'=>['name' =>'备注'],
],
],
];
// try {