cookbook_model.dart
15.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
import 'package:flutter/material.dart';
import 'package:one_key/models/radio_model.dart';
import 'package:one_key/utils/utils.dart';
import 'dart:convert' as convert;
///菜单
class MenuModel {
String id;
String sellerid;
String className;
dynamic classLabel;
String order;
String status;
String classType;
List<MenuSunModel> cookbooklist;
int allSum; //总共选中菜数量
bool isChange = false; //是否发生数量变化
List<dynamic> cookbooklistShow;
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<SpecModel> spec;
int isSpec;
List<PracticeModel> practice;
List<MenuModel> cookList;
int amount; //菜品数量
TextEditingController amountC = TextEditingController();
int moreSum = 0; //排菜编辑页展示选中总数
// String nameType = '3'; //1左侧,2右侧,3顶部分开
// String imageType = '1'; //1大图,2小图
int sort;
int indexNew;
String taste;
String cooks;
DishCookStyle cookStyle;
//名称样式选择数组
List<RadioModel> get nameTypeList {
RadioModel radioModel1 = RadioModel();
radioModel1.title = '菜品名称(味型/烹调)及价格在顶部左侧';
radioModel1.code = '1';
radioModel1.select = cookStyle.nameType == radioModel1.code ? true : false;
RadioModel radioModel2 = RadioModel();
radioModel2.title = '菜品名称(味型/烹调)及价格在顶部右侧';
radioModel2.code = '2';
radioModel2.select = cookStyle.nameType == radioModel2.code ? true : false;
RadioModel radioModel3 = RadioModel();
radioModel3.title = '菜品名称(味型/烹调)及价格在顶部分开';
radioModel3.code = '3';
radioModel3.select = cookStyle.nameType == radioModel3.code ? true : false;
return [radioModel1, radioModel2, radioModel3];
}
//图片样式选择数组
List<RadioModel> get imageTypeList {
RadioModel radioModel1 = RadioModel();
radioModel1.title = '大图展示菜品';
radioModel1.code = '1';
radioModel1.select = cookStyle.imageType == radioModel1.code ? true : false;
RadioModel radioModel2 = RadioModel();
radioModel2.title = '小图展示菜品';
radioModel2.code = '2';
radioModel2.select = cookStyle.imageType == radioModel2.code ? true : false;
return [radioModel1, radioModel2];
}
//图片移动数组
List<RadioModel> get moveList {
RadioModel radioModel1 = RadioModel();
radioModel1.title = '菜品向上移动一个';
radioModel1.code = '1';
radioModel1.select = false;
RadioModel radioModel2 = RadioModel();
radioModel2.title = '菜品向下移动一个';
radioModel2.code = '2';
radioModel2.select = false;
return [radioModel1, radioModel2];
}
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,
this.sort,
this.taste,
this.cooks,
this.cookStyle});
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'];
if (json['spec'] != null) {
spec = [];
json['spec'].forEach((v) {
spec.add(new SpecModel.fromJson(v));
});
}
isSpec = json['isSpec'];
// practice = json['practice'];
if (json['practice'] != null) {
practice = [];
// if (json['practice'].length > 0 && json['practice'][0] is String) {
// } else {
json['practice'].forEach((v) {
if (v is Map) {
practice.add(new PracticeModel.fromJson(v));
} else if (v is PracticeModel) {
practice.add(v);
}
});
// }
}
amount = 0;
amountC.text = '0';
if (json['cookList'] != null) {
cookList = [];
json['cookList'].forEach((v) {
cookList.add(new MenuModel.fromJson2(v));
});
}
// imageType = Utils.randomGet(1, 3) ?? '1';
// nameType = Utils.randomGet(1, 4) ?? '3';
// imageType = name == '小炒肉' || name == '水煮肉片' || name == '西湖牛肉羹' ? '2' : '1';
// nameType = '1';
sort = json['sort'];
taste = json['taste'];
cooks = json['cooks'];
json['cook_style'] != null && json['cook_style'] != ''
? cookStyle = DishCookStyle.fromJson(json['cook_style'] is Map
? json['cook_style']
: convert.json.decode(json['cook_style']))
: cookStyle = DishCookStyle.fromJson({
// 'image_type': image != null && image != '' ? '1' : '2',
'image_type': '1',
'name_type': '3'
});
}
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'];
if (json['spec'] != null) {
spec = [];
json['spec'].forEach((v) {
spec.add(new SpecModel.fromJson(v));
});
}
isSpec = json['isSpec'];
// practice = json['practice'];
if (json['practice'] != null) {
practice = [];
// if (json['practice'].length > 0 && json['practice'][0] is String) {
// } else {
json['practice'].forEach((v) {
if (v is Map) {
practice.add(new PracticeModel.fromJson(v));
} else if (v is PracticeModel) {
practice.add(v);
}
});
// }
}
amount = 0;
amountC.text = '0';
if (json['cookList'] != null) {
cookList = [];
json['cookList'].forEach((v) {
cookList.add(v);
});
}
taste = json['taste'];
cooks = json['cooks'];
json['cook_style'] != null && json['cook_style'] != ''
? cookStyle = DishCookStyle.fromJson(json['cook_style'] is Map
? json['cook_style']
: convert.json.decode(json['cook_style']))
: cookStyle = DishCookStyle.fromJson({
// 'image_type': image != null && image != '' ? '1' : '2',
'image_type': '1',
'name_type': '3'
});
}
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'];
if (json['spec'] != null) {
spec = [];
json['spec'].forEach((v) {
spec.add(new SpecModel.fromJson(v));
});
}
isSpec = json['isSpec'];
// practice = json['practice'];
if (json['practice'] != null) {
practice = [];
// if (json['practice'].length > 0 && json['practice'][0] is String) {
// } else {
json['practice'].forEach((v) {
if (v is Map) {
practice.add(new PracticeModel.fromJson(v));
} else if (v is PracticeModel) {
practice.add(v);
}
});
// }
}
amount = json['amount'] ?? 0;
amountC.text = amount.toString();
if (json['cookList'] != null) {
cookList = [];
json['cookList'].forEach((v) {
cookList.add(new MenuModel.fromJson2(v));
});
}
taste = json['taste'];
cooks = json['cooks'];
json['cook_style'] != null && json['cook_style'] != ''
? json['cook_style'] is DishCookStyle
? json['cook_style']
: cookStyle = DishCookStyle.fromJson(json['cook_style'] is Map
? json['cook_style']
: convert.json.decode(json['cook_style']))
: cookStyle = DishCookStyle.fromJson({
// 'image_type': image != null && image != '' ? '1' : '2',
'image_type': '1',
'name_type': '3'
});
}
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;
data['sort'] = this.sort;
data['taste'] = this.taste;
data['cooks'] = this.cooks;
data['cook_style'] = this.cookStyle;
return data;
}
}
class SpecModel {
String id;
String cid;
String specid;
String specs;
String price;
String memberPrice;
Null clearNum;
String status;
SpecModel(
{this.id,
this.cid,
this.specid,
this.specs,
this.price,
this.memberPrice,
this.clearNum,
this.status});
SpecModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
cid = json['cid'];
specid = json['specid'];
specs = json['specs'];
price = json['price'];
memberPrice = json['member_price'];
clearNum = json['clear_num'];
status = json['status'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['cid'] = this.cid;
data['specid'] = this.specid;
data['specs'] = this.specs;
data['price'] = this.price;
data['member_price'] = this.memberPrice;
data['clear_num'] = this.clearNum;
data['status'] = this.status;
return data;
}
}
class PracticeModel {
String id;
String cid;
String practice;
String name;
String price;
String memberPrice;
PracticeModel(
{this.id,
this.cid,
this.practice,
this.name,
this.price,
this.memberPrice});
PracticeModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
cid = json['cid'];
practice = json['practice'];
name = json['name'];
price = json['price'];
memberPrice = json['member_price'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['cid'] = this.cid;
data['practice'] = this.practice;
data['name'] = this.name;
data['price'] = this.price;
data['member_price'] = this.memberPrice;
return data;
}
}
class DishCookStyle {
String imageType; //1大图,2小图
String nameType; //1左侧,2右侧,3顶部分开
DishCookStyle({this.imageType, this.nameType});
DishCookStyle.fromJson(Map<String, dynamic> json) {
imageType = json['image_type'];
nameType = json['name_type'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['image_type'] = this.imageType;
data['name_type'] = this.nameType;
return data;
}
}