2022-11-05 13:35:16 +08:00

152 lines
4.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var GanttMenu = function() {
GanttMenu.superclass.constructor.call(this);
};
mini.extend(GanttMenu, mini.Menu, {
_create: function() {
GanttMenu.superclass._create.call(this);
var menuItems = [
// { type: "menuitem", iconCls: "icon-goto", text: mini.Gantt.Goto_Text, name: "goto"},
// '-',
// { type: "menuitem", iconCls: "icon-upgrade", text: mini.Gantt.UpGrade_Text, name: "upgrade" },
// { type: "menuitem", iconCls: "icon-downgrade", text: mini.Gantt.DownGrade_Text, name: "downgrade" },
// '-',
{
type: "menuitem",
iconCls: "icon-add",
text: mini.Gantt.Add_Text,
name: "add",
},
{
type: "menuitem",
iconCls: "icon-edit",
text: mini.Gantt.Edit_Text,
name: "edit",
},
{
type: "menuitem",
iconCls: "icon-remove",
text: mini.Gantt.Remove_Text,
name: "remove",
},
"-",
{
type: "menuitem",
iconCls: "icon-zoomin",
text: mini.Gantt.ZoomIn_Text,
name: "zoomin",
},
{
type: "menuitem",
iconCls: "icon-zoomout",
text: mini.Gantt.ZoomOut_Text,
name: "zoomout",
},
];
this.setItems(menuItems);
// this.goto = mini.getbyName("goto", this);
this.zoomIn = mini.getbyName("zoomin", this);
this.zoomOut = mini.getbyName("zoomout", this);
// this.upgrade = mini.getbyName("upgrade", this);
// this.downgrade = mini.getbyName("downgrade", this);
this.add = mini.getbyName("add", this);
this.edit = mini.getbyName("edit", this);
this.remove = mini.getbyName("remove", this);
// this.goto.on("click", this.__OnGoto, this);
this.zoomIn.on("click", this.__OnZoomIn, this);
this.zoomOut.on("click", this.__OnZoomOut, this);
// this.upgrade.on("click", this.__OnUpgrade, this);
// this.downgrade.on("click", this.__OnDowngrade, this);
this.add.on("click", this.__OnAdd, this);
this.edit.on("click", this.__OnEdit, this);
this.remove.on("click", this.__OnRemove, this);
},
// __OnGoto: function (e) {
// var gantt = this.owner;
// var task = gantt.getSelected();
// if (task) {
// gantt.scrollIntoView(task);
// }
// },
__OnZoomIn: function(e) {
var gantt = this.owner;
gantt.zoomIn();
},
__OnZoomOut: function(e) {
var gantt = this.owner;
gantt.zoomOut();
},
// __OnUpgrade: function (e) {
// var gantt = this.owner;
// var task = gantt.getSelected();
// if (task) {
// gantt.upgradeTask(task);
// }
// },
// __OnDowngrade: function (e) {
// var gantt = this.owner;
// var task = gantt.getSelected();
// if (task) {
// gantt.downgradeTask(task);
// }
// },
__OnAdd: function(e) {
console.log("点击新增执行");
var gantt = this.owner;
var targetTask = gantt.getSelected();
var task = gantt.newTask();
console.log("=====添加", task);
//加到选中任务之后
// gantt.addTask(task, "after", targetTask);
// 新增弹窗
// 没有父级的时候
if (!targetTask) {
// var x;
// var name=prompt("请输入任务名称",""); //显示默认文本 ""
// var duration=prompt("请输入工期",""); //显示默认文本 ""
// var duration=prompt("请输入工期",""); //显示默认文本 ""
// var dutyUserName=prompt("请输入负责人名称",""); //显示默认文本 ""
// console.log('name',name,duration,dutyUserName,)
}
},
__OnEdit: function(e) {
var gantt = this.owner;
var task = gantt.getSelected();
if (!task) {
alert("请先选中任务再编辑哦!");
}
},
__OnRemove: function(e) {
var gantt = this.owner;
var task = gantt.getSelected();
//获取请求地址
let url = window.parent.document.getElementById("iframe").contentWindow
.location.search;
var parameter = url.split("="); //所有参数
var requestUrl = parameter[1].split("&")[0]; //请求服务器的地址
console.log("=======task", task);
if (task) {
if (confirm('确定删除任务 "' + task.taskName + '" ')) {
gantt.removeTask(task);
axios
.get(requestUrl + "xmgl/progressTask/deleteById", {
params: { id: task.id },
})
.then((res) => {
console.log("删除", res);
if (res.data.code == 200) {
alert("删除成功!");
}
});
}
} else {
alert("请选择要删除的任务");
}
},
});