Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c37574b8
authored
Nov 04, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
处理询价单逻辑
parent
2c481f0b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
117 additions
and
47 deletions
app/Admin/Actions/Grid/HandleInquiry.php
app/Admin/Controllers/InquiryController.php
app/Admin/Forms/HandleInquiry.php
app/Admin/Traits/BatchAction.php
resources/lang/en/global.php
resources/lang/zh_CN/global.php
app/Admin/Actions/Grid/HandleInquiry.php
View file @
c37574b8
...
...
@@ -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;
}
}
app/Admin/Controllers/InquiryController.php
View file @
c37574b8
...
...
@@ -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'
);
});
}
}
app/Admin/Forms/HandleInquiry.php
0 → 100644
View file @
c37574b8
<?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'
,
];
}
}
app/Admin/Traits/BatchAction.php
0 → 100644
View file @
c37574b8
<?php
namespace
App\Admin\Traits
;
use
Dcat\Admin\Grid\GridAction
;
class
BatchAction
extends
GridAction
{
public
function
getSelectedKeysScript
()
{
return
"Dcat.grid.selected('
{
$this
->
parent
->
getName
()
}
')"
;
}
}
resources/lang/en/global.php
View file @
c37574b8
...
...
@@ -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'
=>
[
//
...
...
resources/lang/zh_CN/global.php
View file @
c37574b8
...
...
@@ -38,6 +38,9 @@ return [
'root'
=>
'顶级'
,
'scaffold'
=>
'代码生成器'
,
'UserAddress'
=>
'用户地址管理'
,
'operate_must_single'
=>
'该操作只能单选'
,
'handle_status'
=>
'处理状态'
,
'handle_result'
=>
'处理结果'
,
],
'options'
=>
[
//
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment