fix 修复 代码生成菜单选项回显问题
This commit is contained in:
parent
a0bcdf0cde
commit
61417032b7
@ -136,54 +136,53 @@ const genInfo = ref(genInfoForm);
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
const basicForm = basicInfo.value.$refs.basicInfoForm;
|
||||
const genForm = genInfo.value.$refs.genInfoForm;
|
||||
const basicForm = basicInfo.value.$refs.basicInfoForm;
|
||||
const genForm = genInfo.value.$refs.genInfoForm;
|
||||
|
||||
Promise.all([basicForm, genForm].map(getFormPromise)).then(async res => {
|
||||
const validateResult = res.every(item => !!item);
|
||||
if (validateResult) {
|
||||
const genTable: any = Object.assign({}, info.value);
|
||||
genTable.columns = columns.value;
|
||||
genTable.params = {
|
||||
treeCode: info.value?.treeCode,
|
||||
treeName: info.value.treeName,
|
||||
treeParentCode: info.value.treeParentCode,
|
||||
parentMenuId: info.value.parentMenuId
|
||||
};
|
||||
const response = await updateGenTable(genTable);
|
||||
proxy?.$modal.msgSuccess(response.msg);
|
||||
if (response.code === 200) {
|
||||
close();
|
||||
}
|
||||
} else {
|
||||
proxy?.$modal.msgError("表单校验未通过,请重新检查提交内容");
|
||||
}
|
||||
});
|
||||
Promise.all([basicForm, genForm].map(getFormPromise)).then(async res => {
|
||||
const validateResult = res.every(item => !!item);
|
||||
if (validateResult) {
|
||||
const genTable: any = Object.assign({}, info.value);
|
||||
genTable.columns = columns.value;
|
||||
genTable.params = {
|
||||
treeCode: info.value?.treeCode,
|
||||
treeName: info.value.treeName,
|
||||
treeParentCode: info.value.treeParentCode,
|
||||
parentMenuId: info.value.parentMenuId
|
||||
};
|
||||
const response = await updateGenTable(genTable);
|
||||
proxy?.$modal.msgSuccess(response.msg);
|
||||
if (response.code === 200) {
|
||||
close();
|
||||
}
|
||||
} else {
|
||||
proxy?.$modal.msgError("表单校验未通过,请重新检查提交内容");
|
||||
}
|
||||
});
|
||||
}
|
||||
const getFormPromise = (form: any) => {
|
||||
return new Promise(resolve => {
|
||||
form.validate((res: any) => {
|
||||
resolve(res);
|
||||
});
|
||||
return new Promise(resolve => {
|
||||
form.validate((res: any) => {
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
}
|
||||
const close = () => {
|
||||
const obj = { path: "/tool/gen", query: { t: Date.now(), pageNum: route.query.pageNum } };
|
||||
proxy?.$tab.closeOpenPage(obj);
|
||||
const obj = {path: "/tool/gen", query: {t: Date.now(), pageNum: route.query.pageNum}};
|
||||
proxy?.$tab.closeOpenPage(obj);
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const tableId = route.params && route.params.tableId as string;
|
||||
if (tableId) {
|
||||
// 获取表详细信息
|
||||
const res = await getGenTable(tableId);
|
||||
res.data.info.parentMenuId = Number(res.data.info.parentMenuId);
|
||||
columns.value = res.data.rows;
|
||||
info.value = res.data.info;
|
||||
tables.value = res.data.tables;
|
||||
/** 查询字典下拉列表 */
|
||||
const response = await getDictOptionselect();
|
||||
dictOptions.value = response.data;
|
||||
}
|
||||
const tableId = route.params && route.params.tableId as string;
|
||||
if (tableId) {
|
||||
// 获取表详细信息
|
||||
const res = await getGenTable(tableId);
|
||||
columns.value = res.data.rows;
|
||||
info.value = res.data.info;
|
||||
tables.value = res.data.tables;
|
||||
/** 查询字典下拉列表 */
|
||||
const response = await getDictOptionselect();
|
||||
dictOptions.value = response.data;
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
@ -226,9 +226,9 @@ import { listMenu } from '@/api/system/menu';
|
||||
import { ComponentInternalInstance, PropType } from 'vue';
|
||||
|
||||
interface MenuOptionsType {
|
||||
menuId: number;
|
||||
menuName: string;
|
||||
children: MenuOptionsType[] | undefined;
|
||||
menuId: number | string;
|
||||
menuName: string;
|
||||
children: MenuOptionsType[] | undefined;
|
||||
}
|
||||
|
||||
const subColumns = ref<any>([]);
|
||||
@ -236,14 +236,14 @@ const menuOptions = ref<Array<MenuOptionsType>>([]);
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
const props = defineProps({
|
||||
info: {
|
||||
type: Object as PropType<any>,
|
||||
default: null
|
||||
},
|
||||
tables: {
|
||||
type: Array as PropType<any[]>,
|
||||
default: null
|
||||
}
|
||||
info: {
|
||||
type: Object as PropType<any>,
|
||||
default: null
|
||||
},
|
||||
tables: {
|
||||
type: Array as PropType<any[]>,
|
||||
default: null
|
||||
}
|
||||
});
|
||||
|
||||
const infoForm = computed(() => props.info);
|
||||
@ -252,45 +252,46 @@ const table = computed(() => props.tables);
|
||||
|
||||
// 表单校验
|
||||
const rules = ref({
|
||||
tplCategory: [{ required: true, message: "请选择生成模板", trigger: "blur" }],
|
||||
packageName: [{ required: true, message: "请输入生成包路径", trigger: "blur" }],
|
||||
moduleName: [{ required: true, message: "请输入生成模块名", trigger: "blur" }],
|
||||
businessName: [{ required: true, message: "请输入生成业务名", trigger: "blur" }],
|
||||
functionName: [{ required: true, message: "请输入生成功能名", trigger: "blur" }]
|
||||
tplCategory: [{required: true, message: "请选择生成模板", trigger: "blur"}],
|
||||
packageName: [{required: true, message: "请输入生成包路径", trigger: "blur"}],
|
||||
moduleName: [{required: true, message: "请输入生成模块名", trigger: "blur"}],
|
||||
businessName: [{required: true, message: "请输入生成业务名", trigger: "blur"}],
|
||||
functionName: [{required: true, message: "请输入生成功能名", trigger: "blur"}]
|
||||
});
|
||||
const subSelectChange = () => {
|
||||
infoForm.value.subTableFkName = "";
|
||||
infoForm.value.subTableFkName = "";
|
||||
}
|
||||
const tplSelectChange = (value: string) => {
|
||||
if (value !== "sub") {
|
||||
infoForm.value.subTableName = "";
|
||||
infoForm.value.subTableFkName = "";
|
||||
}
|
||||
if (value !== "sub") {
|
||||
infoForm.value.subTableName = "";
|
||||
infoForm.value.subTableFkName = "";
|
||||
}
|
||||
}
|
||||
const setSubTableColumns = (value: string) => {
|
||||
table.value.forEach(item => {
|
||||
const name = item.tableName;
|
||||
if (value === name) {
|
||||
subColumns.value = item.columns;
|
||||
return;
|
||||
}
|
||||
})
|
||||
table.value.forEach(item => {
|
||||
const name = item.tableName;
|
||||
if (value === name) {
|
||||
subColumns.value = item.columns;
|
||||
return;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 查询菜单下拉树结构 */
|
||||
const getMenuTreeselect = async () => {
|
||||
const res = await listMenu();
|
||||
const data = proxy?.handleTree<MenuOptionsType>(res.data, "menuId");
|
||||
const res = await listMenu();
|
||||
res.data.forEach(m => m.menuId = m.menuId.toString());
|
||||
const data = proxy?.handleTree<MenuOptionsType>(res.data, "menuId");
|
||||
if (data) {
|
||||
menuOptions.value = data
|
||||
}
|
||||
menuOptions.value = data
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.info.subTableName, val => {
|
||||
setSubTableColumns(val);
|
||||
setSubTableColumns(val);
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
getMenuTreeselect();
|
||||
getMenuTreeselect();
|
||||
})
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user