Commit 0243c1df by 宁成龙

完善用户详情页面

parent 32ecedd4
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace App\Admin\Controllers; namespace App\Admin\Controllers;
use App\Admin\Renderable\UserDetail;
use App\Admin\Repositories\User; use App\Admin\Repositories\User;
use App\Admin\Repositories\UserAddress;
use App\Admin\Service\UserService; use App\Admin\Service\UserService;
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
...@@ -40,27 +42,8 @@ class UserController extends AdminController ...@@ -40,27 +42,8 @@ class UserController extends AdminController
*/ */
protected function detail($id) protected function detail($id)
{ {
return Show::make($id, new User(), function (Show $show) { $address_list = (\App\Admin\Renderable\UserAddress::make(["key" => $id])->render());
$show->field('id'); return UserDetail::make(["key" => $id])->render()->render().$address_list;
$show->field('user_sn');
$show->field('name');
$show->field('email');
$show->field('email_verified_at');
$show->field('password');
$show->field('phone');
$show->field('remember_token');
$show->field('account_properties');
$show->field('status');
$show->field('company_name');
$show->field('first_name');
$show->field('sale_id');
$show->field('sale_name');
$show->field('last_name');
$show->field('created_time');
$show->field('update_time');
$show->field('created_at');
$show->field('updated_at');
});
} }
/** /**
......
<?php
namespace App\Admin\Renderable;
use App\Admin\Repositories\Inquiry;
use App\Admin\Repositories\User;
use App\Admin\Service\UserAddressService;
use App\Admin\Service\UserService;
use App\Models\InquiryItems;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
use Dcat\Admin\Models\Administrator;
use Dcat\Admin\Show;
use Dcat\Admin\Widgets\Table;
class UserAddress extends \Dcat\Admin\Support\LazyRenderable
{
public function render()
{
return Grid::make(new \App\Admin\Repositories\UserAddress(), function (Grid $grid) {
$grid->model()->where('user_id', $this->key);
$grid->title("address");
$grid->disableFilterButton();
$grid->disableRefreshButton();
$grid->disableBatchDelete();
$grid->disableCreateButton();
UserAddressService::listField($grid);
});
// $addressList = \App\Models\UserAddress::getListByUserId($id);
}
}
<?php
namespace App\Admin\Renderable;
use App\Admin\Repositories\Inquiry;
use App\Admin\Repositories\User;
use App\Models\InquiryItems;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
use Dcat\Admin\Models\Administrator;
use Dcat\Admin\Show;
use Dcat\Admin\Widgets\Table;
class UserDetail extends \Dcat\Admin\Support\LazyRenderable
{
public function render()
{
$id = $this->key;
// 只填充内容,不需要标题
return Show::make($id, new User(), function (Show $show) {
$show->panel()
->tools(function ($tools) {
// $tools->disableEdit();
$tools->disableList();
$tools->disableDelete();
});
$show->row(function (Show\Row $show) {
$show->width(4)->field('company_name');
$show->width(4)->field('user_sn');
});
$show->row(function (Show\Row $show) {
$show->width(4)->field('first_name');
$show->width(4)->field('last_name');
});
$show->row(function (Show\Row $show) {
$show->width(4)->field('phone');
$show->width(4)->field('email');
});
$show->row(function (Show\Row $show) {
$show->width(4)->field('reg_source')->using(admin_trans('user.options.reg_source'));
$show->width(4)->field('remark');
});
});
}
}
<?php
namespace App\Admin\Renderable;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
use Dcat\Admin\Models\Administrator;
class UserTable extends LazyRenderable
{
public function grid(): Grid
{
return Grid::make(new Administrator(), function (Grid $grid) {
$grid->column('id', 'ID')->sortable();
$grid->column('username');
$grid->column('name');
$grid->column('created_at');
$grid->column('updated_at');
$grid->quickSearch(['id', 'username', 'name']);
$grid->paginate(10);
$grid->disableActions();
$grid->filter(function (Grid\Filter $filter) {
$filter->like('username')->width(4);
$filter->like('name')->width(4);
});
});
}
}
<?php
namespace App\Admin\Service;
use App\Models\Cms\CmsUser;
class CmsUserService
{
/**
* 根据不同的部门权限以及部门id来获取员工列表
* getCmsUserListByDepartmentType
* @param $departmentType
* @param $departmentId
* @return array
* @author tioncico
* Time: 9:38 AM
*/
public static function getCmsUserListByDepartmentType($departmentType,$departmentId)
{
$res = CmsUser::pluck('name', 'userId')
->toArray();
return $res;
}
}
<?php
namespace App\Admin\Service;
use App\Admin\Actions\User\UserAssignAction;
use App\Admin\Actions\User\UserStatusAction;
use App\Admin\Actions\User\UserTransferAction;
use App\Models\User;
use Dcat\Admin\Grid;
class UserAddressService
{
public static function listField(Grid $grid)
{
$grid->column('address_id');
$grid->column('consignee');
$grid->column('email');
$grid->column('phone');
$grid->column('detail_address');
$grid->column('city');
$grid->column('address_type');
$grid->column('post_code');
$grid->column('country');
$grid->column('province');
}
}
...@@ -27,8 +27,8 @@ class UserService ...@@ -27,8 +27,8 @@ class UserService
$filter->startWith('user_sn')->width(2); $filter->startWith('user_sn')->width(2);
$filter->startWith('name')->width(2); $filter->startWith('name')->width(2);
$filter->equal('status')->select(admin_trans('user.options.status'))->width(2); $filter->equal('status')->select(admin_trans('user.options.status'))->width(2);
$filter->equal('sale_id', trans('user.fields.sale_name'))->select(CmsUser::pluck('name', 'userId') $filter->equal('sale_id', trans('user.fields.sale_name'))->select
->toArray())->width(3); (CmsUserService::getCmsUserListByDepartmentType(1, 0))->width(3);
$filter->equal('reg_source')->select(admin_trans('user.options.reg_source'))->width(2); $filter->equal('reg_source')->select(admin_trans('user.options.reg_source'))->width(2);
}); });
} }
...@@ -37,7 +37,7 @@ class UserService ...@@ -37,7 +37,7 @@ class UserService
{ {
$grid->column('company_name'); $grid->column('company_name');
$grid->column('user_sn')->link(function ($user_sn) { $grid->column('user_sn')->link(function ($user_sn) {
return admin_url('smc_user/' . $user_sn); return admin_url('/' . $user_sn);
}); });
$grid->column('name'); $grid->column('name');
$grid->column('phone'); $grid->column('phone');
...@@ -61,16 +61,18 @@ class UserService ...@@ -61,16 +61,18 @@ class UserService
public static function userListActions(Grid $grid) public static function userListActions(Grid $grid)
{ {
$grid->setActionClass(Grid\Displayers\Actions::class); $grid->setActionClass(Grid\Displayers\Actions::class);
$grid->disableEditButton();
$grid->actions(function (Grid\Displayers\Actions $actions) { $grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->disableDelete(); $actions->disableDelete();
$actions->disableEdit(); $actions->disableEdit();
$actions->disableQuickEdit(); $actions->disableQuickEdit();
$actions->disableView(); $actions->disableView();
// 当前行的数据数组 // 当前行的数据数组
$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
btn-mini">detail</a> ');
//状态按钮 //状态按钮
$actions->append(new UserStatusAction()); $actions->append(new UserStatusAction());
}); });
......
...@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model; ...@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
* @property $address_type 地址类型;0:个人,1:公司 * @property $address_type 地址类型;0:个人,1:公司
* @property $consignee 收货人/收货公司 * @property $consignee 收货人/收货公司
* @property $email 邮箱 * @property $email 邮箱
* @property $zipcode 邮政编码 * @property $post_code 邮政编码
* @property $phone 手机/电话 * @property $phone 手机/电话
* @property $country 国家 * @property $country 国家
* @property $province 省份 * @property $province 省份
...@@ -21,10 +21,20 @@ use Illuminate\Database\Eloquent\Model; ...@@ -21,10 +21,20 @@ use Illuminate\Database\Eloquent\Model;
* @property $is_default 是否默认(1=是|0=否) * @property $is_default 是否默认(1=是|0=否)
* @property $create_time 创建时间 * @property $create_time 创建时间
* @property $update_time 修改时间 * @property $update_time 修改时间
* @property $last_name 姓
* @property $first_name 名
* @property $company_name 公司名称
*/ */
class UserAddress extends Model class UserAddress extends Model
{ {
use HasDateTimeFormatter; use HasDateTimeFormatter;
protected $table = 'user_address'; protected $table = 'user_address';
public static function getListByUserId($userId)
{
$res = self::where('user_id', $userId)->get();
return ($res) ? $res->toArray() : [];
}
} }
<?php <?php
return [ return [
'labels' => [ 'labels' => [
'UserAddress' => 'UserAddress', 'UserAddress' => 'UserAddress',
'user-address' => 'UserAddress', 'user-address' => 'UserAddress',
], ],
'fields' => [ 'fields' => [
"address_id" => "用户用户地址ID",
"user_id" => "会员ID",
"address_type" => "地址类型;0:个人,1:公司",
"consignee" => "收货人/收货公司",
"email" => "邮箱",
"post_code" => "邮政编码",
"phone" => "手机/电话",
"country" => "国家",
"province" => "省份",
"city" => "城市",
"detail_address" => "详细地址",
"is_default" => "是否默认(1=是|0=否)",
"create_time" => "创建时间",
"update_time" => "修改时间",
], ],
'options' => [ 'options' => [
], ],
......
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