This commit is contained in:
zhutianqi
2021-07-04 18:05:26 +08:00
parent 91aa3554e5
commit bb0f02f730
3 changed files with 217 additions and 402 deletions
@@ -3,26 +3,17 @@
<div id="domesticStandardDatabase" :class="{ 'tree-close': sideClose }" class="demo-spin-article v-class">
<div class="tree-content" :class="{ 'tree-closed': sideClose }">
<div class="tree">
<laws-tree :zNodes="zNodes"
ref="domesticTree"
treeDivId="domesticTree"
showRMenu
deptSelect
autoSelect
add-id="Q8SLTYESAL"
edit-id="94V5KRZUJF"
remove-id="5F7U4B2Q24"
:drag="hasPermissionDrag"
drag-bind=".drag-table"
drag-dom="drag-row"
:hideRMenuNode="['gxhbq', 'wdsc']"
@treeAdd="(treeId, treeNode) => clickDropMenu('newMenu', treeNode)"
@treeEdit="(treeId, treeNode) => clickDropMenu('editMenu', treeNode)"
@treeClick="(treeId, treeNode) => treeClick(treeNode)"
@treeRightClick="(treeId, treeNode) => treeRightClick(treeNode)"
@treeRemove="(treeId, treeNode) => clickDropMenu('deleteMenu', treeNode)"
@drag="drag"
></laws-tree>
<el-tree
ref="tree"
node-key="id"
class="filter-tree"
:props="props"
:data="treeList"
highlight-current
@node-click="treeClick"
default-expand-all
:expand-on-click-node="false">
</el-tree>
</div>
<div class="tree-collapse" @click="treeCollapse" :class="{ 'tree-close': sideClose }">
<!--切换折叠样式-->
@@ -961,6 +952,11 @@ export default {
},
data () {
return {
props: {
label: 'menuName',
children: 'children'
},
treeList: [],
visibleOrgTable: false,
orgTableVal: '',
orgTableValName: '',
@@ -1693,104 +1689,12 @@ export default {
})
}
},
// 二级菜单新建,编辑,删除
clickDropMenu (name, treeNode) {
this.selectSarMenu = JSON.parse(JSON.stringify(treeNode))
if (undefined !== this.selectSarMenu.id) { // 当前有选中节点
if (name === 'newMenu') {
this.menuModalTitle = '新增目录'
this.menuModalFlag = true
this.menuAddOrUpdateFlag = 1
this.sarMenu = {
id: '',
parentId: '',
menuName: '',
sorDivide: 'INLAND_STAND',
displaySeq: '',
parentIds: '',
remarks: ''
}
} else if (name === 'editMenu') {
this.menuModalTitle = '编辑目录'
this.menuModalFlag = true
this.menuAddOrUpdateFlag = 2
this.sarMenu.id = treeNode.id
this.sarMenu.parentId = treeNode.pId
this.sarMenu.menuName = treeNode.oldname || treeNode.name
this.sarMenu.displaySeq = treeNode.displaySeq
if (treeNode.remarks == null || treeNode.remarks === '' || treeNode.remarks === 'null') {
this.sarMenu.remarks = ''
} else {
this.sarMenu.remarks = treeNode.remarks
}
} else {
if (this.selectSarMenu.parentId == null) { // 如果父id为null 说明是根目录
this.$message({
title: '提示',
content: '根目录不可删除!'
})
} else {
// deleteMenu 删除二级菜单,先判断是否选中,选中项目,然后调用删除方法
// 先判断目录下是否有菜单
this.$http.post('lawss/sarMenu/judgequeryMenuByPid', this.selectSarMenu, {
_this: this, loading: 'loading'
}, res => {
if (res.data) {
// this.deleteMenuModal = true
this.$confirm('该节点下有记录,确定删除?', '提示', {
confirmButtonText: '确定',
confirmButtonClass: 'common-button-primary',
cancelButtonText: '取消',
type: 'warning',
roundButton: false
}).then(() => {
this.$http.post('lawss/sarMenu/deleteMenuAndChildren', this.selectSarMenu, {
_this: this, loading: 'loading'
}, res => {
this.selectMenu() // 删除成功后,更新二级菜单
// 获取下一个节点
let currentNode = this.$refs.domesticTree.getNextNode()
let nodeId = ''
// 如果这个节点为null, 本次删除了最后一个节点
if (currentNode === null) {
// 选中根节点
this.$refs.domesticTree.selectRootNode()
} else {
nodeId = currentNode.id
}
this.getDomesticStandardTable(nodeId)
}, e => {
})
}).catch(() => {
// 取消删除,清空选择
// this.$refs.selections.clearSelection()
})
} else {
this.sureDeleteSarMenu()
}
}, e => {
})
}
}
} else {
this.$Modal.info({
title: '提示',
content: '请选择节点!'
})
}
},
treeClick (treeNode) {
this.selectSarMenu = treeNode // 记录当前选中的二级菜单
this.standCommonlySearch.menuId = treeNode.id
this.sarStandardsSearch.menuId = treeNode.id // 将当前二级菜单的id传回后台做标准的条件查询
this.sarStandardsSearch.page = 1
this.standCommonlySearch.page = 1
this.getDomesticStandardTable(this.tableFlag) // 根据选中的二级菜单查询对应的标准列表
},
treeRightClick (treeNode) {
this.selectSarMenu = treeNode // 记录当前选中的二级菜单
this.standCommonlySearch.menuId = treeNode.id
this.sarStandardsSearch.menuId = treeNode.id
this.getDomesticStandardTable(this.tableFlag)
},
// 点击搜索按钮
searchBtnClick (standCommonlySearch) {
@@ -1906,43 +1810,12 @@ export default {
},
// 查询二级菜单
selectMenu () {
return new Promise((resolve, reject) => {
this.$http.get('lawss/sarMenu/selectMenuByRole', {sorDivide: 'INLAND_STAND'}, {
_this: this
}, res => {
let treeNode = []
this.parentNode = {}
if (res.data == null) {
res.data = []
}
res.data.map((item, index) => {
let treeItem = {}
for (let key in item) {
if (key === 'parentId') {
treeItem.pId = item[key]
treeItem.parentId = item[key]
} else if (key === 'menuName') {
treeItem.name = item[key]
} else {
treeItem[key] = item[key]
}
if (this.initZNode === '' && item.id === '64df1d5522bb49c09af2') { this.initZNode = treeItem }
}
treeNode[index] = treeItem
// 记录最外层父节点
if (treeItem.parentId === '' || treeItem.parentId == null) {
this.parentNode = treeItem
}
})
this.zNodes = treeNode
// 查完左侧目录后,如果没有选中的,设置最外层选中
if (JSON.stringify(this.selectSarMenu) === '{}' || !this.selectSarMenu) {
this.selectSarMenu = JSON.parse(JSON.stringify(this.parentNode))
}
resolve(res)
}, e => {
reject(e)
})
this.$http.get('sarResource/ts-resource', {
sorDivide: 'INLAND_STAND'
}, {}, res => {
if (res.ok) {
this.treeList = res.data
}
})
},
// 树-删除
@@ -2446,7 +2319,12 @@ export default {
}
// this.sarStandardsSearch.menuId = this.selectSarMenu.id
const formData = {...data}
formData.menuId = this.selectSarMenu.id
if (!item) {
formData.menuId = this.sarStandardsSearch.menuId
} else {
formData.menuId = this.selectSarMenu.id
}
// 排序
formData.orderBy = this.orderBy
// 处理我的收藏和个性化标签传参