Merge branch 'master' of git.excellentkk.cn:mkm/nk-lihaink-cn

This commit is contained in:
monanxiao 2023-03-06 09:39:21 +08:00
commit 8c9f245111
24 changed files with 1289 additions and 214 deletions

2
.gitignore vendored
View File

@ -7,7 +7,7 @@
*.ini
.htaccess
404.html
index.html
# index.html
/runtime/*
/public/storage/*
/public/backup/*

View File

@ -3,7 +3,7 @@
* 表单页面
*
*/
namespace app\admin\controller\merchant;
namespace app\admin\controller\merchant\system;
use app\admin\BaseController;

View File

@ -6,7 +6,7 @@
*
* @ 商户入驻申请管理
*/
namespace app\admin\controller\merchant;
namespace app\admin\controller\merchant\system;
use app\admin\BaseController;
use app\validate\merchant\MerchantApplymentsValidate;

View File

@ -0,0 +1,133 @@
<?php
/**
* 商户菜单管理
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
namespace app\admin\controller\merchant\system\auth;
use app\admin\BaseController;
use app\common\model\merchant\system\auth\Menu as MenuModel;
use think\facade\View;
use app\common\controller\FormatList;
use think\exception\ValidateException;
/**
* class Menu
*/
class Menu extends BaseController
{
protected $menu;
protected $params;
function __construct(MenuModel $menu) {
// $this->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());
}
}
}

View File

@ -1,13 +1,32 @@
<?php
/**
* 店铺保证金管理
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
namespace app\admin\controller\merchant\system\merchant;
use app\admin\BaseController;
use think\Request;
use app\common\model\merchant\system\merchant\MerchantMargin as MarchantMarginModel;
/**
* 店铺保证金管理类
*/
class MerchantMargin extends BaseController
{
protected $margin;
public function __construct(MarchantMarginModel $margin)
{
$this->margin = $margin;
}
/**
* 显示资源列表
*

View File

@ -1,76 +1,170 @@
<?php
declare (strict_types = 1);
/**
* 店铺类型管理
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare(strict_types=1);
namespace app\admin\controller\merchant\system\merchant;
use app\admin\BaseController;
use think\Request;
use app\common\model\merchant\system\merchant\MerchantType as MerchantTypeModel;
use app\common\model\merchant\system\auth\Menu as MenuModel;
use app\common\controller\FormatList;
use think\facade\View;
/**
* 店铺类型管理类
*/
class MerchantType extends BaseController
{
protected $merchant;
protected $path;
public function __construct(MerchantTypeModel $merchant)
{
$this->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]);
}
}

View File

@ -1,55 +0,0 @@
<?php
/**
* 商户菜单管理
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
namespace app\admin\controller\merchant\system\merchant\auth;
use app\admin\BaseController;
use app\admin\model\system\auth\Menu as MenuModel;
use app\common\controller\FormatList;
/**
* class Menu
*/
class Menu extends BaseController
{
protected $menu;
protected $is_mer;
protected $url;
protected $category_id;
function __construct(MenuModel $menu) {
// $this->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]);
}
}

View File

@ -1,53 +0,0 @@
<?php
/**
* 商户菜单 model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
namespace app\admin\model\system\auth;
use think\Model;
/**
* Class Menu
*/
class Menu extends Model
{
// 指定连接到商城库
protected $connection = 'shop';
// 指定此model关联表
protected $table = 'eb_system_menu';
/**
* 按条件获取商户菜单数据
*
* @param array $where 过滤字段条件
* @param int $is_mer 菜单类型: 0商城平台菜单 1商户菜单
*
* @return array
*/
function Search(array $where=[], int $is_mer=2):array
{
// 按条件 拼接 select 前sql
$query = self::where('is_mer', $is_mer)->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;
}
}

View File

@ -1,14 +0,0 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\system\merchant;
use think\Model;
/**
* @mixin \think\Model
*/
class MerchantType extends Model
{
//
}

View File

@ -17,35 +17,6 @@ use app\common\middleware\LogMiddleware;
Route::group(function () {
//权限管理
// Route::group('system/menu', function () {
// Route::get('lst', '/getList')->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,
]);

View File

@ -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([

View File

@ -11,7 +11,7 @@
<td>
<select name="pid" lay-verify="required" lay-reqText="请选择父级菜单/节点">
<option value="0">作为顶级菜单/节点</option>
{volist name=":set_recursion(get_admin_rule())" id="v"}
{volist name="$menus" id="v"}
<option value="{$v.id}" {eq name="pid" value="$v.id" }selected="" {/eq}>{$v.title} </option>
{/volist}
</select>
@ -65,8 +65,8 @@
<td>
<select name="pid" lay-verify="required" lay-reqText="请选择父级菜单/节点">
<option value="0">作为顶级节点</option>
{volist name=":set_recursion(get_admin_rule())" id="v"}
<option value="{$v.id}" {eq name="$detail.pid" value="$v.id" }selected="" {/eq}>{$v.title} </option>
{volist name="$menus" id="v"}
<option value="{$v.id}" {eq name="$detail.pid" value="$v.id" }selected="" {/eq}>{$v.title}</option>
{/volist}
</select>
</td>

View File

@ -0,0 +1,93 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<div class="gg-form-bar border-t border-x">
<button class="layui-btn layui-btn-sm add-menu">+ 添加菜单/节点</button>
</div>
<div>
<table class="layui-hide" id="treeTable" lay-filter="treeTable"></table>
</div>
</div>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool', 'treeGrid'];
function gouguInit() {
var treeGrid = layui.treeGrid,table = layui.table, tool = layui.tool;
var pageTable = treeGrid.render({
id: 'treeTable'
, elem: '#treeTable'
, idField: 'id'
, url: "/admin/merchant/menu/lst"
, cellMinWidth: 80
, treeId: 'id'//树形id字段名称
, treeUpId: 'pid'//树形父id字段名称
, treeShowName: 'title'//以树形式显示的字段
, cols: [[
{ field: 'id', width: 80, title: 'ID号', align: 'center' }
, { field: 'sort', width: 60, title: '排序', align: 'center' }
,{field:'icon',title: '菜单图标',width: 80, align: 'center' ,templet: function(d){
var html='<strong class="bi '+d.icon+'"></strong>';
return html;
}}
, { field: 'title', width: 160, title: '菜单/节点名称' }
, { field: 'pid', title: '父ID', width: 80, align: 'center' }
, { field: 'src', title: 'URL链接' }
, {
field: 'menu', width: 100, title: '是否是菜单', align: 'center', templet: function (d) {
var html = '<span style="color:#fbbc05"></span>';
if (d.menu == '1') {
html = '<span style="color:#12bb37"></span>';
}
return html;
}
}
, { field: 'name', width: 110, title: '操作日志名称', align: 'center' }
, {
width: 188, title: '操作', align: 'center'
, templet: function (d) {
var html = '<span class="layui-btn-group"><button class="layui-btn layui-btn-xs" lay-event="add">添加子菜单/节点</button><button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">编辑</button><button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button>';
return html;
}
}
]]
, page: false
});
//表头工具栏事件
$('.add-menu').on('click', function () {
tool.side("/admin/merchant/menu/addform");
return;
});
//操作按钮
treeGrid.on('tool(treeTable)', function (obj) {
console.log(obj);
if (obj.event === 'add') {
tool.side('/admin/merchant/menu/addform?pid=' + obj.data.id);
return;
}
if (obj.event === 'edit') {
tool.side('/admin/merchant/menu/addform?id=' + obj.data.id);
return;
}
if (obj.event === 'del') {
layer.confirm('确定要删除吗?', { icon: 3, title: '提示' }, function (index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete("/admin/merchant/menu/del", { id: obj.data.id }, callback);
layer.close(index);
});
}
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,135 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {display: inline-block}
.editormd li {list-style: inherit;}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<!-- <h3 class="pb-3">新建文章</h3> -->
<table class="layui-table layui-table-form">
<tr>
<td colspan="6" class="layui-td-gray" style="text-align:left">店铺说明</td>
</tr>
<tr>
<td colspan="6">
<textarea class="layui-textarea" id="container_content"></textarea>
</td>
</tr>
</table>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/xm-select.js"></script>
<script>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
var group_access = "{:session('gougu_admin')['group_access']}"
function gouguInit() {
var form =layui.form, tool = layui.tool,tagspicker = layui.tagpicker,laydate=layui.laydate;
laydate.render({
elem: '#test1' //指定元素
});
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
street();
village();
form.on('select(area_id)', function (data) {
street(data.value)
});
function street (id) {
var demo1 = xmSelect.render({
name: 'township',
el: '#demo1',
initValue: [],
prop: {
name: 'name',
value: 'code',
},
data: [],
radio: true,
disabled: group_access == 2 ||group_access == 4? true : false,
on: function (data) {
var arr = data.arr;
if(arr.length > 0){
village(arr[0]['code']);
}else{
village();
}
},
})
$.get('/api/geo/street?pcode=' + id, function (result) {
demo1.update({
data: result.data
})
});
}
function village (id) {
var demo2 = xmSelect.render({
name: 'village',
el: '#demo2',
initValue: [],
prop: {
name: 'name',
value: 'id',
},
data: [],
radio: true,
disabled: group_access == 2 ? true : false,
})
$.get('/api/geo/village?pcode=' + id, function (result) {
demo2.update({
data: result.data
})
});
}
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500
});
//监听提交
form.on('submit(webform)', function (data) {
data.field.content = tinyMCE.editors['container_content'].getContent();
if (data.field.content == '') {
layer.msg('请先完善文章内容');
return false;
}
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.tabRefresh(71);
tool.sideClose(1000);
}
}
tool.post('', data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,209 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">添加店铺类型</h3>
<table class="layui-table layui-table-form">
<tr>
<td colspan="2" class="layui-td-gray">店铺类型名称<font>*</font></td>
<td colspan="6">
<input type="text" name="type_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="123131{$detail.type_name}">
</td>
</tr>
<tr>
<td colspan="2" class="layui-td-gray">店铺类型要求</td>
<td colspan="6">
<textarea class="layui-textarea" name="type_info">{$detail.type_name}</textarea>
</td>
</tr>
<tr>
<td colspan="2" class="layui-td-gray">店铺保证金</td>
<td colspan="6">
<table class="layui-table layui-table-form">
<tr>
<td colspan="2">
<div class="layui-input-block">
<input type="radio" name="is_margin" value="1" title="有" checked="{$detail.is_margin}">
<input type="radio" name="is_margin" value="0" title="无" checked="{$detail.is_margin}">
</div>
</td>
<td colspan="5"></td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="margin" lay-verify="required" lay-reqText="0" autocomplete="off" placeholder="0" class="layui-input" value="{$detail.margin}">
</td>
<td colspan="5">单位:元</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" style="height: 360px;" class="layui-td-gray">店铺权限<font>*</font></td>
<td colspan="6" >
<div class="data-box" data-admin='{:json_encode($dataTree)}'></div>
<div id="test7" class="demo-tree"></div>
</td>
</tr>
<tr>
<td colspan="2" class="layui-td-gray">其它说明</td>
<td colspan="6">
<textarea class="layui-textarea" name="description">{$detail.description}</textarea>
</td>
</tr>
</table>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform" type='button'>立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/xm-select.js"></script>
<script>
var moduleInit = ['tool','treeGrid', 'tagpicker', 'tinymce', 'admin'];
var group_access = "{:session('gougu_admin')['group_access']}"
function gouguInit() {
var treeGrid = layui.treeGrid,table = layui.table
var tool = layui.tool;
var form = layui.form, tool = layui.tool, tagspicker = layui.tagpicker;
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500,
});
// 店铺权限
layui.use(['tree', 'util'], function(){
var tree = layui.tree
,layer = layui.layer
,util = layui.util
//模拟数据
,data = getData();
// [{
// title: '一级1'
// ,id: 1
// ,field: 'name1'
// ,checked: true
// ,spread: true
// ,children: [{}]
// }]
//开启复选框
tree.render({
elem: '#test7'
,data: data
,showCheckbox: true
,id:'id',//菜单id
});
//监听提交
form.on('submit(webform)', function (data) {
console.log(data.field);
// data.field.content = tinyMCE.editors['container_content'].getContent();
if (data.field == '') {
layer.msg('请先完善店铺类型');
return false;
}
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.tabRefresh(71);
tool.sideClose(1000);
}
}
//获得选中的节点
var checkData = tree.getChecked('id');
var list = new Array();
list = getChecked_list(checkData);
data.field.auth = list
tool.post('/admin/merchant/type/add', data.field, callback);
return true;
});
// 获取选中节点的id
function getChecked_list(data) {
var id = "";
$.each(data, function (index, item) {
if (id != "") {
id = id + "," + item.id;
}
else {
id = item.id;
}
var i = getChecked_list(item.children);
if (i != "") {
id = id + "," + i;
}
});
return id;
}
});
}
//获取店铺权限的数据
function getData(){
/* 初始化页面渲染时传过来的js变量 */
let dataContainerElem = document.querySelector('.data-box'),
data = dataContainerElem ? dataContainerElem.dataset : {},
dataBox = {}; //模板变量容器,`.data-box`类选择器所在的所有`data`属性值集合
Object.keys(data).forEach(function (key) {
dataBox[key] = data[key];
if (isJsonString(data[key])) dataBox[key] = JSON.parse(data[key]); //是json格式的字串才转对象
});
/**
* 判断字串是否属于json字串
*/
function isJsonString(str) {
let flag = false;
if (typeof str != 'string') return flag;
try {
JSON.parse(str);
flag = true;
} catch (e) {}
return flag;
}
//所有保存到数据节点的变量都成为`dataBox`对象的属性
return dataBox.admin;
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,138 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<table class="layui-hide" id="store_product" lay-filter="store_product"></table>
</div>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<span class="layui-btn layui-btn-sm side-alert" lay-event="add" data-title="添加商品">+ 添加店铺类型</span>
</div>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a>
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#store_product',
title: '商品表列表',
toolbar: '#toolbarDemo',
url: '/admin/merchant/type/lst',
page: true,
limit: 20,
cellMinWidth: 300,
cols: [
[
{
fixed: 'ID',
field: 'id',
title: '编号',
align: 'center',
width: 80
},
{
field: 'type_name',
title: '店铺类型名称',
align: 'center',
width: 200
},{
field: 'margin',
title: '店铺保证金',
align: 'center',
width: 100
},{
field: 'type_info',
title: '店铺类型要求',
align: 'center',
width: 220
},{
field: 'create_time',
title: '创建时间',
align: 'center',
width: 150
},{
field: 'update_time',
title: '最近修改时问',
align: 'center',
width: 150
},
{
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#barDemo',
width: 190,
align: 'center'
}
]
]
});
//监听表头工具栏事件
table.on('toolbar(store_product)', function(obj){
if (obj.event === 'add') {
tool.side("/admin/merchant/type/form");
return false;
}
});
//监听表格行工具事件
table.on('tool(store_product)', function(obj) {
console.log(obj.data);
var data = obj.data;
if (obj.event === 'read') {
tool.side('/admin/merchant/type/read?id='+obj.data.id);
}
else if (obj.event === 'edit') {
tool.side('/admin/merchant/type/form?id='+obj.data.id);
}
else if (obj.event === 'del') {
layer.confirm('确定要删除该记录吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete("/admin/merchant/type/del", { id: data.id }, callback);
layer.close(index);
});
}
return false;
});
//监听搜索提交
// form.on('submit(searchform)', function(data) {
// layui.pageTable.reload({
// where: {
// keywords: data.field.keywords
// },
// page: {
// curr: 1
// }
// });
// return false;
// });
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,63 @@
{extend name="common/base"/}
{block name="style"}
<style>
.content-article img{max-width:88%!important; height:auto!important; margin:6px 0!important; border-radius:4px;}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<div class="layui-form p-4">
<h3 class="pb-3">文章详情</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">店铺类型名称</td>
<td colspan="7"><input type="text" name="store_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_name}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">店铺类型要求</td>
<td colspan="7">
<input type="text" name="store_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_info}" readonly>
</td>
</tr>
<tr>
<td class="layui-td-gray">店铺保证金</td>
<td colspan="7"><input type="text" name="price" lay-verify="required" lay-reqText="请输入商品关键字"
autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.margin}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">店铺权限</td>
<td colspan="3">
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">其它说明</td>
<td colspan="6">
<textarea class="layui-textarea" name="store_info" readonly>{$detail.store_info}</textarea>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">创建时间</td>
<td colspan="6">
{$detail.create_time}
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">修改时间</td>
<td colspan="6">
{$detail.update_time}
</td>
</tr>
</table>
</div>
{/block}
<!-- /主体 -->

View File

@ -4,7 +4,7 @@
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月2
* @date 2023年03月3
*/
namespace app\common\controller;
@ -19,7 +19,7 @@ class FormatList
* @param string $childrenKey 子级字段名
* @return array
*
* @date 2020-03-27
* @date 2023-03-3
*/
function FormatCategory(array $data, string $idName = "id", string $fieldName = 'pid', $childrenKey = 'children')
{
@ -37,4 +37,34 @@ class FormatList
}
return $result;
}
/**
* 递归排序,用于下拉分类选择菜单
*
* @param array $data 数据源
* @param string $idName 主键
* @param string $fieldName 父级字段
* @param string $childrenKey 子级字段名
* @return array
*
* @date 2023-03-3
*/
function DropDownMenu($result, $pid = 0, $level=-1)
{
/*记录排序后的类别数组*/
static $list = array();
static $space = ['','├─','§§├─','§§§§├─','§§§§§§├─'];
$level++;
foreach ($result as $k => $v) {
if ($v['pid'] == $pid) {
if ($pid != 0) {
$v['title'] = $space[$level] . $v['title'];
}
/*将该类别的数据放入list中*/
$list[] = $v;
self::DropDownMenu($result, $v['id'],$level);
}
}
return $list;
}
}

View File

@ -4,7 +4,7 @@
* @
* @author 刘孝全
*/
namespace app\admin\model;
namespace app\common\model\merchant\system;
use think\model;
use think\facade\Db;

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\merchant;
namespace app\common\model\merchant\system;
use think\Model;

View File

@ -0,0 +1,108 @@
<?php
/**
* 商户菜单 model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
namespace app\common\model\merchant\system\auth;
use think\Model;
use think\exception\ValidateException;
/**
* Class Menu
*/
class Menu extends Model
{
// 指定连接到商城库
protected $connection = 'shop';
// 指定此model关联表
protected $table = 'eb_system_menu';
/**
* 按条件获取商户菜单数据
*
* @param array $where 过滤字段条件
* @param int $is_mer 菜单类型: 0商城平台菜单 1商户菜单
*
* @return array
*/
function Search(array $where=[], int $is_mer=2)
{
// 按条件 拼接 select 前sql
$query = self::where('is_mer', $is_mer)
->field('menu_id as id,pid, sort, route as src,icon,menu_name as title,is_show as status, is_menu as menu')
->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();
if (isset($where['offset'])) $query->page($where['offset'])->limit($where['limit']);
// 隐藏指定字段
$list = $query->hidden(['update_time', 'path'])->select()->toArray();
// 合并为一个数组并返回
$data = compact('count', 'list');
return $data;
}
/**
* 获取指定行数据
*
* @return array $row
*/
function Find($id) {
$row = self::where('menu_id', $id)
->field('menu_id as id,pid, sort, route as src,icon,menu_name as title,is_show as status, is_menu as menu')
->find();
return $row;
}
/**
* 添加
*/
function Add() {}
/**
* 更新
*/
function modify()
{
return true;
}
/**
* 删除指定菜单项
* 由于有三种结果,建议用 try{}catch() 捕获
*
* @return bool||throw Exception
*/
function Del($id)
{
$count = self::where(["pid" => $id])->count();
if ($count > 0) {
throw new ValidateException('该节点下还有子节点,无法删除');
return false;
}
if (self::delete($id) !== false) {
clear_cache('adminRules');
add_log('delete', $id, []);
throw new ValidateException('删除节点成功');
} else {
throw new ValidateException('删除失败');
return false;
}
return true;
}
}

View File

@ -1,7 +1,7 @@
<?php
declare (strict_types = 1);
namespace app\admin\model\system\auth;
namespace aapp\common\model\merchant\system\auth;
use think\Model;

View File

@ -0,0 +1,25 @@
<?php
/**
* 店铺保证金model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
namespace app\common\model\merchant\system\merchant;
use think\Model;
class MerchantMargin extends Model
{
protected $connection = 'shop';
protected $table = '';
function GetList()
{
$list = self::select();
return $list;
}
}

View File

@ -0,0 +1,145 @@
<?php
/**
* 店铺类型管理 model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
namespace app\common\model\merchant\system\merchant;
use think\exception\ValidateException;
use think\Model;
use think\facade\Db;
/**
* @mixin \think\Model
*/
class MerchantType extends Model
{
protected $connection = 'shop';
protected $table = 'eb_merchant_type';
/**
* 查询店铺类型数据
*
* @param int $page 过滤字段条件
* @param int $limit 菜单类型: 0商城平台菜单 1商户菜单
*
* @return array|object
*/
function GetList(int $page, int $limit)
{
$rows = empty($limit) ? get_config('app . page_size') : $limit;
$data = self::field('mer_type_id as id,type_name,margin,is_margin,type_info,description,create_time,update_time')
->order('mer_type_id DESC')
->page($page)
->limit($limit)
->order('mer_type_id DESC')->paginate($rows, false,[
'query' => [], //url额外参数
// 'total' => '', //最大数量
// 'fragment' => '', //url锚点
// 'var_page' => 'page', //分页变量
]);
return $data;
}
/**
* 查询指定店铺类型数据
*
* @param int $page 过滤字段条件
* @param int $limit 菜单类型: 0商城平台菜单 1商户菜单
*
* @return array|object
*/
function Find(int $id)
{
if (empty($id)) {
throw new ValidateException('未传递参数');
return [];
}
$row = self::where('mer_type_id', $id)->field('mer_type_id as id,type_name,margin,type_info,description,is_margin,create_time,update_time')->find();
return $row;
}
/**
* 新增店铺类型数据
*
* @param int $page 过滤字段条件
* @param int $limit 菜单类型: 0商城平台菜单 1商户菜单
*
* @return array|object
*/
function Add(array $set_data) {
if (empty($set_data['type_name'])) {
return 0;
}
$batch['type_name'] = $set_data['type_name'];
$batch['description'] = empty($set_data['description'])?"":$set_data['description'];
$batch['is_margin'] = empty($set_data['is_margin']);
if (!empty($set_data['is_margin'])) {
$batch['margin'] = empty($set_data['margin'])?0:$set_data['margin'];
}
$batch['type_info'] = empty($set_data['type_info'])?'':$set_data['type_info'];
$batch['create_time'] = date('Y-m-d H:i:s',time());
$batch['update_time'] = date('Y-m-d H:i:s',time());
$rows = self::insert($batch);
return $rows;
}
/**
* 更新指定店铺类型数据
*
* @param int $page 过滤字段条件
* @param int $limit 菜单类型: 0商城平台菜单 1商户菜单
*
* @return array|object
*/
function Edit(int $id, array $set_data) {
if (empty($id) || empty($set_data['type_name'])) {
throw new ValidateException('未传递参数');
return 0;
}
$batch['type_name'] = $set_data['type_name'];
$batch['description'] = empty($set_data['description'])?"":$set_data['description'];
$batch['is_margin'] = empty($set_data['is_margin']);
if (!empty($set_data['is_margin'])) {
$batch['margin'] = empty($set_data['margin'])?0:$set_data['margin'];
}
$batch['type_info'] = empty($set_data['type_info'])?'':$set_data['type_info'];
$batch['update_time'] = date('Y-m-d H:i:s',time());
$rows = self::update($batch)->where('mer_type_id', $id)->limit(1);
return $rows;
}
/**
* 删除指定店铺类型数据
*
* @param int $page 过滤字段条件
* @param int $limit 菜单类型: 0商城平台菜单 1商户菜单
*
* @return array|object
*/
function Del(int $id) {
if (empty($id)) {
throw new ValidateException('未传递参数');
return 0;
}
$rows = self::where('mer_type_id', $id)->delete();
return $rows;
}
}