import 'package:liftmanager/common/common.dart';

class ProjectListEntity {

	int pageNum;
	int pageCount;
	int total;
	int pageSize;
	bool hasNext;
	bool hasPrev;
	List<ProjectListItem> rows;

	ProjectListEntity.fromJsonMap(Map<String, dynamic> map):
				pageNum = map["pageNum"],
				pageCount = map["pageCount"],
				total = map["total"],
				pageSize = map["pageSize"],
				hasNext = map["hasNext"],
				hasPrev = map["hasPrev"],
				rows = List<ProjectListItem>.from(map["rows"].map((it) => ProjectListItem.fromJsonMap(it??{})));

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		data['pageNum'] = pageNum;
		data['pageCount'] = pageCount;
		data['total'] = total;
		data['pageSize'] = pageSize;
		data['hasNext'] = hasNext;
		data['hasPrev'] = hasPrev;
		data['rows'] = rows != null ?
		this.rows.map((v) => v.toJson()).toList()
				: null;
		return data;
	}
}


class ProjectListItem {
	String projectId;
	String projectName;
	String projectCode;
	int projectUsage;
	String address;
	String actualNum;
	String province;
	String city;
	String district;
	String startDate;
	String endDate;
	String companyName;
	String companyContact;
	String telephone;
	String areaDirector;
	String areaName;
	String regionId;
	String clerkName;

	getProjectUsageName(){
		try{
			return Constant.projectUsageText[projectUsage];
		}catch(e){
			return "";
		}

	}
	ProjectListItem.fromJsonMap(Map<String, dynamic> map):
				projectId = map["projectId"]??"",
				projectName = map["projectName"]??"",
				projectCode = map["projectCode"]??"",
				projectUsage = map["projectUsage"]??0,
				address = map["address"]??"",
				actualNum = map["actualNum"].toString()??"",
				province = map["province"]??"",
				city = map["city"]??"",
				district = map["district"]??"",
				startDate = map["startDate"]??"",
				endDate = map["endDate"]??"",
				companyName = map["companyName"]??"",
				companyContact = map["companyContact"]??"",
				telephone = map["telephone"]??"",
				areaDirector = map["areaDirector"]??"",
				areaName = map["areaName"]??"",
				regionId = map["regionId"]??"",
				clerkName = map["clerkName"]??"";

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		data['projectName'] = projectName;
		data['projectUsage'] = projectUsage;
		data['address'] = address;
		data['actualNum'] = actualNum;
		data['province'] = province;
		data['city'] = city;
		data['district'] = district;
		data['startDate'] = startDate;
		data['endDate'] = endDate;
		data['companyName'] = companyName;
		data['companyContact'] = companyContact;
		data['telephone'] = telephone;
		data['areaDirector'] = areaDirector;
		data['areaName'] = areaName;
		data['regionId'] = regionId;
		data['clerkName'] = clerkName;
		return data;
	}


}
