修复bug

This commit is contained in:
15090180611 2024-12-31 14:10:47 +08:00
parent 8efdd69259
commit f9222e1b7f
12 changed files with 175 additions and 46 deletions

View File

@ -483,7 +483,7 @@ class Index extends Backend
//调用事件 //调用事件
$data = ['shop' => $shop]; $data = ['shop' => $this->shopModel];
\think\Hook::listen('shop_create_after', $data); \think\Hook::listen('shop_create_after', $data);
db()->commit(); db()->commit();

View File

@ -3,6 +3,8 @@
namespace app\admin\controller\school\help; namespace app\admin\controller\school\help;
use app\common\controller\Backend; use app\common\controller\Backend;
use think\exception\DbException;
use think\response\Json;
/** /**
* 帮助文章 * 帮助文章
@ -28,6 +30,9 @@ class Article extends Backend
$this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("statusList", $this->model->getStatusList());
$this->view->assign("hotList", $this->model->getHotList()); $this->view->assign("hotList", $this->model->getHotList());
$this->view->assign("cateList", $this->model->getCateList());
$this->view->assign("cateListJson", json_encode($this->model->getCateList(), JSON_UNESCAPED_UNICODE));
} }
@ -39,4 +44,41 @@ class Article extends Backend
*/ */
/**
* 查看
*
* @return string|Json
* @throws \think\Exception
* @throws DbException
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if (false === $this->request->isAjax()) {
return $this->view->fetch();
}
//如果发送的来源是 Selectpage则转发到 Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit, $page, $alias, $bind, $excludearray) = $this->buildparams(null, null, ["cate_title"]);
if (isset($excludearray['cate_title']['value']) && $excludearray['cate_title']['value']) {
$help_cate_ids = $excludearray['cate_title']['value'];
$help_cate_ids = implode("|",explode(',',$help_cate_ids));
$expireWhere = ["help_cate_ids REGEXP '({$help_cate_ids})'"];
} else {
$expireWhere = ["1=1"];
}
$list = $this->model
->where($where)
->whereRaw(...$expireWhere)
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
}
} }

View File

@ -33,15 +33,20 @@ class Cate extends Backend
$this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("statusList", $this->model->getStatusList());
Tree::instance()->init(collection($this->model->order('weigh DESC,id ASC')->select())->toArray())->icon = ['    ', '    ', '    ']; Tree::instance()->init(collection($this->model->order('weigh DESC,id ASC')->select())->toArray())->icon = array('    │', '    ', '    └');
$this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'name'); $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'name');
$ruledata = [0 => __('None')]; $ruledata = [0 => __('None')];
foreach ($this->rulelist as $k => &$v) { foreach ($this->rulelist as $k => &$v) {
// $v['name'] = str_replace(' ', ' ', $v['name']);
$ruledata[$v['id']] = $v['name']; $ruledata[$v['id']] = $v['name'];
} }
unset($v); unset($v);
$this->view->assign('ruledata', $ruledata); $this->view->assign('ruledata', $ruledata);
$this->view->assign("cateList", (new \app\admin\model\school\help\Article)->getCateList());
$this->view->assign("cateListJson", json_encode((new \app\admin\model\school\help\Article)->getCateList(), JSON_UNESCAPED_UNICODE));
} }
@ -60,6 +65,12 @@ class Cate extends Backend
public function index() public function index()
{ {
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
//如果发送的来源是 Selectpage则转发到 Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
$list = $this->rulelist; $list = $this->rulelist;
$total = count($this->rulelist); $total = count($this->rulelist);
$result = array("total" => $total, "rows" => $list); $result = array("total" => $total, "rows" => $list);

View File

@ -1,7 +1,7 @@
<?php <?php
return [ return [
'Help_cate_ids' => '平台帮助分类ids', 'Help_cate_ids' => '平台帮助分类',
'Title' => '标题', 'Title' => '标题',
'Content' => '文章详情', 'Content' => '文章详情',
'Status' => '状态', 'Status' => '状态',

View File

@ -1,7 +1,7 @@
<?php <?php
return [ return [
'Pid' => 'pid', 'Pid' => '上级分类',
'Name' => '帮助分类名', 'Name' => '帮助分类名',
'Status' => '状态', 'Status' => '状态',
'Status 1' => '上架', 'Status 1' => '上架',
@ -11,5 +11,17 @@ return [
'Weigh' => '权重', 'Weigh' => '权重',
'Createtime' => '创建时间', 'Createtime' => '创建时间',
'Updatetime' => '修改时间', 'Updatetime' => '修改时间',
'Deletetime' => '删除时间' 'Deletetime' => '删除时间',
'Help_cate_ids' => '平台帮助分类',
'Title' => '标题',
'Content' => '文章详情',
'Hot' => '平台热门',
'Hot 0' => '否',
'Hot 1' => '是',
'Start_time' => '更新时间',
'Toggle all' => '展开',
'Views' => '浏览量',
]; ];

View File

@ -27,9 +27,20 @@ class Article extends Model
protected $append = [ protected $append = [
'status_text', 'status_text',
'hot_text', 'hot_text',
'start_time_text' 'start_time_text',
'cate_title',
]; ];
public function getCateTitleAttr($value, $data)
{
$classes_cate_ids = (isset($data['help_cate_ids']) ? $data['help_cate_ids'] : '');
if(!$classes_cate_ids) return '';
//$classes_cate_ids 查询分类表 names 已逗号拼接返回
$classes_cate_title = Cate::where('id','in',$classes_cate_ids)->column('name');
return implode(',',$classes_cate_title);
}
protected static function init() protected static function init()
{ {
@ -80,5 +91,9 @@ class Article extends Model
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
} }
public function getCateList(){
return Cate::column("name", 'id');
}
} }

View File

@ -3,7 +3,7 @@
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Help_cate_ids')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Help_cate_ids')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input id="c-help_cate_ids" data-rule="required" data-source="school/help/cate/index" data-max-select-limit="3" data-multiple="true" data-params='{"custom[status]":"1"}' class="form-control selectpage" name="row[help_cate_ids]" type="text" value="{$q_help_cate_ids}"> <input id="c-help_cate_ids" data-rule="required" data-source="school/help/cate/index" data-max-select-limit="3" data-multiple="true" data-params='{"custom[status]":"1","isTree":1}' class="form-control selectpage" name="row[help_cate_ids]" type="text" value="{$q_help_cate_ids}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -54,12 +54,12 @@
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="0"> <input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="0">
</div> </div>
</div> </div>
<div class="form-group"> <!-- <div class="form-group">-->
<label class="control-label col-xs-12 col-sm-2">{:__('Views')}:</label> <!-- <label class="control-label col-xs-12 col-sm-2">{:__('Views')}:</label>-->
<div class="col-xs-12 col-sm-8"> <!-- <div class="col-xs-12 col-sm-8">-->
<input id="c-views" class="form-control" name="row[views]" type="number" value="0"> <!-- <input id="c-views" class="form-control" name="row[views]" type="number" value="0">-->
</div> <!-- </div>-->
</div> <!-- </div>-->
<div class="form-group layer-footer"> <div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label> <label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">

View File

@ -3,7 +3,7 @@
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Help_cate_ids')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Help_cate_ids')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input id="c-help_cate_ids" data-rule="required" data-source="school/help/cate/index" data-max-select-limit="3" data-multiple="true" data-params='{"custom[status]":"1"}' class="form-control selectpage" name="row[help_cate_ids]" type="text" value="{$row.help_cate_ids|htmlentities}"> <input id="c-help_cate_ids" data-rule="required" data-source="school/help/cate/index" data-max-select-limit="3" data-multiple="true" data-params='{"custom[status]":"1","isTree":1}' class="form-control selectpage" name="row[help_cate_ids]" type="text" value="{$row.help_cate_ids|htmlentities}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -54,12 +54,12 @@
<input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}"> <input id="c-weigh" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
</div> </div>
</div> </div>
<div class="form-group"> <!-- <div class="form-group">-->
<label class="control-label col-xs-12 col-sm-2">{:__('Views')}:</label> <!-- <label class="control-label col-xs-12 col-sm-2">{:__('Views')}:</label>-->
<div class="col-xs-12 col-sm-8"> <!-- <div class="col-xs-12 col-sm-8">-->
<input id="c-views" class="form-control" name="row[views]" type="number" value="{$row.views|htmlentities}"> <!-- <input id="c-views" class="form-control" name="row[views]" type="number" value="{$row.views|htmlentities}">-->
</div> <!-- </div>-->
</div> <!-- </div>-->
<div class="form-group layer-footer"> <div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label> <label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">

View File

@ -92,4 +92,6 @@
</div> </div>
</div> </div>
<script>
var cateListJson ={$cateListJson};
</script>

View File

@ -764,11 +764,12 @@ class Backend extends Controller
} }
if ($istree && !$primaryvalue) { if ($istree && !$primaryvalue) {
$tree = Tree::instance(); $tree = Tree::instance();
$tree->init(collection($list)->toArray(), 'pid'); $tree->init(collection($list)->toArray(), 'pid')->icon = array('&nbsp;&nbsp;&nbsp;&nbsp;│', '&nbsp;&nbsp;&nbsp;&nbsp;├', '&nbsp;&nbsp;&nbsp;&nbsp;└');
$list = $tree->getTreeList($tree->getTreeArray(0), $field); $list = $tree->getTreeList($tree->getTreeArray(0), $field);
if (!$ishtml) { if (!$ishtml) {
foreach ($list as &$item) { foreach ($list as &$item) {
$item = str_replace('&nbsp;', ' ', $item); // $item = str_replace('&nbsp;', ' ', $item);
} }
unset($item); unset($item);
} }

View File

@ -15,7 +15,8 @@ class ShopHook
["shop"=>$shop] = $params; ["shop"=>$shop] = $params;
//机构初始化数据
ManystoreShop::initData($shop->id);
} }
@ -76,8 +77,6 @@ class ShopHook
ManystoreShop::initData($shop->id); ManystoreShop::initData($shop->id);
} }

View File

@ -43,18 +43,38 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
// 过滤偶数然后将其乘以10最后求和 // 过滤偶数然后将其乘以10最后求和
let sumOfDoubledEvens = numbers.map(item => item.id).join(","); // 求和 let sumOfDoubledEvens = numbers.map(item => item.id).join(","); // 求和
$("#myTabContent2 .form-commonsearch input[name='help_cate_ids']").val(sumOfDoubledEvens); $("#myTabContent2 .form-commonsearch input[name='cate_title']").val(sumOfDoubledEvens);
$("#myTabContent2 .btn-refresh").trigger("click"); $("#myTabContent2 .btn-refresh").trigger("click");
}); });
$("#table1").on("change", "input:checkbox[name='btSelectAll']", function (e) {
// var ids = $(this).data("index"); //数据id
// var checked = $(this).prop('checked'); //选中状态
// Layer.alert(JSON.stringify(Table.api.selecteddata(table)));
let numbers = Table.api.selecteddata(table);
// 过滤偶数然后将其乘以10最后求和
let sumOfDoubledEvens = numbers.map(item => item.id).join(","); // 求和
$("#myTabContent2 .form-commonsearch input[name='cate_title']").val(sumOfDoubledEvens);
$("#myTabContent2 .btn-refresh").trigger("click");
});
}, },
columns: [ columns: [
[ [
{checkbox: true}, {checkbox: true},
{field: 'id', title: __('Id')}, {field: 'id', title: __('Id')},
{field: 'pid', title: __('Pid'),visible:false}, {field: 'pid', title: __('Pid'),visible:false},
{field: 'name', title: __('Name') , align: 'left', formatter: Controller.api.formatter.name, clickToSelect: !false}, {field: 'name', title: __('Name') ,width:180, align: 'left', formatter: Controller.api.formatter.name, clickToSelect: !false},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.toggle}, {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.toggle},
{field: 'weigh', title: __('Weigh'), operate: false}, {field: 'weigh', title: __('Weigh'), operate: false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
@ -83,17 +103,32 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
// return row.status == '2'||row.status == '3'; // return row.status == '2'||row.status == '3';
// } // }
}, },
// {
// name: 'article',
// title: '文章列表',
// text: '文章列表',
// icon: 'fa fa-list',
// classname: 'btn btn-primary btn-xs btn-click',
// click: function (e, data) {
// $("#myTabContent2 .form-commonsearch input[name='help_cate_ids']").val(data.id);
// $("#myTabContent2 .btn-refresh").trigger("click");
// }
// },
{ {
name: 'article', name: 'article',
title: '文章列表', text: __('添加文章'),
text: '文章列表', title: __('添加文章'),
icon: 'fa fa-list', classname: 'btn btn-danger btn-xs btn-dialog',
classname: 'btn btn-primary btn-xs btn-click', icon: 'fa fa-files-o',
click: function (e, data) { // dropdown : '更多',
$("#myTabContent2 .form-commonsearch input[name='help_cate_ids']").val(data.id); url: article_url,
$("#myTabContent2 .btn-refresh").trigger("click"); callback: function (data) {
}
} },
// visible: function (row) {
// return row.status == '2'||row.status == '3';
// }
},
], events: Table.api.events.operate, formatter: Table.api.formatter.operate}, ], events: Table.api.events.operate, formatter: Table.api.formatter.operate},
@ -200,10 +235,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
}); });
// 获取选中项 // // 获取选中项
$(document).on("click", "#table1 .btn-selected", function () { // $(document).on("click", "#table1 .btn-selected", function () {
Layer.alert(JSON.stringify(Table.api.selecteddata(table))); // Layer.alert(JSON.stringify(Table.api.selecteddata(table)));
}); // });
}, },
second: function () { second: function () {
@ -230,8 +265,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
[ [
{checkbox: true}, {checkbox: true},
{field: 'id', title: __('Id')}, {field: 'id', title: __('Id')},
{field: 'help_cate_ids', title: __('Help_cate_ids'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, // {field: 'help_cate_ids', title: __('Help_cate_ids'), operate: 'LIKE', table: table, class: 'autocontent', searchList: cateListJson, formatter: Table.api.formatter.flag},
{field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'cate_title', title: __('Help_cate_ids'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'title', title: __('Title'), operate: '=', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status}, {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
{field: 'hot', title: __('Hot'), searchList: {"0":__('Hot 0'),"1":__('Hot 1')}, formatter: Table.api.formatter.normal}, {field: 'hot', title: __('Hot'), searchList: {"0":__('Hot 0'),"1":__('Hot 1')}, formatter: Table.api.formatter.normal},
{field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
@ -317,9 +354,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
api: { api: {
formatter: { formatter: {
name: function (value, row, index) { name: function (value, row, index) {
value = value.toString().replace(/(&|&amp;)nbsp;/g, '&nbsp;'); // value = value.toString().replace(/(&|&amp;)nbsp;/g, ' ');
value = htmlDecode(value);
var caret = row.haschild == 1 || row.ismenu == 1 ? '<i class="fa fa-caret-right"></i>' : ''; var caret = row.haschild == 1 || row.ismenu == 1 ? '<i class="fa fa-caret-right"></i>' : '';
value = value.indexOf("&nbsp;") > -1 ? value.replace(/(.*)&nbsp;/, "$1" + caret) : caret + value; value = caret + value;
value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value; value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="' return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
@ -336,10 +374,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
} }
}; };
function htmlDecode(input) {
var doc = new DOMParser().parseFromString(input, 'text/html');
return doc.documentElement.textContent;
}
var add_url = function (row,dom) { var add_url = function (row,dom) {
return 'school/help/cate/add?pid='+row.id; return 'school/help/cate/add?pid='+row.id;
} }
var article_url = function (row,dom) {
console.log(row);
return 'school/help/article/add?help_cate_ids='+row.id;
}
return Controller; return Controller;
}); });