Commit 03be81b9 by 杨树贤

优化前端

parent 9a212bf4
......@@ -3,14 +3,7 @@
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 BatchAction
{
......@@ -25,26 +18,31 @@ class HandleInquiry extends BatchAction
public function render()
{
$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-filter"></i><span class="d-none d-sm-inline"> Handle</span>
<span class="filter-count"></span>
<i class="feather icon-filter"></i><span class="d-none d-sm-inline" style="margin-left: 5px">'.$buttonName.'</span>
</button>');
}
protected function getModalScript()
{
// 弹窗显示后往隐藏的id表单中写入批量选中的行ID
$warning = admin_trans('global.labels.operate_must_single');
$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();
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,33 +24,31 @@ 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->like('user.company_name')->width(3);
$filter->like('user.id')->width(3);
$filter->equal('inquiry_id')->width(3);
$filter->like('user.email')->width(3);
$filter->like('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_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();
// 标题
......@@ -57,17 +57,21 @@ class InquiryController extends AdminController
$list = InquiryDetail::inquiryItems($this->inquiry_id);
return new Card($detail) . new Card($list);
});
$grid->column('task_type')->display(admin_trans('inquiry.options.task_type.1'));
$grid->column('user.phone');
$grid->column('user.email');
$grid->column('status')->using(admin_trans('inquiry.options.status'))->badge([
-1 => 'danger',
0 => 'primary',
1 => 'success'
])->sortable();
$grid->column('remark');
$grid->column('priority')->using(admin_trans('inquiry.options.priority'))->badge([
1 => 'primary',
2 => 'success',
3 => 'danger'
]);
$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) : '';
......
......@@ -4,6 +4,7 @@ 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;
......@@ -21,6 +22,13 @@ class HandleInquiry extends Form implements LazyRenderable
*/
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']
......@@ -49,8 +57,7 @@ class HandleInquiry extends Form implements LazyRenderable
public function default()
{
return [
'name' => 'John Doe',
'email' => 'John.Doe@gmail.com',
];
}
}
......@@ -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');
......

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,7 +32,8 @@ return [
'create' => 'create',
'root' => 'root',
'scaffold' => 'scaffold',
'operate_must_single' => 'This operation can only be a single option',
'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',
],
......
......@@ -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',
......
......@@ -39,6 +39,7 @@ return [
'scaffold' => '代码生成器',
'UserAddress' => '用户地址管理',
'operate_must_single' => '该操作只能单选',
'operate_must_select_data' => '请选择要操作的数据',
'handle_status' => '处理状态',
'handle_result' => '处理结果',
],
......
......@@ -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