-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.html
More file actions
587 lines (574 loc) · 15.3 KB
/
base.html
File metadata and controls
587 lines (574 loc) · 15.3 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
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="/socket.io/socket.io.js"></script>
<script src="client/util/js/util.js"></script>
<script src="client/util/js/common.js"></script>
<script src="client/util/js/lib/tpl.js"></script>
<script src="client/util/js/components/popup.js"></script>
<script src="client/util/js/components/grid.js"></script>
<script src="client/util/js/components/tree.js"></script>
<script src="client/util/js/components/nestedList.js"></script>
<script src="client/util/js/components/chart/base.js"></script>
<script src="client/util/js/components/alert.js"></script>
<script src="client/util/js/components/chart/histogram.js"></script>
<script src="client/util/js/components/chart/line.js"></script>
<script src="client/util/js/components/chart/pie.js"></script>
<link href="client/util/css/base.css" rel="stylesheet">
<link href="client/util/css/grid.css" rel="stylesheet">
<link href="client/util/css/tree.css" rel="stylesheet">
<link href="client/util/css/pop.css" rel="stylesheet">
<link href="client/util/css/alert.css" rel="stylesheet">
<link href="client/util/css/common.css" rel="stylesheet">
<link href="client/util/css/nestedList.css" rel="stylesheet">
<link href="client/util/css/chart/line.css" rel="stylesheet">
</head>
<body>
<header>
<div class="header">addison system</div>
<nav class="">
<ul>
<li>点餐系统</li>
<li class="change-theme">更换主题
<ul class="theme-ul"></ul>
</li>
</ul>
</nav>
</header>
<aside class="left">
</aside>
<article class="right">
</article>
<footer>
</footer>
<script>
var socket = io.connect(msj.ip);
var role = msj.role, events = msj.et;
var ws = msj.webServices;
var me = {
role: role.base,
id: Math.random() * 1989
};
var line, histogram, grid;
//页面枚举
var pageName = {
realTime: 'rt',
made: 'made',
history: 'history',
analysisHistogram: 'analysisHistogram',
analysisLine: 'analysisLine'
}
//左侧菜单初始化数据
var data = [
{
node: '功能',
items: [
{
text: '当前账单',
name: pageName.realTime
},
{
text: '菜已做完',
name: pageName.made
},
{
text: '历史记录',
name: pageName.history
}
]
},
{
node: '统计',
items: [
{
text: '柱状图',
name: pageName.analysisHistogram
},
{
text: '折线图',
name: pageName.analysisLine
}
]
},
{
node: '账户管理',
items: [
{
text: '个人资料',
name: pageName.analysisHistogram
},
{
text: '密码管理',
name: pageName.analysisLine
}
]
}
]
//主题枚举
var bc = {
lightBlue: 'c-lightblue',
darkRed: 'c-darkred',
silver: 'c-silver',
origin: 'c-origin',
darkBlue: 'c-darkblue'
}
var theme = localStorage.getItem('theme') || bc.darkBlue;
//发送登陆事件
socket.emit(events.login, me);
//登陆成功回调
socket.on(events.loginSuccess, function (o) {
if (o.id == me.id) {
console.log('login success');
grid = new Grid({
parent: '.right',
title: '报表数据',
baseColor: theme,
fields: [
{en: 'did', cn: '桌号', sort: true},
{en: 'order', cn: '菜单', items: [
{en: 'text', cn: '菜名'},
{en: 'count', cn: '份数'},
{en: 'value', cn: '价钱'},
{en: 'sum', cn: '总价'},
{en: 'statues', cn: '状态'}
]},
{en: 'price', cn: '总价', sum: true, sort: true},
{en: 'time', cn: '时间', sort: true},
{en: 'statues', cn: '状态', isHide: true},
{ en: 'id', cn: '', isHide: true},
{en: 'operate', cn: '操作', buttons: [
{
text: '付款',
id: 'g-pay',
click: function (id) {
socket.emit(events.pay, id, function () {
console.log(arguments);
});
},
require: 'id'
}
]}
],
data: {list: []},
isToolBar: false,
isTitle: false,
height: 500,
width: 1000,
//是否启用多选
isMulti: false,
page: {
count: 8
},
popup: new popup({
tpl: msj.tpl.popup,
listTpl: msj.tpl.popList,
listContainer: '.order-list-body',
baseColor: theme,
data: {list: [
{text: 'asd'},
{text: '333'}
]},
btn: {
parent: '.btn-c',
buttons: [
{
text: '添加',
cls: 'add',
events: {
click: function (e) {
//this is popup object
var data = [];
Array.prototype.forEach.call(this.nestedList.el.querySelectorAll('.nested-selected'), function (item) {
data.push({
text: item.childNodes[0].innerHTML,
value: item.childNodes[1].innerHTML,
count: 1,
sum: item.childNodes[1].innerHTML * 1
})
})
this.updataList(data, true);
}
}
},
{
text: '提交数据',
cls: 'pop-submit',
events: {
click: function (e) {
socket.emit(events.changeList, this.changeList);
}
}
},
{
text: '取消',
cls: 'cancel',
events: {
click: function (e) {
this.hide();
}
}
}
]},
events: {
rendered: function () {
this.nestedList = new NestedList({
tpl: msj.tpl.d,
data: [
{
text: '凉菜',
tpl: msj.tpl.e,
items: [
{text: '茴香花生米', price: '10'},
{text: '老醋花生米', price: '11'},
{text: '炝干豆丝', price: '10'},
{text: '炝土豆丝', price: '10'},
{text: '红油肚丝', price: '20'},
{text: '辣拌鸡胗', price: '24'},
{text: '拍黄瓜', price: '10'},
{text: '老虎菜', price: '10'},
{text: '大拉皮', price: '14'},
{text: '三河豆腐丝', price: '10'},
{text: '皮蛋豆腐', price: '8'},
{text: '辣根木耳', price: '12'},
{text: '炝金针蘑瓜丝', price: '18'},
{text: '肉丝拌粉条', price: '18'}
]
},
{
text: '饺子',
tpl: msj.tpl.e,
child: [
{
text: '素馅水饺',
tpl: msj.tpl.e,
items: [
{text: '韭菜鸡蛋', price: '8'},
{text: '小白菜鸡蛋', price: '10'},
{text: '素三鲜(木耳,虾仁,鸡蛋)', price: '16'},
{text: '黄瓜鸡蛋', price: '10'},
{text: '西红柿鸡蛋', price: '12'},
{text: '青椒鸡蛋', price: '10'},
{text: '平菇玉米粒鸡蛋', price: '12'},
{text: '茴香鸡蛋', price: '10'}
]
},
{
text: '猪肉水饺',
tpl: msj.tpl.e,
items: [
{text: '猪肉白菜', img: '', price: '8'},
{text: '猪肉芹菜', img: '', price: '10'},
{text: '猪肉酸菜', img: '', price: '10'},
{text: '猪肉茴香', img: '', price: '10'},
{text: '猪肉韭菜', price: '10'},
{text: '猪肉香菇', price: '12'},
{text: '猪肉青椒', price: '10'},
{text: '猪肉大葱', price: '12'},
{text: '肉三鲜(虾仁,鲜贝,猪肉)', price: '28'}
]
},
{
text: '鸡肉水饺',
tpl: msj.tpl.e,
items: [
{text: '马蹄玉米粒', price: '18'},
{text: '鸡肉韭菜', price: '16'}
]
},
{
text: '牛肉水饺',
tpl: msj.tpl.e,
items: [
{text: '牛肉萝卜', price: '16'},
{text: '牛肉胡萝卜', price: '16'},
{text: '牛肉韭菜', price: '18'},
{text: '牛肉大葱', price: '18'},
{text: '牛肉西红柿', price: '18'}
]
},
{
text: '羊驴肉水饺',
tpl: msj.tpl.e,
items: [
{text: '羊肉胡萝卜', price: '22'},
{text: '羊肉香菜', price: '26'},
{text: '羊肉洋葱', price: '26'},
{text: '羊肉大葱', price: '26'},
{text: '驴肉葱花', price: '18'}
]
}
]
},
{
text: '干锅',
tpl: msj.tpl.e,
items: [
{text: '干锅娃娃菜', price: '18'},
{text: '干锅茶树菇', price: '24'},
{text: '干锅土豆片', price: '18'}
]
},
{
text: '热菜',
tpl: msj.tpl.e,
items: [
{text: '爆炒圆白菜', price: '16'},
{text: '韭菜炒鸡蛋', price: '10'},
{text: '木耳炒白菜片', price: '10'},
{text: '青椒丝炒肉丝', price: '20'},
{text: '宫保鸡丁', price: '20'},
{text: '小炒肉', price: '20'},
{text: '杭椒牛柳', price: '38'},
{text: '干煸豆角', price: '18'},
{text: '炒肉木耳', price: '24'},
{text: '家常炖豆腐', price: '16'},
{text: '毛血旺', price: '26'},
{text: '鱼香茄子', price: '18'},
{text: '尖椒炒肉', price: '20'},
{text: '溜豆腐', price: '20'},
{text: '酱炖大豆腐', price: '18'},
{text: '滑子蘑炒肉', price: '22'},
{text: '杏鲍菇炒肉', price: '24'},
{text: '酸辣土豆丝', price: '12'},
{text: '苦瓜煎蛋', price: '16'},
{text: '啤酒地瓜条', price: '26'},
{text: '麻辣豆腐', price: '14'},
{text: '土豆片炖豆腐', price: '18'},
{text: '熘肝尖', price: '20'},
{text: '回锅肉', price: '32'},
{text: '红烧排骨', price: '48'},
{text: '溜肥肠', price: '38'},
{text: '尖椒护心肉', price: '38'},
{text: '小鸡炖蘑菇', price: '38'},
{text: '木须肉', price: '20'},
{text: '锅包肉', price: '32'},
{text: '酱腔骨', price: '48'},
{text: '尖椒干豆腐', price: '14'},
{text: '地三鲜', price: '18'},
{text: '鱼香肉丝', price: '18'},
{text: '乡村扒茄子', price: '18'},
{text: '酸菜粉', price: '16'},
{text: '芹菜粉', price: '16'},
{text: '京酱肉丝', price: '20'},
{text: '烧茄子', price: '16'},
{text: '红烧排骨土豆玉米', price: '48'},
{text: '大丰收', price: '68'},
{text: '溜肉段', price: '32'},
{text: '肉段烧茄子', price: '26'},
{text: '得莫利炖鱼', price: '48'},
{text: '红烧鲤鱼', price: '38'},
{text: '猪肉炖粉条', price: '28'},
{text: '糖醋里脊', price: '32'},
{text: '猪头酸菜炖粉条', price: '28'}
]
}
],
parent: this.el,
height: '130px',
width: '400px'
}).render();
}
}
})
});
init();
}
});
//接客
socket.on(events.addDesk, function (desk) {
if (Object.prototype.toString.call(desk) == '[object Object]') {
desk = [desk];
}
var data = [];
for (var i = 0, len = desk.length; i < len; i++) {
(function (index) {
var d = desk[index];
var o = {did: 0, order: '', price: 0};
o.did = d.dn;
o.data = d.data.list;
o.statues = d.statues;
o.id = d._id;
o.time = msj.getDate(d.date);
var detail = d.data.list;
for (var j = 0, l = detail.length; j < l; j++) {
(function (jj) {
o.price += parseInt(detail[jj].sum);
}(j))
}
data.push(o);
}(i))
}
grid.addData(data);
});
//付款
socket.on(events.pay, function (data) {
if (data.success) {
grid.updateSingleData(data.id, {
statues: 'pay'
})
setTimeout(function () {
grid.delData(data.id, true);
}, 3000);
}
})
// 菜单制作完成,删除菜单
socket.on(events.makeOver, function (data) {
if (data.success) {
grid.updateSingleData(data.id, data.data, function () {
setTimeout(function () {
grid.delData(data.id, true);
}, 3000)
});
}
})
//修改菜单
socket.on(events.changeList, function (data) {
if (data.success) {
console.log(data);
grid.popup.refreshChangeList().hide();
grid.update();
} else {
console.log(data.msg);
}
})
//一个菜完成
socket.on(events.oneOk, function (data) {
if (data.success) {
var d = grid.getDataById(data.one.id);
for (var i = 0; i < d.data.length; i++) {
var obj = d.data[i];
if (obj.text == data.one.text && obj.statues != 'made') {
obj.statues = 'made';
break;
}
}
grid.updateSingleData(data.one.id, d);
new alert({
time: 5000,
text: d.did + '号桌,' + data.one.text + '已经做好'
}).render();
}
})
//初始化左侧导航
window.left = new Tree({
data: data,
parent: '.left',
baseColor: theme,
isDrag: false,
leafClick: function (e) {
var name = e.target.getAttribute('data-name');
location.hash = 'page=' + name;
}
});
//处理功能模块切换
window.onhashchange = function (e) {
init();
}
function init() {
document.querySelector('nav').className = theme;
if (location.href.indexOf('#') == -1) {
location.href = location.href + '#statues=' + pageName.realTime;
}
var page = location.hash.split('=')[1];
grid.page.ci = 0;
switch (page) {
case pageName.realTime:
getData('statues=begin', function (data) {
data && grid.update(data, function () {
this.show();
});
line && line.hide();
histogram && histogram.hide();
}, true, ws.data);
break;
case pageName.made:
getData('statues=made', function (data) {
data && grid.update(data, function () {
this.show();
});
line && line.hide();
histogram && histogram.hide();
}, true, ws.data);
break;
case pageName.history:
getData('statues=end', function (data) {
data && grid.update(data, function () {
//this is grid
this.show();
});
line && line.hide();
histogram && histogram.hide();
}, true, ws.data)
break;
case pageName.analysisHistogram:
if (!histogram) {
histogram = new Histogram({
label: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
data: randomData(12),
title: '流水报表',
height: 400,
width: 500,
container: '.right',
isQuery: true
})
} else {
histogram.reDraw(randomData(12), true);
}
histogram && histogram.show();
grid && grid.hide();
line && line.hide();
break;
case pageName.analysisLine:
grid.hide();
if (!line) {
line = new Line({
container: '.right',
label: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
data: randomData(12),
title: 'asd',
height: 400,
width: 500,
isQuery: true
})
} else {
line.reDraw(randomData(12), true);
}
histogram && histogram.hide();
grid && grid.hide();
line && line.show();
break;
default :
break;
}
}
//主题切换
function initThemeSelect() {
var html = []
for (var i in bc) {
html.push('<li class="' + bc[i] + '">' + i + '</li>');
}
var el = document.querySelector('.theme-ul');
el.innerHTML = html.join('');
el.height = el.offsetHeight;
el.style.display = 'none';
el.style.left = el.parentNode.offsetLeft + 'px';
el.style.top = '20px';
var ct = document.querySelector('.change-theme');
ct.onmouseover = function () {
el.style.display = 'block';
}
ct.onmouseout = function (e) {
el.style.display = 'none';
}
el.onclick = function (e) {
localStorage.setItem('theme', e.target.className);
el.style.display = 'none';
location.reload();
}
}
initThemeSelect();
</script>
</body>
</html>