新增目录菜单的删除功能,下级有目录时间无法删除

This commit is contained in:
WangHao
2020-08-29 17:26:41 +08:00
parent 395c945b77
commit 208ae4692c
8 changed files with 97 additions and 12 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
@ -123,8 +124,31 @@ public class SqMenuController extends BaseController
@PreAuthorize("@ss.hasPermi('bookmark:menu:remove')")
@Log(title = "书签菜单", businessType = BusinessType.DELETE)
@DeleteMapping("/{menuIds}")
public AjaxResult remove(@PathVariable Long[] menuIds)
public AjaxResult removes(@PathVariable Long[] menuIds)
{
return toAjax(sqMenuService.deleteSqMenuByIds(menuIds));
}
/**
* 删除书签菜单
*/
@Log(title = "书签菜单", businessType = BusinessType.DELETE)
@DeleteMapping("/delete/{menuId}")
public AjaxResult remove(@PathVariable Long menuId)
{
SysUser sysUser=getAuthUser();
//查询目录下是否还有目录
SqMenu sqMenu=new SqMenu();
sqMenu.setParentId(menuId);
List<SqMenu> sqMenuList=sqMenuService.selectSqMenuList(sqMenu);
if (sqMenuList==null||sqMenuList.isEmpty()){
return toAjax(sqMenuService.deleteSqMenuById(menuId,sysUser.getUserId()));
}else{
return AjaxResult.error("删除失败,该目录下级还有目录菜单");
}
}
}

View File

@ -49,7 +49,7 @@ export function updateMenu(data) {
// 删除书签菜单
export function delMenu(menuId) {
return request({
url: '/bookmark/menu/' + menuId,
url: '/bookmark/menu/delete/' + menuId,
method: 'delete'
})
}

View File

@ -69,7 +69,7 @@
<hr class="bookamrk-hr"/>
<el-col :span="24" v-for="bm in bookmarkList">
<div class="bookmark">
<div class="bookmark" :data-id="bm.id" @click="windowurl(bm.url,bm.bookmarkId)">
<p class="bookmark-title">{{bm.title}}</p>
<div class="">
<p class="description">{{bm.description}}</p>
@ -138,6 +138,7 @@
start: undefined,
},
bookmarkList:[],
urltext:'?from=yunshuqian.com',//网址域名起推广作用
}
},
filters: {
@ -175,11 +176,32 @@
}
});
},
windowurl(url,bookmarkId){
// window.open(url+this.urltext);
window.open(url);
//如果是回收站打开的 就修改状态
// if (this.$route.params.menuId=6666){
// this.$axios.get(`/api/bookmark/updateBookmarkStart?bookmarkId=${bookmarkId}`).then(response => {
//
// if (response.status == 200 && response.data.status == 'success') {
// this.momentlList()
// this.$message({type: 'success', message: '此书签被打开,移除稍后再看,并且公开显示!'})
//
// }else {
// this.$message({type: 'error', message: '移除失败!'})
// }
//
// });
// }
},
},
}
</script>

View File

@ -3,7 +3,7 @@
<el-container>
<transition name="el-zoom-in-left">
<el-aside width="300px" style="height:900px" v-show="isShowZtree" class="transition-box">
<el-aside width="300px" style="height:900px;box-shadow: inset -1px 0 0 rgba(0,0,0,.1);" v-show="isShowZtree" class="transition-box">
<el-header class="aside-logo">
@ -137,6 +137,10 @@
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="danger" round @click="deleteMmenu(form.menuId)">删除</el-button>
<el-button type="primary" round @click="submitForm">确定</el-button>
<el-button round @click="cancel">取消</el-button>
@ -273,7 +277,7 @@
getTreeselect() {
listMenuByUserId().then(response => {
this.menuOptions = [];
const data = { menuId: 0, menuName: '顶级节点', children: [] };
const data = { menuId: 0, menuName: '顶级菜单', children: [] };
data.children = this.handleTree(response.data, "menuId", "parentId");
this.menuOptions.push(data);
});
@ -298,6 +302,12 @@
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.menuId != undefined) {
if (this.form.menuId==this.form.parentId){
this.msgError("不能讲上级菜单设置为本身");
return;
}
updateMenu(this.form).then(response => {
if (response.code === 200) {
this.msgSuccess("修改成功");
@ -465,6 +475,33 @@
return false;
},
//删除书签目录
deleteMmenu(menuId){
this.$confirm('是否删除此目录菜单?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delMenu(menuId).then(response => {
// if(){}
this.$message({
type: 'success',
message: '删除成功!'
});
this.open = false;
this.getList();
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
}
},
mounted(){
window['editBookmark'] = (e) => {
@ -479,6 +516,8 @@
}
</script>
<style >
@ -569,7 +608,7 @@
margin-right: 11px;
}
.aside-logo{
background-color: #fff;
/*background-color: #fff;*/
opacity: 0.9;
}
.aside-logo img{

View File

@ -61,7 +61,7 @@ public interface SqMenuMapper extends MyMapper<SqMenu>
* @param menuId 书签菜单ID
* @return 结果
*/
public int deleteSqMenuById(Long menuId);
public int deleteSqMenuById(@Param("menuId")Long menuId,@Param("userId")Long userId);
/**
* 批量删除书签菜单

View File

@ -65,5 +65,5 @@ public interface ISqMenuService
* @param menuId 书签菜单ID
* @return 结果
*/
public int deleteSqMenuById(Long menuId);
public int deleteSqMenuById(Long menuId,Long userId);
}

View File

@ -101,8 +101,8 @@ public class SqMenuServiceImpl implements ISqMenuService
* @return 结果
*/
@Override
public int deleteSqMenuById(Long menuId)
public int deleteSqMenuById(Long menuId,Long userId)
{
return sqMenuMapper.deleteSqMenuById(menuId);
return sqMenuMapper.deleteSqMenuById(menuId,userId);
}
}

View File

@ -73,8 +73,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where menu_id = #{menuId}
</update>
<delete id="deleteSqMenuById" parameterType="Long">
delete from sq_menu where menu_id = #{menuId}
<delete id="deleteSqMenuById" parameterType="SqMenu">
delete from sq_menu where menu_id = #{menuId} and user_id = #{userId}
</delete>
<delete id="deleteSqMenuByIds" parameterType="String">