From c02cd2b9d319030b670c0a7115dedcb351f01be2 Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期一, 09 三月 2026 16:48:03 +0800
Subject: [PATCH] 1.递交
---
src/views/gantt/index.vue | 85 ++++++++++++++++++------------------------
1 files changed, 36 insertions(+), 49 deletions(-)
diff --git a/src/views/gantt/index.vue b/src/views/gantt/index.vue
index df9ebe5..940d419 100644
--- a/src/views/gantt/index.vue
+++ b/src/views/gantt/index.vue
@@ -1,7 +1,9 @@
<template>
<div style="padding: 0 10px">
+ <!-- 椤堕儴鎺у埗鏍忥細鍖呭惈缂╂斁閫夋嫨鍣ㄣ�佷紭鍏堢骇閫夋嫨鍣ㄣ�佹棩鏈熻寖鍥撮�夋嫨鍣ㄥ拰鎿嶄綔鎸夐挳 -->
<div style="padding: 10px 0;display: flex;">
+ <!-- 鏃堕棿鍒诲害閫夋嫨鍣細鐢ㄤ簬璋冩暣鐢樼壒鍥剧殑鏃堕棿绮掑害 -->
<el-select
v-model="scaleValue"
size="mini"
@@ -15,6 +17,7 @@
:value="item.code"
/>
</el-select>
+ <!-- 浼樺厛绾ф柟娉曢�夋嫨鍣細璁惧浼樺厛鎴栨椂闂翠紭鍏� -->
<el-select
v-model="priorityMethod"
size="mini"
@@ -29,6 +32,7 @@
:value="item.code"
/>
</el-select>
+ <!-- 鏃ユ湡鑼冨洿閫夋嫨鍣細鎺у埗鐢樼壒鍥炬樉绀虹殑鏃ユ湡鑼冨洿 -->
<el-date-picker
v-model="ganttDateRange"
style="margin-left: 10px;"
@@ -42,25 +46,30 @@
end-placeholder="缁撴潫鏃ユ湡"
@change="ganttDateRangeChange"
/>
+ <!-- 鑾峰彇閫変腑浠诲姟鎸夐挳锛氳幏鍙栧綋鍓嶅閫夋閫変腑鐨勪换鍔� -->
<el-button type="primary" style="margin-left: 10px;" size="mini" @click="handleGetSelected">
鑾峰彇澶嶉�夋閫変腑浠诲姟
</el-button>
+ <!-- 娓呯┖閫夋嫨鎸夐挳锛氭竻绌哄綋鍓嶅閫夋鐨勯�夋嫨 -->
<el-button size="mini" @click="handleClearSelection">
娓呯┖澶嶉�夋閫夋嫨
</el-button>
+ <!-- 棰勬帓鎸夐挳锛氭墽琛岄鎺掗�昏緫 -->
<el-button size="mini" type="primary" @click="prepareArrange">
棰勬帓
</el-button>
+ <!-- 棰勬帓杩涘害鏄剧ず锛氭樉绀洪鎺掕繘搴︾粺璁� -->
<el-button size="mini" disabled>
棰勬帓杩涘害锛歿{ canArrangeNumber }}/{{ needArrangeNumber }}
</el-button>
</div>
+ <!-- 鐢樼壒鍥惧鍣細鐢ㄤ簬娓叉煋DHTMLX Gantt鍥捐〃 -->
<div id="gantt_here" style="width:100%; height:calc(90vh - 50px);" />
- <!-- 鍒嗛〉缁勪欢 -->
+ <!-- 鍒嗛〉缁勪欢锛氱敤浜庡垎椤垫樉绀哄ぇ閲忎换鍔℃暟鎹� -->
<div class="pagination-container">
<el-pagination
:current-page="currentPage"
@@ -76,7 +85,7 @@
</template>
<script>
-import { gantt } from '@/components/dhtmlxGantt'
+import { gantt } from '@/components/dhtmlxGantt' // 鐩墠dhtmlxgantt鐗堟湰8.0.x
import '@/components/dhtmlxGantt/codebase/dhtmlxgantt.css'
import { handleDateReduceOneDay, handleDatetime, handleDatetime2 } from '@/utils/global'
import { nanoid } from 'nanoid'
@@ -109,9 +118,9 @@
{ code: 'time', name: '鏃堕棿浼樺厛' }
],
pickerOptions: {
- disabledDate(time) {
- return time.getTime() <= Date.now() - 24 * 60 * 60 * 1000
- }
+ // disabledDate(time) {
+ // return time.getTime() <= Date.now() - 24 * 60 * 60 * 1000
+ // }
}
}
},
@@ -121,9 +130,6 @@
// 鏀瑰彉鏃ユ湡鑼冨洿閰嶇疆
this.ganttDateRangeChange(this.ganttDateRange)
-
- // 鐒跺悗鍔犺浇浠诲姟鏁版嵁锛堜細鑷姩娓叉煋褰撳墠椤碉級
- // this.loadTasks()
},
methods: {
@@ -208,7 +214,6 @@
return `<input type="checkbox" class="taskCheckBox" data-action="check-row" ${checked} />`
}
},
- // { name: 'wbs', label: '鑺傜偣', width: 80, template: gantt.getWBSCode },
{ name: 'text', tree: true, align: 'center', label: '浠诲姟鍚嶇О', width: 240, resize: true, editor: textEditor },
{ name: 'saleOrder', align: 'center', label: '閿�鍞鍗�', width: 100, resize: true },
{ name: 'partName', align: 'center', label: '浜у搧鍚嶇О', width: 80, resize: true },
@@ -216,7 +221,6 @@
{
name: 'progress', align: 'center', label: '杩涘害', width: 120, resize: true, template: function(task) {
return `<input type="range" onmousedown="event.preventDefault()" onmouseup="event.preventDefault()" id="taskRange" value="${task.progress * 100}"/> ${task.progress * 100}%`
- // return `<el-progress :percentage='${task.progress * 100}'></el-progress> ${task.progress * 100}%`
}
},
{ name: 'start_date', align: 'center', label: '寮�濮嬫棩鏈�', width: 80, resize: true, editor: startDateEditor },
@@ -242,8 +246,6 @@
// 鑷畾涔夋诞鍔ㄦ鐨勬樉绀哄唴瀹� tooltip娴姩妗嗘樉绀虹殑End Date琚拷鍔�1鐨勯棶棰樹慨澶嶏紙搴旇鏄剧ず鏁版嵁搴撶殑鍘熷鍊硷級
gantt.templates.tooltip_text = function(start, end, task) {
- // return '<b>浠诲姟:</b> ' + task.text + '<br/><b>寮�濮嬫椂闂�:</b> ' + `${gantt.date.date_to_str('%Y-%m-%d')(start)}` + '<br/><b>缁撴潫鏃堕棿:</b> ' + handleDateReduceOneDay(end)
- // return '<b>浠诲姟:</b> ' + task.text + '<br/><b>寮�濮嬫椂闂�:</b> ' + handleDatetime2(start) + '<br/><b>缁撴潫鏃堕棿:</b> ' + handleDateReduceOneDay(end) + '<br/><b>杩涘害:</b> ' + task.progress * 100 + '%'
return '<b>浠诲姟:</b> ' + task.text +
'<br/><b>' + `${task.type === 'task' ? '浜ц兘' : '鐢熶骇鏁伴噺'}` + ' :</b> ' + task.producedCount +
'<br/><b>杩涘害:</b> ' + task.progress * 100 + '%' +
@@ -252,15 +254,8 @@
}
gantt.templates.task_text = function(start, end, task) {
- // return '<span style="color: white; font-weight: bold; text-shadow: 1px 1px 1px #000;">' +
- // task.description + ' - ' +
- // '</span>'
- // return task.description
- // return task.progress * 100 + '%'
-
if (task.type === 'task2') {
return `<div class="task2Css">${task.producedCount}</div>`
- // return task.producedCount
}
if (task.type === 'task3') {
return `<div class="task3Css">${task.producedCount}</div>`
@@ -268,14 +263,11 @@
return ''
}
- // 璁剧疆鎸佺画鏃堕棿鍗曚綅涓哄皬鏃�
- // gantt.config.duration_unit = 'hour'
-
+ // 璁剧疆鎸佺画鏃堕棿鍗曚綅涓哄垎閽�
gantt.config.duration_unit = 'minute'
gantt.config.duration_step = 1
// gantt.config.show_task_cells = false //闅愯棌鐢樼壒鍥惧唴閮ㄥ埢搴︾嚎
gantt.init('gantt_here')
- // 娉ㄦ剰锛氳繖閲屼笉绔嬪嵆鍔犺浇鏁版嵁锛岃�屾槸绛夊緟loadTasks琚皟鐢�
// 缁戝畾鐢樼壒鍥剧偣鍑讳簨浠讹紙瀹樻柟鎺ㄨ崘鐨勪簨浠跺鎵樼敤娉曪級
gantt.attachEvent('onTaskClick', (id, e) => {
@@ -305,8 +297,6 @@
// 鍒濆鍖栧畬鎴愬悗鍚屾涓�娆¢�変腑鐘舵��
this.syncSelected()
-
- // this.loadTasks()
},
// 鍔犺浇浠诲姟鏁版嵁
@@ -594,9 +584,24 @@
item.children.forEach((it, ind) => {
// 杩欓噷搴旇瑕佺敓鎴愪竴涓互璁惧缁村害涓哄熀纭�鐨勬暟缁� 涓嶉噸涓嶆紡
if (!newArr.map(i => i.partCode).includes(it.AdvaDevicNumber)) {
- console.log(' it.AdvaDevicNumber,', it.AdvaDevicNumber)
newArr.push({
id: it.AdvaDevicNumber,
+ type: 'project',
+ text: '鎴戞槸鐖剁骇',
+ partName: it.AdvaDevicName,
+ partCode: it.AdvaDevicNumber,
+ start_date: handleDatetime2(item.YearDate + ' ' + it.OneStartDate.split('~')[0]), // 杩欎釜鏄棤鏁堢殑锛屽彧鏄负浜嗛鎺抪repareArrange鏂规硶閲岄潰涓嶆姤閿�
+ end_date: handleDatetime2(item.YearDate + ' ' + it.OneStartDate.split('~')[1]), // 杩欎釜鏄棤鏁堢殑锛屽彧鏄负浜嗛鎺抪repareArrange鏂规硶閲岄潰涓嶆姤閿�
+ // duration: this.calculateTimeRangeInMinutes(it.OneStartDate),
+ checked: false,
+ progress: 0.6,
+ parent: 0,
+ saleOrder: 'SO-2026-01001',
+ open: true
+ })
+
+ newArr.push({
+ id: it.AdvaDevicNumber + ind.toString(),
type: 'project',
text: '浠诲姟鍚嶇О棰勭暀',
partName: it.AdvaDevicName,
@@ -607,7 +612,7 @@
render: 'split', // 鐢ㄤ簬鍦ㄤ竴涓伐浣滄椂闂存鍐呮樉绀轰笉涓嬶紝闇�瑕佽繘琛屽垎鍓叉樉绀�
checked: false,
progress: 0,
- parent: 0,
+ parent: it.AdvaDevicNumber,
saleOrder: 'SO-2026-01001'
})
}
@@ -617,20 +622,17 @@
if (it[this.fivePeriodsTimeName[i]]) {
const duration = this.calculateTimeRangeInMinutes(it[this.fivePeriodsTimeName[i]]) // 宸ユ湡 鍗曚綅 鍒嗛挓
newArr.push({
- // id: index.toString() + ind.toString() + i.toString(),
id: nanoid(),
type: 'task',
text: '浠诲姟鍚嶇О棰勭暀',
partName: it.AdvaDevicName,
partCode: it.AdvaDevicNumber,
start_date: handleDatetime2(item.YearDate + ' ' + it[this.fivePeriodsTimeName[i]].split('~')[0]),
- // start_date: new Date(handleDatetime2(item.YearDate + ' ' + it[this.fivePeriodsTimeName[i]].split('~')[0])).getTime() < new Date().getTime() ? handleDatetime2(new Date()) : handleDatetime2(item.YearDate + ' ' + it[this.fivePeriodsTimeName[i]].split('~')[0]),
- // end_date: new Date(handleDatetime2(item.YearDate + ' ' + it[this.fivePeriodsTimeName[i]].split('~')[1])).getTime() < new Date().getTime() ? handleDatetime2(new Date()) : handleDatetime2(item.YearDate + ' ' + it[this.fivePeriodsTimeName[i]].split('~')[1]),
end_date: handleDatetime2(item.YearDate + ' ' + it[this.fivePeriodsTimeName[i]].split('~')[1]),
duration,
checked: false,
progress: 0,
- parent: it.AdvaDevicNumber,
+ parent: it.AdvaDevicNumber + ind.toString(),
saleOrder: 'SO-2026-01001',
// 瑕佸湪姣忎竴涓椂闂存鍐呯畻鍑鸿兘鐢熶骇澶氬皯涓� 宸ユ湡锛堝垎閽燂級涔樹互60 闄や互鐢熶骇鑺傛媿 * 绋煎姩鐜�
producedCount: (duration * 60 / it.AdvaDevicRhythm) * (it.AdvaDevicCropMob / 100),
@@ -655,11 +657,10 @@
partCode: item.part_code,
start_date: item.time_start,
end_date: item.time_end,
- // duration: this.calculateTimeRangeInMinutes(it.OneStartDate),
duration: this.calculateTimeRangeInMinutes(item.time_start.split(' ')[1] + '~' + item.time_end.split(' ')[1]),
checked: false,
progress: 0,
- parent: item.eqp_code,
+ parent: item.eqp_code + '0',
saleOrder: 'SO-2026-01001',
producedCount: item.alloc_qty
})
@@ -694,13 +695,9 @@
// 浣跨敤鍘熸湁鐨勭ず渚嬫暟鎹綔涓哄熀纭�
this.allTasks = newArr.filter(i => i.schedulingPossible !== false)
- // this.allTasks = newArr
-
this.totalTasks = this.allTasks.length
this.updatePaginatedTasks()
this.renderGanttChart()
-
- // this.prepareArrange()
},
// 鏇存柊鍒嗛〉鍚庣殑浠诲姟鏁版嵁
@@ -777,7 +774,7 @@
// 娓叉煋鐢樼壒鍥�
renderGanttChart() {
gantt.clearAll()
- console.log(JSON.parse(JSON.stringify(this.paginatedTasks)))
+ // console.log(JSON.parse(JSON.stringify(this.paginatedTasks)))
gantt.parse({
'data': this.paginatedTasks
})
@@ -787,7 +784,6 @@
// 椤靛ぇ灏忔敼鍙�
handleSizeChange(newSize) {
- console.log('鎵ц2')
this.pageSize = newSize
this.currentPage = 1 // 閲嶇疆鍒扮涓�椤�
this.updatePaginatedTasks()
@@ -797,7 +793,6 @@
// 褰撳墠椤垫敼鍙�
handleCurrentChange(newPage) {
- console.log('鎵ц1')
// 璁$畻鏈�澶ч〉鏁帮紝闃叉瓒呭嚭鑼冨洿
const maxPage = Math.ceil(this.totalTasks / this.pageSize)
if (newPage > maxPage) {
@@ -835,12 +830,11 @@
// 鑾峰彇鎵�鏈夐�変腑鐨勪换鍔D
// this.selectedIds = [...new Set(this.allTasks.filter(t => t.checked).map(t => t.id))]//鏁扮粍鍘婚噸
this.selectedIds = this.allTasks.filter(t => t.checked).map(t => t.id)
- console.log(this.selectedIds)
},
// 鑾峰彇閫変腑浠诲姟锛堢ず渚嬶級
handleGetSelected() {
- const selected = this.allTasks.filter(t => t.checked)
+ // const selected = this.allTasks.filter(t => t.checked)
// this.$notify.success(`褰撳墠宸查�変腑${selected.length} 鏉′换鍔)
this.$notify.success(`鐐瑰嚮浜哷)
},
@@ -941,14 +935,7 @@
}
})
- // for (let i = 0; i < this.allTasks.length; i++) {
- //
- // }
-
this.allTasks = [...this.allTasks, ...newArr]
-
- console.log(JSON.parse(JSON.stringify(this.allTasks)), '888')
-
this.totalTasks = this.allTasks.length
this.updatePaginatedTasks()
this.renderGanttChart()
--
Gitblit v1.9.3