From 0a937914bf35905dea668a19228fced6db2bd8dd Mon Sep 17 00:00:00 2001 From: monanxiao Date: Sat, 18 Mar 2023 17:56:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=8E=E5=8F=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=B1=95=E7=A4=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/nk/User.php | 18 +++++++++++------- app/admin/model/InformationUserMsg.php | 11 +++++++++++ app/admin/model/ShopUser.php | 10 ++++++++++ app/admin/model/ShopUserGroup.php | 25 +++++++++++++++++++++++++ app/admin/view/nk/user/index.html | 6 ++++-- 5 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 app/admin/model/ShopUserGroup.php diff --git a/app/admin/controller/nk/User.php b/app/admin/controller/nk/User.php index 234e284..5b01dff 100644 --- a/app/admin/controller/nk/User.php +++ b/app/admin/controller/nk/User.php @@ -6,6 +6,8 @@ use app\admin\BaseController; use think\facade\View; use think\facade\Db; +use app\admin\model\InformationUserMsg; + /** * 文章 * @@ -46,7 +48,9 @@ class User extends BaseController } //权限组信息 if ($this->adminInfo['group_access'] != 1) { + $find = Db::table('fa_szxc_information_useraddress')->where('admin_id', $this->adminInfo['id'])->find(); + if ($find) { if ($find['auth_range'] == 1) { $mmm['area_id'] = $find['area_id']; @@ -78,18 +82,18 @@ class User extends BaseController } } //权限组信息 - $total = Db::table('fa_szxc_information_usermsg') - ->alias('m') + $total = InformationUserMsg::alias('m') ->where($mmm) ->where($map) ->count(); - $list = Db::table('fa_szxc_information_usermsg') - ->alias('m') + + $list = InformationUserMsg::alias('m') ->where($mmm) ->where($map) - ->join(['fa_user' => 'u'], 'm.user_id=u.id') - ->join(['fa_user_group' => 'g'], 'g.id=u.group_id') - ->field('u.id,m.name,m.phone,u.avatar,u.group_id,u.status,m.gender,m.age,g.name group_name,m.householder_id') + // ->join(['shop.eb_user' => 'u'], 'm.user_id=u.id') + // ->join(['shop.eb_user_group' => 'g'], 'g.id=u.group_id') + // ->field('u.id,m.name,m.phone,u.avatar,u.group_id,u.status,m.gender,m.age,g.name group_name,m.householder_id') + ->with(['user.userGroup']) ->withAttr('count', function ($value, $data) { if ($data['householder_id'] != 0) { $count = Db::table('fa_szxc_information_usermsg')->where('householder_id', $data['householder_id'])->count(); diff --git a/app/admin/model/InformationUserMsg.php b/app/admin/model/InformationUserMsg.php index 216316e..18c01bb 100644 --- a/app/admin/model/InformationUserMsg.php +++ b/app/admin/model/InformationUserMsg.php @@ -19,4 +19,15 @@ class InformationUserMsg extends Model // 设置当前模型对应的完整数据表名称 protected $table = 'fa_szxc_information_usermsg'; + /** + * + * 关联用户表 + * + */ + public function user() + { + return $this->hasOne(ShopUser::class, 'uid', 'user_id'); + } + + } \ No newline at end of file diff --git a/app/admin/model/ShopUser.php b/app/admin/model/ShopUser.php index 76f66ee..3794112 100644 --- a/app/admin/model/ShopUser.php +++ b/app/admin/model/ShopUser.php @@ -41,4 +41,14 @@ class ShopUser extends Model { return $this->hasOne(InformationUserMsg::class, 'user_id', 'uid'); } + + /** + * + * 关联用户分组表 + * + */ + public function userGroup() + { + return $this->hasOne(ShopUserGroup::class, 'group_id', 'group_id'); + } } \ No newline at end of file diff --git a/app/admin/model/ShopUserGroup.php b/app/admin/model/ShopUserGroup.php new file mode 100644 index 0000000..ff880a1 --- /dev/null +++ b/app/admin/model/ShopUserGroup.php @@ -0,0 +1,25 @@ +', + templet: function (d){ + return `
`; + }, },{ field: 'gender', title: '性别',