$(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']);
}
}
})
}
})
})
});
JQ同一元素crud
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...