|
|
@ -283,9 +283,6 @@ |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import { |
|
|
|
gantt |
|
|
|
} from '@/utils/dhtmlxgantt' |
|
|
|
import moment from 'moment' |
|
|
|
import { |
|
|
|
getWorklineTree, |
|
|
@ -308,7 +305,7 @@ |
|
|
|
interrupt, |
|
|
|
} from '@/styles/variables.scss' |
|
|
|
|
|
|
|
var that |
|
|
|
var that, gantt; |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
@ -394,129 +391,134 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
var hourToStr = gantt.date.date_to_str('%H:%i') |
|
|
|
var hourRangeFormat = function (step) { |
|
|
|
return function (date) { |
|
|
|
var intervalEnd = new Date(gantt.date.add(date, step, 'hour') - 1) |
|
|
|
return hourToStr(date) + ' - ' + hourToStr(intervalEnd) |
|
|
|
} |
|
|
|
} |
|
|
|
// 获取资源 |
|
|
|
getWorklineTree().then(({ |
|
|
|
code, |
|
|
|
data |
|
|
|
}) => { |
|
|
|
if (code === 200 && Object.keys(data).length) { |
|
|
|
this.data = [data] || [] |
|
|
|
} else { |
|
|
|
this.data = [] |
|
|
|
} |
|
|
|
}) |
|
|
|
that = this |
|
|
|
this.zoomConfig = { |
|
|
|
minColumnWidth: 40, |
|
|
|
maxColumnWidth: 40, |
|
|
|
levels: [ |
|
|
|
[{ |
|
|
|
unit: 'month', |
|
|
|
format: '%Y %M', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'day', |
|
|
|
step: 1, |
|
|
|
format: function (date) { |
|
|
|
const day = moment(date).date() |
|
|
|
return `${day}日-${that.getWeek(date)}` |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'hour', |
|
|
|
step: 1, |
|
|
|
format: '%H:%i' |
|
|
|
}, |
|
|
|
], |
|
|
|
[{ |
|
|
|
unit: 'day', |
|
|
|
format: '%d %M', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'hour', |
|
|
|
format: hourRangeFormat(12), |
|
|
|
step: 12 |
|
|
|
}, |
|
|
|
], |
|
|
|
[{ |
|
|
|
unit: 'day', |
|
|
|
format: '%d %M', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'hour', |
|
|
|
format: hourRangeFormat(6), |
|
|
|
step: 6 |
|
|
|
}, |
|
|
|
], |
|
|
|
[{ |
|
|
|
unit: 'day', |
|
|
|
format: '%d %M', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'hour', |
|
|
|
format: '%H:%i', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'minute', |
|
|
|
step: 1, |
|
|
|
format: '%H:%i' |
|
|
|
let setGannt = setInterval(()=>{ |
|
|
|
if(window.gantt){ |
|
|
|
gantt=window.gantt; |
|
|
|
clearInterval(setGannt); |
|
|
|
var hourToStr = gantt.date.date_to_str('%H:%i') |
|
|
|
var hourRangeFormat = function (step) { |
|
|
|
return function (date) { |
|
|
|
var intervalEnd = new Date(gantt.date.add(date, step, 'hour') - 1) |
|
|
|
return hourToStr(date) + ' - ' + hourToStr(intervalEnd) |
|
|
|
} |
|
|
|
} |
|
|
|
// 获取资源 |
|
|
|
getWorklineTree().then(({ |
|
|
|
code, |
|
|
|
data |
|
|
|
}) => { |
|
|
|
if (code === 200 && Object.keys(data).length) { |
|
|
|
this.data = [data] || [] |
|
|
|
} else { |
|
|
|
this.data = [] |
|
|
|
} |
|
|
|
}) |
|
|
|
that = this |
|
|
|
this.zoomConfig = { |
|
|
|
minColumnWidth: 40, |
|
|
|
maxColumnWidth: 40, |
|
|
|
levels: [ |
|
|
|
[{ |
|
|
|
unit: 'month', |
|
|
|
format: '%Y %M', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'day', |
|
|
|
step: 1, |
|
|
|
format: function (date) { |
|
|
|
const day = moment(date).date() |
|
|
|
return `${day}日-${that.getWeek(date)}` |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'hour', |
|
|
|
step: 1, |
|
|
|
format: '%H:%i' |
|
|
|
}, |
|
|
|
], |
|
|
|
[{ |
|
|
|
unit: 'day', |
|
|
|
format: '%d %M', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'hour', |
|
|
|
format: hourRangeFormat(12), |
|
|
|
step: 12 |
|
|
|
}, |
|
|
|
], |
|
|
|
[{ |
|
|
|
unit: 'day', |
|
|
|
format: '%d %M', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'hour', |
|
|
|
format: hourRangeFormat(6), |
|
|
|
step: 6 |
|
|
|
}, |
|
|
|
], |
|
|
|
[{ |
|
|
|
unit: 'day', |
|
|
|
format: '%d %M', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'hour', |
|
|
|
format: '%H:%i', |
|
|
|
step: 1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
unit: 'minute', |
|
|
|
step: 1, |
|
|
|
format: '%H:%i' |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
useKey: 'ctrlKey', |
|
|
|
trigger: 'wheel', |
|
|
|
element: function () { |
|
|
|
return gantt.$root.querySelector('.gantt_task') |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
useKey: 'ctrlKey', |
|
|
|
trigger: 'wheel', |
|
|
|
element: function () { |
|
|
|
return gantt.$root.querySelector('.gantt_task') |
|
|
|
}, |
|
|
|
} |
|
|
|
gantt.config.work_time = true |
|
|
|
gantt.config.task_height = 30 |
|
|
|
gantt.config.row_height = 50 |
|
|
|
gantt.config.scale_height = 60 |
|
|
|
gantt.config.min_column_width = 40 |
|
|
|
gantt.config.show_progress = false // 隐藏进度条 |
|
|
|
gantt.config.date_format = '%Y-%m-%d %H:%i:%s' |
|
|
|
gantt.config.duration_unit = 'minute'; // 设置任务刻度 |
|
|
|
gantt.config.drag_resize = false // 禁止拉伸 |
|
|
|
gantt.config.show_links = false // 删除link线 |
|
|
|
gantt.i18n.setLocale('cn'); // 设置语言 |
|
|
|
gantt.config.readonly = true // 禁止拖动 |
|
|
|
} |
|
|
|
gantt.config.work_time = true |
|
|
|
gantt.config.task_height = 30 |
|
|
|
gantt.config.row_height = 50 |
|
|
|
gantt.config.scale_height = 60 |
|
|
|
gantt.config.min_column_width = 40 |
|
|
|
gantt.config.show_progress = false // 隐藏进度条 |
|
|
|
gantt.config.date_format = '%Y-%m-%d %H:%i:%s' |
|
|
|
gantt.config.duration_unit = 'minute'; // 设置任务刻度 |
|
|
|
gantt.config.drag_resize = false // 禁止拉伸 |
|
|
|
gantt.config.show_links = false // 删除link线 |
|
|
|
gantt.i18n.setLocale('cn'); // 设置语言 |
|
|
|
gantt.config.readonly = true // 禁止拖动 |
|
|
|
|
|
|
|
// default columns definition |
|
|
|
gantt.config.columns = [{ |
|
|
|
name: 'text', |
|
|
|
label: '流水线名称', |
|
|
|
tree: true, |
|
|
|
width: '200' |
|
|
|
}, ] |
|
|
|
// default columns definition |
|
|
|
gantt.config.columns = [{ |
|
|
|
name: 'text', |
|
|
|
label: '流水线名称', |
|
|
|
tree: true, |
|
|
|
width: '200' |
|
|
|
}, ] |
|
|
|
|
|
|
|
// 缩放时,重新注册相关事件,解决缩放时相关事件失效问题 |
|
|
|
gantt.attachEvent("onGanttScroll", function (left, top) { |
|
|
|
that.taskEventFn(); |
|
|
|
}); |
|
|
|
// 缩放时,重新注册相关事件,解决缩放时相关事件失效问题 |
|
|
|
gantt.attachEvent("onGanttScroll", function (left, top) { |
|
|
|
that.taskEventFn(); |
|
|
|
}); |
|
|
|
|
|
|
|
gantt.ext.zoom.init(this.zoomConfig); |
|
|
|
gantt.clearAll(); |
|
|
|
gantt.init('gantt-chart') |
|
|
|
gantt.ext.zoom.init(this.zoomConfig); |
|
|
|
gantt.clearAll(); |
|
|
|
gantt.init('gantt-chart') |
|
|
|
} |
|
|
|
},500) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 拖拽快管理器. |
|
|
|
// blockPool: 用于放置未定位拖拽块的元素 |
|
|
|
buildBlockManager(blockPool) { |
|
|
|
const _this = this; |
|
|
|
|
|
|
|
function addBlock() { |
|
|
|
const div = document.createElement('div') |
|
|
|
div.classList.add('block') |
|
|
|