gate.js
1.69 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
/**
* Created by LiQZ
* 开关控制
*/
module.exports=function(app) {
/* 首页 */
app.get("/operations/gate/index","operations.gate.Index", function () {
this.$extend = {
moduleName: "运营管理",
pageName: "开关控制管理"
}
});
/* 添加页面 */
app.get("/operations/gate/add","operations.gate.Edit", function () {
this.$extend = {
moduleName: "运营管理",
pageName: "开关控制管理",
action: '/operations/gate/save'
}
});
/* 编辑页面 */
app.get("/operations/gate/:id","operations.gate.Edit","gate_findGateByID", function (response) {
// 日期处理
response.data.createTimeStr = toDate(response.data.createTime);
response.data.updateTimeStr = toDate(response.data.updateTime);
// 转化成 json 页面直接获取
this.$extend = {
moduleName: "运营管理",
pageName: "开关控制管理",
action: "/operations/gate/save",
type: "update",
data: response.data
}
});
app.post("/operations/gate/list", "gate_gateList");
app.post("/operations/gate/save", "gate_gateSaveOrUpdate");
app.post("/operations/gate/delete", "gate_gateDelete");
}
function toDate(seconds) {
if (!seconds || seconds <= 0) { return ''; }
var date = new Date(seconds * 1000);
return fixTwo(date.getFullYear()) + '-' + fixTwo((date.getMonth() + 1)) + '-' + fixTwo(date.getDate()) + ' ' + fixTwo(date.getHours()) + ':' + fixTwo(date.getMinutes()) + ':' + fixTwo(date.getSeconds());
}
function fixTwo(number) {
return number < 10? "0" + number: number;
}