diff --git a/app/Admin/Actions/Show/BargainOrderRemark.php b/app/Admin/Actions/Show/BargainOrderRemark.php new file mode 100644 index 00000000..375190b9 --- /dev/null +++ b/app/Admin/Actions/Show/BargainOrderRemark.php @@ -0,0 +1,32 @@ + 备注'; + + /** + * 按钮样式定义,默认 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("style}\">{$this->title}  "); + } +} diff --git a/app/Admin/Controllers/BargainOrderController.php b/app/Admin/Controllers/BargainOrderController.php index addc6771..373cb282 100644 --- a/app/Admin/Controllers/BargainOrderController.php +++ b/app/Admin/Controllers/BargainOrderController.php @@ -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()); }); })); }); diff --git a/app/Admin/Forms/BargainOrderRemark.php b/app/Admin/Forms/BargainOrderRemark.php new file mode 100644 index 00000000..a73caec0 --- /dev/null +++ b/app/Admin/Forms/BargainOrderRemark.php @@ -0,0 +1,61 @@ +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(); + } +} diff --git a/database/seeders/AdminPermissionSeeder.php b/database/seeders/AdminPermissionSeeder.php index cb1648e4..e81859e4 100644 --- a/database/seeders/AdminPermissionSeeder.php +++ b/database/seeders/AdminPermissionSeeder.php @@ -426,6 +426,9 @@ class AdminPermissionSeeder extends Seeder 'bargain_orders'=>[ 'name' =>'砍价活动记录', 'curd' => ['index', 'show'], + 'children'=>[ + 'remark'=>['name' =>'备注'], + ], ], ]; // try {