|
@@ -32,6 +32,34 @@
|
|
|
placeholder="请输入菜单标识"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="菜单图标" prop="piconUrl" v-if="activeName !== '3'">
|
|
|
+ <el-popover
|
|
|
+ placement="bottom-start"
|
|
|
+ width="460"
|
|
|
+ trigger="click"
|
|
|
+ @show="$refs['iconSelect'].reset()"
|
|
|
+ >
|
|
|
+ <IconSelect
|
|
|
+ ref="iconSelect"
|
|
|
+ @selected="selected"
|
|
|
+ :active-icon="menuForm.piconUrl"
|
|
|
+ />
|
|
|
+ <el-input
|
|
|
+ slot="reference"
|
|
|
+ v-model="menuForm.piconUrl"
|
|
|
+ placeholder="点击选择图标"
|
|
|
+ readonly
|
|
|
+ >
|
|
|
+ <svg-icon
|
|
|
+ v-if="menuForm.piconUrl"
|
|
|
+ slot="prefix"
|
|
|
+ :icon-class="menuForm.piconUrl"
|
|
|
+ style="width: 25px; height: 25px"
|
|
|
+ />
|
|
|
+ <i v-else slot="prefix" class="el-icon-search el-input__icon" />
|
|
|
+ </el-input>
|
|
|
+ </el-popover>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="路由地址:" prop="purl" v-if="activeName !== '1'">
|
|
|
<el-input
|
|
|
v-model="menuForm.purl"
|
|
@@ -65,12 +93,13 @@
|
|
|
<script>
|
|
|
import Treeselect from "@riophae/vue-treeselect";
|
|
|
import { addMenuFn, updateMenuFn } from "@/api/system";
|
|
|
-
|
|
|
+import IconSelect from "@/components/IconSelect";
|
|
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
Treeselect,
|
|
|
+ IconSelect,
|
|
|
},
|
|
|
props: {
|
|
|
activeName: {
|
|
@@ -91,6 +120,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ name: "",
|
|
|
menuForm: {
|
|
|
parentId: null,
|
|
|
pname: null,
|
|
@@ -98,6 +128,7 @@ export default {
|
|
|
pstat: null,
|
|
|
pcode: null,
|
|
|
permissionShow: null,
|
|
|
+ piconUrl: "",
|
|
|
},
|
|
|
addMenuRules: {
|
|
|
permissionShow: {
|
|
@@ -105,9 +136,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 +144,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 +165,77 @@ 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, "新值");
|
|
|
+ // 选择图标
|
|
|
+ selected(name) {
|
|
|
+ this.menuForm = {
|
|
|
+ ...this.menuForm,
|
|
|
+ piconUrl: name,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ 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 === "编辑") {
|
|
|
+ console.log(this.row, this.row.piconUrl, "piconUrl");
|
|
|
+ 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,
|
|
|
+ piconUrl: this.row.permissionIconUrl,
|
|
|
+ };
|
|
|
+ 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,
|
|
|
+ piconUrl: this.row.permissionIconUrl,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } 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 +247,6 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
submit() {
|
|
|
- const that = this;
|
|
|
this.$refs["addUserForm"].validate((valid) => {
|
|
|
if (valid) {
|
|
|
if (this.title === "编辑" && this.row) {
|
|
@@ -239,7 +260,7 @@ export default {
|
|
|
message: "编辑成功",
|
|
|
});
|
|
|
this.cancel();
|
|
|
- that.$emit("updateList");
|
|
|
+ this.$emit("updateList");
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
this.$message({
|
|
@@ -248,7 +269,6 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
} else if (this.title === "新增") {
|
|
|
- console.log("新增", this.activeName);
|
|
|
addMenuFn({
|
|
|
...this.menuForm,
|
|
|
purl:
|
|
@@ -263,7 +283,7 @@ export default {
|
|
|
message: "新增成功",
|
|
|
});
|
|
|
this.cancel();
|
|
|
- that.$emit("updateList");
|
|
|
+ this.$emit("updateList");
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
this.$message({
|
|
@@ -292,4 +312,8 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style scoped lang="scss"></style>
|
|
|
+<style scoped lang="scss">
|
|
|
+::v-deep .el-input__prefix {
|
|
|
+ line-height: 50px !important;
|
|
|
+}
|
|
|
+</style>
|