$(function () {
$("#add-steps-btn").click(function (event) {
event.preventDefault();
var steps =$("#steps-tbody > tr");
var steps_len = steps.length;
var case_id =$("#steps-tbody").attr("case_id");
var steps_json ="";
var steps_data = [];
for (var i =0; i<value_len;i++){
var tdArr = steps.eq(i).find("td");
var request_url = tdArr.eq(0).find("input").val();
var request_haeders=tdArr.eq(1).find("input").val();
var methods_id = tdArr.eq(2).find("select").val();
var request_data = tdArr.eq(3).find("input").val();
var request_result = tdArr.eq(4).find("input").val();
if (!request_url || !request_data ||! request_result){
zlalert.alertInfoToast("请输入完整的用例步骤数据!");
return;
}
steps_json = {
'request_url':request_url,
'request_haeders':request_haeders,
'methods_id':methods_id,
'request_data':request_data,
'request_result':request_result
};
steps_data.push(steps_json);
}
var data1 = {
"case_id":case_id,
"steps_json":steps_data
};
console.log(data1);
$.post({
"url":"/Aaddcase/",
"content-type":"application/json;charset=utf-8",
"data":JSON.stringify(data1),
"success":function (data) {
if (data['code']==200){
zlalert.alertSuccessToast('操作成功!');
}else {
zlalert.alertInfo(data["message"]);
}
}
})
})
});
网友评论