commit
This commit is contained in:
@@ -3,10 +3,18 @@ const SYS_MENU_RECOMMEND_SETTING_COMPONENT = {
|
||||
<el-dialog title="推荐配置" :visible.sync="dialogVisible" width="50%">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-input
|
||||
v-model="menuKeyword"
|
||||
clearable
|
||||
prefix-icon="el-icon-search"
|
||||
placeholder="请输入菜单名称搜索"
|
||||
style="margin-bottom: 10px">
|
||||
</el-input>
|
||||
<el-tree ref="menuTree"
|
||||
style="max-height: 500px;overflow-y: auto"
|
||||
:data="menuData"
|
||||
style="max-height: 450px;overflow-y: auto"
|
||||
:data="menuData"
|
||||
:check-on-click-node="true"
|
||||
:filter-node-method="filterMenuNode"
|
||||
node-key="id"
|
||||
show-checkbox
|
||||
@check-change="checkChange"
|
||||
@@ -40,6 +48,7 @@ const SYS_MENU_RECOMMEND_SETTING_COMPONENT = {
|
||||
platform: null,
|
||||
dialogVisible: false,
|
||||
menuData: [],
|
||||
menuKeyword: '',
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "label"
|
||||
@@ -51,15 +60,31 @@ const SYS_MENU_RECOMMEND_SETTING_COMPONENT = {
|
||||
type: '',
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
menuKeyword(value) {
|
||||
if (this.$refs.menuTree) {
|
||||
this.$refs.menuTree.filter(value)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onOpen(platform, type) {
|
||||
this.platform = platform
|
||||
this.type = type
|
||||
this.checkedKeys = []
|
||||
this.$set(this, 'menuKeyword', '')
|
||||
this.dialogVisible = true
|
||||
this.listTree()
|
||||
},
|
||||
|
||||
// 仅过滤左侧菜单树的显示,不修改节点勾选状态,保证搜索前的选择仍能提交。
|
||||
filterMenuNode(value, data) {
|
||||
if (!value) {
|
||||
return true
|
||||
}
|
||||
return (data.label || data.name || '').indexOf(value) !== -1
|
||||
},
|
||||
|
||||
listTree() {
|
||||
this.$axios.post("/platform/sys/menu/menuAll", { platform: this.platform }).then((res) => {
|
||||
if (res.code === 0) {
|
||||
@@ -101,9 +126,13 @@ const SYS_MENU_RECOMMEND_SETTING_COMPONENT = {
|
||||
this.$confirm("您确定要提交吗?", "提示", {
|
||||
type: "warning"
|
||||
}).then(() => {
|
||||
// 提交时从完整菜单树读取选中节点,搜索隐藏的已选节点也必须保留。
|
||||
const selectedNodes = this.$refs.menuTree
|
||||
? this.$refs.menuTree.getCheckedNodes(true, false)
|
||||
: this.checkedNodes
|
||||
this.$axios
|
||||
.post("/platform/sys/menu/updateRecommendSetting", {
|
||||
menuIds: JSON.stringify(this.checkedNodes.map((item) => item.id)),
|
||||
menuIds: JSON.stringify(selectedNodes.map((item) => item.id)),
|
||||
platform: this.platform,
|
||||
type: this.type
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user