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
693664e7
authored
Nov 15, 2022
by
宁成龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善客户地址删除
parent
96cc3845
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
267 additions
and
12 deletions
app/Admin/Actions/User/UserEditAction.php
app/Admin/Actions/UserAddress/UserAddressDeleteAction.php
app/Admin/Actions/UserAddress/UserAddressEditAction.php
app/Admin/Forms/User/EditUserHandle.php
app/Admin/Forms/UserAddress/EditUserAddressHandle.php
app/Admin/Renderable/UserAddress.php
app/Admin/Service/UserService.php
app/Models/UserAddress.php
app/Admin/Actions/User/UserEditAction.php
View file @
693664e7
...
@@ -26,12 +26,6 @@ class UserEditAction extends AbstractTool
...
@@ -26,12 +26,6 @@ class UserEditAction extends AbstractTool
$this
->
action
=
$action
;
$this
->
action
=
$action
;
}
}
// // 确认弹窗信息
// public function confirm()
// {
// return '您确定要已选中的文章吗?';
// }
public
function
render
()
public
function
render
()
{
{
$form
=
EditUserHandle
::
make
([
'key'
=>
$this
->
getKey
()]);
$form
=
EditUserHandle
::
make
([
'key'
=>
$this
->
getKey
()]);
...
...
app/Admin/Actions/UserAddress/UserAddressDeleteAction.php
0 → 100644
View file @
693664e7
<?php
namespace
App\Admin\Actions\UserAddress
;
use
App\Admin\Service\UserService
;
use
App\Models\Order
as
OrderModel
;
use
App\Models\User
;
use
App\Models\UserAddress
;
use
Dcat\Admin\Grid\BatchAction
;
use
Dcat\Admin\Grid\Tools\AbstractTool
;
use
Illuminate\Http\Request
;
use
Dcat\Admin\Grid\RowAction
;
class
UserAddressDeleteAction
extends
RowAction
{
/**
* 按钮样式定义,默认 btn btn-white waves-effect
*
* @var string
*/
protected
$style
=
'btn btn-white waves-effect'
;
/**
* 按钮文本
*
* @return string|void
*/
public
function
title
()
{
$buttonName
=
"删除"
;
return
$buttonName
;
}
public
function
html
()
{
$class
=
$this
->
getElementClass
();
$color
=
"btn btn-danger btn-sm btn-mini"
;
// 获取当前行数据ID
$id
=
$this
->
getKey
();
$this
->
setHtmlAttribute
([
'data-id'
=>
$id
,
"class"
=>
"
{
$class
}
{
$color
}
"
,
]);
return
parent
::
html
();
}
/**
* 确认弹窗,如果不需要则返回空即可
*
* @return array|string|void
*/
public
function
confirm
()
{
$buttonName
=
"删除"
;
return
[
"是否确认
{
$buttonName
}
?"
];
}
/**
* 处理请求
* 如果你的类中包含了此方法,则点击按钮后会自动向后端发起ajax请求,并且会通过此方法处理请求逻辑
*
* @param Request $request
*/
public
function
handle
(
Request
$request
)
{
// 获取 parameters 方法传递的参数
$rowData
=
$request
->
get
(
'rowData'
);
try
{
UserAddress
::
deleteById
(
$rowData
[
'address_id'
]);
}
catch
(
\Throwable
$e
)
{
return
$this
->
response
()
->
error
(
$e
->
getMessage
());
}
return
$this
->
response
()
->
success
(
'操作成功'
)
->
refresh
();
}
/**
* 设置请求参数
*
* @return array|void
*/
public
function
parameters
()
{
return
[
'rowData'
=>
$this
->
row
,
];
}
}
app/Admin/Actions/UserAddress/UserAddressEditAction.php
0 → 100644
View file @
693664e7
<?php
namespace
App\Admin\Actions\UserAddress
;
use
App\Admin\Forms\User\AssignUserHandle
;
use
App\Admin\Forms\UserAddress\EditUserAddressHandle
;
use
App\Admin\Forms\User\EditUserHandle
;
use
App\Models\Order
as
OrderModel
;
use
App\Models\User
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Grid\BatchAction
;
use
Dcat\Admin\Grid\Tools\AbstractTool
;
use
Dcat\Admin\Widgets\Modal
;
use
Illuminate\Http\Request
;
use
Dcat\Admin\Grid\RowAction
;
class
UserAddressEditAction
extends
AbstractTool
{
protected
$action
;
protected
$htmlClasses
=
[
'btn btn-sm btn-primary'
];
// 注意action的构造方法参数一定要给默认值
public
function
__construct
(
$title
=
null
,
$action
=
1
)
{
$this
->
title
=
$title
;
$this
->
action
=
$action
;
}
public
function
render
()
{
$form
=
EditUserAddressHandle
::
make
([
'key'
=>
$this
->
getKey
()]);
$buttonName
=
trans
(
'user.labels.handle'
);
return
Modal
::
make
()
->
lg
()
->
title
(
$this
->
title
)
->
body
(
$form
->
payload
([
'key'
=>
$this
->
getKey
()]))
->
onLoad
(
$this
->
getModalScript
())
->
button
(
'<button style="margin-right: 5px" class="btn btn-sm btn-primary">
<i class="feather icon-check-circle"></i> <span class="d-none d-sm-inline" style="margin-left: 5px">'
.
$buttonName
.
'</span>
</button>'
);
}
protected
function
getModalScript
()
{
return
<<<JS
var key = {$this->getKey()}
$('#id').val(key);
JS;
}
public
function
html
()
{
return
parent
::
html
();
// TODO: Change the autogenerated stub
}
// 设置请求参数
public
function
parameters
()
{
return
[
'action'
=>
$this
->
action
,
];
}
}
app/Admin/Forms/User/EditUserHandle.php
View file @
693664e7
...
@@ -61,7 +61,7 @@ class EditUserHandle extends Form implements LazyRenderable
...
@@ -61,7 +61,7 @@ class EditUserHandle extends Form implements LazyRenderable
$form
->
width
(
5
)
->
text
(
'email'
);
$form
->
width
(
5
)
->
text
(
'email'
);
});
});
$this
->
row
(
function
(
Row
$form
)
{
$this
->
row
(
function
(
Row
$form
)
{
$form
->
width
(
5
)
->
text
(
'reg_source'
)
->
required
();
$form
->
width
(
5
)
->
select
(
'reg_source'
)
->
options
(
admin_trans
(
'user.options.reg_source'
)
)
->
required
();
$form
->
width
(
5
)
->
text
(
'remark'
);
$form
->
width
(
5
)
->
text
(
'remark'
);
});
});
}
}
...
...
app/Admin/Forms/UserAddress/EditUserAddressHandle.php
0 → 100644
View file @
693664e7
<?php
namespace
App\Admin\Forms\UserAddress
;
use
App\Models\Cms\CmsUser
;
use
App\Models\Inquiry
;
use
App\Models\User
;
use
Dcat\Admin\Contracts\LazyRenderable
;
use
Dcat\Admin\Form\Row
;
use
Dcat\Admin\Traits\LazyWidget
;
use
Dcat\Admin\Widgets\Form
;
class
EditUserAddressHandle
extends
Form
implements
LazyRenderable
{
use
LazyWidget
;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public
function
handle
(
array
$input
)
{
try
{
$id
=
explode
(
","
,
$input
[
'id'
]);
// $userList = User::getListByIdArr($ids);
$userInfo
=
User
::
getInfoByUserId
(
$id
);
if
(
!
$userInfo
)
{
throw
new
\Exception
(
'客户不存在'
);
}
User
::
updateById
(
$id
,
$input
);
return
$this
->
response
()
->
success
(
trans
(
'admin.update_succeeded'
))
->
refresh
();
}
catch
(
\Throwable
$throwable
)
{
// var_dump((string)$throwable);
return
$this
->
response
()
->
error
(
trans
(
'admin.update_failed'
));
}
}
/**
* Build a form here.
*/
public
function
form
()
{
$this
->
disableResetButton
();
$this
->
hidden
(
'id'
)
->
attribute
(
'id'
,
'id'
)
->
width
(
4
);
$this
->
row
(
function
(
Row
$form
)
{
$form
->
width
(
5
)
->
text
(
'company_name'
)
->
required
();
$form
->
width
(
5
)
->
text
(
'user_sn'
);
});
$this
->
row
(
function
(
Row
$form
)
{
$form
->
width
(
5
)
->
text
(
'first_name'
)
->
required
();
$form
->
width
(
5
)
->
text
(
'last_name'
);
});
$this
->
row
(
function
(
Row
$form
)
{
$form
->
width
(
5
)
->
text
(
'phone'
)
->
required
();
$form
->
width
(
5
)
->
text
(
'email'
);
});
$this
->
row
(
function
(
Row
$form
)
{
$form
->
width
(
5
)
->
select
(
'reg_source'
)
->
options
(
admin_trans
(
'user.options.reg_source'
))
->
required
();
$form
->
width
(
5
)
->
text
(
'remark'
);
});
}
/**
* The data of the form.
*
* @return array
*/
public
function
default
()
{
$userInfo
=
User
::
getInfoByUserId
(
$this
->
payload
[
'key'
]);
return
$userInfo
;
}
}
app/Admin/Renderable/UserAddress.php
View file @
693664e7
...
@@ -2,6 +2,11 @@
...
@@ -2,6 +2,11 @@
namespace
App\Admin\Renderable
;
namespace
App\Admin\Renderable
;
use
App\Admin\Actions\UserAddress\UserAddressDeleteAction
;
use
App\Admin\Actions\User\UserAssignAction
;
use
App\Admin\Actions\User\UserStatusAction
;
use
App\Admin\Actions\User\UserTransferAction
;
use
App\Admin\Actions\UserAddress\UserAddressEditAction
;
use
App\Admin\Repositories\Inquiry
;
use
App\Admin\Repositories\Inquiry
;
use
App\Admin\Repositories\User
;
use
App\Admin\Repositories\User
;
use
App\Admin\Service\UserAddressService
;
use
App\Admin\Service\UserAddressService
;
...
@@ -22,11 +27,27 @@ class UserAddress extends \Dcat\Admin\Support\LazyRenderable
...
@@ -22,11 +27,27 @@ class UserAddress extends \Dcat\Admin\Support\LazyRenderable
$grid
->
title
(
"address"
);
$grid
->
title
(
"address"
);
$grid
->
disableFilterButton
();
$grid
->
disableFilterButton
();
$grid
->
disableRefreshButton
();
$grid
->
disableRefreshButton
();
$grid
->
disableBatchDelete
();
$grid
->
disableCreateButton
();
$grid
->
disableCreateButton
();
$grid
->
disableBatchDelete
();
$grid
->
disableEditButton
();
UserAddressService
::
listField
(
$grid
);
UserAddressService
::
listField
(
$grid
);
});
// $addressList = \App\Models\UserAddress::getListByUserId($id);
$grid
->
tools
([
new
UserTransferAction
(
"转让销售"
),
]);
$grid
->
actions
(
function
(
Grid\Displayers\Actions
$actions
)
{
$actions
->
disableDelete
();
$actions
->
disableEdit
();
$actions
->
disableQuickEdit
();
$actions
->
disableView
();
// 当前行的数据数组
// $rowArray = $actions->row->toArray();
// 获取当前行主键值
$deleteAction
=
new
UserAddressDeleteAction
();
$deleteAction
->
setRow
(
$actions
->
row
);
$deleteAction
->
setKey
(
$actions
->
getKey
());
$actions
->
append
(
$deleteAction
);
});
});
}
}
}
}
app/Admin/Service/UserService.php
View file @
693664e7
...
@@ -77,8 +77,8 @@ class UserService
...
@@ -77,8 +77,8 @@ class UserService
// $rowArray = $actions->row->toArray();
// $rowArray = $actions->row->toArray();
// 获取当前行主键值
// 获取当前行主键值
$id
=
$actions
->
getKey
();
$id
=
$actions
->
getKey
();
$actions
->
append
(
'<a href="'
.
admin_url
(
"/users/
{
$id
}
"
)
.
'" class="btn btn-primary btn-sm
$actions
->
append
(
'<a
style="margin-right: 5px"
href="'
.
admin_url
(
"/users/
{
$id
}
"
)
.
'" class="btn btn-primary btn-sm
btn-mini">detail</a>
'
);
btn-mini">detail</a>'
);
//状态按钮
//状态按钮
$actions
->
append
(
new
UserStatusAction
());
$actions
->
append
(
new
UserStatusAction
());
});
});
...
...
app/Models/UserAddress.php
View file @
693664e7
...
@@ -42,4 +42,8 @@ class UserAddress extends Model
...
@@ -42,4 +42,8 @@ class UserAddress extends Model
return
(
$res
)
?
$res
->
toArray
()
:
[];
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
}
public
static
function
deleteById
(
$addressId
){
return
self
::
where
(
'address_id'
,
$addressId
)
->
delete
();
}
}
}
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