|
@@ -91,6 +91,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ name: "",
|
|
|
menuForm: {
|
|
|
parentId: null,
|
|
|
pname: null,
|
|
@@ -105,9 +106,7 @@ export default {
|
|
|
message: "请选择",
|
|
|
trigger: "change",
|
|
|
},
|
|
|
- pcode: [
|
|
|
- { required: true, message: "请填写菜单菜单标识", trigger: "blur" },
|
|
|
- ],
|
|
|
+ pcode: [{ required: true, message: "请填写菜单标识", trigger: "blur" }],
|
|
|
pname: [{ required: true, message: "请填写菜单名称", trigger: "blur" }],
|
|
|
purl: [{ required: true, message: "请填写路由地址", trigger: "blur" }],
|
|
|
parentId: [
|
|
@@ -115,49 +114,20 @@ export default {
|
|
|
],
|
|
|
pstat: [{ required: true, message: "请选择状态", trigger: "change" }],
|
|
|
},
|
|
|
- stateOPtions: [],
|
|
|
+ stateOptions: [],
|
|
|
menuOptions: [
|
|
|
{ permissionId: 0, permissionName: "主类目", children: [] },
|
|
|
],
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
- console.log(this.checkId, "checkid");
|
|
|
- this.menuOptions[0].children.push(...this.tableData);
|
|
|
- if (this.row && this.title === "编辑" && this.activeName === "2") {
|
|
|
- this.menuForm = {
|
|
|
- parentId: this.row.parentId,
|
|
|
- pname: this.row.permissionName,
|
|
|
- purl: this.row.permissionUrl,
|
|
|
- pstat: this.row.permissionState,
|
|
|
- pcode: this.row.permissionCode,
|
|
|
- permissionShow: this.row.permissionShow,
|
|
|
- };
|
|
|
- } else if (this.title === "新增" && this.activeName === "2") {
|
|
|
- this.menuForm.parentId = this.checkId;
|
|
|
- } else {
|
|
|
- this.menuForm.parentId = 0;
|
|
|
- }
|
|
|
+ this.initializeForm();
|
|
|
},
|
|
|
watch: {
|
|
|
row: {
|
|
|
handler(newVal) {
|
|
|
if (newVal) {
|
|
|
- console.log(newVal, "newRowValue");
|
|
|
- if (this.title === "编辑" && this.activeName === "2") {
|
|
|
- this.menuForm = {
|
|
|
- parentId: newVal.parentId,
|
|
|
- pname: newVal.permissionName,
|
|
|
- purl: newVal.permissionUrl,
|
|
|
- pstat: newVal.permissionState,
|
|
|
- pcode: newVal.permissionCode,
|
|
|
- permissionShow: newVal.permissionShow,
|
|
|
- };
|
|
|
- } else if (this.title === "新增" && this.activeName === "2") {
|
|
|
- this.menuForm.parentId = this.checkId;
|
|
|
- } else {
|
|
|
- this.menuForm.parentId = 0;
|
|
|
- }
|
|
|
+ this.initializeForm();
|
|
|
}
|
|
|
},
|
|
|
immediate: true,
|
|
@@ -165,55 +135,67 @@ export default {
|
|
|
},
|
|
|
checkId(newVal) {
|
|
|
if (newVal !== null && newVal !== undefined) {
|
|
|
- console.log(newVal, "checkId");
|
|
|
this.menuForm.parentId = newVal;
|
|
|
- if (
|
|
|
- this.menuForm.pname === null &&
|
|
|
- this.row &&
|
|
|
- this.title === "编辑" &&
|
|
|
- this.activeName === "2"
|
|
|
- ) {
|
|
|
- console.log(this.props, " this.row");
|
|
|
- this.menuForm = {
|
|
|
- parentId: this.row.parentId,
|
|
|
- pname: this.row.permissionName,
|
|
|
- purl: this.row.permissionUrl,
|
|
|
- pstat: this.row.permissionState,
|
|
|
- pcode: this.row.permissionCode,
|
|
|
- permissionShow: this.row.permissionShow,
|
|
|
- };
|
|
|
- }
|
|
|
+ this.initializeForm();
|
|
|
}
|
|
|
},
|
|
|
tableData: {
|
|
|
handler(newData) {
|
|
|
this.$nextTick(() => {
|
|
|
- console.log("gengxin", this.setExpandAll(newData));
|
|
|
- this.setExpandAll(newData);
|
|
|
this.menuOptions[0].children = [];
|
|
|
- this.menuOptions[0].children.push(...this.tableData);
|
|
|
+ this.menuOptions[0].children.push(...newData);
|
|
|
});
|
|
|
},
|
|
|
immediate: true,
|
|
|
deep: true,
|
|
|
},
|
|
|
},
|
|
|
-
|
|
|
methods: {
|
|
|
- setExpandAll(expand) {
|
|
|
- const table = this.$refs.table;
|
|
|
- if (table) {
|
|
|
- this.tableData.forEach((row) => {
|
|
|
- table.toggleRowExpansion(row, expand);
|
|
|
- if (row.children) {
|
|
|
- row.children.forEach((child) => {
|
|
|
- table.toggleRowExpansion(child, expand);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- console.log(this.tableData, "新值");
|
|
|
+ initializeForm() {
|
|
|
+ console.log(this.checkId, "checkid");
|
|
|
+ this.menuOptions[0].children.push(...this.tableData);
|
|
|
+ if (this.row && this.title === "编辑" && this.activeName === "2") {
|
|
|
+ this.menuForm = {
|
|
|
+ parentId: this.row.parentId,
|
|
|
+ pname: this.row.permissionName,
|
|
|
+ purl: this.row.permissionUrl,
|
|
|
+ pstat: this.row.permissionState,
|
|
|
+ pcode: this.row.permissionCode,
|
|
|
+ permissionShow: this.row.permissionShow,
|
|
|
+ };
|
|
|
+ } else if (this.title === "新增" && this.activeName === "2") {
|
|
|
+ this.menuForm.parentId = this.checkId;
|
|
|
+ } else {
|
|
|
+ this.menuForm.parentId = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.row && this.title === "编辑") {
|
|
|
+ this.menuForm = {
|
|
|
+ parentId: this.row.parentId,
|
|
|
+ pname: this.row.permissionName,
|
|
|
+ purl: this.row.permissionUrl,
|
|
|
+ pstat: this.row.permissionState,
|
|
|
+ pcode: this.row.permissionCode,
|
|
|
+ permissionShow: this.row.permissionShow,
|
|
|
+ };
|
|
|
+ if (this.activeName === "1") {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.menuForm = {
|
|
|
+ pname: this.row.permissionName,
|
|
|
+ pstat: this.row.permissionState,
|
|
|
+ parentId: 0,
|
|
|
+ pcode: this.row.permissionCode,
|
|
|
+ permissionShow: this.row.permissionShow,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else if (this.title === "新增" && this.activeName === "2") {
|
|
|
+ this.menuForm.parentId = this.checkId;
|
|
|
+ } else {
|
|
|
+ this.menuForm.parentId = 0;
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
normalizer(node) {
|
|
|
if (node.children && !node.children.length) {
|
|
|
delete node.children;
|
|
@@ -225,7 +207,6 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
submit() {
|
|
|
- const that = this;
|
|
|
this.$refs["addUserForm"].validate((valid) => {
|
|
|
if (valid) {
|
|
|
if (this.title === "编辑" && this.row) {
|
|
@@ -239,7 +220,7 @@ export default {
|
|
|
message: "编辑成功",
|
|
|
});
|
|
|
this.cancel();
|
|
|
- that.$emit("updateList");
|
|
|
+ this.$emit("updateList");
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
this.$message({
|
|
@@ -248,7 +229,6 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
} else if (this.title === "新增") {
|
|
|
- console.log("新增", this.activeName);
|
|
|
addMenuFn({
|
|
|
...this.menuForm,
|
|
|
purl:
|
|
@@ -263,7 +243,7 @@ export default {
|
|
|
message: "新增成功",
|
|
|
});
|
|
|
this.cancel();
|
|
|
- that.$emit("updateList");
|
|
|
+ this.$emit("updateList");
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
this.$message({
|