function LSTChildrencategoryId string consolelog开始执行LSTChildren方法; 查的是自己就是父级 getChildrenCategoryForm id categoryId then data = dataforEachitem = Objecta
在函数LSTChildren中,formData2是一个没有定义的变量。你需要在函数的开始处定义它,例如:let formData2 = {};。
此外,在finally块中,loading.value是一个未定义的变量。你需要确保在使用之前已经定义了它。
最后,在openDialog函数中,你使用了formData2.categoryId,但是在LSTChildren函数中,并没有给formData2赋值。所以你需要在调用LSTChildren之前先给formData2赋一个初始值,例如:let formData2 = {};。
修正后的代码如下所示:
function LSTChildren(categoryId?: string) {
console.log("..开始执行LSTChildren方法..........");
let formData2 = {};
// 查的是自己(就是父级)
getChildrenCategoryForm({ id: categoryId })
.then(({ data }) => {
data.forEach(item => {
Object.assign(formData2, item);
// console.log("..LSTChildren 完事儿了..?",formData2.categoryId);
});
})
.finally(() => {
loading.value = false;
});
// }
console.log("..LSTChildren 完事儿了.吗啊啊啊啊.formData2是是撒大大啊 ?", formData2.categoryId);
}
function openDialog(categoryItem?: CategoryPageVO) {
console.log('categoryItem是什么啊啊啊————————————————————————', categoryItem);
let formData2 = {};
LSTChildren(categoryItem.categoryId);
dialog.visible = true;
if (categoryItem) {
dialog.title = "修改类目";
loading.value = true;
formData.categoryId = categoryItem.categoryId;
formData.categoryName = categoryItem.categoryName;
// formData.parentCategoryId = categoryItem.parentCategoryId;/////先查一个只有父id的接口
// 然后父id的显示就是
formData.parentCategoryId = formData2.categoryId;
formData.categoryDesp = categoryItem.categoryDesp;
formData.categoryIcon = categoryItem.categoryIcon;
// formData.status = categoryItem.status;
// formData.orderNum=categoryItem.orderNum;
// formData.userId=categoryItem.userId;
console.log('------------formData.parentCategoryId', formData.parentCategoryId);
console.log('-----------parentCategoryId', categoryItem.parentCategoryId);
// Object.assign(formData, categoryItem); ///表单
} else {
dialog.title = "新增类目";
// formData.orderNum = 1;//lxh:新增第一条默认是最小值1 再增一条就是2 逐次递增 如果有两个1 那新增的第三条排序就显示2//再提交处新增
console.log("---这是打开表单新增的openDialog新增---");
}
}
请注意,这里假设你已经在其他地方定义了loading.value变量,并且已经导入了getChildrenCategoryForm函数和CategoryPageVO类型。如果还有其他错误,请提供更多的代码和错误信息。
原文地址: https://www.cveoy.top/t/topic/i7dn 著作权归作者所有。请勿转载和采集!