| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="上级菜单"> |
| | | <el-tree-select |
| | | @change = "parentIdChange" |
| | | v-model="formAddMenu.parentId" |
| | | clearable |
| | | node-key="id" |
| | | placeholder="上级菜单" |
| | | ref="parentTree" |
| | | :data="parentData" |
| | | check-strictly |
| | | :props="{ label: 'title' }" |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="菜单类型" prop="belongApplication"> |
| | | <el-radio-group v-model="formAddMenu.belongApplication"> |
| | | <el-radio v-for="item in belongApplicationList" :label="item.label" :key="item.id">{{item.value}}</el-radio> |
| | | <el-form-item label="菜单类型" prop="category"> |
| | | <el-radio-group v-model="formAddMenu.category" @change="categoryChange"> |
| | | <el-radio v-for="item in categoryList" :label="item.label" :key="item.id">{{item.value}}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="新窗口" prop="isOpen"> |
| | | <el-radio-group v-model="formAddMenu.isOpen"> |
| | | <el-radio-group v-model="formAddMenu.isOpen" @change="isOpenChange"> |
| | | <el-radio :label="1">否</el-radio> |
| | | <el-radio :label="2">是</el-radio> |
| | | </el-radio-group> |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="启用缓存" prop="keepAlive"> |
| | | <el-radio-group v-model="formAddMenu.keepAlive"> |
| | | <el-radio :label="1">否</el-radio> |
| | | <el-radio :label="2">是</el-radio> |
| | | <el-radio-group v-model="formAddMenu.keepAlive" @change="keepAliveChange"> |
| | | <el-radio :label="0">否</el-radio> |
| | | <el-radio :label="1">是</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="所属应用" prop="category"> |
| | | <el-select v-model="formAddMenu.category" style="width: 100%"> |
| | | <el-form-item label="所属应用" prop="belongApplication"> |
| | | <el-select v-model="formAddMenu.belongApplication" style="width: 100%" @change="belongApplicationChange"> |
| | | <el-option v-for="item in applicationList" :key="item.code" :label="item.name" :value="item.code"/> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | emits: ['success', 'closed'], |
| | | data() { |
| | | return { |
| | | fixed: false, |
| | | parentData: {}, |
| | | belongApplicationList: [ |
| | | {label: 1,id: "1",value: "APP"}, |
| | | {label: 2,id: "2",value: "菜单"}, |
| | | {label: 3,id: "3",value: "按钮"}, |
| | | {label: 4,id: "4",value: "卡片"} |
| | | categoryList: [ |
| | | {label: 0,id: "0",value: "APP"}, |
| | | {label: 1,id: "1",value: "菜单"}, |
| | | {label: 2,id: "2",value: "按钮"}, |
| | | {label: 3,id: "3",value: "卡片"} |
| | | ], |
| | | value1: true, |
| | | mode: "add", |
| | |
| | | name: "", |
| | | path: "", |
| | | parentId: "", |
| | | $parentId: "", |
| | | code: "", |
| | | $belongApplication: '菜单', |
| | | belongApplication: 2, |
| | | $belongApplication: '', |
| | | belongApplication: '', |
| | | alias: "", |
| | | isOpen: 1, |
| | | $isOpen: "否", |
| | | keepAlive: 2, |
| | | keepAlive: 1, |
| | | $keepAlive: "是", |
| | | $category: "", |
| | | category: "", |
| | |
| | | this.parentIdload(); |
| | | }, |
| | | methods: { |
| | | parentIdChange(val) { |
| | | var $parentId = this.$refs.parentTree.getCurrentNode().title; |
| | | this.formAddMenu.$parentId = $parentId; |
| | | }, |
| | | belongApplicationChange(val) { |
| | | var $belongApplication = this.applicationList.find(option=>option.code === val).name; |
| | | this.formAddMenu.$belongApplication = $belongApplication; |
| | | }, |
| | | categoryChange(val) { |
| | | var $category = this.categoryList.find(option=>option.id == val).value; |
| | | this.formAddMenu.$category = $category; |
| | | }, |
| | | isOpenChange(val) { |
| | | if(val == "1") { |
| | | this.formAddMenu.$isOpen = "否"; |
| | | } |
| | | if(val == "2") { |
| | | this.formAddMenu.$isOpen = "是"; |
| | | } |
| | | }, |
| | | keepAliveChange(val) { |
| | | if(val == "0") { |
| | | this.formAddMenu.$keepAlive = "否"; |
| | | } |
| | | if(val == "1") { |
| | | this.formAddMenu.$keepAlive = "是"; |
| | | } |
| | | }, |
| | | parentIdload(node, resolve) { |
| | | this.$HTTP.get("/api/blade-system/menu/tree").then(res=> { |
| | | if(res.code == 200) { |
| | |
| | | this.$refs.dialogForm.validate(async (valid) => { |
| | | if (valid) { |
| | | this.isSaveing = true; |
| | | var res = await this.$API.demo.post.post(this.form); |
| | | this.isSaveing = false; |
| | | if(res.code == 200){ |
| | | this.$emit('success', this.form, this.mode) |
| | | this.visible = false; |
| | | this.$message.success("操作成功") |
| | | }else{ |
| | | this.$alert(res.message, "提示", {type: 'error'}) |
| | | } |
| | | this.$HTTP.post("/api/blade-system/menu/submit",this.formAddMenu).then(res=> { |
| | | this.isSaveing = false; |
| | | if(res.code == 200) { |
| | | this.$emit('success', this.formAddMenu, this.mode); |
| | | this.visible = false; |
| | | this.$message.success("操作成功"); |
| | | }else { |
| | | this.$alert(res.message, "提示", {type: 'error'}); |
| | | } |
| | | }) |
| | | }else{ |
| | | return false; |
| | | } |
| | |
| | | }, |
| | | //表单注入数据 |
| | | setData(data){ |
| | | if(data.parentId == "0") { |
| | | data.parentId = ""; |
| | | } |
| | | //可以和上面一样单个注入,也可以像下面一样直接合并进去 |
| | | Object.assign(this.formAddMenu, data) |
| | | if(data.fixed) { //新增子项 |
| | | this.formAddMenu.parentId = data.id; |
| | | }else { |
| | | Object.assign(this.formAddMenu, data); |
| | | } |
| | | } |
| | | } |
| | | } |