/* 定义一些常用、通用的方法,供外部调用 -----------------------------------------------------------------------------*/ function CreateGantt() { var gantt = new PlusGantt(); //创建甘特图调度插件 new GanttSchedule(gantt); gantt.setStyle("width:800px;height:400px"); gantt.setAllowDragDrop(true); gantt.setColumns([ { header: "序号", field: "ID",width: 50 ,enterCommit: false}, // new StatusColumn(), // { header: mini.Gantt.Name_Text, field: "Name", width: 200, name: "taskname", // editor: { type: "textbox" } // }, { header: mini.Gantt.Name_Text, field: "nodeName", width: 200, name: "taskname", editor: { type: "textbox" } }, // { header: mini.Gantt.PredecessorLink_Text, field: "PredecessorLink", // editor: { // type: "textbox" // }, // oncellbeginedit: function (e) { // var table = e.source, gantt = table.owner; // var links = e.value; // e.value = gantt.getLinkString(links); // } // }, // { header: mini.Gantt.Duration_Text, field: "Duration", // editor: { // type: "spinner", minValue: 0, maxValue: 1000 // } // }, // { header: mini.Gantt.Start_Text, field: "Start", // editor: { // type: "datepicker" // } // }, { header: '计划完成时间', field: "plannedCompletionTime", editor: { type: "datepicker" } }, { header: "预计完成日期", field: "estimatedCompletionDate",enterCommit: false, editor: { type: "datepicker"} }, { header: "实际完成日期", field: "actualFinishDate", editor: { type: "datepicker" } }, { header: '状态', field: "nodeState", editor: { type: "textbox" } }, ]); //设置节点列 gantt.setTreeColumn("taskname"); gantt.on("drawcell", function (e) { // console.log(e); if (e.column.field == "Name" && e.record.Summary) { e.cellHtml = '' + e.cellHtml + ''; } // if (e.column.field == "Start" || e.column.field == "Finish") { // // var d = e.value; // // console.log(e.cellHtml); // console.log(d); // if (d) { // e.cellHtml = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate(); // } // } if (e.column.field == "plannedCompletionTime") { e.cellHtml = e.value; } if (e.column.field == "estimatedCompletionDate") { e.cellHtml = e.value; } if (e.column.field == "actualFinishDate") { e.cellHtml = e.value; } if (e.column.field == "nodeName") { e.cellHtml = e.value; } if (e.column.field == "nodeState") { e.cellHtml = e.value == 1?'进行中':e.value == 2?'逾期':e.value == 3?'正常完成':e.value == 4?'提前完成':e.value == 5?'逾期完成':''; } if (e.column.field == "PredecessorLink") { e.cellHtml = gantt.getLinkString(e.value); } }); gantt.on("drawitem", function (e) { // console.log(e); var item = e.item; var left = e.itemBox.left, top = e.itemBox.top, width = e.itemBox.width ?e.itemBox.width - 24*9:12, height = e.itemBox.height; // console.log(!item.Summary && !item.Milestone); if (!item.Summary && !item.Milestone) { var percentWidth = width * (item.PercentComplete / 100); // item.nodeState = 4 let leftColor,rightColor,contenColor,display,itemConten,itemColor; if (item.nodeState == 1){ leftColor = '#4C87FE' rightColor = '' display = 'none' itemConten = '计划完成时间' itemColor = '#4C87FE' }else if (item.nodeState == 2){ leftColor = '#4C87FE' rightColor = '' contenColor = 'rgba(255, 0, 0,0.8)' display = 'none' itemConten = '逾期' + item.deferDiffDay + '天' width = item.deferDiffDay*24 + 24 itemColor = 'rgb(255, 0, 0)' } else if (item.nodeState == 3){ leftColor = '#44D7B6' rightColor = '' display = 'none' itemConten = '任务准时完成' itemColor = '#44D7B6' }else if (item.nodeState == 4){ leftColor = '#F7D300' rightColor = '#4C87FE' contenColor = 'rgba(148, 130, 7,0.8)' display = 'inline-block' itemConten = '提前' + item.beforeCompleteDiffDay + '天完成' itemColor = '#F7D300' }else if (item.nodeState == 5){ leftColor = '#4C87FE'; rightColor = '#CD5B6E'; contenColor = 'rgba(136, 18, 31,0.8)'; display = 'inline-block'; itemConten = '逾期' + item.deferCompleteDiffDay + '天完成'; itemColor = '#CD5B6E' } let leftS // if(left + width > 200){ // leftS = left - 100 // }else { // leftS = left + width + 12 // } // console.log(leftS); e.itemHtml = '