1.添加对话框
对话框通过visible属性控制显示与否
2.添加方法数据对象
3.添加方法
新增成功后的操作写在then里面,我刚开始没注意写在then外面导致新增成功没有及时刷新
append(node, data) {
this.dialogVisible = true;
this.category.parentCid = data.catId;
this.category.catLevel = data.catLevel + 1;
},
saveCategory() {
this.$http({
url: this.$http.adornUrl("/product/category/save"),
method: "post",
data: this.$http.adornData(this.category, false),
}).then(({ data }) => {
this.$message({
type: "success",
message: "新增成功!",
});
this.getDataList();
this.expandedkeys = [this.category.parentCid];
this.dialogVisible = false;
});
},
4.新增分类测试成功