:合并分支:店铺类型代码逻辑调整优化
This commit is contained in:
commit
5ca21a7e11
@ -42,7 +42,7 @@ class Menu extends BaseController
|
||||
*/
|
||||
function Lst(){
|
||||
// 查出商户所有菜单数据
|
||||
$data = $this->menu->Search([], 1);
|
||||
$data = $this->menu->getList([], 1);
|
||||
|
||||
to_assign(0,'',$data['list']);
|
||||
}
|
||||
@ -62,9 +62,9 @@ class Menu extends BaseController
|
||||
View::assign('detail', $detail);
|
||||
}
|
||||
// 查出商户所有菜单数据
|
||||
$data = $this->menu->Search([], 1);
|
||||
$data = $this->menu->getList([], 1);
|
||||
$menus = $format->DropDownMenu($data['list']);
|
||||
|
||||
|
||||
View::assign('id', $id);
|
||||
View::assign('pid', $pid);
|
||||
View::assign('menus',$menus);
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace app\admin\controller\merchant\system\merchant;
|
||||
|
||||
use app\admin\BaseController;
|
||||
use app\admin\controller\merchant\system\auth\Menu;
|
||||
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;
|
||||
@ -81,8 +82,12 @@ class MerchantType extends BaseController
|
||||
|
||||
// 给菜单权限附加选中状态
|
||||
foreach($data['list'] as $k=>$item) {
|
||||
if (in_array($item['id'], $checked_list['list'][0]['auth_ids'])) {
|
||||
$data['list'][$k]['checked'] = true;
|
||||
foreach ($checked_list['list'] as $auth) {
|
||||
if (in_array($item['id'], $auth['auth_ids'])) {
|
||||
if ($item['pid']>0 && $item['title']!='权限')
|
||||
$data['list'][$k]['checked'] = true;
|
||||
$data['list'][$k]['spread'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,9 +151,30 @@ class MerchantType extends BaseController
|
||||
$param = get_params();
|
||||
$id = isset($param['id']) ? (int)$param['id'] : 0;
|
||||
|
||||
$detail = $this->merchant->Find($id);
|
||||
$detail = $this->merchant->getDetail($id);
|
||||
|
||||
if (!empty($detail)) {
|
||||
// 查出商户所有菜单数据权限 tree
|
||||
$menu = app()->make(MenuModel::class);
|
||||
$data = $menu->getList([],1);
|
||||
|
||||
// 获取已有权限
|
||||
$checked_list = $this->merchant->getList(['mer_type_id'=>$id]);
|
||||
|
||||
// 给菜单权限附加选中状态
|
||||
$list = [];
|
||||
foreach($data['list'] as $k=>$item) {
|
||||
foreach ($checked_list['list'] as $auth) {
|
||||
if (in_array($item['id'], $auth['auth_ids'])) {
|
||||
if ($item['pid']>0 && $item['title']!='权限')
|
||||
$data['list'][$k]['checked'] = true;
|
||||
$data['list'][$k]['spread'] = true;
|
||||
array_push($list, $data['list'][$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$format = app()->make(FormatList::class);
|
||||
View::assign('dataTree', $format->FormatCategory($list));
|
||||
View::assign('detail', $detail);
|
||||
return view($this->path['read']);
|
||||
} else {
|
||||
|
@ -11,7 +11,7 @@
|
||||
<td>
|
||||
<select name="pid" lay-verify="required" lay-reqText="请选择父级菜单/节点">
|
||||
<option value="0">作为顶级菜单/节点</option>
|
||||
{volist name="$menus" id="v"}
|
||||
{volist name="menus" id="v"}
|
||||
<option value="{$v.id}" {eq name="pid" value="$v.id" }selected="" {/eq}>{$v.title} </option>
|
||||
{/volist}
|
||||
</select>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<div class="layui-btn-group">
|
||||
<input id="chonse_start_date" type="hidden" name="start_date" value="" readonly placeholder="选择时间">
|
||||
<input id="chonse_end_date" type="hidden" name="end_date" value="" readonly placeholder="选择时间">
|
||||
<button name="both" lay-submit="" lay-filter="chonse_date" type="button" class="layui-btn layui-btn-normal">全部</button>
|
||||
<button id="both" name="both" lay-submit="" lay-filter="chonse_date" type="button" class="layui-btn layui-btn-normal">全部</button>
|
||||
<button name="today" lay-submit="" lay-filter="chonse_date" type="button" class="layui-btn layui-btn-normal layui-btn-primary">今天</button>
|
||||
<button name="yeserday" lay-submit="" lay-filter="chonse_date" type="button" class="layui-btn layui-btn-normal layui-btn-primary">昨天</button>
|
||||
<button name="week" lay-submit="" lay-filter="chonse_date" type="button" class="layui-btn layui-btn-normal layui-btn-primary">最近7天</button>
|
||||
@ -288,7 +288,9 @@
|
||||
, range: ['#start-date', '#end-date']
|
||||
,done: function(value, date, endDate){
|
||||
switchDateForm(true);
|
||||
|
||||
|
||||
$('#both').removeClass('layui-btn-primary')
|
||||
$('#both').siblings().addClass('layui-btn-primary')
|
||||
active['reload'] ? active['reload'].call(this) : '';
|
||||
}
|
||||
});
|
||||
|
@ -20,14 +20,14 @@
|
||||
<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="{$detail.type_name}">
|
||||
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="">
|
||||
</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>
|
||||
<textarea class="layui-textarea" name="type_info"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -38,15 +38,15 @@
|
||||
<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}">
|
||||
<input type="radio" name="is_margin" value="1" title="有" checked="">
|
||||
<input type="radio" name="is_margin" value="0" title="无" checked="">
|
||||
</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}">
|
||||
<input type="text" name="margin" lay-verify="required" lay-reqText="0" autocomplete="off" placeholder="0" class="layui-input" value="">
|
||||
</td>
|
||||
<td colspan="5">单位:元</td>
|
||||
</tr>
|
||||
@ -64,7 +64,7 @@
|
||||
<tr>
|
||||
<td colspan="2" class="layui-td-gray">其它说明</td>
|
||||
<td colspan="6">
|
||||
<textarea class="layui-textarea" name="description">{$detail.description}</textarea>
|
||||
<textarea class="layui-textarea" name="description"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -116,7 +116,6 @@
|
||||
|
||||
//监听提交
|
||||
form.on('submit(webform)', function (data) {
|
||||
console.log(data.field);
|
||||
// data.field.content = tinyMCE.editors['container_content'].getContent();
|
||||
if (data.field == '') {
|
||||
layer.msg('请先完善店铺类型');
|
||||
@ -132,10 +131,18 @@
|
||||
|
||||
//获得选中的节点
|
||||
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);
|
||||
var list = getChecked_list(checkData);
|
||||
|
||||
var params = new Object();
|
||||
params.id = data.field.id
|
||||
params.type_name = data.field.type_name
|
||||
params.type_info = data.field.type_info
|
||||
params.is_margin = data.field.is_margin
|
||||
params.margin = data.field.margin
|
||||
params.description = data.field.description
|
||||
params.auth = list
|
||||
|
||||
tool.post('/admin/merchant/type/add', params, callback);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
@ -56,7 +56,7 @@
|
||||
<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>
|
||||
<div id="test7" class="demo-tree-more"></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -103,8 +103,6 @@
|
||||
var tree = layui.tree
|
||||
,layer = layui.layer
|
||||
,util = layui.util
|
||||
,spread = true
|
||||
//模拟数据
|
||||
,data = getData();
|
||||
|
||||
//开启复选框
|
||||
@ -112,12 +110,15 @@
|
||||
elem: '#test7'
|
||||
,data: data
|
||||
,showCheckbox: true
|
||||
,id:'id',//菜单id
|
||||
,id:'id'//菜单id
|
||||
// ,click: function(obj){
|
||||
// var data = obj.data; //获取当前点击的节点数据
|
||||
// }
|
||||
});
|
||||
|
||||
|
||||
//监听提交
|
||||
form.on('submit(webform)', function (data) {
|
||||
console.log(data.field);
|
||||
// data.field.content = tinyMCE.editors['container_content'].getContent();
|
||||
if (data.field == '') {
|
||||
layer.msg('请先完善店铺类型');
|
||||
@ -133,12 +134,20 @@
|
||||
|
||||
//获得选中的节点
|
||||
var checkData = tree.getChecked('id');
|
||||
var list = new Array();
|
||||
list = getChecked_list(checkData);
|
||||
data.field.auth = list
|
||||
tool.put('/admin/merchant/type/edit', data.field, callback);
|
||||
var list = getChecked_list(checkData);
|
||||
|
||||
return true;
|
||||
var params = new Object();
|
||||
params.id = data.field.id
|
||||
params.type_name = data.field.type_name
|
||||
params.type_info = data.field.type_info
|
||||
params.is_margin = data.field.is_margin
|
||||
params.margin = data.field.margin
|
||||
params.description = data.field.description
|
||||
params.auth = list
|
||||
|
||||
tool.put('/admin/merchant/type/edit', params, callback);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// 获取选中节点的id
|
||||
@ -191,7 +200,7 @@
|
||||
}
|
||||
|
||||
//所有保存到数据节点的变量都成为`dataBox`对象的属性
|
||||
console.log(dataBox.admin);
|
||||
// console.log(dataBox.admin)
|
||||
return dataBox.admin;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,6 @@
|
||||
|
||||
//监听表格行工具事件
|
||||
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);
|
||||
|
@ -32,15 +32,15 @@
|
||||
<tr>
|
||||
<td class="layui-td-gray">店铺权限</td>
|
||||
<td colspan="3">
|
||||
|
||||
|
||||
<div class="data-box" data-admin='{:json_encode($dataTree)}'></div>
|
||||
<div id="test7" class="demo-tree-more"></div>
|
||||
</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>
|
||||
<textarea class="layui-textarea" name="store_info" readonly>{$detail.type_info}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -60,4 +60,68 @@
|
||||
</table>
|
||||
</div>
|
||||
{/block}
|
||||
<!-- /主体 -->
|
||||
<!-- /主体 -->
|
||||
{block name="script"}
|
||||
|
||||
<script>
|
||||
var moduleInit = ['tool','treeGrid', 'tagpicker', 'tinymce', 'admin'];
|
||||
var group_access = "{:session('gougu_admin')['group_access']}"
|
||||
|
||||
function gouguInit() {
|
||||
|
||||
// 店铺权限
|
||||
layui.use(['tree', 'util'], function(){
|
||||
var tree = layui.tree
|
||||
,layer = layui.layer
|
||||
,util = layui.util
|
||||
,data = getData();
|
||||
|
||||
//开启复选框
|
||||
tree.render({
|
||||
elem: '#test7'
|
||||
,data: data
|
||||
,showLine:false
|
||||
,id:'id'//菜单id
|
||||
// ,click: function(obj){
|
||||
// var data = obj.data; //获取当前点击的节点数据
|
||||
// }
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//获取店铺权限的数据[数据来自模板变量]
|
||||
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) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
//所有保存到数据节点的变量都成为`dataBox`对象的属性
|
||||
// console.log(dataBox.admin)
|
||||
return dataBox.admin;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
{/block}
|
@ -64,8 +64,8 @@ class FormatList
|
||||
$level++;
|
||||
foreach ($data as $k => $v) {
|
||||
if ($v['pid'] == $pid) {
|
||||
$v['title'] = '';
|
||||
if ($pid != 0) {
|
||||
$v['title'] = isset($v['title'])?$v['title']:'';
|
||||
$v['title'] = $space[$level] . $v['title'];
|
||||
}
|
||||
/*将该类别的数据放入list中*/
|
||||
|
@ -364,7 +364,9 @@ class Relevance extends Model
|
||||
*/
|
||||
public function batchInsert(array $data)
|
||||
{
|
||||
return Relevance::insertAll($data);
|
||||
$rows = Relevance::insertAll($data);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,13 +98,13 @@ class MerchantType extends Model
|
||||
*
|
||||
* @return array|object
|
||||
*/
|
||||
function Find(int $id)
|
||||
function getDetail(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();
|
||||
$row = self::search(['mer_type_id'=>$id])->find();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user