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