this.$refs[name].validate(valid => {
if(valid && this.formValidate.Id == undefined || this.formValidate.Id == "") {
//存课包明细信息
localStorage.setItem(
"DetailedPackage",
JSON.stringify(this.DetailedPackage)
);
//存课包价格
localStorage.setItem(
"PricePackage",
JSON.stringify(this.PricePackage)
);
//接口发送上边的data
Create(this.Interface, this.formValidate).then(res => {
console.log(res.data)
this.reload();
//拿课包的Id和明细价格
this.packageId = res.data.Data.Id
this.packageDetail = JSON.parse(
localStorage.DetailedPackage
);
console.log(this.packageDetail)
this.packagePrise = JSON.parse(
localStorage.PricePackage
);
console.log(this.packagePrise)
if(res.data.ErrCode === '0') {
AddOrUpdateCourse(this.Interface, {
PackageId: this.packageId,
CourseCollection: this.packageDetail
}).then(res => {
console.log(res.data)
}).catch(err => {
console.log(err)
})
AddOrUpdatePrice(this.Interface, {
PackageId: this.packageId,
PriceCollection: this.packagePrise
}).then(res => {
console.log(res.data)
this.$Message.success("添加成功");
this.reload();
}).catch(err => {
console.log(err)
})
}
}).catch(err => {
console.log(err)
})
} else {
//修改表单
Update(this.Interface, this.formValidate).then(res => {
console.log(res.data)
this.$Message.success("修改成功");
}).catch(err => {
console.log(err)
})
}
})
},