|
|
@@ -329,25 +329,42 @@ export default {
|
|
|
|
|
|
submitForm() {
|
|
|
console.log('提交表单数据:', this.form); // 调试日志
|
|
|
- this.form.userId = this.userId;
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
|
- if (this.form.id != null) {
|
|
|
- updateCollection(this.form).then(res => {
|
|
|
+ // 深拷贝表单数据,避免直接修改原始 form
|
|
|
+ const submitData = { ...this.form };
|
|
|
+ submitData.userId = this.userId;
|
|
|
+
|
|
|
+ // 如果未关联产品疗法,清除相关字段(避免传 null/0 等无效值)
|
|
|
+ if (submitData.isPackage !== 1) {
|
|
|
+ delete submitData.packageId;
|
|
|
+ delete submitData.payType;
|
|
|
+ delete submitData.amount;
|
|
|
+ } else {
|
|
|
+ // 如果关联了疗法,但支付类型不是物流代收,则清除 amount
|
|
|
+ if (submitData.payType !== 2) {
|
|
|
+ delete submitData.amount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('实际提交数据:', submitData); // 调试用
|
|
|
+
|
|
|
+ if (submitData.id != null) {
|
|
|
+ updateCollection(submitData).then(res => {
|
|
|
this.msgSuccess("修改成功");
|
|
|
this.open = false;
|
|
|
this.$parent.$parent.closeCollection();
|
|
|
this.$refs['form'].resetFields();
|
|
|
this.handleShare(res.data);
|
|
|
- })
|
|
|
+ });
|
|
|
} else {
|
|
|
- addCollection(this.form).then(res => {
|
|
|
+ addCollection(submitData).then(res => {
|
|
|
this.msgSuccess("添加成功");
|
|
|
this.open = false;
|
|
|
this.$parent.$parent.closeCollection();
|
|
|
this.$refs['form'].resetFields();
|
|
|
this.handleShare(res.data);
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
});
|