
var options = {
	style: {
		"task-list-header-label": {
			"text-align": "center",
			"width": "100%"
		},
		"task-list-item-value-container": {
			"width": "100%"
		},
		"chart-row-project": {
			"cursor": "pointer"
		},
		"chart-row-milestone": {
			"cursor": "pointer"
		},
		"chart-row-task": {
			"cursor": "pointer"
		}
	},
	title: {
		label: "标题",
		html: false,
	},
	taskList: {
		columns: [
			{
				id: 1,
				label: "类型",
				value: (task) => task.type=="project"?"项目":task.type=="milestone"?"WBS":task.type=="task"?"作业计划":"",
				width: 70
			}, {
				id: 2,
				label: "名称",
				value: 'label',
				width: 200,
				expander: true,
				html: true
			}, {
				id: 4,
				label: "开始日期",
				value: (task) => task.startDate.format("YYYY-MM-DD"),
				width: 80
			}, {
				id: 5,
				label: "工期",
				value: (task) => (task.duration/(24*60*60)).toFixed(2)+"天",
				width: 90
			}, {
				id: 6,
				label: "进度",
				value: (task) => task.progress.toFixed(2)+"%",
				width: 70
			}
		]
	},
	scope: {
		before: 10,
		after: 10
	},
	calendar: {
		hour: {
			display: false,
		}
	},
	locale: {
		code: "zh",
		weekdays: "星期天_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),
		months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_")
	}
};

var cc_gantt_model;

var app = GanttElastic.mount({
	el: "#gantt",
	tasks: [],
	options: options,
	ready(ganttInstance) {
		console.log("ready!", ganttInstance);
		ganttInstance.$on('chart-project-click', ({ event, data }) => {
			console.log('项目鼠标点击', { event, data });
			
			if (cc_gantt_model){
				cc_gantt_model.invoke("GanttChartEventProjectClick",data.pkID);
			}
		});
		ganttInstance.$on('chart-milestone-click', ({ event, data }) => {
			console.log('里程碑鼠标点击', { event, data });
			
			if (cc_gantt_model){
				cc_gantt_model.invoke("GanttChartEventWBSClick",data.pkID);
			}
		});
		ganttInstance.$on("chart-task-click", ({ event, data }) => {
			console.log("任务鼠标点击", { event, data });
			
			if (cc_gantt_model){
				cc_gantt_model.invoke("GanttChartEventOperationPlanClick",data.pkID);
			}
		});
		ganttInstance.$on("chart-project-mouseover", ({ event, data }) => {
			console.log("项目鼠标悬停", { event, data });
			
			if (cc_gantt_model){
				//cc_gantt_model.invoke("GanttChartEventProjectMouseover",data.pkID);
			}
		});
		ganttInstance.$on("chart-milestone-mouseover", ({ event, data }) => {
			console.log("里程碑鼠标悬停", { event, data });
			
			if (cc_gantt_model){
				//cc_gantt_model.invoke("GanttChartEventWBSMouseover",data.pkID);
			}
		});
		ganttInstance.$on("chart-task-mouseover", ({ event, data }) => {
			console.log("任务鼠标悬停", { event, data });
			
			if (cc_gantt_model){
				//cc_gantt_model.invoke("GanttChartEventOperationPlanMouseover",data.pkID);
			}
		});
		ganttInstance.$on('taskList-project-click', ({ event, data, column }) => {
			console.log('项目鼠标点击', { event, data, column });
		});
		ganttInstance.$on('taskList-milestone-click', ({ event, data, column }) => {
			console.log('里程碑鼠标点击', { event, data, column });
		});
		ganttInstance.$on('taskList-task-click', ({ event, data, column }) => {
			console.log('任务鼠标点击', { event, data, column });
		});
		ganttInstance.$on("times-timeZoom-change", (event) => {
			console.log("时间精度缩放", event);
		});
	}
});