Commit 72010999 authored by arvin's avatar arvin

架次视图路线页面

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