Commit b5407afa authored by 旭艳's avatar 旭艳

装配计划维护二期-甘特图

parent fbc75a35
......@@ -19,10 +19,19 @@
</div>
</div>
</header>
</div>
<main>
<div v-show="loading" class="load">
<i class="el-icon-loading" />
<span>数据加载中···</span>
</div>
<div :id="onlyUuid" :ref="onlyUuid" style="height: calc(100vh - 100px)" />
</main>
</div>
</template>
<script>
// import CsvExportor from 'csv-exportor'
import { post } from '@/utils/http'
export default {
name: 'TfMomWebContent',
......@@ -30,43 +39,512 @@ export default {
return {
disabledGenerateUpdates: true,
planStatusData: [],
planStatusLoading: true
planStatusLoading: true,
generateOrUpdateShow: false,
onlyUuid: 'assemblyPlan-gantt',
ganttAssembling: '',
tasks: {},
loading: false,
// eslint-disable-next-line no-undef
gantt: Gantt.getGanttInstance(),
tooltipId: null,
tooltipLoading: true,
tooltipData: {},
planLoading: false,
openTree: [],
project: null,
searchData: {}
}
},
created() {
this.getPlanStatus()
},
mounted() {
this.initGantt()
this.getPlanStatus()
this.$bus.$on('getGantData', (data, planData) => {
this.project = planData[0]
this.disabledGenerateUpdates = false
this.searchData = data
this.getAllData(data)
})
},
methods: {
/**
* 装配计划生成及更新
*/
generateOrUpdate() {
// const that = this
// if (that.generateOrUpdateShow) {
// that.$message({
// showClose: true,
// message: '正在更新,请稍后再试',
// type: 'warning'
// })
// } else {
// that.generateOrUpdateShow = true
// 初始化甘特图
initGantt() {
const that = this
const ganttStm = this.gantt
ganttStm.plugins({
tooltip: true
})
var zoomConfig = {
levels: [
[
{
unit: 'month',
step: 1,
format: '%Y-%m'
},
{
unit: 'day',
step: 1,
format: '%m-%d'
}
],
[
{
unit: 'day',
step: 1,
format: '%Y-%m-%d'
},
{
unit: 'hour',
step: 1,
format: '%H:%i:%s'
}
]
],
useKey: 'ctrlKey',
trigger: 'wheel',
element: function() {
return ganttStm.$root.querySelector('.gantt_task')
}
}
ganttStm.templates.tooltip_text = function(start, end, task) {
var html = null
if (task.$level === 0) {
html =
'<b>站位/装配单元:</b> ' +
task.text +
'<br><b>工期:</b> ' +
task.constPeriod +
'天' +
'<br/><b>计划开工时间:</b> ' +
that.formatDate(task.start_date) +
'<br/><b>计划完工时间:</b> ' +
that.formatDate(task.end_date)
// + '<br><b>齐套率:</b> ' +
// task.fitRates || 0
// '<br><b>状态:</b> ' + task.status
// '<br><b>问题状态:</b> ' + task.problemStatus
return html
} else {
html =
'<br><b>站位/装配单元:</b> ' +
task.text +
'<br><b>工期:</b> ' +
task.constPeriod +
'天' +
'<br/><b>计划开工时间:</b> ' +
that.formatDate(task.start_date) +
'<br/><b>计划完工时间:</b> '
// + that.formatDate(task.end_date) +
// '<br><b>齐套率:</b> ' +
// task.fitRates || 0
// '<br><b>状态:</b> ' + task.status
// '<br><b>问题状态:</b> ' + task.problemStatus
return html
// }
// return html
}
}
ganttStm.config.scroll_on_click = true
ganttStm.templates.link_class = function(link) {
if (link.isCritical) {
return 'critical_path'
}
}
ganttStm.templates.rightside_text = function(start, end, task) {
return '<b></b>' + (task.right_text || ' ')
}
ganttStm.templates.progress_text = function(start, end, task) {
return (
"<span style='text-align:left;'>" +
Math.round(task.progress * 100) +
'% </span>'
)
}
ganttStm.templates.timeline_cell_class = function(task, date) {
var isWorkTime =
new Date(date).getDay() === 0 || new Date(date).getDay() === 6
if (isWorkTime) {
return 'week_end'
}
return ''
}
ganttStm.templates.task_class = function(st, end, item) {
if (item.$level === 0) {
return 'level' + item.status || ''
} else {
return item.status || ''
}
}
ganttStm.attachEvent('onLinkDblClick', function(id, e) {
return false
})
ganttStm.attachEvent('onAfterTaskUpdate', function(id, item) {
// var data = {
// id: item.tooltipId,
// scheduledStart: that.formatDate(item.start_date)
// }
// that.$refs.gantt.loading = true
// // 如果项目计划状态为已下达
// // 生成
// if (that.projectStatus === 'Y') {
// that.generateProject()
// that.updatePlanTime(data)
})
// 当分支被打开时触发
ganttStm.attachEvent('onTaskOpened', function(id) {
that.openTree.push(Number(id))
})
// 当分支关闭时触发
ganttStm.attachEvent('onTaskClosed', function(id) {
var arr = that.openTree
arr.splice(
arr.findIndex((item) => item === Number(id)),
1
)
})
ganttStm.attachEvent('onTaskClick', function(id, e) {
if (e.target.classList[0] === 'seepdf') {
that.seePdf(id)
}
return true
})
// ganttStm.attachEvent('onBeforeTaskDrag', function(id, new_item) {
// // eslint-disable-next-line eqeqeq
// var links = ganttStm.getTableData().data.links.filter(p => p.target == id)
// links.forEach(p => {
// that.ganttStm.getLink(p.id).lag = 0
// that.ganttStm.refreshLink(p.id)
// })
// // 设置链接可修改
// return true
// })
// ganttStm.attachEvent('onAfterAutoSchedule', function(id, item) {
// that.diffLinks()
// })
// that.generateOrUpdateShow = false
// // })
ganttStm.config.columns = [
{
name: 'id',
label: '节点',
width: 80,
align: 'center',
resize: true,
template: function(task) {
return (
"<span class='gantt_grid_wbs'>" +
(ganttStm.getWBSCode(task) || '') +
'</span>'
)
}
},
// {
// name: 'fitRates',
// label: '齐套率',
// align: 'center',
// width: 60,
// resize: true
// },
// {
// name: 'status',
// label: '状态',
// align: 'center',
// width: 80,
// resize: true,
// template: function(task) {
// if (task.$level === 0) {
// const state = that.planStateOptions.find(r => r.value === task.status)
// return (
// "<div class='ca color " +
// task.status +
// "'>" +
// (state && state.label || task.status) +
// '</div>'
// )
// } else {
// // 更新
// // that.initAoLinks()
// that.updateProject()
// const state = that.stateOptions.find(r => r.value === task.status)
// return (
// "<div class='ao color " +
// task.status +
// "'>" +
// (state && state.label || task.status) +
// '</div>'
// )
// }
// }
// },
// {
// name: 'problemStatus',
// label: '问题状态',
// align: 'center',
// width: 80,
// resize: true
// },
{
name: 'text',
label: '站位/装配单元',
align: 'left',
width: 200,
tree: true,
resize: true,
template: function(obj) {
if (obj.$level === 1) {
return (
"<div class='seepdf'>" +
obj.text +
'</div>'
)
}
return obj.text
}
},
{
name: 'constPeriod',
label: '工期(时)',
align: 'center',
width: 60,
resize: true
},
{
name: 'start_date',
label: '计划开工时间',
align: 'center',
width: 120,
resize: true,
template: function(obj) {
return that.formatDate(obj.start_date)
}
},
{
name: 'end_date',
label: '计划完工时间',
align: 'center',
width: 120,
resize: true,
template: function(obj) {
return that.formatDate(obj.end_date)
}
},
{
name: 'predecessors',
label: '前置节点',
width: 100,
align: 'center',
resize: true,
template: function(task) {
var links = task.$target
var labels = []
for (var i = 0; i < links.length; i++) {
var link = ganttStm.getLink(links[i])
var label = ganttStm.getWBSCode(ganttStm.getTask(link.source))
labels.push(label)
}
return (
"<span class='gantt_grid_predecessors'>" +
labels.join(', ') +
'</span>'
)
}
}
]
ganttStm.config.date_format = '%Y-%m-%d %H:%i:%s'
ganttStm.config.duration_unit = 'minute'
ganttStm.config.scale_height = 70
ganttStm.config.min_column_width = 60
ganttStm.config.drag_progress = false
ganttStm.config.drag_resize = false
ganttStm.config.drag_links = false
ganttStm.config.details_on_dblclick = false
ganttStm.config.show_task_cells = true
// ganttStm.config.auto_scheduling = true
// ganttStm.config.auto_scheduling_initial = false
ganttStm.config.open_split_tasks = true
ganttStm.config.autoscroll = true
this.$nextTick(() => {
ganttStm.ext.zoom.init(zoomConfig)
ganttStm.init(this.$refs[this.onlyUuid])
})
},
// 获取甘特图数据
getAllData(val) {
const sortiesId = val.sorties.split(':')[0]
const sortiesTypeId = val.sorties.split(':').slice(-1)[0]
const params = {
'searchItems': { 'items': [{ 'fieldName': 'aircraftSortiesId', 'operator': 'EQ', 'value': sortiesId }, { 'fieldName': 'soritesTypeId', 'operator': 'EQ', 'value': sortiesTypeId }] },
'openProps': [
{
'name': 'extProcessExecutorRoutes'
},
{
'name': 'extPositionPlans'
},
{
'name': 'extPositionLinks',
'openProps': [
{
'name': 'target',
'openProps': [
{
'name': 'extProcessExecutorRoutes'
},
{
'name': 'wrProduction'
}
]
}
]
}],
'sortItem': [{ 'fieldName': 'serialNumber', 'sortOrder': 'asc' }]
}
this.planLoading = true
this.$api.searchApi('ExtPosition', params).then(res => {
if (res.items && res.items.content) {
this.refrehGantt(res.items.content)
}
}).catch((err) => {
console.log(err)
this.planLoading = false
})
},
refrehGantt(data) {
if (!data.length) {
return
}
const params = {
links: [],
data: []
}
data.forEach(p => {
this.addwrProduction(p, params)
this.addLink(p, params)
if (p.extPositionLinks) {
p.extPositionLinks.forEach(t => {
this.addAO(p, t, params)
this.addLink(t, params)
})
}
})
this.$nextTick(() => {
this.gantt.clearAll()
this.gantt.parse(params)
// this.start_date = this.getLongTime()
})
},
addLink(item, params) {
const links = item.extProcessExecutorRoutes
if (links) {
links.forEach(link => {
params.links.push(this.toLink(link))
})
}
},
toLink(l) {
return {
cid: l.id,
tid: l.currNodeId,
source: l.prevNodeId,
target: l.currNodeId,
type: '0',
isCritical: l.isCritical
}
},
addAO(m, p, params) {
if (p.target) {
params.data.push(this.toAO(m, p.target))
}
},
addwrProduction(p, params) {
if (p.extPositionPlans && p.extPositionPlans[0]) {
params.data.push(this.toWrProduction(p))
}
},
toWrProduction(p) {
return {
type: 'project',
id: p.id,
start_date: p.extPositionPlans[0].scheduledStart,
text: p.serialNumber,
right_text: p.name,
isLeaf: true,
materNo: p.materNo,
status: p.extPositionPlans[0].planState,
// 齐套率
// fitRates: Math.round((p.fitRates || 0) * 1000) / 10 + '%',
// 问题状态
// problemStatus: p.problemStatus,
// progress: Math.round((p.extPositionPlans[0].percentage || 0) * 10) / 1000,
wrStateCode: p.extPositionPlans[0].planState,
airModelId: p.extPositionPlans[0].aircraftTypeId,
sortiesId: p.extPositionPlans[0].aircraftSortiesId,
constPeriod: Number(p.extPositionPlans[0].costHours) || 0,
open: this.openTree.includes(p.id),
duration:
(new Date(p.extPositionPlans[0].scheduledEnd) -
new Date(p.extPositionPlans[0].scheduledStart)) /
1000 /
60
}
},
toAO(m, p) {
return {
id: p.id,
start_date: p.wrProduction[0].scheduledStart,
status: p.wrProduction[0].planState,
text: p.serialNumber,
parent: m.id,
right_text: p.name,
// 齐套率
// fitRates: Math.round(p.fitRates * 1000) / 10 + '%',
// 问题状态
// problemStatus: p.problemStatus,
tooltipId: p.wrProduction[0].id,
// progress: p.joExecutePlan[0].percentage,
constPeriod: Number(p.wrProduction[0].costHours) || 0,
open: this.openTree.includes(p.id),
duration:
(new Date(p.wrProduction[0].scheduledEnd) -
new Date(p.wrProduction[0].scheduledStart)) /
1000 /
60
}
},
/**
* 装配计划生成及更新
*/
generateOrUpdate() {
if (this.generateOrUpdateShow) {
this.$message({
showClose: true,
message: '正在更新,请稍后再试',
type: 'warning'
})
} else {
this.generateOrUpdateShow = true
}
// 生成
this.generateProject()
},
generateProject() {
const that = this
post(`/ExtPositionPlan/generateOrUpdate?id=${that.project.id}`, {},)
// post(`/ExtPositionPlan/generateOrUpdate?id=220731108341000`, {},)
.then((res) => {
if (res) {
if (res && res.message && res.message.includes('成功')) {
that.generateOrUpdateShow = false
that.getAllData(this.searchData)
}
} else {
that.$message({
showClose: true,
message: res.message,
type: 'error'
})
}
})
.catch((err) => console.error(err))
.finally(() => {
that.loading = false
})
},
/**
* 获取站位/装配单元计划状态
......@@ -91,6 +569,13 @@ export default {
this.planStatusLoading = false
})
})
},
formatDate(date) {
var text =
new Date(date).toLocaleDateString().split('/').join('-') +
' ' +
new Date(date).toTimeString().split(' ')[0]
return text
}
}
}
......@@ -98,6 +583,24 @@ export default {
<style lang="scss" scoped>
.tf-mom-web-content{
header{
display: flex;
justify-content: space-between;
padding: 8px;
.left {
> button > span > i {
margin-left: 10px;
font-size: 14px;
font-weight: bold;
color: rgb(30, 110, 214);
}
> span {
margin-left: 20px;
font-size: 10px;
color: red;
}
}
.right {
display: flex;
> .legnd {
......@@ -133,6 +636,10 @@ export default {
}
}
}
}
main{
padding: 0 8px;
}
}
</style>
......@@ -105,20 +105,20 @@
align="center"
>
<el-table-column
prop="extPosition.serialNumber"
prop="serialNumber"
label="站位"
width="60"
align="center"
/>
<el-table-column
prop="scheduledStart"
prop="extPositionPlans[0].scheduledStart"
label="计划开工"
min-width="50"
align="center"
:formatter="formatterDate"
/>
<el-table-column
prop="scheduledEnd"
prop="extPositionPlans[0].scheduledEnd"
label="计划完工"
min-width="50"
align="center"
......@@ -167,7 +167,7 @@ export default {
* 格式化时间值
*/
formatterDate(row, column, cellValue, index) {
return new Date(cellValue).toLocaleDateString()
return cellValue ? new Date(cellValue).toLocaleDateString() : ''
},
/**
* 格式化状态值
......@@ -268,8 +268,6 @@ export default {
this.$nextTick(() => {
if (this.statusData.length) {
this.form.status = false
// this.statusData[0].dictKey
// this.getProjectPlan()
}
})
} else {
......@@ -358,7 +356,7 @@ export default {
// }
this.$refs.projectPlanTable.setCurrentRow(this.projectPlanData[0])
this.getStation(this.projectPlanData[0])
this.getStation()
} else {
this.$message({
showClose: true,
......@@ -373,10 +371,27 @@ export default {
/**
* 获取站位
*/
getStation(val) {
if (val) {
this.standData = val.standData
getStation() {
const sortiesId = this.form.sorties.split(':')[0]
const sortiesTypeId = this.form.sorties.split(':').slice(-1)[0]
const params = {
'searchItems': { 'items': [{ 'fieldName': 'aircraftSortiesId', 'operator': 'EQ', 'value': sortiesId }, { 'fieldName': 'soritesTypeId', 'operator': 'EQ', 'value': sortiesTypeId }] },
'openProps': [{ name: 'extPositionPlans' }],
'sortItem': [{ 'fieldName': 'serialNumber', 'sortOrder': 'asc' }]
}
this.standLoading = true
this.$api.searchApi('ExtPosition', params).then(res => {
if (res.items) {
this.standData = res.items.content
} else {
this.standData = []
}
this.standLoading = false
this.$bus.$emit('getGantData', this.form, this.projectPlanData)
}).catch(() => {
this.standData = []
this.standLoading = false
})
}
}
}
......
......@@ -444,7 +444,7 @@ export default {
return {
id: p.id,
start_date: p.joExecutePlan[0].scheduledStart,
status: p.joExecutePlan[0].state,
status: p.joExecutePlan[0].planState,
text: p.serialNumber,
parent: m.id,
right_text: p.name,
......
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