|
|
@@ -44,6 +44,13 @@ export class PurchaseList {
|
|
|
export class Cuisine {
|
|
|
@Trace id?: number;
|
|
|
@Trace name?: string;
|
|
|
+
|
|
|
+ constructor(i?: Cuisine) {
|
|
|
+ if (i) {
|
|
|
+ this.id = i.id;
|
|
|
+ this.name = i.name;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 宝宝信息
|
|
|
@@ -102,9 +109,9 @@ export class DayPlan {
|
|
|
|
|
|
constructor(i?: DayPlan) {
|
|
|
if (i) {
|
|
|
- this.breakfast = i.breakfast;
|
|
|
- this.lunch = i.lunch;
|
|
|
- this.dinner = i.dinner;
|
|
|
+ this.breakfast = new Cuisine(i.breakfast);
|
|
|
+ this.lunch = new Cuisine(i.lunch);
|
|
|
+ this.dinner = new Cuisine(i.dinner);
|
|
|
} else {
|
|
|
this.breakfast = new Cuisine();
|
|
|
this.lunch = new Cuisine();
|
|
|
@@ -135,15 +142,21 @@ export class WeeklyPlanPurchaseList {
|
|
|
this.wednesday = new DayPlan();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 浅拷贝
|
|
|
+ * @description: 因为 ObservedV2 直接使用实例化对象进行数据请求会在前面加一个 __ob__。 所以需要进行浅拷贝
|
|
|
+ * @param plan
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
static clone(plan: WeeklyPlanPurchaseList){
|
|
|
return {
|
|
|
- friday: plan.friday,
|
|
|
- monday: plan.monday,
|
|
|
- saturday: plan.saturday,
|
|
|
- sunday: plan.sunday,
|
|
|
- thursday: plan.thursday,
|
|
|
- tuesday: plan.tuesday,
|
|
|
- wednesday: plan.wednesday,
|
|
|
+ friday: JSON.parse(JSON.stringify(plan.friday)),
|
|
|
+ monday: JSON.parse(JSON.stringify(plan.monday)),
|
|
|
+ saturday: JSON.parse(JSON.stringify(plan.saturday)),
|
|
|
+ sunday: JSON.parse(JSON.stringify(plan.sunday)),
|
|
|
+ thursday: JSON.parse(JSON.stringify(plan.thursday)),
|
|
|
+ tuesday: JSON.parse(JSON.stringify(plan.tuesday)),
|
|
|
+ wednesday: JSON.parse(JSON.stringify(plan.wednesday)),
|
|
|
id: plan.id,
|
|
|
} as WeeklyPlanPurchaseList
|
|
|
}
|