Skip to content

Commit

Permalink
不同的栏目模型可以混合穿插
Browse files Browse the repository at this point in the history
  • Loading branch information
arterli committed Jun 6, 2018
1 parent 341451d commit e53b9a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "CMSWing",
"description": "基于ThinkJS(Node.js MVC)和MySQL的功能强大的电子商务平台及CMS建站系统",
"version": "1.3.1",
"version": "1.3.2",
"scripts": {
"start": "node development.js",
"lint": "eslint src/",
Expand Down
23 changes: 13 additions & 10 deletions src/controller/admin/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ module.exports = class extends think.cmswing.admin {
}
async gettreeAction() {
// 添加,编辑,移动合并
let mold = 0;
if (!think.isEmpty(this.get('mold'))) {
mold = this.get('mold');
let mold = {};
if (this.get('mold') === 'all') {
mold = {mold: ['<', 3]};
} else if (!think.isEmpty(this.get('mold'))) {
mold = {mold: this.get('mold')};
} else {
const cid = this.get('from') || this.get('cid') || 0;
const res = await this.model('category').field('mold').find(cid);
if (!think.isEmpty(res)) { mold = res.mold }
// const cid = this.get('from') || this.get('cid') || 0;
// const res = await this.model('category').field('mold').find(cid);
// if (!think.isEmpty(res)) { mold = { mold: res.mold } }
mold = {mold: ['<', 3]};
}
const tree = await this.db.gettree(0, 'id,name,title,sort,pid,allow_publish,status', {mold: mold});
const tree = await this.db.gettree(0, 'id,name,title,sort,pid,allow_publish,status', mold);
return this.json(tree);
}

Expand Down Expand Up @@ -433,7 +436,7 @@ module.exports = class extends think.cmswing.admin {
if (data.merge == 1) { // 如果合并删除源栏目
await this.model('category').delete({where: {id: data.source}});
}
await update_cache('category');// 更新栏目缓存
await update_cache('category');// 更新栏目缓存
return this.success({name: '成功!', url: '/admin/category/index'});
}
} else {
Expand Down Expand Up @@ -489,7 +492,7 @@ module.exports = class extends think.cmswing.admin {
if (data.merge == 1) { // 如果合并删除源栏目
await this.model('category').delete({where: {id: data.source_id}});
}
await update_cache('category');// 更新栏目缓存
await update_cache('category');// 更新栏目缓存
return this.success({name: '成功!', url: '/admin/category/index'});
} else {
const data = this.get();
Expand Down Expand Up @@ -521,7 +524,7 @@ module.exports = class extends think.cmswing.admin {
async isappAction() {
const up = await this.model('category').where({id: this.get('ids')}).update({isapp: this.get('isapp')});
if (up) {
await update_cache('category');// 更新栏目缓存
await update_cache('category');// 更新栏目缓存
return this.success({name: '操作成功!'});
} else {
return this.fail('操作失败!');
Expand Down
3 changes: 2 additions & 1 deletion view/admin/channel_add.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@

//获取上级菜单
$.ajax({
url: "/admin/channel/getchannel",
url: "/admin/category/gettree",
data:{mold:'all'},
success: function (msg) {
/* 展示生成的HTML */
$("#pid").html(category_to_html(msg));
Expand Down

0 comments on commit e53b9a4

Please sign in to comment.