|
@@ -1,13 +1,8 @@
|
|
|
<template>
|
|
|
<div class="ganCss">
|
|
|
<!-- v-show="showGantt" -->
|
|
|
- <gantt-elastic
|
|
|
- :options="options"
|
|
|
- :tasks="tasks"
|
|
|
- @tasks-changed="tasksUpdates"
|
|
|
- @options-changed="optionsUpdate"
|
|
|
- @dynamic-style-changed="styleUpdate"
|
|
|
- >
|
|
|
+ <gantt-elastic :options="options" :tasks="tasks" @tasks-changed="tasksUpdates" @options-changed="optionsUpdate"
|
|
|
+ @dynamic-style-changed="styleUpdate">
|
|
|
</gantt-elastic>
|
|
|
|
|
|
<!-- -->
|
|
@@ -15,6 +10,7 @@
|
|
|
</template>
|
|
|
|
|
|
<style>
|
|
|
+
|
|
|
</style>
|
|
|
<script>
|
|
|
import GanttElastic from "gantt-elastic";
|
|
@@ -131,17 +127,18 @@ let options = {
|
|
|
},
|
|
|
};
|
|
|
export default {
|
|
|
+ props: ['Json'],
|
|
|
// name: "Gantt",
|
|
|
components: {
|
|
|
GanttElastic,
|
|
|
// GanttHeader
|
|
|
},
|
|
|
- props: {
|
|
|
- gantData: {},
|
|
|
- flags: {
|
|
|
- type: String,
|
|
|
- },
|
|
|
- },
|
|
|
+ // props: {
|
|
|
+ // gantData: {},
|
|
|
+ // flags: {
|
|
|
+ // type: String,
|
|
|
+ // },
|
|
|
+ // },
|
|
|
data() {
|
|
|
return {
|
|
|
showGantt: false,
|
|
@@ -150,81 +147,81 @@ export default {
|
|
|
TaskData: [],
|
|
|
sontaskData: "",
|
|
|
tasks: [
|
|
|
- {
|
|
|
- id: 1,
|
|
|
- label: "项目一",
|
|
|
- start: this.getTody(new Date(), 4),
|
|
|
- end: this.getTody(new Date(), -30),
|
|
|
- duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
- percent: 85,
|
|
|
- type: "task",
|
|
|
- style: {
|
|
|
- base: {
|
|
|
- fill: "#4a83d0",
|
|
|
- stroke: "#4a83d0",
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- id: 2,
|
|
|
- label: "项目二",
|
|
|
- start: this.getTody(new Date(), 10),
|
|
|
- end: this.getTody(new Date(), -50),
|
|
|
- duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
- percent: 85,
|
|
|
- type: "task",
|
|
|
- style: {
|
|
|
- base: {
|
|
|
- fill: "#4a83d0",
|
|
|
- stroke: "#4a83d0",
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- id: 3,
|
|
|
- label: "项目三",
|
|
|
- start: this.getTody(new Date(), 15),
|
|
|
- end: this.getTody(new Date(), -80),
|
|
|
- duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
- percent: 85,
|
|
|
- type: "task",
|
|
|
- style: {
|
|
|
- base: {
|
|
|
- fill: "#4a83d0",
|
|
|
- stroke: "#4a83d0",
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- id: 4,
|
|
|
- label: "项目四",
|
|
|
- start: this.getTody(new Date(), 7),
|
|
|
- end: this.getTody(new Date(), -15),
|
|
|
- duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
- percent: 85,
|
|
|
- type: "task",
|
|
|
- style: {
|
|
|
- base: {
|
|
|
- fill: "#4a83d0",
|
|
|
- stroke: "#4a83d0",
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- id: 5,
|
|
|
- label: "项目五",
|
|
|
- start: this.getTody(new Date(), 3),
|
|
|
- end: this.getTody(new Date(), -40),
|
|
|
- duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
- percent: 85,
|
|
|
- type: "task",
|
|
|
- style: {
|
|
|
- base: {
|
|
|
- fill: "#4a83d0",
|
|
|
- stroke: "#4a83d0",
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
+ // {
|
|
|
+ // id: 1,
|
|
|
+ // label: "项目一",
|
|
|
+ // start: this.getTody(new Date(), 4),
|
|
|
+ // end: this.getTody(new Date(), -30),
|
|
|
+ // duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
+ // percent: 85,
|
|
|
+ // type: "task",
|
|
|
+ // style: {
|
|
|
+ // base: {
|
|
|
+ // fill: "#4a83d0",
|
|
|
+ // stroke: "#4a83d0",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: 2,
|
|
|
+ // label: "项目二",
|
|
|
+ // start: this.getTody(new Date(), 10),
|
|
|
+ // end: this.getTody(new Date(), -50),
|
|
|
+ // duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
+ // percent: 85,
|
|
|
+ // type: "task",
|
|
|
+ // style: {
|
|
|
+ // base: {
|
|
|
+ // fill: "#4a83d0",
|
|
|
+ // stroke: "#4a83d0",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: 3,
|
|
|
+ // label: "项目三",
|
|
|
+ // start: this.getTody(new Date(), 15),
|
|
|
+ // end: this.getTody(new Date(), -80),
|
|
|
+ // duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
+ // percent: 85,
|
|
|
+ // type: "task",
|
|
|
+ // style: {
|
|
|
+ // base: {
|
|
|
+ // fill: "#4a83d0",
|
|
|
+ // stroke: "#4a83d0",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: 4,
|
|
|
+ // label: "项目四",
|
|
|
+ // start: this.getTody(new Date(), 7),
|
|
|
+ // end: this.getTody(new Date(), -15),
|
|
|
+ // duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
+ // percent: 85,
|
|
|
+ // type: "task",
|
|
|
+ // style: {
|
|
|
+ // base: {
|
|
|
+ // fill: "#4a83d0",
|
|
|
+ // stroke: "#4a83d0",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: 5,
|
|
|
+ // label: "项目五",
|
|
|
+ // start: this.getTody(new Date(), 3),
|
|
|
+ // end: this.getTody(new Date(), -40),
|
|
|
+ // duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
+ // percent: 85,
|
|
|
+ // type: "task",
|
|
|
+ // style: {
|
|
|
+ // base: {
|
|
|
+ // fill: "#4a83d0",
|
|
|
+ // stroke: "#4a83d0",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // },
|
|
|
],
|
|
|
options,
|
|
|
dynamicStyle: {},
|
|
@@ -232,7 +229,7 @@ export default {
|
|
|
base: {
|
|
|
fill: "#4a83d0",
|
|
|
stroke: "#4a83d0",
|
|
|
- height:20,
|
|
|
+ height: 20,
|
|
|
},
|
|
|
},
|
|
|
unfinishedStyle: {
|
|
@@ -246,33 +243,21 @@ export default {
|
|
|
flag: true,
|
|
|
};
|
|
|
},
|
|
|
- created() {},
|
|
|
+ created() { },
|
|
|
mounted() {
|
|
|
- that = this;
|
|
|
- if (this.gantData) {
|
|
|
- this.getTaskList(this.gantData.id);
|
|
|
- }
|
|
|
+ this.getTaskList();
|
|
|
},
|
|
|
computed: {},
|
|
|
watch: {
|
|
|
- gantData: function (news, old) {
|
|
|
- this.getTaskList(news.id);
|
|
|
- },
|
|
|
+ Json: {
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ handler(newValue, oldValue) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
- // addTask() {
|
|
|
- // this.tasks.push({
|
|
|
- // id: this.lastId++,
|
|
|
- // label:
|
|
|
- // '<a href="https://images.pexels.com/photos/423364/pexels-photo-423364.jpeg?auto=compress&cs=tinysrgb&h=650&w=940" target="_blank" style="color:#0077c0;">Yeaahh! you have added a task bro!</a>',
|
|
|
- // user:
|
|
|
- // '<a href="https://images.pexels.com/photos/423364/pexels-photo-423364.jpeg?auto=compress&cs=tinysrgb&h=650&w=940" target="_blank" style="color:#0077c0;">Awesome!</a>',
|
|
|
- // start: getDate(24 * 3),
|
|
|
- // duration: 1 * 24 * 60 * 60 * 1000,
|
|
|
- // percent: 50,
|
|
|
- // type: "project"
|
|
|
- // });
|
|
|
- // },
|
|
|
handleClose() {
|
|
|
this.dialogVisible = false;
|
|
|
},
|
|
@@ -314,77 +299,31 @@ export default {
|
|
|
return iDays;
|
|
|
},
|
|
|
//获取数据-----------------------------------------------------
|
|
|
- getTaskList(id) {
|
|
|
- var that = this;
|
|
|
-
|
|
|
- var params = {};
|
|
|
- params["projectId"] = id;
|
|
|
- this.$ajax
|
|
|
- .post("/ipm/index.php?a=default.taskList", params)
|
|
|
- .then(function (res) {
|
|
|
- if (res.data.success) {
|
|
|
- // that.showGantt = true;
|
|
|
- that.TaskData.length = [];
|
|
|
- var list = res.data.datas;
|
|
|
- var startTime = list[0].startTime;
|
|
|
- var endTime = list[list.length - 1].endTime;
|
|
|
- var diffTime = that.datedifference(endTime, startTime);
|
|
|
- var temp1 = {
|
|
|
- id: Number(id),
|
|
|
- label: that.gantData.name,
|
|
|
- nums: "",
|
|
|
- user: "无",
|
|
|
- start: startTime,
|
|
|
- end: endTime,
|
|
|
- duration: diffTime * 24 * 60 * 60 * 1000,
|
|
|
- percent: 85,
|
|
|
- type: "project",
|
|
|
- };
|
|
|
- that.TaskData.push(temp1);
|
|
|
- for (var i = 0; i < list.length; i++) {
|
|
|
- var temp = {
|
|
|
- id: Number(list[i].id) + 1,
|
|
|
- code: list[i].code,
|
|
|
- label:
|
|
|
- '<span style="color:#0077c0;">' + list[i].name + "</span>",
|
|
|
- text: list[i].name,
|
|
|
- nums: list[i].statusText,
|
|
|
- user: list[i].operatePerson,
|
|
|
- parentId: Number(list[i].projectId), //parentId 要跟父级的id对应
|
|
|
- start: list[i].startTime,
|
|
|
- end: list[i].endTime,
|
|
|
- duration:
|
|
|
- that.datedifference(list[i].endTime, list[i].startTime) *
|
|
|
- 24 *
|
|
|
- 60 *
|
|
|
- 60 *
|
|
|
- 1000, //获取时间差 任务完成的时间段
|
|
|
- percent: 50,
|
|
|
- type: "milestone",
|
|
|
- // collapsed: true,
|
|
|
- style: {
|
|
|
- base: {
|
|
|
- fill: "#4a83d0",
|
|
|
- stroke: "#4a83d0",
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
- that.TaskData.push(temp);
|
|
|
- }
|
|
|
-
|
|
|
- if (that.TaskData.length > 0) {
|
|
|
- that.showGantt = true;
|
|
|
- that.tasksUpdates(that.TaskData, 2);
|
|
|
- that.optionsUpdate(that.options, 2);
|
|
|
- }
|
|
|
- } else {
|
|
|
- that.showGantt = false;
|
|
|
- that.$message.warning(res.data.message);
|
|
|
- }
|
|
|
- });
|
|
|
+ getTaskList() {
|
|
|
+ var unitJson = this.Json
|
|
|
+ for (var i = 0; i < unitJson.length; i++) {
|
|
|
+ let task = unitJson[i].chapterInfo[0].taskJson
|
|
|
+ for (var j = 0; j < task.length; j++) {
|
|
|
+ this.tasks.push({
|
|
|
+ id: i+'-'+j,
|
|
|
+ label: '第'+(i+1)+'阶段-'+task[j].task,
|
|
|
+ start: this.getTody(task[j].time[0]),
|
|
|
+ end: this.getTody(task[j].time[1]),
|
|
|
+ duration: 30 * 24 * 60 * 60 * 1000,
|
|
|
+ percent: 85,
|
|
|
+ type: "task",
|
|
|
+ style: {
|
|
|
+ base: {
|
|
|
+ fill: "#4a83d0",
|
|
|
+ stroke: "#4a83d0",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
//点击弹出-----------------------------------------------------
|
|
|
- showDialog(data) {},
|
|
|
+ showDialog(data) { },
|
|
|
|
|
|
tasksUpdates(tasks, num) {
|
|
|
if (num == 2) {
|
|
@@ -406,5 +345,6 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
<style scoped>
|
|
|
+
|
|
|
</style>
|
|
|
|