Commit 2921268a by 孙龙
parents 5d9879bd 6e828431
......@@ -52,4 +52,4 @@ PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
START_IFRAME_TAB=false
START_IFRAME_TAB=true
......@@ -2,70 +2,48 @@
namespace App\Admin\Actions\Grid;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\Tools\AbstractTool;
use Dcat\Admin\Traits\HasPermissions;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use App\Admin\Traits\BatchAction;
use Dcat\Admin\Widgets\Modal;
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();
$buttonName = trans('inquiry.labels.handle');
return Modal::make()->lg()->title($this->title)->body($form)
->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>');
}
/**
* @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 = trans('global.labels.operate_must_single');
$warning2 = trans('global.labels.operate_must_select_data');
return <<<JS
// 获取选中的ID数组
var key = {$this->getSelectedKeysScript()}
if (key.length > 1){
Dcat.swal.error('$warning');
Dcat.reload();
return false;
}
if (!key.length){
Dcat.swal.error('$warning2');
Dcat.reload();
}
$('#inquiry_id').val(key);
JS;
}
}
......@@ -7,6 +7,8 @@ use App\Admin\Renderable\BarChart;
use App\Admin\Renderable\InquiryDetail;
use App\Admin\Renderable\PostTable;
use App\Admin\Repositories\Inquiry;
use App\Models\Cms\CmsUser;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
......@@ -22,63 +24,67 @@ class InquiryController extends AdminController
*/
protected function grid()
{
return Grid::make(new Inquiry(['user']), function (Grid $grid) {
return Grid::make(new Inquiry(['user','sales_user']), function (Grid $grid) {
$grid->showFilter();
$grid->disableActions();
$grid->filter(function ($filter) {
$filter->expand(true);
$filter->equal('inquiry_id')->width(3);
$filter->like('inquiry_sn')->width(3);
$filter->equal('status')->select(admin_trans('inquiry.options.status'))->width(3);
$filter->equal('priority')->select(admin_trans('inquiry.options.priority'))->width(3);
$filter->like('user.email')->width(3);
$filter->like('user.phone')->width(3);
$filter->equal('sales_name')->select(admin_trans('inquiry.options.priority'))->width(3);
$filter->whereBetween('create_time', function ($q) {
$start = strtotime($this->input['start'] ?? null);
$end = strtotime($this->input['end'] ?? null);
$q->whereBetween('create_time', [$start, $end]);
})->datetime()->width(3);
$filter->startWith('user.company_name')->width(3);
$filter->startWith('user.id')->width(3);
$filter->equal('inquiry_id')->width(3);
$filter->startWith('user.email')->width(3);
$filter->startWith('user.phone')->width(3);
$filter->like('inquiry_sn')->width(3);
$filter->equal('priority')->select(admin_trans('inquiry.options.priority'))->width(3);
$filter->equal('status')->select(admin_trans('inquiry.options.status'))->width(3);
$filter->equal('sales_id',trans('inquiry.fields.sales_name'))->select(CmsUser::pluck('name', 'userId')->toArray())->width(3);
});
$grid->tools(new HandleInquiry(admin_trans('inquiry.labels.handle')));
$grid->model()->orderBy('inquiry_id', 'desc');
$grid->column('inquiry_id')->sortable();
$grid->column('task_type')->display(admin_trans('inquiry.options.task_type.1'));
$grid->column('user.email');
$grid->column('inquiry_sn')->modal(function (Grid\Displayers\Modal $modal) {
$modal->xl();
$modal->icon('fa fa-list-ul');
// 标题
$modal->title(admin_trans('inquiry.labels.inquiry_detail'));
$detail = InquiryDetail::make(['key' => $this->inquiry_id]);
$list = InquiryDetail::inquiryItems($this->inquiry_id);
return new Card($detail) . new Card($list);
});
$grid->column('status')->using(admin_trans('inquiry.options.status'))->badge([
$grid->column('task_type')->display(admin_trans('inquiry.options.task_type.1'));
$grid->column('user.phone')->copyable();
$grid->column('user.email')->copyable();
$grid->column('status')->using(admin_trans('inquiry.options.status'))->dot([
-1 => 'danger',
0 => 'primary',
0 => 'info',
1 => 'success'
])->sortable();
$grid->column('remark');
$grid->column('priority')->using(admin_trans('inquiry.options.priority'))->badge([
0 => 'default',
1 => 'primary',
2 => 'success',
3 => 'danger'
]);
2 => 'danger'
])->sortable();
$grid->column('remark')->limit(10);
$grid->column('sales_user.name');
$grid->column('user_types')->using(admin_trans('inquiry.options.user_types'));
$grid->column('processing_time')->display(function ($time) {
return $time ? date('Y-m-d H:i:s', $time) : '';
});
})->sortable();
$grid->column('create_time')->display(function ($time) {
return date('Y-m-d H:i:s', $time);
});
})->sortable();
$grid->column('update_time')->display(function ($time) {
return $time ? date('Y-m-d H:i:s', $time) : '';
});
})->sortable();
});
}
......@@ -125,4 +131,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\Alert;
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)
{
$status = Inquiry::where('inquiry_id', $input['inquiry_id'])->value('status');
if ($status !== Inquiry::STATUS_PENDING) {
return $this
->response()
->error(trans('inquiry.labels.inquiry_handle_status_wrong'))
->refresh();
}
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 [
];
}
}
<?php
namespace App\Admin\Traits;
use Dcat\Admin\Grid\GridAction;
class BatchAction extends GridAction {
public function getSelectedKeysScript()
{
return "Dcat.grid.selected('{$this->parent->getName()}')";
}
}
......@@ -41,8 +41,13 @@ body {
font-size: 12px;!important;
}
.content-body {
margin-top: -15px;
/*.content-body {*/
/* margin-top: -15px;*/
/*}*/
.filter-box {
padding: 0;
padding-top: 1.8rem;
}
.table-main {
......@@ -133,6 +138,10 @@ background: #f2f2f2;
background: white;
}
body:not(.dark-mode) .app-content {
background: white;
}
body:not(.dark-mode) .table-main table.custom-data-table thead,
body:not(.dark-mode) .table-fixed table.custom-data-table thead tr th{
position: sticky;
......
......@@ -12,7 +12,7 @@ Route::group([
'middleware' => config('admin.route.middleware'),
], function (Router $router) {
$router->get('/', 'HomeController@index');
$router->get('/index', 'HomeController@index');
$router->resource('userAddress', 'UserAddressController');
$router->resource('inquiry', 'InquiryController');
$router->resource('order', 'OrderController');
......
......@@ -18,6 +18,10 @@ class Inquiry extends Model
public $timestamps = false;
const STATUS_PROCESSED = 1;
const STATUS_PENDING = 0;
const STATUS_CLOSED = -1;
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id');
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.

7.76 KB | W: | H:

7.39 KB | W: | H:

public/vendor/dcat-admin/images/logo.png
public/vendor/dcat-admin/images/logo.png
public/vendor/dcat-admin/images/logo.png
public/vendor/dcat-admin/images/logo.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -32,6 +32,10 @@ return [
'create' => 'create',
'root' => 'root',
'scaffold' => 'scaffold',
'operate_must_single' => 'This operation can be performed only in one option',
'operate_must_select_data' => 'Please select your operation item',
'handle_status' => 'Handle Status',
'handle_result' => 'Handle Result',
],
'options' => [
//
......
......@@ -4,7 +4,8 @@ return [
'Inquiry' => 'Inquiry',
'inquiry' => 'Inquiry',
'inquiry_detail' => 'Inquiry Detail',
'handle' => 'Handle'
'handle' => 'Handle',
'inquiry_handle_status_wrong' => 'Only pending inquiry can be handle',
],
'fields' => [
'inquiry_id' => 'Id',
......
......@@ -38,6 +38,10 @@ return [
'root' => '顶级',
'scaffold' => '代码生成器',
'UserAddress' => '用户地址管理',
'operate_must_single' => '该操作只能单选',
'operate_must_select_data' => '请选择要操作的数据',
'handle_status' => '处理状态',
'handle_result' => '处理结果',
],
'options' => [
//
......
......@@ -4,7 +4,8 @@ return [
'Inquiry' => 'Inquiry',
'inquiry' => 'Inquiry',
'inquiry_detail' => '询价详情',
'handle' => '处理'
'handle' => '处理',
'inquiry_handle_status_wrong' => '只有待处理的询价才能被处理',
],
'fields' => [
'inquiry_id' => 'Id',
......
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