diff --git a/app/common/repositories/user/UserPartnerRepository.php b/app/common/repositories/user/UserPartnerRepository.php index aa8f7ca..4caf383 100644 --- a/app/common/repositories/user/UserPartnerRepository.php +++ b/app/common/repositories/user/UserPartnerRepository.php @@ -73,10 +73,16 @@ class UserPartnerRepository extends BaseRepository public function changePartnerForm($uid) { /** @var UserLabelRepository $make */ - $list = $this->dao->getAll($uid)->column('partner_id'); - $partnerForm = new PartnerDao(); - $option = $partnerForm->getAll(); - return compact('list', 'option'); + $list = $this->dao->getAll($uid)->column('partner_id') ?? []; + $data = ['partner_id' => $list]; + return Elm::createForm(Route::buildUrl('systemUserChangePartner', compact('uid'))->build(), [ + Elm::selectMultiple('partner_id', '用户合作人角色')->options(function () { + $partnerForm = new PartnerDao(); + $option = $partnerForm->getAll(); + return $option; + }), + ])->setTitle('编辑合作人角色')->formData($data); + //return compact('list', 'option'); } public function editPartner(int $uid, array $partner_id = []) @@ -88,7 +94,7 @@ class UserPartnerRepository extends BaseRepository if (!empty($partner_id)) { $data = []; foreach ($partner_id as $k => $v) { - $data[] = ['uid' => $uid, 'partner_id' => $v,'create_time' => date("Y-m-d H:i:s")]; + $data[] = ['uid' => $uid, 'partner_id' => $v, 'create_time' => date("Y-m-d H:i:s")]; } UserPartner::getInstance()->insertAll($data); } diff --git a/app/controller/admin/system/admin/Partner.php b/app/controller/admin/system/admin/Partner.php index 24b51ae..06622b1 100644 --- a/app/controller/admin/system/admin/Partner.php +++ b/app/controller/admin/system/admin/Partner.php @@ -63,7 +63,7 @@ class Partner extends BaseController public function update(PartnerRoleValidate $validate) { - + $data = $this->request->params(['name', 'ratio', 'is_area', 'area_level', 'area_id', ['status', 1], ['type', 1], ['max_role_num', 0], 'brand_id', 'trade_id','id']); $validate->check($data); diff --git a/app/controller/admin/user/User.php b/app/controller/admin/user/User.php index 134c0c9..13540bf 100644 --- a/app/controller/admin/user/User.php +++ b/app/controller/admin/user/User.php @@ -605,7 +605,7 @@ class User extends BaseController { if (!$this->repository->exists($id)) return app('json')->fail('数据不存在'); - return app('json')->success($partnerRepository->changePartnerForm($id)); + return app('json')->success(formToData($partnerRepository->changePartnerForm($id))); } public function changePartner(PartnerRepository $partnerRepository,UserPartnerRepository $userPartnerRepository)