| | |
| | | selectedIds: [], |
| | | // 分页相关数据 |
| | | currentPage: 1, |
| | | pageSize: 10, |
| | | pageSize: 20, |
| | | totalTasks: 0, |
| | | allTasks: [], // 存储所有任务数据 |
| | | paginatedTasks: [] // 当前页的任务数据 |
| | |
| | | // 不再对齐时间轴刻度(比如天格子),而是按“小时”对齐 |
| | | gantt.config.round_dnd_dates = false |
| | | // 最小步长还是 1 小时,但你已经从“天格子”变成“小时格子”了 |
| | | gantt.config.time_step = 60 // 60 分钟 = 1 小时 |
| | | // gantt.config.time_step = 60 // 60 分钟 = 1 小时 |
| | | gantt.config.time_step = 1 // 1分钟 |
| | | |
| | | gantt.config.row_height = 32 // 行高 |
| | | gantt.config.bar_height = 20 // bar高 |
| | |
| | | |
| | | // 是否是工作时间 |
| | | /* ↓↓↓ Working Time configuration ↓↓↓ */ |
| | | // gantt.templates.scale_cell_class = function(date) { |
| | | // if (!gantt.isWorkTime(date)) { |
| | | // return 'weekend' |
| | | // } |
| | | // } |
| | | // |
| | | // gantt.templates.timeline_cell_class = function(item, date) { |
| | | // if (!gantt.isWorkTime({ date: date, task: item })) { |
| | | // return 'weekend' |
| | | // } |
| | | // } |
| | | gantt.templates.scale_cell_class = function(date) { |
| | | if (!gantt.isWorkTime(date)) { |
| | | return 'weekend' |
| | | } |
| | | } |
| | | |
| | | // gantt.config.work_time = true |
| | | gantt.templates.timeline_cell_class = function(item, date) { |
| | | if (!gantt.isWorkTime({ date: date, task: item })) { |
| | | return 'weekend' |
| | | } |
| | | } |
| | | |
| | | // gantt.addCalendar({ |
| | | // id: 'custom1', |
| | | // worktime: { |
| | | // hours: ['8:00-12:30', '13:00-17:30'], // global work hours for weekdays |
| | | // days: [0, 1, 1, 1, 1, 1, 1] |
| | | // } |
| | | // }) |
| | | gantt.config.work_time = true |
| | | |
| | | gantt.addCalendar({ |
| | | id: 'customCalendar1', |
| | | worktime: { |
| | | hours: ['8:00-12:30', '13:00-17:30'], // global work hours for weekdays |
| | | days: [0, 1, 1, 1, 1, 1, 1] |
| | | } |
| | | }) |
| | | |
| | | // gantt.addCalendar({ |
| | | // id: 'custom2', |
| | |
| | | // return '<span style="color: white; font-weight: bold; text-shadow: 1px 1px 1px #000;">' + |
| | | // task.description + ' - ' + |
| | | // '</span>' |
| | | return task.description |
| | | // return task.description |
| | | return task.progress * 100 + '%' |
| | | } |
| | | |
| | | // JavaScript 配置 |
| | | // gantt.templates.grid_row_class = function(start, end, task) { |
| | | // // 只对 id = 3 的任务行处理 |
| | | // // if (task.id !== 7) return |
| | | // |
| | | // // if (task.start_date === '2025-04-07 06:23') { |
| | | // if (task.id === 8) { |
| | | // console.log(task, 11) |
| | | // return 'row-completed' |
| | | // } |
| | | // |
| | | // return '' // 其他情况返回默认 |
| | | // } |
| | | |
| | | gantt.init('gantt_here') |
| | | // 注意:这里不立即加载数据,而是等待loadTasks被调用 |
| | |
| | | 'id': 1, |
| | | 'text': '工单:MO-2025-05-001', |
| | | saleOrder: 'SO-2025-05001', |
| | | 'calendar_id': 'customCalendar1', |
| | | partName: '跑步机', |
| | | partCode: 'Run01', |
| | | description: '排产数量:500 报工数量:100 进度:20%', |
| | |
| | | 'id': 2, |
| | | 'text': '工序:切割', |
| | | saleOrder: 'SO-2025-05001', |
| | | 'calendar_id': 'customCalendar1', |
| | | partName: '跑步机', |
| | | partCode: 'Run01', |
| | | description: '排产数量:500 报工数量:100 进度:20%', |
| | |
| | | 'id': 3, |
| | | 'text': '设备:金工车间1号设备', |
| | | saleOrder: 'SO-2025-05001', |
| | | 'calendar_id': 'customCalendar1', |
| | | partName: '跑步机', |
| | | partCode: 'Run01', |
| | | description: '排产数量:500 报工数量:100 进度:20%', |
| | |
| | | 'id': 4, |
| | | 'text': '设备:金工车间2号设备', |
| | | saleOrder: 'SO-2025-05001', |
| | | 'calendar_id': 'customCalendar1', |
| | | partName: '跑步机', |
| | | partCode: 'Run01', |
| | | description: '排产数量:500 报工数量:100 进度:20%', |
| | |
| | | 'progress': 0.2, |
| | | 'owner': [{ 'resource_id': '5', 'value': 2 }], |
| | | checked: false |
| | | }, { |
| | | }, |
| | | { |
| | | 'id': 5, |
| | | 'text': '工单:MO-2025-05-002', |
| | | saleOrder: 'SO-2025-05002', |
| | | 'calendar_id': 'customCalendar1', |
| | | partName: '走步机', |
| | | partCode: 'W01', |
| | | description: '排产数量:1000 报工数量:500 进度:50%', |
| | |
| | | 'id': 6, |
| | | 'text': '工序:切割', |
| | | saleOrder: 'SO-2025-05002', |
| | | 'calendar_id': 'customCalendar1', |
| | | partName: '走步机', |
| | | partCode: 'W01', |
| | | description: '排产数量:1000 报工数量:500 进度:50%', |
| | |
| | | 'text': '设备:金工车间3号设备', |
| | | saleOrder: 'SO-2025-05002', |
| | | partName: '走步机', |
| | | 'calendar_id': 'customCalendar1', |
| | | partCode: 'W01', |
| | | description: '排产数量:1000 报工数量:500 进度:50%', |
| | | 'type': 'task', |
| | | 'start_date': '2025-04-07 00:00', |
| | | 'start_date': '2025-04-07 06:23', |
| | | 'parent': '6', |
| | | 'duration': 3, |
| | | 'progress': 0.5, |
| | |
| | | saleOrder: 'SO-2025-05002', |
| | | partName: '走步机', |
| | | partCode: 'W01', |
| | | 'calendar_id': 'customCalendar1', |
| | | description: '排产数量:1000 报工数量:600 进度:60%', |
| | | 'type': 'task', |
| | | render: 'split', // 用于在一个工作时间段内显示不下,需要进行分割显示 |
| | | 'start_date': '2025-04-12 00:00', |
| | | 'parent': '6', |
| | | 'duration': 4, |
| | | 'progress': 0.6, |
| | | 'owner': [{ 'resource_id': '5', 'value': 2 }], |
| | | checked: false |
| | | }, |
| | | { |
| | | 'id': 10, |
| | | 'text': '设备:金工车间4号设备', |
| | | saleOrder: 'SO-2025-05002', |
| | | partName: '走步机', |
| | | partCode: 'W01', |
| | | 'calendar_id': 'customCalendar1', |
| | | description: '排产数量:1000 报工数量:600 进度:60%', |
| | | 'type': 'task', |
| | | render: 'split', |
| | | 'start_date': '2025-04-12 00:00', |
| | | 'parent': '8', |
| | | 'duration': 1, |
| | | 'progress': 0.6, |
| | | 'owner': [{ 'resource_id': '5', 'value': 2 }], |
| | | checked: false |
| | | }, |
| | | { |
| | | 'id': 11, |
| | | 'text': '设备:金工车间4号设备', |
| | | saleOrder: 'SO-2025-05002', |
| | | partName: '走步机', |
| | | partCode: 'W01', |
| | | 'calendar_id': 'customCalendar1', |
| | | description: '排产数量:1000 报工数量:600 进度:60%', |
| | | 'type': 'task', |
| | | render: 'split', |
| | | 'start_date': '2025-04-14 00:00', |
| | | 'parent': '8', |
| | | 'duration': 3, |
| | | 'progress': 0.0, |
| | | 'owner': [{ 'resource_id': '5', 'value': 2 }], |
| | | checked: false |
| | | }, |
| | |
| | | saleOrder: 'SO-2025-05002', |
| | | partName: '走步机', |
| | | partCode: 'W01', |
| | | 'calendar_id': 'customCalendar1', |
| | | description: '排产数量:1000 报工数量:400 进度:40%', |
| | | 'type': 'task', |
| | | 'start_date': '2025-04-10 00:00', |
| | |
| | | margin: unset; |
| | | } |
| | | |
| | | /*.gantt_task_cell {*/ |
| | | /* background: rgba(5, 185, 100, .1);*/ |
| | | /*}*/ |
| | | .gantt_task_cell { |
| | | background: rgba(5, 185, 100, .1); |
| | | } |
| | | |
| | | /*!*非工作日*!*/ |
| | | /*.weekend {*/ |
| | | /* background: rgba(255, 255, 255, 0.5);*/ |
| | | .weekend { |
| | | background: rgba(255, 255, 255, 0.1); |
| | | /*background: red;*/ |
| | | } |
| | | |
| | | /*.row-completed {*/ |
| | | /* background-color: #bee4be !important; !* 浅绿色 *!*/ |
| | | /*}*/ |
| | | |
| | | /*.gantt_grid_head_cell[data-column-id="duration"],*/ |
| | | /*.gantt_row .gantt_cell[data-column-name="duration"] {*/ |
| | | /* background-color: #f5f5f5 !important;*/ |
| | | /*}*/ |
| | | |
| | | /* 为任务条内部的进度条添加圆角,保持视觉统一 */ |