selectByCondition 服务


//sql查询语句
var countSql = 'SELECT * FROM `tbl_DataTable_005_md_cus`';
// sql语句拼接;
function getSqlParam(sql, params) {
    var arr = [];
    var whereParam = '';
    for (var key in params) {
        if (params.hasOwnProperty(key)) {
            var element = params[key];
            log.debug("countData", element);
            if(element != null) {
                arr.push('`' + key + '` = "' + element + '"');
            }
        }
    }
    if (arr.length) {
        whereParam = ' where ' + arr.join(' and ');
    };
    return sql + whereParam;
}
log.debug("zhong_wen_qch", zhong_wen_qch);
// sql过滤条件,空处理;
countSql = getSqlParam(countSql, {
    zhong_wen_qch: zhong_wen_qch || null,
    sys_org_code: sys_org_code || null,
    sys_company_code: sys_company_code || null,
    ke_hu_bian_ma: ke_hu_bian_ma || null
});
// 调试sql;
log.debug("zhong_wen_qch", zhong_wen_qch)

var countParam = {
    "sql": countSql
};
var countInput = {
    input: JSON.stringify(countParam)
};
// 核心:调用DeviceTable下的querySQLExec服务,入参为sql;
var countData = ObjectPool.get("DataTable_005").executeService("querySQLExec", countInput);
log.debug("countData", countData);
// countData转化成table控件格式;
function tableDataProcess(tableData) {
    var error = tableData.error;
    if (error == "true") {
        return {};
    }
    var total = tableData.total || 0;
    var data = tableData.data;
    var list = data.dataSource;
    var pagination = {
       current: page || 1,
       pageSize: per_page || 20,
       total: total
    };
    var rows = {
       list: list,
       pagination: pagination
    }
    return rows;
};

var result = tableDataProcess(countData);
result;

关联文章

APP集成案例之WMS ∣ 步骤一:创建对象模型

APP集成案例之WMS ∣ 步骤二:列表页面

APP集成案例之WMS ∣ 步骤三:增加列表记录

APP集成案例之WMS ∣ 步骤四:编辑列表记录

APP集成案例之WMS ∣ 步骤五:删除列表记录