Commit e13caab2 authored by arvin's avatar arvin

装配单元路线修改保存功能

parent ae2fec0c
......@@ -43,6 +43,10 @@ export default {
loading: false,
dialogFlag: false,
unitList: [],
modifyData: {
task: [],
links: []
},
// eslint-disable-next-line no-undef
gantt: Gantt.getGanttInstance(),
initGanttFlag: false,
......@@ -138,6 +142,40 @@ export default {
duration: this.toDuration(n.workHour)
}
},
calcCriticalPath(link) {
},
modifyLink(link, operator) {
const _link = {
sourceId: Number(link.source),
targetId: Number(link.target),
isCritical: link.isCritical,
id: link.cid,
operator
}
if (operator === 'ADD') {
// 判断是否为恢复旧数据
const item = this.modifyData.links.find(l => l.sourceId === _link.sourceId && l.targetId === _link.targetId)
if (item) {
item.operator = ''
} else {
this.modifyData.links.push(_link)
}
} else {
// 判断是为删除新数据
const itemIdx = this.modifyData.links.findIndex(l => !l.id && l.sourceId === _link.sourceId && l.targetId === _link.targetId)
if (itemIdx > -1) {
const item = this.modifyData.links[itemIdx]
if (item.id) {
item.operator = 'REMOVE'
} else {
this.modifyData.links.splice(itemIdx, 1)
}
} else {
this.modifyData.links.push(_link)
}
}
},
getData(flag) {
if (!flag && this.loading && (this.currentId === this.node.id)) {
return
......@@ -146,6 +184,10 @@ export default {
this.gantt.clearAll()
this.AOname = ''
this.loading = true
this.modifyData = {
data: [],
links: []
}
const params = {
searchItems: { 'items': [{ 'fieldName': 'sourceId', 'operator': 'EQ', 'value': this.currentId }] },
'sortItem': [{ 'fieldName': 'modifyTime', 'sortOrder': 'asc' }],
......@@ -434,9 +476,15 @@ export default {
text += '<b>' + to.text + '</b>的 '
return text
}
ganttAss.attachEvent('onAfterLinkAdd', function(id, item) {
that.modifyLink(item, 'ADD')
console.log('onAfterLinkAdd', id, item)
})
// 删除连接后触发
ganttAss.attachEvent('onAfterLinkDelete', function(id, item) {
console.log('onAfterLinkDelete', id, item)
var target = ganttAss.getTask(item.target)
that.modifyLink(item, 'REMOVE')
var targetLength = target.$target.length
if (!targetLength) {
var data = {
......@@ -453,15 +501,11 @@ export default {
// 当分支被打开时触发
ganttAss.attachEvent('onTaskOpened', function(id) {
that.openTree.push(Number(id))
})
// 当分支关闭时触发
ganttAss.attachEvent('onTaskClosed', function(id) {
var arr = that.openTree
arr.splice(
arr.findIndex((item) => item === Number(id)),
1
)
})
ganttAss.attachEvent('onBeforeTaskDisplay', function(id, task) {
if (task.priority) {
......@@ -544,10 +588,6 @@ export default {
const pTask = this.params.data.find(t => t.id === task.parent)
if (pTask) {
parentTasks.push(pTask)
const gTask = this.params.data.find(t => t.id === pTask.parent)
if (gTask) {
parentTasks.push(gTask)
}
}
}
})
......@@ -556,6 +596,32 @@ export default {
this.gantt.parse({
data: [...tasks, ...parentTasks]
})
},
save() {
const params = this.modifyData.links.filter(r => r.operator)
.map(link => {
if (link.operator === 'ADD' || link.operator === 'MODIFY') {
return {
prevNodeId: link.sourceId,
prevNodeIdType: 'ExtProcessPlan',
subTypeName: 'ExtProcessExecutorRoute',
isCritical: link.isCritical,
currNodeId: link.targetId,
currNodeIdType: 'ExtProcessPlan',
id: link.id,
operator: link.operator
}
}
if (link.operator === 'REMOVE') {
return {
id: link.id,
operator: 'REMOVE'
}
}
})
this.$api.recursion('ExtProcessExecutorRoute', params, true).then(res => {
this.getData()
})
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment