后端模块更新

前端模板路径设置
This commit is contained in:
2020-03-29 21:46:46 +08:00
parent 4893580b70
commit 05654b269c
12 changed files with 123 additions and 49 deletions

View File

@@ -25,7 +25,7 @@ class Channel extends Base {
/* 获取频道列表 */
$map[] = ['status', '>', -1];
if ($type) {
$map['type'] = $type;
$map[] = ['type', '=', $type];
}
$list = $channel->where($map)->order('sort asc,id asc')->select()->append(['status_text'])->toArray();
@@ -157,36 +157,38 @@ class Channel extends Base {
* @author huajie <banhuajie@163.com>
*/
public function sort() {
if ($this->request->isGet()) {
$ids = input('ids');
$pid = input('pid');
//获取排序的数据
$map = array('status' => array('gt', -1));
if (!empty($ids)) {
$map['id'] = array('in', $ids);
} else {
if ($pid !== '') {
$map['pid'] = $pid;
}
}
$list = db('Channel')->where($map)->field('id,title')->order('sort asc,id asc')->select();
$this->assign('list', $list);
$this->setMeta('导航排序');
return $this->fetch();
} elseif ($this->request->isPost()) {
$ids = input('post.ids');
if ($this->request->isPost()) {
$ids = $this->request->param('ids', '');
$ids = explode(',', $ids);
$data = [];
foreach ($ids as $key => $value) {
$res = db('Channel')->where(array('id' => $value))->setField('sort', $key + 1);
$data[] = ['id' => $value, 'sort' => $key];
}
if ($res !== false) {
return $this->success('排序成功!', url('admin/channel/index'));
$result = (new ChannelM())->saveAll($data);
if ($result !== false) {
return $this->success('排序成功!', url('/admin/channel/index'));
} else {
return $this->error('排序失败!');
}
} else {
return $this->error('非法请求!');
}else{
$ids = $this->request->param('ids', '');
$pid = $this->request->param('pid', '');
$map = [];
//获取排序的数据
$map[] = ['status', '>', -1];
if ($ids && strrpos($ids, ",")) {
$map[] = ['id', 'IN', explode(",", $ids)];
}else{
if ($pid) {
$map[] = ['pid', '=', $pid];
}
}
$list = ChannelM::where($map)->field('id,title')->order('sort asc,id asc')->select();
$this->data = [
'list' => $list
];
return $this->fetch();
}
}