const SYS_MENU_RECOMMEND_SETTING_COMPONENT = { template: ` {{ scope.node.label }} 取 消 确 定 `, data() { return { platform: null, dialogVisible: false, menuData: [], defaultProps: { children: "children", label: "label" }, checkedNodes: [], checkedKeys: [], type: '', } }, methods: { onOpen(platform, type) { this.platform = platform this.type = type this.checkedKeys = [] this.dialogVisible = true this.listTree() }, listTree() { this.$axios.post("/platform/sys/menu/menuAll", { platform: this.platform }).then((res) => { if (res.code === 0) { this.setTreeDisabled(res.data) this.menuData = res.data console.log(this.checkedKeys) //设置选中的节点 this.$refs.menuTree.setCheckedKeys(this.checkedKeys) //获取选中的节点 this.$nextTick(() => { this.checkedNodes = this.$refs.menuTree.getCheckedNodes(true, false) }) } }) }, setTreeDisabled(data) { data.forEach((item) => { if ((this.type === 'service' && item.isRecommendService) || (this.type === 'app' && item.isRecommendApp)) { this.checkedKeys.push(item.id) } if (!item.href && item.type === "menu" && this.type === 'service') { item.disabled = true } if (this.type === 'app') { delete item.children } if (item.children && item.children.length) { this.setTreeDisabled(item.children) } }) }, checkChange(currObj, isChecked) { this.checkedNodes = this.$refs.menuTree.getCheckedNodes(true, false) }, submit() { this.$confirm("您确定要提交吗?", "提示", { type: "warning" }).then(() => { this.$axios .post("/platform/sys/menu/updateRecommendSetting", { menuIds: JSON.stringify(this.checkedNodes.map((item) => item.id)), platform: this.platform, type: this.type }) .then((resp) => { if (resp.code === 0) { this.checkedKeys = [] this.listTree() this.$message.success(resp.msg) this.$emit("refresh", null) } }) }) } }, created() {} }