|
@@ -220,6 +220,7 @@
|
|
|
v-model="formData.routePath"
|
|
|
:options="menus"
|
|
|
:normalizer="normalizer"
|
|
|
+ @change="treeSelectChange"
|
|
|
:show-count="true"
|
|
|
placeholder="请选择父级路由"
|
|
|
/>
|
|
@@ -589,6 +590,7 @@ export default {
|
|
|
loading: false, //表格加载
|
|
|
tableDataList: [], //数据
|
|
|
editData: {},
|
|
|
+ menuOrderNum: 0,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -614,15 +616,16 @@ export default {
|
|
|
primaryKeyList() {
|
|
|
return this.tableFieldList.filter((item) => !item.isChildren);
|
|
|
},
|
|
|
- menuOrderNum() {
|
|
|
- if (!this.formData.routePath) return 0;
|
|
|
- let targetMenu = this.getTargetMenu(this.menus);
|
|
|
- if (targetMenu.children?.length) {
|
|
|
- return targetMenu.children.length;
|
|
|
- } else {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- },
|
|
|
+ // menuOrderNum() {
|
|
|
+ // if (!this.formData.routePath) return 0;
|
|
|
+ // let targetMenu = this.getTargetMenu(this.menus);
|
|
|
+ // console.log(targetMenu);
|
|
|
+ // if (targetMenu.children?.length) {
|
|
|
+ // return targetMenu.children.length;
|
|
|
+ // } else {
|
|
|
+ // return 0;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
},
|
|
|
watch: {
|
|
|
tableName: function (val) {
|
|
@@ -639,8 +642,17 @@ export default {
|
|
|
this.relationTableList = [];
|
|
|
}
|
|
|
},
|
|
|
+ "formData.routePath"(nval, oval) {
|
|
|
+ let targetMenu = this.getTargetMenu(this.menus);
|
|
|
+ this.menuOrderNum = targetMenu.children ? targetMenu.children.length : 0;
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 树形控件change回调
|
|
|
+ treeSelectChange(val) {
|
|
|
+ //没有change事件
|
|
|
+ console.log("val", val);
|
|
|
+ },
|
|
|
// 获取目标menu
|
|
|
getTargetMenu(menus) {
|
|
|
for (let i = 0; i < menus.length; i++) {
|
|
@@ -1305,7 +1317,31 @@ export default {
|
|
|
let echoData = JSON.parse(res.data.echoData);
|
|
|
this.tableName = echoData.tableName;
|
|
|
this.tableFieldList = echoData.tableFieldData;
|
|
|
- this.formData = echoData.formData;
|
|
|
+ let {
|
|
|
+ isShowList,
|
|
|
+ timeFormate,
|
|
|
+ orderByColumn,
|
|
|
+ isAsc,
|
|
|
+ primaryKey,
|
|
|
+ menuName,
|
|
|
+ } = echoData.formData;
|
|
|
+ Object.assign(this.formData, {
|
|
|
+ menuName,
|
|
|
+ isShowList,
|
|
|
+ timeFormate,
|
|
|
+ orderByColumn,
|
|
|
+ isAsc,
|
|
|
+ primaryKey,
|
|
|
+ });
|
|
|
+ this.formData.routePath = this.getParentMenuId(
|
|
|
+ res.data.menuId,
|
|
|
+ this.menus,
|
|
|
+ {}
|
|
|
+ );
|
|
|
+ if (!this.formData.routePath) {
|
|
|
+ this.$message.warning("该表格菜单路由已经删除,请重新配置");
|
|
|
+ }
|
|
|
+ // this.formData.routePath
|
|
|
this.editData = res.data;
|
|
|
let val = await getParticMenu(res.data.sqlKey);
|
|
|
if (val.code == 200) {
|
|
@@ -1315,12 +1351,24 @@ export default {
|
|
|
this.$message.error("数据回显失败");
|
|
|
}
|
|
|
},
|
|
|
+ // 获取父级menuId
|
|
|
+ getParentMenuId(menuId, menus, parentItem) {
|
|
|
+ for (let i = 0; i < menus.length; i++) {
|
|
|
+ let item = menus[i];
|
|
|
+ if (item.menuId == menuId) {
|
|
|
+ return parentItem?.menuId;
|
|
|
+ } else if (item.children?.length) {
|
|
|
+ return this.getParentMenuId(menuId, item.children, item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return undefined;
|
|
|
+ },
|
|
|
},
|
|
|
created() {},
|
|
|
- mounted() {
|
|
|
+ async mounted() {
|
|
|
this.getAllTable();
|
|
|
this.initDragTable();
|
|
|
- this.getMenuList();
|
|
|
+ await this.getMenuList();
|
|
|
if (this.$route.query.tId) {
|
|
|
this.tId = this.$route.query.tId;
|
|
|
this.initTableData(this.tId);
|