Commit 239a35e3 by 宁成龙

完善新增客户地址功能

parent 693664e7
......@@ -4,7 +4,7 @@ namespace App\Admin\Actions\UserAddress;
use App\Admin\Forms\User\AssignUserHandle;
use App\Admin\Forms\UserAddress\EditUserAddressHandle;
use App\Admin\Forms\UserAddress\SaveUserAddressHandle;
use App\Admin\Forms\User\EditUserHandle;
use App\Models\Order as OrderModel;
use App\Models\User;
......@@ -16,7 +16,7 @@ use Illuminate\Http\Request;
use Dcat\Admin\Grid\RowAction;
class UserAddressEditAction extends AbstractTool
class UserAddressCreateAction extends AbstractTool
{
protected $action;
protected $htmlClasses = ['btn btn-sm btn-primary'];
......@@ -29,23 +29,23 @@ class UserAddressEditAction extends AbstractTool
public function render()
{
$form = EditUserAddressHandle::make(['key'=>$this->getKey()]);
$form = SaveUserAddressHandle::make(['user_id'=>$this->getKey()]);
$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">
<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>
</button>');
}
protected function getModalScript()
{
return <<<JS
var key = {$this->getKey()}
$('#id').val(key);
$('#user_id').val(key);
JS;
}
public function html()
{
return parent::html(); // TODO: Change the autogenerated stub
......@@ -56,6 +56,7 @@ JS;
{
return [
'action' => $this->action,
'user_id'=>$this->getKey()
];
}
}
......
......@@ -3,6 +3,7 @@
namespace App\Admin\Forms\UserAddress;
use App\Models\Cms\CmsUser;
use App\Models\Country;
use App\Models\Inquiry;
use App\Models\User;
use Dcat\Admin\Contracts\LazyRenderable;
......@@ -10,7 +11,7 @@ use Dcat\Admin\Form\Row;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
class EditUserAddressHandle extends Form implements LazyRenderable
class SaveUserAddressHandle extends Form implements LazyRenderable
{
use LazyWidget;
......@@ -24,12 +25,9 @@ class EditUserAddressHandle extends Form implements LazyRenderable
public function handle(array $input)
{
try {
$id = explode(",", $input['id']);
// $userList = User::getListByIdArr($ids);
$userInfo = User::getInfoByUserId($id);
if (!$userInfo) {
throw new \Exception('客户不存在');
}
$userId = $this->payload['user_id'];
$address = 0;
User::updateById($id, $input);
return $this
->response()
......@@ -47,35 +45,32 @@ class EditUserAddressHandle extends Form implements LazyRenderable
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 $row) {
$row->width(3)->text('first_name')->required();
$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) {
$form->width(5)->text('first_name')->required();
$form->width(5)->text('last_name');
$this->row(function (Row $row) {
$row->width(3)->email('email')->required();
$row->width(3)->text('phone')->required();
});
$this->row(function (Row $form) {
$form->width(5)->text('phone')->required();
$form->width(5)->text('email');
$this->row(function (Row $row) {
$row->width(3)->select('country')->options(Country::getCountryMap())->required();
$row->width(3)->text('province');
$row->width(3)->text('city')->required();
$row->width(2)->text('post_code')->required();
});
$this->row(function (Row $form) {
$form->width(5)->select('reg_source')->options(admin_trans('user.options.reg_source'))->required();
$form->width(5)->text('remark');
$this->row(function (Row $row) {
$row->width(12)->textarea('detail_address')->required();
});
$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;
}
}
......@@ -64,7 +64,7 @@ class CreateUser extends \Dcat\Admin\Support\LazyRenderable
$table->width(2)->text('post_code')->required();
});
$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->width(3)->switch('is_default')->required();
......
......@@ -6,7 +6,7 @@ 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\Actions\UserAddress\UserAddressCreateAction;
use App\Admin\Repositories\Inquiry;
use App\Admin\Repositories\User;
use App\Admin\Service\UserAddressService;
......@@ -32,8 +32,10 @@ class UserAddress extends \Dcat\Admin\Support\LazyRenderable
$grid->disableEditButton();
UserAddressService::listField($grid);
$userAddressCreateAction = new UserAddressCreateAction("新增用户地址");
$userAddressCreateAction->setKey($this->key);
$grid->tools([
new UserTransferAction("转让销售"),
$userAddressCreateAction,
]);
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->disableDelete();
......@@ -46,6 +48,7 @@ class UserAddress extends \Dcat\Admin\Support\LazyRenderable
$deleteAction = new UserAddressDeleteAction();
$deleteAction->setRow($actions->row);
$deleteAction->setKey($actions->getKey());
$actions->append($deleteAction);
});
});
......
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