甘特图新增功能id的处理

This commit is contained in:
骆乐 2022-11-07 13:41:54 +08:00
parent e6d68d55d8
commit fb4cc47beb
3 changed files with 36 additions and 20 deletions

View File

@ -85,6 +85,11 @@
<script type="text/javascript">
// 父级传过来的参数
window.addEventListener('message', function(e) {
console.log(e.data, '父级页面传来的数据')
localStorage.setItem('id',e.data)
})
//页面加载就绪
window.onload = () => {
console.log("window.onload");
@ -164,15 +169,15 @@
// },
// ],
};
console.log("参数传进去了吗", data.PredecessorLink);
// console.log("参数传进去了吗", data.PredecessorLink);
if (dataArr[i].children.length > 0) {
let threeData = dataArr[i].children;
let threeNum = 0;
for (let j = 0; j < dataArr[i].children.length; j++) {
console.log(
"有关联的前置任务嘛",
dataArr[i].children[j].predecessorIds
);
// console.log(
// "有关联的前置任务嘛",
// dataArr[i].children[j].predecessorIds
// );
number++;
let children = {
id: dataArr[i].children[j].id,
@ -529,7 +534,6 @@
//右侧 拖拽
var itemdragcomplete = (e) => {
// console.log('=====拖拽回调',e)
let requestData = {
id: e.item.id,
projectSn: projectSn,
@ -632,10 +636,11 @@
position:absolute;
top: 20%;
left: 30%;
z-index: 9999;
z-index: 999;
width: 400px;
height: 400px;
border: 1px solid #000;
background-color: #fff;
}
.addbox{
margin: 20px;
@ -650,6 +655,7 @@
width:80px;
height: 30px;
margin-top: 20px;
margin-left: 80px;
}
</style>
</html>

View File

@ -97,6 +97,7 @@ mini.extend(GanttMenu, mini.Menu, {
console.log("点击新增执行",e);
var gantt = this.owner;
var targetTask = gantt.getSelected();
console.log('新增选中的',targetTask)
var task = gantt.newTask()
let url = window.parent.document.getElementById("iframe").contentWindow.location.search;
var parameter = url.split("="); //所有参数
@ -104,13 +105,13 @@ mini.extend(GanttMenu, mini.Menu, {
var projectSn = parameter[2].split("&")[0]; //projectSn
// var createUserId = store.state.userInfo.userId
//加到选中任务之后
// gantt.addTask(task, "after", targetTask);
document.getElementById('addDiv').style.display = 'block';
console.log('vvvvv',document.getElementById('addDiv'))
document.getElementById('cancel').onclick=function(){
document.getElementById('addDiv').style.display = 'none';
}
document.getElementById('submit').onclick=function(){
let userid = localStorage.getItem('id')
let data = {}
data.taskName = document.getElementById("taskName").value;
data.duration = document.getElementById("duration").value;
@ -121,20 +122,21 @@ mini.extend(GanttMenu, mini.Menu, {
data.actualStartDate = document.getElementById("actualStartDate").value;
data.actualFinishDate = document.getElementById("actualFinishDate").value;
data.remark = document.getElementById("remark").value;
console.log('data',data)
// document.getElementById('addDiv').style.display = 'none';
// if (!targetTask) {
// data.parentId = e.task.id
// }
console.log('新增的参数',data)
if(typeof(targetTask) != "undefined") {
data.parentId = e.targetTask.id
}
data.projectSn = projectSn
data.createUserId = '4'
console.log('data',data)
data.createUserId = userid
axios
.post(requestUrl + "xmgl/progressTask/addProgressTask", data)
.then((res) => {
console.log('====新增',res)
alert('新增成功!')
document.getElementById('addDiv').style.display = 'none';
console.log('res',res)
if(res.data.code == 200){
alert('新增成功!')
// gantt.loadTasks();
}
});
}
},

View File

@ -9,7 +9,7 @@
</gantt-elastic> -->
<!-- <gantt-header slot="header"></gantt-header>
<gantt-footer slot="footer"></gantt-footer> -->
<iframe :src="'doc/ExtGantt/Ext甘特图.html?url='+baseURL+'&projectSn='+projectSn+'&token='+$store.state.userInfo.token" id="iframe" class="Extgantt" > </iframe>
<iframe @load="load" :src="'doc/ExtGantt/Ext甘特图.html?url='+baseURL+'&projectSn='+projectSn+'&token='+$store.state.userInfo.token" id="iframe" class="Extgantt" > </iframe>
</div>
</div>
</template>
@ -25,6 +25,7 @@ export default {
return {
baseURL:'',
projectSn:'',
userId:"",
tasks: [
{
id: 99,
@ -265,7 +266,14 @@ export default {
created(){
this.baseURL = this.$http.defaults.baseURL;
this.projectSn = this.$store.state.projectSn;
this.userId = this.$store.state.userInfo.userId
},
methods:{
load() {
var idom = document.getElementById('iframe').contentWindow;
idom.postMessage(this.userId)
},
}
};
</script>
<style lang="less" scoped>