周、月时间范围快捷查询

上一月、本月、下一月、上一周、本周、下一周等时间范围快捷查询

function click_id_tb_query()
    --查询内容
end
--快捷查询
function click_id_quick_query(cid)
    local sTime = cutil:getSys14Time();
    local sFrom = cutil:substr(ui:get('id_dt_from'),0,10)..' 00:00:00';
    local sTo = cutil:substr(ui:get('id_dt_to'),0,10)..' 23:59:59';
    local sMonthStart = cutil:substr(sFrom,0,8)..'01 00:00:00';
    local sMonthEnd = cutil:getPreDate(cutil:getNextMonth(sMonthStart),1);
    local iWeek = cutil:week(sFrom);
    local sWeekStart = cutil:getPreDate(sFrom,(iWeek-1)*86400);
    local sWeekEnd = cutil:getNextDate(sWeekStart,7*86400-1);
    local sStart = sFrom;
    local sEnd = sTo;
    if cid == 'id_pre_month' then
        sStart = cutil:getPreMonth(sMonthStart);
        sEnd = cutil:getPreDate(sMonthStart,1);
    elseif cid == 'id_cur_month' then
        sStart = cutil:substr(sTime,0,8)..'01 00:00:00';
        sEnd = cutil:getPreDate(cutil:getNextMonth(sStart),1);
    elseif cid == 'id_next_month' then
        sStart = cutil:getNextMonth(sMonthStart);
        sEnd = cutil:getPreDate(cutil:getNextMonth(sStart),1);
    elseif cid == 'id_pre_week' then
        sStart = cutil:getPreDate(sWeekStart,7*86400);
        sEnd = cutil:getPreDate(sWeekEnd,7*86400);
    elseif cid == 'id_cur_week' then
        iWeek = cutil:week(sTime);
        sStart = cutil:getPreDate(cutil:substr(sTime,0,10)..' 00:00:00',(iWeek-1)*86400);
        sEnd = cutil:getNextDate(sStart,7*86400-1);
    elseif cid == 'id_next_week' then
        sStart = cutil:getNextDate(sWeekStart,7*86400);
        sEnd = cutil:getNextDate(sWeekEnd,7*86400);
    end
    ui:set('id_dt_from', sStart);
    ui:set('id_dt_to', sEnd);
    click_id_tb_query();
end

--快捷查询 上一月,本月,下一月,上一周,本周,下一周
m_tCid = {'id_pre_month','id_cur_month','id_next_month','id_pre_week','id_cur_week','id_next_week'};
for _,v in ipairs(m_tCid) do
    ui:setClickEvent(v, 'click_id_quick_query');
end
ui:setClickEvent('id_tb_query', 'click_id_tb_query');
Copyright © TouchNet 2015 all right reserved,powered by Gitbook最后修订时间: 2022-06-21 09:21:02

results matching ""

    No results matching ""