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