Commit 0529a544 authored by arvin's avatar arvin

甘特图站位路线

parent b751f88f
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"dependencies": { "dependencies": {
"axios": "^0.19.2", "axios": "^0.19.2",
"bpmn-js": "^7.0.0", "bpmn-js": "^7.0.0",
"csv-exportor": "^1.0.2",
"camunda-bpmn-moddle": "^4.4.0", "camunda-bpmn-moddle": "^4.4.0",
"lodash.foreach": "^4.5.0", "lodash.foreach": "^4.5.0",
"moment": "^2.26.0", "moment": "^2.26.0",
......
...@@ -5,14 +5,14 @@ export default { ...@@ -5,14 +5,14 @@ export default {
} }
}, },
mounted() { mounted() {
this.initGantt() this.gantt && this.initGantt()
}, },
methods: { methods: {
initGantt() { initGantt() {
this.setColumnsConfig() this.setColumnsConfig()
this.configLayout() this.usePlugins()
this.gantt.init(this.ganttElId)
this.gantt.i18n.setLocale('cn') this.gantt.i18n.setLocale('cn')
this.configLayout()
}, },
setColumnsConfig() { setColumnsConfig() {
this.gantt.config.columns = this.columns this.gantt.config.columns = this.columns
......
...@@ -33,15 +33,7 @@ export default { ...@@ -33,15 +33,7 @@ export default {
}, },
methods: { methods: {
search() {
},
export() {
},
save() {
}
} }
} }
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
<dee-tools mode="normal" :tools="tools" /> <dee-tools mode="normal" :tools="tools" />
</div> </div>
<div class="content-model"> <div class="content-model">
<step v-show="viewType === 'ExtPosition'" :show-flag="viewType === 'ExtPosition'" :node="node" /> <step ref="ExtPosition" v-show="viewType === 'ExtPosition'" :show-flag="viewType === 'ExtPosition'" :node="node" />
<unit v-show="viewType === 'unit'" :show-flag="viewType === 'unit'" :node="node" /> <unit ref="unit" v-show="viewType === 'unit'" :show-flag="viewType === 'unit'" :node="node" />
<view2 v-show="viewType === 'AircraftSorties'" :show-flag="viewType === 'AircraftSorties'" :node="node" /> <view2 ref="AircraftSorties" v-show="viewType === 'AircraftSorties'" :show-flag="viewType === 'AircraftSorties'" :node="node" />
</div> </div>
</div> </div>
</template> </template>
...@@ -101,14 +101,14 @@ export default { ...@@ -101,14 +101,14 @@ export default {
getData(params) { getData(params) {
this.node = params this.node = params
}, },
import() { export() {
this.$refs[this.viewType].export()
}, },
save() { save() {
this.$refs[this.viewType].save()
}, },
config() { config() {
this.$refs[this.viewType].config()
} }
} }
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<script> <script>
import config from './config' import config from './config'
import data from './data' import data from './data'
import CsvExportor from 'csv-exportor'
export default { export default {
name: 'TfMomWebStep', name: 'TfMomWebStep',
mixins: [config, data], mixins: [config, data],
...@@ -49,7 +50,8 @@ export default { ...@@ -49,7 +50,8 @@ export default {
} }
} }
return '<span>' + labels.join(',') + '</span>' return '<span>' + labels.join(',') + '</span>'
} },
editor: { type: 'custom_datepicker_editor' }
} }
] ]
} }
...@@ -76,7 +78,8 @@ export default { ...@@ -76,7 +78,8 @@ export default {
id: item.id, id: item.id,
parenId: link && link.prevNodeId || '', parenId: link && link.prevNodeId || '',
start_date: '2007-1-1', start_date: '2007-1-1',
duration: item.workHour ? (item.workHour / 8) : 0 type: 'task',
duration: item.workHour ? Number(item.workHour / 8) : 0
}) })
if (link) { if (link) {
params.links.push({ params.links.push({
...@@ -90,9 +93,9 @@ export default { ...@@ -90,9 +93,9 @@ export default {
}) })
} }
}) })
this.params = JSON.parse(JSON.stringify(params)) this.params = params
this.gantt.clearAll() this.gantt.clearAll()
this.gantt.parse(params) this.gantt.parse(this.params)
}, },
getData() { getData() {
this.currentId = this.node.id this.currentId = this.node.id
...@@ -120,7 +123,6 @@ export default { ...@@ -120,7 +123,6 @@ export default {
}, },
configLayout() { configLayout() {
const ganttAg = this.gantt const ganttAg = this.gantt
const that = this
const getInput = function(node) { const getInput = function(node) {
return node.querySelector('input') return node.querySelector('input')
} }
...@@ -194,8 +196,12 @@ export default { ...@@ -194,8 +196,12 @@ export default {
ganttAg.ext.zoom.init(zoomConfig) ganttAg.ext.zoom.init(zoomConfig)
// 允许通过拖放来调整任务大小 // 允许通过拖放来调整任务大小
ganttAg.config.drag_resize = true ganttAg.config.drag_resize = true
ganttAg.config.highlight_critical_path = false ganttAg.config.highlight_critical_path = true
ganttAg.templates.link_class = function(link) {
if (link.isCritical) {
return 'critical_path'
}
}
ganttAg.config.editor_types.custom_datepicker_editor = { ganttAg.config.editor_types.custom_datepicker_editor = {
show: function(id, column, config, placeholder) { show: function(id, column, config, placeholder) {
var html = var html =
...@@ -212,7 +218,7 @@ export default { ...@@ -212,7 +218,7 @@ export default {
focus: function(node) {}, focus: function(node) {},
set_value: function(value, id, column, node) { set_value: function(value, id, column, node) {
// eslint-disable-next-line eqeqeq // eslint-disable-next-line eqeqeq
var data = that.data.links var data = ganttAg.getTableData().data.links
.filter((p) => p.target === id) .filter((p) => p.target === id)
.map((p) => ganttAg.getWBSCode(ganttAg.getTask(p.source))) .map((p) => ganttAg.getWBSCode(ganttAg.getTask(p.source)))
ganttAg.getWBSCode(ganttAg.getTask(id)) ganttAg.getWBSCode(ganttAg.getTask(id))
...@@ -277,12 +283,11 @@ export default { ...@@ -277,12 +283,11 @@ export default {
// 删除连接后触发 // 删除连接后触发
ganttAg.attachEvent('onAfterLinkDelete', function(id, item) { ganttAg.attachEvent('onAfterLinkDelete', function(id, item) {
var target = ganttAg.getTask(item.target) var target = ganttAg.getTask(item.target)
console.log(ganttAg, target)
var targetLength = target.$target.length var targetLength = target.$target.length
if (!targetLength) { if (!targetLength) {
var data = { var data = {
links: this.gantt.getTableData().data.links, links: ganttAg.getTableData().data.links,
data: this.gantt.getTableData().data.data.map((p) => { data: ganttAg.getTableData().data.data.map((p) => {
delete p.end_date delete p.end_date
p.start_date = new Date(2007, 0, 1) p.start_date = new Date(2007, 0, 1)
return p return p
...@@ -298,8 +303,75 @@ export default { ...@@ -298,8 +303,75 @@ export default {
} }
return true return true
}) })
this.$nextTick(() => {
ganttAg.init(this.ganttElId)
})
},
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')
}
},
save() {
const tasks = this.gantt.getTableData().data.data
const links = this.gantt.getTableData().data.links
const params = this.ganttData.map(item => {
const routes = item.extProcessExecutorRoutes.map(r => {
return {
id: r.id,
operator: 'REMOVE'
}
})
const task = tasks.find(r => r.id === item.id)
if (item.extProcessExecutorRoutes) {
const link = links.find(r => r.target === item.id)
if (link) {
routes.push({
operator: 'ADD',
subTypeName: 'ExtProcessExecutorRoute',
prevNodeIdType: 'ExtPosition',
currNodeIdType: 'ExtPosition',
currNodeId: Number(link.target),
prevNodeId: Number(link.source),
isCritical: link.isCritical
})
}
}
return {
id: item.id,
operator: 'MODIFY',
subTypeName: 'ExtPosition',
workHour: task && (task.duration * 8) || 0,
extProcessExecutorRoutes: routes
}
})
this.$api.recursion('ExtPosition', params, true).then(() => {
this.getData()
})
} }
} }
} }
</script> </script>
......
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