Commit 72010999 authored by arvin's avatar arvin

架次视图路线页面

parent 9931c6e1
......@@ -9,8 +9,6 @@ export default {
},
methods: {
initGantt() {
this.setColumnsConfig()
this.usePlugins()
this.gantt.i18n.setLocale('cn')
this.configLayout()
},
......@@ -22,7 +20,6 @@ export default {
tooltip: true,
critical_path: true,
auto_scheduling: true
})
}
......
......@@ -62,6 +62,8 @@ export default {
methods: {
configLayout() {
const ganttAg = this.gantt
this.setColumnsConfig()
this.usePlugins()
const getInput = function(node) {
return node.querySelector('input')
}
......@@ -310,33 +312,21 @@ export default {
this.refreshGantt()
})
},
export(mode) {
if (mode === 'png') {
this.gantt.exportToPNG({
locale: 'CN',
name: 'AG600.png'
// data: this.tasks
})
} else if (mode === 'pdf') {
this.gantt.exportToPDF({
name: 'AG600.pdf'
})
} else {
var dd = this.gantt.getTableData()
const tableData = dd.data.data.filter(p => !p.priority).map((p) => {
return {
index: p.index,
text: p.text,
duration: Math.round(p.duration),
predecessors: Object.values(p)
.filter((item) => item.toString().includes('<span>'))[0]
.replace('<span>', '')
.replace('</span>', '')
}
})
const header = ['节点', '站位号', '工期(天)', '前置']
CsvExportor.downloadCsv(tableData, { header }, '站位路线.csv')
}
export() {
var dd = this.gantt.getTableData()
const tableData = dd.data.data.filter(p => !p.priority).map((p) => {
return {
index: p.index,
text: p.text,
duration: Math.round(p.duration),
predecessors: Object.values(p)
.filter((item) => item.toString().includes('<span>'))[0]
.replace('<span>', '')
.replace('</span>', '')
}
})
const header = ['节点', '站位号', '工期(天)', '前置']
CsvExportor.downloadCsv(tableData, { header }, '站位路线.csv')
},
save() {
if (this.loading) {
......
......@@ -66,7 +66,7 @@ export default {
this.$nextTick(() => {
setTimeout(() => {
this.defaultNodeClick()
}, 100)
}, 400)
})
return [{
id: this.AircraftSortiesId,
......@@ -146,6 +146,7 @@ export default {
if (!this.currentNode) {
return
}
this.$nextTick(() => {
tree.setCurrentKey(this.currentNode.id)
this.$emit('nodeClick', this.currentNode)
......
......@@ -2,7 +2,7 @@
<div class="TfMomWebUnit-model">
<div class="search-bar">
<el-input>
<el-input v-model="AOname" placeholder="AO(号/名称)" class="input-with-select">
<el-input v-model.trim="AOname" placeholder="AO(号/名称)" class="input-with-select">
<el-button slot="append" icon="el-icon-search" @click="search" />
</el-input>
</el-input>
......@@ -44,7 +44,32 @@ export default {
getData() {
},
configLayout() {}
configLayout() {},
search() {
if (!this.AOname) {
return
}
const tasks = this.params.data.filter(task => task.right_text.includes(this.AOname) || task.text.includes(this.AOname))
const parentTasks = []
if (tasks.length) {
tasks.forEach(task => {
if (task.parent) {
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)
}
}
}
})
}
this.gantt.clearAll()
this.gantt.parse({
data: [...tasks, ...parentTasks]
})
}
}
}
</script>
......
<template>
<div class="TfMomWebView-model">
<div v-dee-loading="loading" class="TfMomWebView-model">
<div class="search-bar">
<el-input v-model="AOname" size="small" placeholder="AO(号/名称)" class="input-with-select">
<el-button slot="append" icon="el-icon-search" @click="search" />
</el-input>
</div>
<div :id="ganttElId" class="gatt" />
<div :id="ganttElId" :ref="ganttElId" class="gatt" />
</div>
</template>
<script>
import CsvExportor from 'csv-exportor'
import config from './config'
import data from './data'
export default {
......@@ -31,6 +32,7 @@ export default {
ganttElId: 'view-gantt',
currentId: '',
ganttData: [],
loading: false,
// eslint-disable-next-line no-undef
gantt: Gantt.getGanttInstance(),
initGanttFlag: false,
......@@ -109,29 +111,22 @@ export default {
methods: {
refreshGantt(val) {
if (!val || !val.length) {
this.gantt.parse({ data: [] })
return
}
const params = {
this.params = {
data: [],
links: []
}
val.forEach((item, index) => {
const link = item.extProcessExecutorRoutes && item.extProcessExecutorRoutes[0]
val.forEach((item) => {
// 站点数据
params.data.push(this.toExtPostion(item))
if (link) {
params.links.push(this.toLink(link))
}
this.params.data.push(this.toExtPostion(item))
this.addLink(item)
// 单元数据
if (item.extPositionLinks) {
item.extPositionLinks.forEach(postLink => {
if (postLink.target) {
params.data.push(this.toUnit(postLink.target, item))
const link2 = postLink.target.extProcessExecutorRoutes && postLink.target.extProcessExecutorRoutes[0]
if (link2) {
params.links.push(this.toLink(link2))
}
this.params.data.push(this.toUnit(postLink.target, item))
this.addLink(postLink.target)
// 配置方案
if (postLink.target.sourceExtProcessUsageLink && postLink.target.sourceExtProcessUsageLink[0]) {
......@@ -140,11 +135,8 @@ export default {
ExtCas.sourceExtProcessUsageLink.forEach(AoLink => {
// AO AOR
if (AoLink.target) {
params.data.push(this.toAo(AoLink.target, item))
const link3 = AoLink.target.extProcessExecutorRoutes && AoLink.target.extProcessExecutorRoutes[0]
if (link3) {
params.links.push(this.toLink(link3))
}
this.params.data.push(this.toAo(AoLink.target, postLink.target))
this.addLink(AoLink.target)
}
})
}
......@@ -153,13 +145,14 @@ export default {
})
}
})
this.params = params
this.gantt.clearAll()
this.gantt.parse(this.params)
},
toDuration(workHour) {
return workHour || 0.01
// return (Number(workHour || 0) * 3 * 60) || 0.01
return (Number(workHour || 0) * 3 * 60) || 0.01
},
addLink(item) {
const link = item.extProcessExecutorRoutes && item.extProcessExecutorRoutes[0]
link && this.params.links.push(this.toLink(link))
},
toLink(l) {
return {
......@@ -177,7 +170,6 @@ export default {
type: 'project',
start_date: '2007-01-01',
text: m.serialNumber,
parenId: m.parenId,
parent: p ? p.id : 0,
edition: m.gaceVersion,
right_text: m.name,
......@@ -187,33 +179,37 @@ export default {
toUnit(n, m) {
return {
id: n.id,
type: 'project',
start_date: '2007-01-01',
text: n.serialNumber,
parenId: n.parenId,
edition: n.gaceVersion,
parent: m.id,
parenId: m.id,
right_text: n.name,
duration: this.toDuration(m.workHour)
duration: this.toDuration(n.workHour)
}
},
toAo(m) {
toAo(n, m) {
return {
id: 'xxx',
// type: 'project',
id: n.id,
type: 'task',
start_date: '2007-01-01',
text: m.serialNumber,
parenId: m.parenId,
text: n.serialNumber,
parent: m.id,
edition: m.gaceVersion,
right_text: m.name,
priority: true
parenId: m.id,
edition: n.gaceVersion,
right_text: n.name,
duration: this.toDuration(n.workHour)
}
},
getData() {
this.currentId = this.node.id
if (!this.node || !this.node.children) {
this.gantt.clearAll()
if (!this.node || !this.node.children.length) {
return
}
this.AOname = ''
this.loading = true
const ids = this.node.children.map(r => r.id)
const params = {
searchItems: { 'items': [{ 'fieldName': 'id', 'operator': 'IN', 'value': ids }] },
......@@ -245,35 +241,44 @@ export default {
// ExtProcessUsageLink ExtPosition
this.$api.searchApi('ExtPosition', params).then(res => {
this.refreshGantt(res.items.content || [])
this.loading = false
}).catch(() => {
this.refreshGantt([])
this.loading = false
})
},
showTextBylevel(level) {
if (level === 0) {
return '站位'
}
if (level === 1) {
return '装配单元'
}
if (level === 2) {
return 'AO名称'
}
},
configLayout() {
const ganttIns = this.gantt
const that = this
this.usePlugins()
ganttIns.config.scale_height = 70
ganttIns.config.readonly = true
ganttIns.templates.tooltip_text = function(start, end, task) {
var text = ''
task.$level === 0 ? text = '站位' : (task.$level === 1 ? text = '装配单元' : text = 'AO名称')
var text = that.showTextBylevel(task.$level)
var html =
'<b >站位:</b> ' +
task.text +
'<br><b>工期:</b> ' +
Math.round(task.duration) +
Math.round((task.duration || 0) / (3 * 60)) +
'小时<br><b>版本:</b> ' +
(task.edition || ' ') +
'<br><b>' + text + ':</b> ' +
(task.right_text || ' ')
return html
}
if (that.preservatioTree) {
that.preservatioTree = false
ganttIns.config.open_tree_initially = false
} else {
ganttIns.config.open_tree_initially = true
}
ganttIns.config.open_tree_initially = true
ganttIns.config.date_format = '%Y-%m-%d %H:%i:%s'
ganttIns.config.duration_unit = 'minute'
ganttIns.config.autofit = false
......@@ -418,7 +423,7 @@ export default {
ganttIns.config.drag_resize = false
this.$nextTick(() => {
ganttIns.ext.zoom.init(zoomConfig)
ganttIns.init(this.$refs[this.onlyUuid])
ganttIns.init(this.ganttElId)
})
ganttIns.attachEvent('onBeforeTaskDisplay', function(id, task) {
if (task.priority) {
......@@ -426,8 +431,54 @@ export default {
}
return true
})
this.$nextTick(() => {
ganttIns.init(this.ganttElId)
},
export() {
var dd = this.gantt.getTableData()
const tableData = dd.data.data.filter(p => !p.priority).map(p => {
return {
_1: Object.values(p).filter(item => item && item.toString().includes('gantt_grid_wbs'))[0]
.replace("<span class='gantt_grid_wbs'>", '')
.replace('</span>', ''),
text1: p.text,
edition: p.edition || '',
duration: (p.duration || 0) / (3 * 60),
predecessors: Object.values(p).filter(item => item && item.toString().includes('gantt_grid_predecessors'))[0]
.replace("<span class='gantt_grid_predecessors'>", '')
.replace('</span>', '')
}
})
const header = [
'节点',
'站位号',
'版本',
'工期(时)',
'前置'
]
CsvExportor.downloadCsv(tableData, { header }, '架次视图路线.csv')
},
search() {
if (!this.AOname) {
return
}
const tasks = this.params.data.filter(task => task.$level === 2 && (task.right_text.includes(this.AOname) || task.text.includes(this.AOname)))
const parentTasks = []
if (tasks.length) {
tasks.forEach(task => {
if (task.parent) {
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)
}
}
}
})
}
this.gantt.clearAll()
this.gantt.parse({
data: [...tasks, ...parentTasks]
})
}
}
......
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