$(function () {
$("#add-task-btn").click(function (event) {
var dialog =$("#task-dialog");
dialog.modal("show");
var pj_nameE = dialog.find("#S option:first");
var task_nameE = dialog.find("input[name='task_name']");
var describeE = dialog.find("input[name='describe']");
var create_nameE = dialog.find("input[name='create_name']");
var saveBtn = dialog.find("#save-case-btn");
var username =$("#g_username").html();
pj_nameE.prop("selected", 'selected');
task_nameE.val('');
describeE.val('');
create_nameE.val(username);
saveBtn.removeAttr("data-type");
})
});
$(function () {
$("#save-task-btn").click(function (event) {
event.preventDefault();
var self =$(this);
var submitType = self.attr("data-type");
var task_id = self.attr("data-id");
var pj_name =$("#S option:selected").text();
var task_name =$("input[name='task_name']").val();
var describe =$("input[name='describe']").val();
var create_name =$("input[name='create_name']").val();
if (!pj_name || !task_name ||! describe ||!create_name){
zlalert.alertInfoToast("请输入完整的用例数据!");
return;
}
var url ="";
if(submitType =='update'){
url ='/Utesttask/';
}else {
url ='/Atesttask/'
}
$.post({
'url':url,
'data':{
'task_id':task_id,
'pj_name':pj_name,
'task_name':task_name,
'describe':describe,
'create_name':create_name
},
'success':function (data) {
if(data['code']==200){
window.location.reload();
}else {
zlalert.alertInfo(data['message']);
}
}
})
})
});
$(function () {
$(".edit-task-btn").click(function (event) {
event.preventDefault();
var self =$(this);
var dialog =$("#task-dialog");
dialog.modal("show");
var tr = self.parent().parent();
var pj_name =tr.attr("data-pj_name");
var task_name = tr.attr("data-task_name");
var describe = tr.attr("data-describe");
var create_name = tr.attr("data-create_name");
var pj_nameE = dialog.find("#S");
var task_nameE = dialog.find("input[name='task_name']");
var describeE = dialog.find("input[name='describe']");
var create_nameE = dialog.find("input[name='create_name']");
var saveBtn = dialog.find("#save-task-btn");
pj_nameE.val(pj_name);
task_nameE.val(task_name);
describeE.val(describe);
create_nameE.val(create_name);
saveBtn.attr("data-type","update");
saveBtn.attr("data-id",tr.attr('data-id'))
})
});
$(function () {
$(".delete-task-btn").click(function (event) {
event.preventDefault();
var self =$(this);
var tr = self.parent().parent();
var task_id = tr.attr('data-id');
zlalert.alertConfirm({
"msg":"您确定删除这条测试计划吗?",
"confirmCallback":function () {
$.post({
'url':'/Dtesttask/',
'data':{
'task_id':task_id
},
'success':function (data) {
if (data['code']==200){
window.location.reload();
}else {
zlalert.alertInfo(data['message']);
}
}
})
}
})
})
});