operations.gate.js 1.69 KB
/**
 * 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;
}