cookbook_model.dart 7.37 KB
import 'package:flutter/material.dart';

///菜单

class MenuModel {
  String id;
  String sellerid;
  String className;
  dynamic classLabel;
  String order;
  String status;
  String classType;
  List<MenuSunModel> cookbooklist;
  int allSum; //总共选中菜数量
  bool isChange = false; //是否发生数量变化

  MenuModel(
      {this.id,
      this.sellerid,
      this.className,
      this.classLabel,
      this.order,
      this.status,
      this.classType,
      this.cookbooklist});

  MenuModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    sellerid = json['sellerid'];
    className = json['class_name'];
    classLabel = json['class_label'];
    order = json['order'];
    status = json['status'];
    classType = json['class_type'];
    // allSum = json['allSum'] ?? 0;
    if (json['cookbooklist'] != null) {
      cookbooklist = [];
      json['cookbooklist'][0].forEach((v) {
        cookbooklist.add(new MenuSunModel.fromJson(v));
      });
    }
  }

  MenuModel.fromJson2(Map<String, dynamic> json) {
    id = json['id'];
    sellerid = json['sellerid'];
    className = json['class_name'];
    classLabel = json['class_label'];
    order = json['order'];
    status = json['status'];
    classType = json['class_type'];
    allSum = json['allSum'] ?? 0;
    if (json['cookbooklist'] != null) {
      cookbooklist = [];
      json['cookbooklist'].forEach((v) {
        cookbooklist.add(new MenuSunModel.fromJson2(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['sellerid'] = this.sellerid;
    data['class_name'] = this.className;
    data['class_label'] = this.classLabel;
    data['order'] = this.order;
    data['status'] = this.status;
    data['class_type'] = this.classType;
    data['allSum'] = this.allSum;
    if (this.cookbooklist != null) {
      data['cookbooklist'] = this.cookbooklist.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class MenuSunModel {
  String id;
  String sellerid;
  String mid;
  String cid;
  String lid;
  String unit;
  String name;
  String price;
  String member_price;
  String first_name;
  String search_code;
  String channel;
  String dishesvideo;
  String dishesgif;
  String status;

  String setup;
  String give;
  String clear_num;
  String record_num;
  String image;
  String is_weigh;
  String desc;
  String order_o;
  String cdate;
  List spec;
  int isSpec;
  List practice;
  List<MenuModel> cookList;

  int amount; //菜品数量

  TextEditingController amountC = TextEditingController();
  int moreSum = 0; //排菜编辑页展示选中总数

  MenuSunModel(
      {this.id,
      this.sellerid,
      this.mid,
      this.cid,
      this.lid,
      this.unit,
      this.name,
      this.price,
      this.member_price,
      this.first_name,
      this.search_code,
      this.channel,
      this.dishesvideo,
      this.dishesgif,
      this.status,
      this.setup,
      this.give,
      this.clear_num,
      this.record_num,
      this.image,
      this.is_weigh,
      this.desc,
      this.order_o,
      this.cdate,
      this.spec,
      this.isSpec,
      this.practice,
      this.amount = 0,
      this.cookList,
      this.amountC});

  MenuSunModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    sellerid = json['sellerid'];
    mid = json['mid'];
    lid = json['lid'];
    unit = json['unit'];
    name = json['name'];
    price = json['price'];
    member_price = json['member_price'] ?? json['price'];
    first_name = json['first_name'];
    search_code = json['search_code'];
    channel = json['channel'];
    dishesvideo = json['dishesvideo'];
    dishesgif = json['dishesgif'];
    status = json['status'];
    setup = json['setup'];
    give = json['give'];
    clear_num = json['clear_num'];
    record_num = json['record_num'];
    image = json['image'];
    is_weigh = json['is_weigh'];
    desc = json['desc'];
    order_o = json['order_o'];
    cdate = json['cdate'];
    spec = json['spec'];
    isSpec = json['isSpec'];
    practice = json['practice'];
    amount = 0;
    amountC.text = '0';
    if (json['cookList'] != null) {
      cookList = [];
      json['cookList'].forEach((v) {
        cookList.add(new MenuModel.fromJson2(v));
      });
    }
  }

  MenuSunModel.fromJson3(Map<String, dynamic> json) {
    id = json['id'];
    sellerid = json['sellerid'];
    mid = json['mid'];
    lid = json['lid'];
    unit = json['unit'];
    name = json['name'];
    price = json['price'];
    member_price = json['member_price'];
    first_name = json['first_name'];
    search_code = json['search_code'];
    channel = json['channel'];
    dishesvideo = json['dishesvideo'];
    dishesgif = json['dishesgif'];
    status = json['status'];
    setup = json['setup'];
    give = json['give'];
    clear_num = json['clear_num'];
    record_num = json['record_num'];
    image = json['image'];
    is_weigh = json['is_weigh'];
    desc = json['desc'];
    order_o = json['order_o'];
    cdate = json['cdate'];
    spec = json['spec'];
    isSpec = json['isSpec'];
    practice = json['practice'];
    amount = 0;
    amountC.text = '0';
    if (json['cookList'] != null) {
      cookList = [];
      json['cookList'].forEach((v) {
        cookList.add(v);
      });
    }
  }

  MenuSunModel.fromJson2(Map<String, dynamic> json) {
    id = json['id'];
    sellerid = json['sellerid'];
    mid = json['mid'];
    lid = json['lid'];
    unit = json['unit'];
    name = json['name'];
    price = json['price'];
    member_price = json['member_price'];
    first_name = json['first_name'];
    search_code = json['search_code'];
    channel = json['channel'];
    dishesvideo = json['dishesvideo'];
    dishesgif = json['dishesgif'];
    status = json['status'];
    setup = json['setup'];
    give = json['give'];
    clear_num = json['clear_num'];
    record_num = json['record_num'];
    image = json['image'];
    is_weigh = json['is_weigh'];
    desc = json['desc'];
    order_o = json['order_o'];
    cdate = json['cdate'];
    spec = json['spec'];
    isSpec = json['isSpec'];
    practice = json['practice'];
    amount = json['amount'] ?? 0;
    amountC.text = amount.toString();
    if (json['cookList'] != null) {
      cookList = [];
      json['cookList'].forEach((v) {
        cookList.add(new MenuModel.fromJson2(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['sellerid'] = this.sellerid;
    data['mid'] = this.mid;
    data['lid'] = this.lid;
    data['unit'] = this.unit;
    data['name'] = this.name;
    data['price'] = this.price;
    data['member_price'] = this.member_price;
    data['first_name'] = this.first_name;
    data['search_code'] = this.search_code;
    data['channel'] = this.channel;
    data['dishesvideo'] = this.dishesvideo;
    data['dishesgif'] = this.dishesgif;
    data['status'] = this.status;
    data['setup'] = this.setup;
    data['give'] = this.give;
    data['clear_num'] = this.clear_num;

    data['record_num'] = this.record_num;
    data['image'] = this.image;
    data['is_weigh'] = this.is_weigh;
    data['desc'] = this.desc;
    data['order_o'] = this.order_o;
    data['cdate'] = this.cdate;
    data['spec'] = this.spec;
    data['isSpec'] = this.isSpec;
    data['practice'] = this.practice;
    data['amount'] = this.amount;
    data['cookList'] = this.cookList;
    return data;
  }
}