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
239a35e3
authored
Nov 15, 2022
by
宁成龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善新增客户地址功能
parent
693664e7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
42 deletions
app/Admin/Actions/UserAddress/UserAddressEditAction.php → app/Admin/Actions/UserAddress/UserAddressCreateAction.php
app/Admin/Forms/UserAddress/EditUserAddressHandle.php → app/Admin/Forms/UserAddress/SaveUserAddressHandle.php
app/Admin/Renderable/CreateUser.php
app/Admin/Renderable/UserAddress.php
app/Admin/Actions/UserAddress/UserAddress
Edit
Action.php
→
app/Admin/Actions/UserAddress/UserAddress
Create
Action.php
View file @
239a35e3
...
@@ -4,7 +4,7 @@ namespace App\Admin\Actions\UserAddress;
...
@@ -4,7 +4,7 @@ namespace App\Admin\Actions\UserAddress;
use
App\Admin\Forms\User\AssignUserHandle
;
use
App\Admin\Forms\User\AssignUserHandle
;
use
App\Admin\Forms\UserAddress\
Edit
UserAddressHandle
;
use
App\Admin\Forms\UserAddress\
Save
UserAddressHandle
;
use
App\Admin\Forms\User\EditUserHandle
;
use
App\Admin\Forms\User\EditUserHandle
;
use
App\Models\Order
as
OrderModel
;
use
App\Models\Order
as
OrderModel
;
use
App\Models\User
;
use
App\Models\User
;
...
@@ -16,7 +16,7 @@ use Illuminate\Http\Request;
...
@@ -16,7 +16,7 @@ use Illuminate\Http\Request;
use
Dcat\Admin\Grid\RowAction
;
use
Dcat\Admin\Grid\RowAction
;
class
UserAddress
Edit
Action
extends
AbstractTool
class
UserAddress
Create
Action
extends
AbstractTool
{
{
protected
$action
;
protected
$action
;
protected
$htmlClasses
=
[
'btn btn-sm btn-primary'
];
protected
$htmlClasses
=
[
'btn btn-sm btn-primary'
];
...
@@ -29,23 +29,23 @@ class UserAddressEditAction extends AbstractTool
...
@@ -29,23 +29,23 @@ class UserAddressEditAction extends AbstractTool
public
function
render
()
public
function
render
()
{
{
$form
=
EditUserAddressHandle
::
make
([
'key
'
=>
$this
->
getKey
()]);
$form
=
SaveUserAddressHandle
::
make
([
'user_id
'
=>
$this
->
getKey
()]);
$buttonName
=
trans
(
'user.labels.handle'
);
$buttonName
=
trans
(
'user.labels.handle'
);
return
Modal
::
make
()
->
lg
()
->
title
(
$this
->
title
)
->
body
(
$form
->
payload
([
'
key
'
=>
$this
->
getKey
()]))
->
onLoad
return
Modal
::
make
()
->
lg
()
->
title
(
$this
->
title
)
->
body
(
$form
->
payload
([
'
user_id
'
=>
$this
->
getKey
()]))
->
onLoad
(
$this
->
getModalScript
())
->
button
(
'<button style="margin-right: 5px" class="btn btn-sm btn-primary">
(
$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">'
.
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline" style="margin-left: 5px">'
.
$buttonName
.
'</span>
$buttonName
.
'</span>
</button>'
);
</button>'
);
}
}
protected
function
getModalScript
()
protected
function
getModalScript
()
{
{
return
<<<JS
return
<<<JS
var key = {$this->getKey()}
var key = {$this->getKey()}
$('#id').val(key);
$('#
user_
id').val(key);
JS;
JS;
}
}
public
function
html
()
public
function
html
()
{
{
return
parent
::
html
();
// TODO: Change the autogenerated stub
return
parent
::
html
();
// TODO: Change the autogenerated stub
...
@@ -56,6 +56,7 @@ JS;
...
@@ -56,6 +56,7 @@ JS;
{
{
return
[
return
[
'action'
=>
$this
->
action
,
'action'
=>
$this
->
action
,
'user_id'
=>
$this
->
getKey
()
];
];
}
}
}
}
...
...
app/Admin/Forms/UserAddress/
Edit
UserAddressHandle.php
→
app/Admin/Forms/UserAddress/
Save
UserAddressHandle.php
View file @
239a35e3
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
App\Admin\Forms\UserAddress
;
namespace
App\Admin\Forms\UserAddress
;
use
App\Models\Cms\CmsUser
;
use
App\Models\Cms\CmsUser
;
use
App\Models\Country
;
use
App\Models\Inquiry
;
use
App\Models\Inquiry
;
use
App\Models\User
;
use
App\Models\User
;
use
Dcat\Admin\Contracts\LazyRenderable
;
use
Dcat\Admin\Contracts\LazyRenderable
;
...
@@ -10,7 +11,7 @@ use Dcat\Admin\Form\Row;
...
@@ -10,7 +11,7 @@ use Dcat\Admin\Form\Row;
use
Dcat\Admin\Traits\LazyWidget
;
use
Dcat\Admin\Traits\LazyWidget
;
use
Dcat\Admin\Widgets\Form
;
use
Dcat\Admin\Widgets\Form
;
class
Edit
UserAddressHandle
extends
Form
implements
LazyRenderable
class
Save
UserAddressHandle
extends
Form
implements
LazyRenderable
{
{
use
LazyWidget
;
use
LazyWidget
;
...
@@ -24,12 +25,9 @@ class EditUserAddressHandle extends Form implements LazyRenderable
...
@@ -24,12 +25,9 @@ class EditUserAddressHandle extends Form implements LazyRenderable
public
function
handle
(
array
$input
)
public
function
handle
(
array
$input
)
{
{
try
{
try
{
$id
=
explode
(
","
,
$input
[
'id'
]);
$userId
=
$this
->
payload
[
'user_id'
];
// $userList = User::getListByIdArr($ids);
$address
=
0
;
$userInfo
=
User
::
getInfoByUserId
(
$id
);
if
(
!
$userInfo
)
{
throw
new
\Exception
(
'客户不存在'
);
}
User
::
updateById
(
$id
,
$input
);
User
::
updateById
(
$id
,
$input
);
return
$this
return
$this
->
response
()
->
response
()
...
@@ -47,35 +45,32 @@ class EditUserAddressHandle extends Form implements LazyRenderable
...
@@ -47,35 +45,32 @@ class EditUserAddressHandle extends Form implements LazyRenderable
public
function
form
()
public
function
form
()
{
{
$this
->
disableResetButton
();
$this
->
disableResetButton
();
$this
->
hidden
(
'id'
)
->
attribute
(
'id'
,
'id'
)
->
width
(
4
);
$this
->
row
(
function
(
Row
$form
)
{
$this
->
row
(
function
(
Row
$row
)
{
$form
->
width
(
5
)
->
text
(
'company_name'
)
->
required
();
$row
->
width
(
3
)
->
text
(
'first_name'
)
->
required
();
$form
->
width
(
5
)
->
text
(
'user_sn'
);
$row
->
width
(
3
)
->
text
(
'last_name'
)
->
required
();
});
$this
->
row
(
function
(
Row
$row
)
{
$row
->
width
(
3
)
->
select
(
'address_type'
)
->
options
(
admin_trans
(
'user-address.options.address_type'
))
->
required
();
$row
->
width
(
3
)
->
text
(
'company_name'
);
});
});
$this
->
row
(
function
(
Row
$
form
)
{
$this
->
row
(
function
(
Row
$
row
)
{
$
form
->
width
(
5
)
->
text
(
'first_name
'
)
->
required
();
$
row
->
width
(
3
)
->
email
(
'email
'
)
->
required
();
$
form
->
width
(
5
)
->
text
(
'last_name'
);
$
row
->
width
(
3
)
->
text
(
'phone'
)
->
required
(
);
});
});
$this
->
row
(
function
(
Row
$form
)
{
$this
->
row
(
function
(
Row
$row
)
{
$form
->
width
(
5
)
->
text
(
'phone'
)
->
required
();
$row
->
width
(
3
)
->
select
(
'country'
)
->
options
(
Country
::
getCountryMap
())
->
required
();
$form
->
width
(
5
)
->
text
(
'email'
);
$row
->
width
(
3
)
->
text
(
'province'
);
$row
->
width
(
3
)
->
text
(
'city'
)
->
required
();
$row
->
width
(
2
)
->
text
(
'post_code'
)
->
required
();
});
});
$this
->
row
(
function
(
Row
$form
)
{
$this
->
row
(
function
(
Row
$row
)
{
$form
->
width
(
5
)
->
select
(
'reg_source'
)
->
options
(
admin_trans
(
'user.options.reg_source'
))
->
required
();
$row
->
width
(
12
)
->
textarea
(
'detail_address'
)
->
required
();
$form
->
width
(
5
)
->
text
(
'remark'
);
});
$this
->
row
(
function
(
Row
$row
)
{
$row
->
width
(
3
)
->
switch
(
'is_default'
)
->
required
();
});
});
}
}
/**
* The data of the form.
*
* @return array
*/
public
function
default
()
{
$userInfo
=
User
::
getInfoByUserId
(
$this
->
payload
[
'key'
]);
return
$userInfo
;
}
}
}
app/Admin/Renderable/CreateUser.php
View file @
239a35e3
...
@@ -64,7 +64,7 @@ class CreateUser extends \Dcat\Admin\Support\LazyRenderable
...
@@ -64,7 +64,7 @@ class CreateUser extends \Dcat\Admin\Support\LazyRenderable
$table
->
width
(
2
)
->
text
(
'post_code'
)
->
required
();
$table
->
width
(
2
)
->
text
(
'post_code'
)
->
required
();
});
});
$table
->
row
(
function
(
Form\Row
$table
)
{
$table
->
row
(
function
(
Form\Row
$table
)
{
$table
->
width
(
3
)
->
textarea
(
'detail_address'
)
->
required
();
$table
->
width
(
12
)
->
textarea
(
'detail_address'
)
->
required
();
});
});
$table
->
row
(
function
(
Form\Row
$table
)
{
$table
->
row
(
function
(
Form\Row
$table
)
{
$table
->
width
(
3
)
->
switch
(
'is_default'
)
->
required
();
$table
->
width
(
3
)
->
switch
(
'is_default'
)
->
required
();
...
...
app/Admin/Renderable/UserAddress.php
View file @
239a35e3
...
@@ -6,7 +6,7 @@ use App\Admin\Actions\UserAddress\UserAddressDeleteAction;
...
@@ -6,7 +6,7 @@ use App\Admin\Actions\UserAddress\UserAddressDeleteAction;
use
App\Admin\Actions\User\UserAssignAction
;
use
App\Admin\Actions\User\UserAssignAction
;
use
App\Admin\Actions\User\UserStatusAction
;
use
App\Admin\Actions\User\UserStatusAction
;
use
App\Admin\Actions\User\UserTransferAction
;
use
App\Admin\Actions\User\UserTransferAction
;
use
App\Admin\Actions\UserAddress\UserAddress
Edit
Action
;
use
App\Admin\Actions\UserAddress\UserAddress
Create
Action
;
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
;
...
@@ -32,8 +32,10 @@ class UserAddress extends \Dcat\Admin\Support\LazyRenderable
...
@@ -32,8 +32,10 @@ class UserAddress extends \Dcat\Admin\Support\LazyRenderable
$grid
->
disableEditButton
();
$grid
->
disableEditButton
();
UserAddressService
::
listField
(
$grid
);
UserAddressService
::
listField
(
$grid
);
$userAddressCreateAction
=
new
UserAddressCreateAction
(
"新增用户地址"
);
$userAddressCreateAction
->
setKey
(
$this
->
key
);
$grid
->
tools
([
$grid
->
tools
([
new
UserTransferAction
(
"转让销售"
)
,
$userAddressCreateAction
,
]);
]);
$grid
->
actions
(
function
(
Grid\Displayers\Actions
$actions
)
{
$grid
->
actions
(
function
(
Grid\Displayers\Actions
$actions
)
{
$actions
->
disableDelete
();
$actions
->
disableDelete
();
...
@@ -46,6 +48,7 @@ class UserAddress extends \Dcat\Admin\Support\LazyRenderable
...
@@ -46,6 +48,7 @@ class UserAddress extends \Dcat\Admin\Support\LazyRenderable
$deleteAction
=
new
UserAddressDeleteAction
();
$deleteAction
=
new
UserAddressDeleteAction
();
$deleteAction
->
setRow
(
$actions
->
row
);
$deleteAction
->
setRow
(
$actions
->
row
);
$deleteAction
->
setKey
(
$actions
->
getKey
());
$deleteAction
->
setKey
(
$actions
->
getKey
());
$actions
->
append
(
$deleteAction
);
$actions
->
append
(
$deleteAction
);
});
});
});
});
...
...
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