Commit 4ddfa4cc authored by jingnan's avatar jingnan 👀

Merge branch 'dev' of http://94.191.100.41/tfmom/tf-mom-web into dev

parents b537f4e7 9931c6e1
...@@ -17,7 +17,6 @@ export default { ...@@ -17,7 +17,6 @@ export default {
setColumnsConfig() { setColumnsConfig() {
this.gantt.config.columns = this.columns this.gantt.config.columns = this.columns
}, },
usePlugins() { usePlugins() {
this.gantt.plugins({ this.gantt.plugins({
tooltip: true, tooltip: true,
......
...@@ -5,18 +5,20 @@ export default { ...@@ -5,18 +5,20 @@ export default {
} }
}, },
watch: { watch: {
showFlag(val) { showFlag: {
if (!val) { immediate: true,
return handler(val) {
} if (!val) {
if (!this.node) { return
return }
} if (!this.node) {
if (this.node.id === this.currentId) { return
return }
} if (this.node.id === this.currentId) {
this.getData() return
}, }
this.getData()
} },
node: { node: {
immediate: true, immediate: true,
deep: true, deep: true,
......
...@@ -60,67 +60,6 @@ export default { ...@@ -60,67 +60,6 @@ export default {
}, },
methods: { methods: {
refreshGantt() {
const val = this.ganttData
if (!val || !val.length) {
this.gantt.parse({ data: [] })
return
}
const params = {
data: [],
links: []
}
val.forEach((item, index) => {
const link = item.extProcessExecutorRoutes && item.extProcessExecutorRoutes[0]
params.data.push({
index: index + 1,
text: item.serialNumber,
id: item.id,
parenId: link && link.prevNodeId || '',
start_date: '2007-1-1',
type: 'task',
duration: item.workHour ? Number(item.workHour / 8) : 0
})
if (link) {
params.links.push({
cid: link.id,
tid: link.currNodeId,
source: link.prevNodeId,
target: link.currNodeId,
type: '0',
isCritical: link.isCritical
})
}
})
this.params = params
this.gantt.clearAll()
this.gantt.parse(this.params)
},
getData() {
this.currentId = this.node.id
const params = {
'searchItems': { 'items': [{ 'fieldName': 'aircraftSortiesId', 'operator': 'EQ', 'value': this.node.id }] },
'sortItem': [{ 'fieldName': 'serialNumber', 'sortOrder': 'asc' }],
'openProps': [
{
'name': 'extProcessExecutorRoutes'
}
]
}
this.$api.searchApi('ExtPosition', params).then(res => {
if (res.items.content) {
this.ganttData = res.items.content
} else {
this.ganttData = []
}
this.refreshGantt()
}).catch(() => {
this.ganttData = []
this.refreshGantt()
})
},
configLayout() { configLayout() {
const ganttAg = this.gantt const ganttAg = this.gantt
const getInput = function(node) { const getInput = function(node) {
...@@ -310,6 +249,67 @@ export default { ...@@ -310,6 +249,67 @@ export default {
ganttAg.init(this.ganttElId) ganttAg.init(this.ganttElId)
}) })
}, },
refreshGantt() {
const val = this.ganttData
if (!val || !val.length) {
this.gantt.parse({ data: [] })
return
}
const params = {
data: [],
links: []
}
val.forEach((item, index) => {
const link = item.extProcessExecutorRoutes && item.extProcessExecutorRoutes[0]
params.data.push({
index: index + 1,
text: item.serialNumber,
id: item.id,
parenId: link && link.prevNodeId || '',
start_date: '2007-1-1',
type: 'task',
duration: item.workHour ? Number(item.workHour / 8) : 0
})
if (link) {
params.links.push({
cid: link.id,
tid: link.currNodeId,
source: link.prevNodeId,
target: link.currNodeId,
type: '0',
isCritical: link.isCritical
})
}
})
this.params = params
this.gantt.clearAll()
this.gantt.parse(this.params)
},
getData() {
this.currentId = this.node.id
const params = {
'searchItems': { 'items': [{ 'fieldName': 'aircraftSortiesId', 'operator': 'EQ', 'value': this.node.id }] },
'sortItem': [{ 'fieldName': 'serialNumber', 'sortOrder': 'asc' }],
'openProps': [
{
'name': 'extProcessExecutorRoutes'
}
]
}
this.$api.searchApi('ExtPosition', params).then(res => {
if (res.items.content) {
this.ganttData = res.items.content
} else {
this.ganttData = []
}
this.refreshGantt()
}).catch(() => {
this.ganttData = []
this.refreshGantt()
})
},
export(mode) { export(mode) {
if (mode === 'png') { if (mode === 'png') {
this.gantt.exportToPNG({ this.gantt.exportToPNG({
...@@ -391,12 +391,12 @@ export default { ...@@ -391,12 +391,12 @@ export default {
} }
.gantt_critical_task{ .gantt_critical_task{
background: #f39c4f; background: #f39c4f;
border: 1px solid #f39c4f; border: 1px solid #f39c4f;
} }
.gantt_task_line{ .gantt_task_line{
&.workday_over{ &.workday_over{
background: #f39c4f; background: #f39c4f;
border: 1px solid #f39c4f; border: 1px solid #f39c4f;
} }
} }
} }
......
<template> <template>
<div class="TfMomWebView-model"> <div class="TfMomWebView-model">
<div class="search-bar"> <div class="search-bar">
<el-input> <el-input v-model="AOname" size="small" placeholder="AO(号/名称)" class="input-with-select">
<el-input v-model="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>
</div> </div>
<div :id="ganttElId" class="gatt" /> <div :id="ganttElId" class="gatt" />
</div> </div>
...@@ -31,9 +30,75 @@ export default { ...@@ -31,9 +30,75 @@ export default {
return { return {
ganttElId: 'view-gantt', ganttElId: 'view-gantt',
currentId: '', currentId: '',
ganttData: [],
// eslint-disable-next-line no-undef
gantt: Gantt.getGanttInstance(),
initGanttFlag: false,
params: null,
AOname: '' AOname: ''
} }
}, },
computed: {
columns() {
const ganttIns = this.gantt
return [
{
name: '',
label: '节点',
align: 'left',
width: 60,
resize: true,
template: function(task) {
return (
"<span class='gantt_grid_wbs'>" + (ganttIns.getWBSCode(task) ||
'') + '</span>'
)
}
},
{
name: 'text',
label: '站位号',
align: 'left',
width: 160,
tree: true,
resize: true
},
{
name: 'edition',
label: '版本',
align: 'center',
width: 50,
resize: true
},
{
name: 'duration',
label: '工期(时)',
align: 'center',
width: 60,
resize: true,
template: function(task) {
return Math.round((task.duration || 0) / (3 * 60))
}
},
{
name: 'predecessors',
label: '前置',
width: 60,
align: 'center',
template: function(task) {
var links = task.$target
var labels = []
for (var i = 0; i < links.length; i++) {
var link = ganttIns.getLink(links[i])
var label = ganttIns.getWBSCode(ganttIns.getTask(link.source))
if (!labels.includes(label)) { labels.push(label) }
}
return "<span class='gantt_grid_predecessors'>" + labels.join(', ') + '</span>'
}
}
]
}
},
watch: { watch: {
}, },
...@@ -42,14 +107,352 @@ export default { ...@@ -42,14 +107,352 @@ export default {
}, },
methods: { methods: {
getData() { refreshGantt(val) {
if (!val || !val.length) {
this.gantt.parse({ data: [] })
return
}
const params = {
data: [],
links: []
}
val.forEach((item, index) => {
const link = item.extProcessExecutorRoutes && item.extProcessExecutorRoutes[0]
// 站点数据
params.data.push(this.toExtPostion(item))
if (link) {
params.links.push(this.toLink(link))
}
// 单元数据
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))
}
// 配置方案
if (postLink.target.sourceExtProcessUsageLink && postLink.target.sourceExtProcessUsageLink[0]) {
const ExtCas = postLink.target.sourceExtProcessUsageLink[0].target
if (ExtCas && ExtCas.sourceExtProcessUsageLink) {
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 = params
this.gantt.clearAll()
this.gantt.parse(this.params)
},
toDuration(workHour) {
return workHour || 0.01
// return (Number(workHour || 0) * 3 * 60) || 0.01
}, },
configLayout() {} toLink(l) {
return {
cid: l.id,
tid: l.currNodeId,
source: l.prevNodeId,
target: l.currNodeId,
type: '0',
isCritical: l.isCritical
}
},
toExtPostion(m, p) {
return {
id: m.id,
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,
duration: this.toDuration(m.workHour)
}
},
toUnit(n, m) {
return {
id: n.id,
start_date: '2007-01-01',
text: n.serialNumber,
parenId: n.parenId,
edition: n.gaceVersion,
parent: m.id,
right_text: n.name,
duration: this.toDuration(m.workHour)
}
},
toAo(m) {
return {
id: 'xxx',
// type: 'project',
start_date: '2007-01-01',
text: m.serialNumber,
parenId: m.parenId,
parent: m.id,
edition: m.gaceVersion,
right_text: m.name,
priority: true
}
},
getData() {
this.currentId = this.node.id
if (!this.node || !this.node.children) {
return
}
const ids = this.node.children.map(r => r.id)
const params = {
searchItems: { 'items': [{ 'fieldName': 'id', 'operator': 'IN', 'value': ids }] },
'sortItem': [{ 'fieldName': 'serialNumber', 'sortOrder': 'asc' }],
'openProps': [
{
'name': 'extProcessExecutorRoutes'
}, {
'name': 'extPositionLinks',
openProps: [{
'name': 'target',
openProps: [{ 'name': 'extProcessExecutorRoutes' }, {
'name': 'sourceExtProcessUsageLink', // sourceExtProcessUsageLink targetExtProcessUsageLink
openProps: [{
'name': 'target',
openProps: [{
'name': 'sourceExtProcessUsageLink',
openProps: [{
'name': 'target',
openProps: [{ 'name': 'extProcessExecutorRoutes' }]
}]
}]
}]
}]
}]
}
]
}
// ExtProcessUsageLink ExtPosition
this.$api.searchApi('ExtPosition', params).then(res => {
this.refreshGantt(res.items.content || [])
}).catch(() => {
this.refreshGantt([])
})
},
configLayout() {
const ganttIns = this.gantt
const that = this
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 html =
'<b >站位:</b> ' +
task.text +
'<br><b>工期:</b> ' +
Math.round(task.duration) +
'小时<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.date_format = '%Y-%m-%d %H:%i:%s'
ganttIns.config.duration_unit = 'minute'
ganttIns.config.autofit = false
ganttIns.config.auto_scheduling_move_projects = true
ganttIns.config.details_on_dblclick = false
ganttIns.config.auto_scheduling = true
ganttIns.config.scroll_on_click = true
ganttIns.config.start_on_monday = true
ganttIns.config.min_column_width = 60
var zoomConfig = {
levels: [
[
{
unit: 'month',
// step: 1,
format: function(date) {
var month = (new Date(date).getFullYear() - 2007) * 12 + new Date(date).getMonth() + 1
return month + '月' // ganttAg.date.getWeek(date)
}
},
{
unit: 'week',
format: function(date) {
var newDate = new Date(date)
var oldDate = new Date('2007/01/01')
var days = (newDate - oldDate) / (1 * 24 * 60 * 60 * 7 * 1000)
return Math.ceil(days + 1) + '周' // ganttIns.date.getWeek(date)
}
}
],
[
{
unit: 'week',
format: function(date) {
var newDate = new Date(date)
var oldDate = new Date('2007/01/01')
var days = (newDate - oldDate) / (1 * 24 * 60 * 60 * 7 * 1000)
return Math.ceil(days + 1) + '周' // ganttIns.date.getWeek(date)
}
},
{
unit: 'day',
format: function(date) {
var newDate = new Date(date)
var oldDate = new Date('2007/01/01')
var days = (newDate - oldDate) / (1 * 24 * 60 * 60 * 1000)
return Math.ceil(days + 1) + '日' // ganttIns.date.getWeek(date)
}
}
],
[
{
unit: 'day',
format: function(date) {
var newDate = new Date(date)
var oldDate = new Date('2007/01/01')
var days = (newDate - oldDate) / (1 * 24 * 60 * 60 * 1000)
return Math.ceil(days + 1) + '日' // ganttIns.date.getWeek(date)
}
},
{
unit: 'hour',
format: '%H'
}
]
],
startDate: new Date('2007/01/01'),
useKey: 'ctrlKey',
trigger: 'wheel',
element: function() {
return ganttIns.$root.querySelector('.gantt_task')
}
}
ganttIns.config.columns = [
{
name: '',
label: '节点',
align: 'left',
width: 60,
resize: true,
template: function(task) {
return (
"<span class='gantt_grid_wbs'>" + (ganttIns.getWBSCode(task) ||
'') + '</span>'
)
}
},
{
name: 'text',
label: '站位号',
align: 'left',
width: 160,
tree: true,
resize: true
},
{
name: 'edition',
label: '版本',
align: 'center',
width: 50,
resize: true
},
{
name: 'duration',
label: '工期(时)',
align: 'center',
width: 60,
resize: true,
template: function(task) {
return Math.round((task.duration || 0) / (3 * 60))
}
},
{
name: 'predecessors',
label: '前置',
width: 60,
align: 'center',
template: function(task) {
var links = task.$target
var labels = []
for (var i = 0; i < links.length; i++) {
var link = ganttIns.getLink(links[i])
var label = ganttIns.getWBSCode(ganttIns.getTask(link.source))
if (!labels.includes(label)) { labels.push(label) }
}
return "<span class='gantt_grid_predecessors'>" + labels.join(', ') + '</span>'
}
}
]
ganttIns.templates.link_class = function(link) {
if (link.isCritical) {
return 'critical_path'
}
}
ganttIns.templates.rightside_text = function(start, end, task) {
return '<b></b>' + (task.right_text || ' ')
}
ganttIns.templates.task_class = function(st, end, item) {
return (item.$level === 0 ? 'workday_over' : item.$level === 1 ? 'workday_ok' : '')
}
ganttIns.config.drag_resize = false
this.$nextTick(() => {
ganttIns.ext.zoom.init(zoomConfig)
ganttIns.init(this.$refs[this.onlyUuid])
})
ganttIns.attachEvent('onBeforeTaskDisplay', function(id, task) {
if (task.priority) {
return false
}
return true
})
this.$nextTick(() => {
ganttIns.init(this.ganttElId)
})
}
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" >
.TfMomWebView-model{
.search-bar{
width: 300px;
margin-bottom: 8px;
}
height: 100%;
.gatt{
height: calc(100% - 40px );
}
.gantt_critical_task{
background: #f39c4f;
border: 1px solid #f39c4f;
}
.gantt_task_line{
&.workday_over{
background: #f39c4f;
border: 1px solid #f39c4f;
}
}
}
</style> </style>
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