Commit c37574b8 by 杨树贤

处理询价单逻辑

parent 2c481f0b
......@@ -2,70 +2,50 @@
namespace App\Admin\Actions\Grid;
use App\Admin\Traits\BatchAction;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\Displayers\Button;
use Dcat\Admin\Grid\Tools\AbstractTool;
use Dcat\Admin\Traits\HasPermissions;
use Dcat\Admin\Widgets\Modal;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class HandleInquiry extends AbstractTool
class HandleInquiry extends BatchAction
{
/**
* @return string
*/
protected $title = 'Handle';
protected $title = 'Handle';
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('/');
}
/**
* @return string|void
*/
protected function href()
public function render()
{
// 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>');
}
/**
* @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()
protected function getModalScript()
{
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
{
return Grid::make(new Inquiry(['user']), function (Grid $grid) {
$grid->showFilter();
$grid->disableActions();
$grid->filter(function ($filter) {
$filter->expand(true);
$filter->equal('inquiry_id')->width(3);
......@@ -125,4 +125,20 @@ class InquiryController extends AdminController
$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 [
'create' => 'create',
'root' => 'root',
'scaffold' => 'scaffold',
'operate_must_single' => 'This operation can only be a single option',
'handle_status' => 'Handle Status',
'handle_result' => 'Handle Result',
],
'options' => [
//
......
......@@ -38,6 +38,9 @@ return [
'root' => '顶级',
'scaffold' => '代码生成器',
'UserAddress' => '用户地址管理',
'operate_must_single' => '该操作只能单选',
'handle_status' => '处理状态',
'handle_result' => '处理结果',
],
'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