diff --git a/.gitignore b/.gitignore index 4f90f60..9be8bf4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ *.ini .htaccess 404.html -index.html +# index.html /runtime/* /public/storage/* /public/backup/* diff --git a/app/admin/controller/merchant/system/merchant/Merchant.php b/app/admin/controller/merchant/system/Merchant.php similarity index 78% rename from app/admin/controller/merchant/system/merchant/Merchant.php rename to app/admin/controller/merchant/system/Merchant.php index 620f30a..3b67d20 100644 --- a/app/admin/controller/merchant/system/merchant/Merchant.php +++ b/app/admin/controller/merchant/system/Merchant.php @@ -3,7 +3,7 @@ * 表单页面 * */ -namespace app\admin\controller\merchant; +namespace app\admin\controller\merchant\system; use app\admin\BaseController; diff --git a/app/admin/controller/merchant/system/merchant/MerchantApplyments.php b/app/admin/controller/merchant/system/MerchantApplyments.php similarity index 95% rename from app/admin/controller/merchant/system/merchant/MerchantApplyments.php rename to app/admin/controller/merchant/system/MerchantApplyments.php index 5948ab6..ba78965 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantApplyments.php +++ b/app/admin/controller/merchant/system/MerchantApplyments.php @@ -6,7 +6,7 @@ * * @ 商户入驻申请管理 */ -namespace app\admin\controller\merchant; +namespace app\admin\controller\merchant\system; use app\admin\BaseController; use app\validate\merchant\MerchantApplymentsValidate; diff --git a/app/admin/controller/merchant/system/auth/Menu.php b/app/admin/controller/merchant/system/auth/Menu.php new file mode 100644 index 0000000..24b50a9 --- /dev/null +++ b/app/admin/controller/merchant/system/auth/Menu.php @@ -0,0 +1,133 @@ +adminInfo = get_login_admin(); + + $this->menu = $menu; + + $this->params = get_params() ; + } + + /** + * 空白菜单页,由前端 ajax 获取数据 + */ + function Index() { + return view('merchant/system/auth/menu/index'); + } + + /** + * 菜单列表 + */ + function Lst(){ + // 查出商户所有菜单数据 + $data = $this->menu->Search([], 1); + + to_assign(0,'',$data['list']); + } + + /** + * 表单页 + * TODO: 操作日志要另建表做关联 + * 操作日志待开发 + * + */ + function AddForm(FormatList $format){ + $id = isset($this->params['id']) ? $this->params['id'] : 0; + $pid = isset($this->params['pid']) ? $this->params['pid'] : 0; + if($id>0){ + $detail = $this->menu->Find($id); + $detail['name'] = $detail['title']; + View::assign('detail', $detail); + } + // 查出商户所有菜单数据 + $data = $this->menu->Search([], 1); + $menus = $format->DropDownMenu($data['list']); + + View::assign('id', $id); + View::assign('pid', $pid); + View::assign('menus',$menus); + + return view('merchant/system/auth/menu/add'); + } + + /** + * 添加菜单 + */ + function Add(){ + echo 'add'; + $this->params['src'] = preg_replace('# #','',$this->params['src']); + // if ($param['id'] == 0) { + try { + validate(RuleCheck::class)->scene('add')->check($this->params); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $this->params['create_time'] = time(); + $rid = Db::name('AdminRule')->strict(false)->field(true)->insertGetId($this->params); + //自动为系统所有者管理组分配新增的节点 + $group = Db::name('AdminGroup')->find(1); + if (!empty($group)) { + $newGroup['id'] = 1; + $newGroup['rules'] = $group['rules'] . ',' . $rid; + Db::name('AdminGroup')->strict(false)->field(true)->update($newGroup); + add_log('add', $rid, $this->params); + } + // } + // 删除后台节点缓存 + clear_cache('adminRules'); + return to_assign(); + } + + /** + * 编辑菜单 + */ + function Edit(){ + echo 'edit'; + if ($this->params['id'] > 0) { + try { + validate(RuleCheck::class)->scene('edit')->check($this->params); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + Db::name('AdminRule')->strict(false)->field(true)->update($this->params); + add_log('edit', $this->params['id'], $this->params); + } + } + + /** + * 删除菜单 + */ + function Del(){ + $id = get_params("id"); + try{ + $this->menu->Del($id); + return to_assign(0, "删除节点成功"); + }catch(ValidateException $e){ + return to_assign(1, $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/admin/controller/merchant/system/merchant/MerchantMargin.php b/app/admin/controller/merchant/system/merchant/MerchantMargin.php index 80c38a4..0f7f159 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantMargin.php +++ b/app/admin/controller/merchant/system/merchant/MerchantMargin.php @@ -1,13 +1,32 @@ margin = $margin; + } + /** * 显示资源列表 * diff --git a/app/admin/controller/merchant/system/merchant/MerchantType.php b/app/admin/controller/merchant/system/merchant/MerchantType.php index 56a55d6..1a3dff9 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantType.php +++ b/app/admin/controller/merchant/system/merchant/MerchantType.php @@ -1,76 +1,170 @@ merchant = $merchant; + $this->path = [ + 'index' => 'merchant/system/merchant/type/index', + 'read' => 'merchant/system/merchant/type/read', + 'add' => 'merchant/system/merchant/type/add' + ]; + } + /** - * 显示店铺类型列表 + * 空白菜单页,由前端 ajax 获取数据 + */ + public function Index() + { + return View($this->path['index']); + } + + /** + * 添加/编辑 表单页 + */ + public function Form(MenuModel $menu, FormatList $format) + { + $param = get_params(); + $id = isset($param['id']) ? (int)$param['id'] : 0; + + if (!empty($id)) { + // 进入编辑页,显示店铺数据 + $detail = $this->merchant->Find($id); + } + if (empty($detail)) { + $detail = [ + "create_time" => '', + "description" => '', + "id" => '', + "margin" => 0, + "is_margin" => 0, + "type_info" => '', + "description" => '', + "type_name" => '', + "update_time" => '' + ]; + } + + // 查出商户所有菜单数据 + $data = $menu->Search([], 1); + View::assign('dataTree', $format->FormatCategory($data['list'])); + View::assign('detail', $detail); + + return view($this->path['add']); + } + + /** + * 输出店铺类型列表数据 * * @return \think\Response */ public function Lst() { - echo 1723; + $param = get_params(); + $page = empty($param['page']) ? 1 : (int)$param['page']; + $limit = empty($param['limit']) ? 10 : (int)$param['limit']; + + $data = $this->merchant->GetList($page, $limit); + + return table_assign(0, '', $data); } /** + * TODO: 关联权限待完成 + * * 添加店铺类型. * * @return \think\Response */ public function Add() { - // + $params = get_params(); + + $batch['type_name'] = $params['type_name']; + $batch['description'] = $params['description']; + $batch['is_margin'] = $params['is_margin']; + $batch['margin'] = $params['margin']; + $batch['type_info'] = $params['type_info']; + $menu_ids = $params['auth']; + + // 更新权限 + // $this->menu->update($menu_ids); + + $rows = $this->merchant->Add($batch); + + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } /** - * 保存新建的资源 + * 查看指定的店铺详情 * - * @param \think\Request $request * @return \think\Response */ - public function save(Request $request) + public function Read() { - // + $param = get_params(); + $id = isset($param['id']) ? (int)$param['id'] : 0; + + $detail = $this->merchant->Find($id); + + if (!empty($detail)) { + View::assign('detail', $detail); + return view($this->path['read']); + } else { + throw new \think\exception\HttpException(404, '找不到页面'); + } } /** - * 显示指定的店铺详情 + * TODO: 关联权限待完成 + * 编辑指定菜单. * * @param int $id * @return \think\Response */ - public function Detail($id) + public function Edit() { - // - } + $params = get_params(); - /** - * 显示编辑资源表单页. - * - * @param int $id - * @return \think\Response - */ - public function edit($id) - { - // - } + $batch['type_name'] = $params['type_name']; + $batch['description'] = $params['description']; + $batch['is_margin'] = $params['is_margin']; + $batch['margin'] = $params['margin']; + $batch['type_info'] = $params['type_info']; + $menu_ids = $params['auth']; - /** - * 保存更新的资源 - * - * @param \think\Request $request - * @param int $id - * @return \think\Response - */ - public function update(Request $request, $id) - { - // + // 更新权限 + // $this->menu->update($menu_ids); + + $rows = $this->merchant->Add($batch); + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } /** @@ -79,12 +173,39 @@ class MerchantType extends BaseController * @param int $id * @return \think\Response */ - public function delete($id) + public function Del() { - // + $param = get_params(); + if (empty($param['id'])) { + return 0; + } + $id = (int)$param['id']; + + $rows = $this->merchant->Del($id); + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } - public function Mark(){} - public function Description(){} + /** + * 备注表单页 + */ + + /** + * 店铺类型备注 + */ + public function Mark() + { + $params = get_params(); + return to_assign(0, ''); + } + + /** + * 店铺类型说明 + */ + public function Description() + { + View::assign('detail', []); + return View('merchant/system/merchant/descr/index', ['id' => 1]); + } } diff --git a/app/admin/controller/merchant/system/merchant/auth/Menu.php b/app/admin/controller/merchant/system/merchant/auth/Menu.php deleted file mode 100644 index 1c4efe0..0000000 --- a/app/admin/controller/merchant/system/merchant/auth/Menu.php +++ /dev/null @@ -1,55 +0,0 @@ -adminInfo = get_login_admin(); - - $this->menu = $menu; - - // 模块,0 平台, 1商户 - $this->is_mer = get_params('is_m', 0) == 0 ? 2 : 2; - $this->category_id=354; - $this->url=[ - '/admin/nk.classroom/index?category_id='.$this->category_id, - '/admin/nk.classroom/add', - '/admin/nk.classroom/edit', - '/admin/nk.classroom/del', - '/admin/nk.classroom/read', - ]; - } - - function Index() { - return view('merchant/system/auth/index',['url'=>$this->url]); - } - - function Lst(FormatList $formatList){ - // 查出商户所有菜单数据 - $list = $this->menu->Search([], 1); - - // 格式化成多维数组 - // $data = $formatList->FormatCategory($list['list'], "menu_id"); - to_assign(0,'操作成功',$list); - // return view('merchant/system/auth/index',['url'=>$this->url]); - } -} \ No newline at end of file diff --git a/app/admin/model/system/auth/Menu.php b/app/admin/model/system/auth/Menu.php deleted file mode 100644 index a1843ed..0000000 --- a/app/admin/model/system/auth/Menu.php +++ /dev/null @@ -1,53 +0,0 @@ -order('sort DESC,menu_id ASC'); - if (isset($where['pid'])) $query->where('pid', (int)$where['pid']); - if (isset($where['keyword'])) $query->whereLike('menu_name|route', "%{$where['keyword']}%"); - if (isset($where['is_menu'])) $query->where('is_menu', (int)$where['is_menu']); - - // 查询记录总行数 - // $count = $query->count(); - - // 隐藏指定字段 - $list = $query->hidden(['update_time', 'path'])->select()->toArray(); - - // 合并为一个数组并返回 - // compact('count', 'list'); - - return $list; - } -} diff --git a/app/admin/model/system/merchant/MerchantType.php b/app/admin/model/system/merchant/MerchantType.php deleted file mode 100644 index 8ba9f73..0000000 --- a/app/admin/model/system/merchant/MerchantType.php +++ /dev/null @@ -1,14 +0,0 @@ -name('systemMenuGetLst')->option([ - // '_alias' => '平台菜单/权限列表', - // ]); - // Route::get('create/form', '/createForm')->name('systemMenuCreateForm')->option([ - // '_alias' => '平台菜单/权限添加表单', - // '_auth' => false, - // '_form' => 'systemMenuCreate', - // ]); - // Route::get('update/form/:id', '/updateForm')->name('systemMenuUpdateForm')->option([ - // '_alias' => '平台菜单/权限编辑表单', - // '_auth' => false, - // '_form' => 'systemMenuUpdate', - // ]); - // Route::post('create', '/create')->name('systemMenuCreate')->option([ - // '_alias' => '平台菜单/权限添加', - // ]); - // Route::post('update/:id', '/update')->name('systemMenuUpdate')->option([ - // '_alias' => '平台菜单/权限编辑', - // ]); - // Route::delete('delete/:id', '/delete')->name('systemMenuDelete')->option([ - // '_alias' => '平台菜单/权限删除', - // ]); - // })->prefix('admin.system.auth.Menu')->option([ - // '_path' => '/setting/menu', - // '_auth' => true, - // ]); - //商户权限管理 Route::group('merchant/menu', function () { Route::get('index', '/index')->name('systemMerchantMenuIndex')->option([ @@ -56,26 +27,27 @@ Route::group(function () { Route::get('lst', '/lst')->name('systemMerchantMenuGetLst')->append(['merchant' => 1])->option([ '_alias' => '商户菜单/权限列表', ]); - Route::get('create/form', '/createForm')->name('systemMerchantMenuCreateForm')->append(['merchant' => 1])->option([ + + Route::post('add', '/add')->name('systemMerchantMenuCreate')->append(['merchant' => 1])->option([ + '_alias' => '商户菜单/权限添加', + ]); + Route::post('edit/:id', '/edit')->name('systemMerchantMenuUpdate')->append(['merchant' => 1])->option([ + '_alias' => '商户菜单/权限编辑', + ]); + Route::get('addform', '/AddForm')->name('systemMerchantMenuCreateForm')->append(['merchant' => 1])->option([ '_alias' => '商户菜单/权限添加表单', '_auth' => false, '_form' => 'systemMerchantMenuCreate', ]); - Route::get('update/form/:id', '/updateForm')->name('systemMerchantMenuUpdateForm')->append(['merchant' => 1])->option([ + Route::get('editform', '/editform')->name('systemMerchantMenuUpdateForm')->append(['merchant' => 1])->option([ '_alias' => '商户菜单/权限编辑表单', '_auth' => false, '_form' => 'systemMerchantMenuUpdate', ]); - Route::post('create', '/create')->name('systemMerchantMenuCreate')->append(['merchant' => 1])->option([ - '_alias' => '商户菜单/权限添加', - ]); - Route::post('update/:id', '/update')->name('systemMerchantMenuUpdate')->append(['merchant' => 1])->option([ - '_alias' => '商户菜单/权限编辑', - ]); - Route::delete('delete/:id', '/delete')->name('systemMerchantMenuDelete')->append(['merchant' => 1])->option([ + Route::delete('del/:id', '/del')->name('systemMerchantMenuDelete')->append(['merchant' => 1])->option([ '_alias' => '商户菜单/权限删除', ]); - })->prefix('merchant.system.merchant.auth.Menu')->option([ + })->prefix('merchant.system.auth.Menu')->option([ '_path' => '/merchant/menu', '_auth' => true, ]); diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index 8b9e287..1432f04 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -46,19 +46,25 @@ Route::group(function(){ // 店铺类型 Route::group('/merchant/type',function(){ + Route::get('index', '/index')->name('systemMerchantTypeLst')->option([ + '_alias' => '列表', + ]); Route::get('lst', '/lst')->name('systemMerchantTypeLst')->option([ '_alias' => '列表', ]); - Route::get('detail/:id', '/detail')->name('systemMerchantTypeDetail')->option([ + Route::get('read', '/read')->name('systemMerchantTypeDetail')->option([ '_alias' => '详情', ]); + Route::get('form', '/form')->name('systemMerchantTypeAdd')->option([ + '_alias' => '添加/编辑页', + ]); Route::post('add', '/add')->name('systemMerchantTypeAdd')->option([ '_alias' => '添加', ]); - Route::put('edit/:id', '/edit')->name('systemMerchantTypeUpdate')->option([ + Route::put('edit', '/edit')->name('systemMerchantTypeUpdate')->option([ '_alias' => '编辑', ]); - Route::delete('del/:id', '/del')->name('systemMerchantTypeDelete')->option([ + Route::delete('del', '/del')->name('systemMerchantTypeDelete')->option([ '_alias' => '删除', ]); Route::get('mark/:id', '/markForm')->name('systemMerchantTypeMarkForm')->option([ @@ -66,11 +72,11 @@ Route::group(function(){ '_auth' => false, '_form' => 'systemMerchantTypeMark', ]); - Route::post('mark/:id', '/mark')->name('systemMerchantTypeMark')->option([ + Route::post('mark', '/mark')->name('systemMerchantTypeMark')->option([ '_alias' => '备注', ]); - Route::get('description', '/description')->name('systemMerchantTypeDescrForm')->option([ + Route::get('descr', '/description')->name('systemMerchantTypeDescrForm')->option([ '_alias' => '店铺类型说明', ]); Route::post('description', '/description')->name('systemMerchantTypeDescr')->option([ diff --git a/app/admin/view/merchant/system/auth/add.html b/app/admin/view/merchant/system/auth/menu/add.html similarity index 94% rename from app/admin/view/merchant/system/auth/add.html rename to app/admin/view/merchant/system/auth/menu/add.html index 49d2fca..2b494c5 100644 --- a/app/admin/view/merchant/system/auth/add.html +++ b/app/admin/view/merchant/system/auth/menu/add.html @@ -11,7 +11,7 @@
店铺类型名称 | ++ | ||||||
店铺类型要求 | ++ + | +||||||
店铺保证金 | ++ | ||||||
店铺权限 | ++ + + | +||||||
其它说明 | ++ + | +||||||
创建时间 | ++ {$detail.create_time} + | +||||||
修改时间 | ++ {$detail.update_time} + | +