Commit 3350abd8 by 宁成龙

新增转让客户

parent d6f05ad6
Showing with 28 additions and 13 deletions
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
namespace App\Admin\Actions\User; namespace App\Admin\Actions\User;
use App\Admin\Forms\User\AssignUserHandle;
use App\Models\Order as OrderModel; use App\Models\Order as OrderModel;
use App\Models\User; use App\Models\User;
use Dcat\Admin\Grid\BatchAction; use Dcat\Admin\Grid\BatchAction;
use Dcat\Admin\Grid\Tools\AbstractTool; use Dcat\Admin\Grid\Tools\AbstractTool;
use Dcat\Admin\Widgets\Modal;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Dcat\Admin\Grid\RowAction; use Dcat\Admin\Grid\RowAction;
...@@ -14,6 +16,7 @@ use Dcat\Admin\Grid\RowAction; ...@@ -14,6 +16,7 @@ use Dcat\Admin\Grid\RowAction;
class UserTransferAction extends BatchAction class UserTransferAction extends BatchAction
{ {
protected $action; protected $action;
protected $htmlClasses = ['btn btn-primary btn-sm btn-mini'];
// 注意action的构造方法参数一定要给默认值 // 注意action的构造方法参数一定要给默认值
public function __construct($title = null, $action = 1) public function __construct($title = null, $action = 1)
...@@ -25,18 +28,37 @@ class UserTransferAction extends BatchAction ...@@ -25,18 +28,37 @@ class UserTransferAction extends BatchAction
// 确认弹窗信息 // 确认弹窗信息
public function confirm() public function confirm()
{ {
return '您确定要发布已选中的文章吗?'; return '您确定要已选中的文章吗?';
}
public function render()
{
$form = AssignUserHandle::make();
$buttonName = trans('user.labels.handle');
return Modal::make()->lg()->title($this->title)->body($form->payload([]))->onLoad($this->getModalScript())->button('<button class="btn btn-primary">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline" style="margin-left: 5px">' . $buttonName . '</span>
</button>');
}
protected function getModalScript()
{
// 弹窗显示后往隐藏的id表单中写入批量选中的行ID
$warning = trans('global.labels.operate_must_select_data');
return <<<JS
var key = {$this->getSelectedKeysScript()}
if (!key.length){
Dcat.swal.error('$warning');
Dcat.reload();
}
$('#id').val(key);
JS;
} }
public function html() public function html()
{ {
$class = $this->getElementClass();
$this->setHtmlAttribute([
"class" => "{$class} btn btn-primary btn-sm btn-mini",
]);
return parent::html(); // TODO: Change the autogenerated stub return parent::html(); // TODO: Change the autogenerated stub
} }
// 处理请求 // 处理请求
public function handle(Request $request) public function handle(Request $request)
{ {
...@@ -46,11 +68,6 @@ class UserTransferAction extends BatchAction ...@@ -46,11 +68,6 @@ class UserTransferAction extends BatchAction
// 获取请求参数 // 获取请求参数
$action = $request->get('action'); $action = $request->get('action');
foreach (Post::find($keys) as $post) {
$post->released = $action;
$post->save();
}
$message = $action ? '文章发布成功' : '文章下线成功'; $message = $action ? '文章发布成功' : '文章下线成功';
return $this->response()->success($message)->refresh(); return $this->response()->success($message)->refresh();
...@@ -64,5 +81,3 @@ class UserTransferAction extends BatchAction ...@@ -64,5 +81,3 @@ class UserTransferAction extends BatchAction
]; ];
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment