m_pGantt = CLuaGantUtil();
m_pGantt:SetGant(ui:getDialogName(), 'id_gantt');
function get_gird_help(helpGrid)
helpGrid:reset();
helpGrid:addField('grid_id');
helpGrid:addField('test_name1');
helpGrid:addField('test_name2');
for i=1,50 do
help_add_line(helpGrid, 'grid_'..i, 'test'..math.random(1, 99), 'test'..math.random(1, 99));
end
end
function help_add_line(help, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12)
local line = CVector();
line:push_back(s1)
while true do
if s2 == nil then break; end line:push_back(s2)
if s3 == nil then break; end line:push_back(s3)
if s4 == nil then break; end line:push_back(s4)
if s5 == nil then break; end line:push_back(s5)
if s6 == nil then break; end line:push_back(s6)
if s7 == nil then break; end line:push_back(s7)
if s8 == nil then break; end line:push_back(s8)
if s9 == nil then break; end line:push_back(s9)
if s10 == nil then break; end line:push_back(s10)
if s11 == nil then break; end line:push_back(s11)
if s12 == nil then break; end line:push_back(s12)
break;
end
help:addVectorValue(line);
end
function get_task_help(helpTask)
helpTask:reset();
helpTask:addField("task_id");
helpTask:addField("grid_id");
helpTask:addField("start_time");
helpTask:addField("end_time");
helpTask:addField("text");
helpTask:addField("bg_color");
helpTask:addField("tip");
help_add_line(helpTask, 'task_1','grid_1','2020-11-11 07:00:00', '2020-11-12 08:00:00', 'task内容', '3534663', '第一行\n第二行');
help_add_line(helpTask, 'task_2','grid_1','2020-11-14 12:00:00', '2020-11-15 08:00:00', '显示task_2', '643525234', '鼠标停靠浮窗1...');
help_add_line(helpTask, 'task_3','grid_2','2020-11-13 07:00:00', '2020-11-13 11:00:00', '显示task_3', '456745672', '鼠标停靠浮窗1...');
help_add_line(helpTask, 'task_4','grid_3','2020-11-14 07:00:00', '2020-11-14 15:00:00', '显示task_4', '182345', '鼠标停靠浮窗1...');
help_add_line(helpTask, 'task_5','grid_4','2020-11-15 07:00:00', '2020-11-15 16:00:00', '显示task_5', '196758', '鼠标停靠浮窗1...');
help_add_line(helpTask, 'task_6','grid_4','2020-11-16 07:00:00', '2020-11-16 17:00:00', '显示task_6', '9976786', '鼠标停靠浮窗1...');
help_add_line(helpTask, 'task_7','grid_3','2020-11-17 07:00:00', '2020-11-17 20:00:00', '显示task_7', '9234534', '鼠标停靠浮窗1...');
help_add_line(helpTask, 'task_8','grid_4','2020-11-18 07:00:00', '2020-11-18 22:00:00', '显示task_8', '8765832', '鼠标停靠浮窗1...');
help_add_line(helpTask, 'task_9','grid_5','2020-11-19 01:00:00', '2020-11-19 08:00:00', '显示task_9', '478563445', '鼠标停靠浮窗1...');
end
function init_gantt()
ui:setProp('id_gantt', "time_accuracy", '1');
ui:setProp('id_gantt', "split_hour", '4');
ui:setProp('id_gantt', "row_height", '30');
ui:setProp('id_gantt', "task_height", '26');
ui:setProp('id_gantt', "task_width", '120');
ui:setProp('id_gantt', "allowed_drag_horizontal", '1');
ui:setProp('id_gantt', "allowed_drag_vertical", '1');
ui:setProp('id_gantt', "mult_sel_model", '0');
end
function test_gantt_main()
init_gantt()
local helpGrid = CSelectHelp();
local helpTask = CSelectHelp();
get_gird_help(helpGrid);
get_task_help(helpTask);
m_pGantt:setGridHelp(helpGrid);
m_pGantt:setDateRange('2020-11-11', '2020-11-30');
m_pGantt:setTaskHelp(helpTask, true);
ui:addRightMenu('id_gantt', 'test_grid_header_1', '/picture/common/toolbar/com_tool_debug.png', '表头1', 0);
ui:addRightMenu('id_gantt', 'test_grid_header_2', '/picture/common/toolbar/com_tool_debug.png', '表头2', 0);
ui:addRightMenu('id_gantt', 'test_grid_1', '/picture/common/toolbar/com_tool_debug.png', '表格单元格1', 1);
ui:addRightMenu('id_gantt', 'test_grid_2', '/picture/common/toolbar/com_tool_debug.png', '表格单元格1', 1);
ui:addRightMenu('id_gantt', 'test_gantt_header_1', '/picture/common/toolbar/com_tool_debug.png', '甘特图表头1', 2);
ui:addRightMenu('id_gantt', 'test_gantt_header_2', '/picture/common/toolbar/com_tool_debug.png', '甘特图表头2', 2);
ui:addRightMenu('id_gantt', 'test_gantt_1', '/picture/common/toolbar/com_tool_debug.png', '甘特图单元格1', 3);
ui:addRightMenu('id_gantt', 'test_gantt_2', '/picture/common/toolbar/com_tool_debug.png', '甘特图单元格2', 3);
ui:addRightMenu('id_gantt', 'test_gantt_task_1', '/picture/common/toolbar/com_tool_debug.png', '甘特图task1', 4);
ui:addRightMenu('id_gantt', 'test_gantt_task_2', '/picture/common/toolbar/com_tool_debug.png', '甘特图task2', 4);
ui:setRightMenuCilckEvent('id_gantt', 'click_gantt_right_munu');
end
function click_gantt_right_munu(sCid, sMenuID)
if sMenuID == 'test_grid_1' then
elseif sMenuID == 'test_gantt_task_1' then
end
end
function click_gant_id_gantt(sCid, sType, sValue)
if sType == 'grid' then
local sGridID = sValue;
elseif sType == 'gantt' then
local sGridID = sValue;
elseif sType == 'task' then
local sTaskID = sValue;
end
end
function double_click_id_gantt(sCid, sType, sTaskID)
if sType == 'task' then
print(sTaskID)
end
end
function process_gantt_change(sCid, sCmd, itString)
if sCmd == 'move_task' then
local itTask = CIntent();
itTask:fromString(itString);
itTask:dump();
end
end
test_gantt_main();
ui:setClickEvent('id_gantt', 'click_gant_id_gantt');
ui:setDoubleClickEvent('id_gantt', 'double_click_id_gantt');
ui:setValueChangeEvent('id_gantt', 'process_gantt_change');