Commit c37574b8 by 杨树贤

处理询价单逻辑

parent 2c481f0b
...@@ -2,70 +2,50 @@ ...@@ -2,70 +2,50 @@
namespace App\Admin\Actions\Grid; namespace App\Admin\Actions\Grid;
use App\Admin\Traits\BatchAction;
use Dcat\Admin\Actions\Response; use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\Displayers\Button;
use Dcat\Admin\Grid\Tools\AbstractTool; use Dcat\Admin\Grid\Tools\AbstractTool;
use Dcat\Admin\Traits\HasPermissions; use Dcat\Admin\Traits\HasPermissions;
use Dcat\Admin\Widgets\Modal;
use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class HandleInquiry extends AbstractTool class HandleInquiry extends BatchAction
{ {
/** /**
* @return string * @return string
*/ */
protected $title = 'Handle'; protected $title = 'Handle';
protected $style = 'btn btn-primary feather icon-check-square'; protected $style = 'btn btn-primary feather icon-check-square';
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
dd($this);
$keys = $this->getKey();
dd($request->all());
return $this->response()
->success('Processed successfully.')
->redirect('/');
}
/** public function render()
* @return string|void
*/
protected function href()
{ {
// return admin_url('auth/users'); $form = \App\Admin\Forms\HandleInquiry::make();
return Modal::make()->lg()->title($this->title)->body($form)
->onLoad($this->getModalScript())
->button('<button class="btn btn-primary">
<i class="feather icon-filter"></i><span class="d-none d-sm-inline"> Handle</span>
<span class="filter-count"></span>
</button>');
} }
/** protected function getModalScript()
* @return string|array|void
*/
public function confirm()
{
return ['Confirm?', 'contents'];
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
}
/**
* @return array
*/
protected function parameters()
{ {
return []; // 弹窗显示后往隐藏的id表单中写入批量选中的行ID
$warning = admin_trans('global.labels.operate_must_single');
return <<<JS
// 获取选中的ID数组
var key = {$this->getSelectedKeysScript()}
if (key.length > 1){
Dcat.swal.error('$warning');
Dcat.reload();
return false;
}
$('#inquiry_id').val(key);
JS;
} }
} }
...@@ -24,7 +24,7 @@ class InquiryController extends AdminController ...@@ -24,7 +24,7 @@ class InquiryController extends AdminController
{ {
return Grid::make(new Inquiry(['user']), function (Grid $grid) { return Grid::make(new Inquiry(['user']), function (Grid $grid) {
$grid->showFilter(); $grid->showFilter();
$grid->disableActions();
$grid->filter(function ($filter) { $grid->filter(function ($filter) {
$filter->expand(true); $filter->expand(true);
$filter->equal('inquiry_id')->width(3); $filter->equal('inquiry_id')->width(3);
...@@ -125,4 +125,20 @@ class InquiryController extends AdminController ...@@ -125,4 +125,20 @@ class InquiryController extends AdminController
$form->text('update_time'); $form->text('update_time');
}); });
} }
protected function handleInquiry()
{
return Form::make(new Inquiry(), function (Form $form) {
$form->display('inquiry_id');
$form->text('sales_id');
$form->text('inquiry_sn');
$form->text('status');
$form->text('remark');
$form->text('priority');
$form->text('user_types');
$form->text('processing_time');
$form->text('create_time');
$form->text('update_time');
});
}
} }
<?php
namespace App\Admin\Forms;
use App\Models\Inquiry;
use Dcat\Admin\Models\Administrator;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Contracts\LazyRenderable;
class HandleInquiry extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
Inquiry::where('inquiry_id', $input['inquiry_id'])->update([
'status' => $input['status'],
'processing_result' => $input['handle_result']
]);
return $this
->response()
->success(trans('admin.update_succeeded'))
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->hidden('inquiry_id')->attribute('id', 'inquiry_id');
$this->radio('status')->options(admin_trans('inquiry.options.status'))->default(0)->required();
$this->textarea('handle_result', admin_trans('global.labels.handle_result'))->rows(5)->required();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
return [
'name' => 'John Doe',
'email' => 'John.Doe@gmail.com',
];
}
}
<?php
namespace App\Admin\Traits;
use Dcat\Admin\Grid\GridAction;
class BatchAction extends GridAction {
public function getSelectedKeysScript()
{
return "Dcat.grid.selected('{$this->parent->getName()}')";
}
}
...@@ -32,6 +32,9 @@ return [ ...@@ -32,6 +32,9 @@ return [
'create' => 'create', 'create' => 'create',
'root' => 'root', 'root' => 'root',
'scaffold' => 'scaffold', 'scaffold' => 'scaffold',
'operate_must_single' => 'This operation can only be a single option',
'handle_status' => 'Handle Status',
'handle_result' => 'Handle Result',
], ],
'options' => [ 'options' => [
// //
......
...@@ -38,6 +38,9 @@ return [ ...@@ -38,6 +38,9 @@ return [
'root' => '顶级', 'root' => '顶级',
'scaffold' => '代码生成器', 'scaffold' => '代码生成器',
'UserAddress' => '用户地址管理', 'UserAddress' => '用户地址管理',
'operate_must_single' => '该操作只能单选',
'handle_status' => '处理状态',
'handle_result' => '处理结果',
], ],
'options' => [ 'options' => [
// //
......
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