Jquery记录
//添加行
function AddRow(obj) {
var con = obj.parentNode.parentNode.cloneNode(true);
obj.parentNode.parentNode.parentNode.insertAdjacentElement("beforeEnd", con);
//每次添加行的时候清空工作时间和内容,其他不清空
$("#serviceData tr:last").find("input[name=workDate]").val("");
$("#serviceData tr:last").find("input[name=workcontent]").val("");
//得到多少行
var table = document.getElementById("serviceData");
var rows = table.rows.length;
//设置id
var newId = "workDate" + rows;
$("#serviceData tr:last").find("input[name=workDate]").attr("Id", newId);
//工时新增
laydate.render({
elem: '#'+newId
});
//工作时间输入逻辑处理
WorkHourInput();
}
//删除行
function DelRow(obj) {
$(obj).parent().parent().remove();
}
//显示涉及服务
function Z_ShowProLinePicker(obj) {
//记录当前点击的行数
var row = $(obj).parent().parent().index();
$("#service_nowclickRowindex").val(row);
$("#servicemodal").modal('show');
}
//涉及服务选择(多选)
function SelectProLine(obj) {
var id = $(obj).attr("id");
var name = $(obj).attr("name");
//得到点击的行数
var rowIndex = parseInt($("#service_nowclickRowindex").val()) + 1;
var nameInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(4) input:eq(1)");
var oldNameValue = nameInp.val();
var idInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(4) input:eq(0)");
var oldIdValue = idInp.val();
if (oldIdValue.indexOf(id) != -1) {//包含就是删除
$(obj).parent().find("i[name=ischecked]").hide();// //选中图标的隐藏
if (oldIdValue.indexOf("," + id) != -1) {
oldNameValue = oldNameValue.replace("," + name, '');
oldIdValue = oldIdValue.replace("," + id, '');
} else {
oldNameValue = oldNameValue.replace(name, '');
oldIdValue = oldIdValue.replace(id, '');
}
nameInp.val(oldNameValue);
idInp.val(oldIdValue);
} else {//不包含就是增加
$(obj).parent().find("i[name=ischecked]").show();// //选中图标的显示
if (oldNameValue.length > 0) {
nameInp.val(oldNameValue + "," + name);
idInp.val(oldIdValue + "," + id);
}
else {
nameInp.val(name);
idInp.val(id);
}
}
nameInp.attr("title", nameInp.val());
}
//涉及服务选择(单选)
function SelectProLineSingle(obj) {
var name = $(obj).attr("name");
//得到点击的行数
var rowIndex = parseInt($("#service_nowclickRowindex").val()) + 1;
$("#serviceData tr:eq(" + rowIndex + ") td:eq(4) input:eq(0)").val(name);
$("#servicemodal").modal('hide');
}
//子任务点击选择
function SelectSubTask(obj) {
$("#choseapprovePerson").hide();
$("#chosedApproves").hide();
$("#approvePerson").empty();
$("#selectapprovePersonId").val("");
//都要是小写
var projectName = $(obj).data("projectname");
var projectManager = $(obj).data("projectmanager");
var taskName = $(obj).data("taskname");
var taskManager = $(obj).data("taskmanager");
var subTaskName = $(obj).data("subtaskname");
var subTaskManager = $(obj).data("subtaskmanager");
var subTaskId = $(obj).data("subtaskid");
var subtaskidDes = $(obj).data("subtaskiddes");
var estimate_hours = $(obj).data("estimate_hours");
var totalUseHours = $(obj).data("totalUsehours");
var projectId = $(obj).data("projectid");
var taskId = $(obj).data("taskid");
var productline3id = $(obj).data("productline3id");//三级服务产品线id
var servicetype = $(obj).data("servicetype");//虚拟四级
var productline3name = $(obj).data("productline3name");//三级服务产品线值
var hardwareProline = $(obj).data("hardwareproline");//硬件产品线value
var hardwareProlineName = $(obj).data("hardwareprolinename");//硬件产品线name
var payContent = $(obj).data("paycontent");
var customerName = $(obj).data("customername").trim();//客户名称
var contract_No = $(obj).data("contract_no");//合同号
var secondOrder_No = $(obj).data("secondorder_no");//二级订单号
var projectType = $(obj).data("projecttype");//项目类型
//合同订单
//支持类可选,选择来源是子任务对应客户的合同订单
//非支持类带过来,根据项目合同号自动关联并显示,不予许修改
//(服务合同默认为对应合同号,产品合同默认二级订单号,借货合同默认合同号,营销需求默认合同号)
//产品线
//当虚拟四级为:增值IT和增值CT时,产品线栏位为灰色不可选(在当前界面录入);
//当虚拟四级为:支持类,将任务层级的产品线默认读取过来,用户只需要选择产品,为必须
//当虚拟四级为:上述三种之外,用户手工选择产品线,然后手工选择产品。 ,为必须
//初始化
$("#serviceData").find("input[name=workhour]").attr("disabled", "disabled");
$("#serviceData").find("input[name=onpassagehour]").attr("disabled", "disabled");
$("#serviceData").find("input[name=overhour]").attr("disabled", "disabled");
$("#serviceData").find("input[name=totalhour]").attr("disabled", "disabled");
$("#serviceData").find("input[name=productlinetext]").val("").attr("disabled", false);
$("#serviceData").find("input[name=productline]").val();
$("#serviceData").find("input[name=IsShowAll]").val(1);//设置为1
$("#serviceData").find("input[name=productline]").val("[]");
$("input[name=SearchKey]").val("");
$("#appointApproverDiv").hide();
if (servicetype == "ZZ_it" || servicetype == "ZZ_ct") {//增值it,ct
$("#serviceData").find("input[name=productlinetext]").val("不涉及").attr("disabled", "disabled");
$("#serviceData").find("input[name=workhour]").attr("disabled", false);
$("#serviceData").find("input[name=onpassagehour]").attr("disabled", false);
$("#serviceData").find("input[name=overhour]").attr("disabled", false);
}
else if (servicetype == "ZCL") {//支持类
if (hardwareProline.length > 0) {//有值
$("#serviceData").find("input[name=productline]").val("[{\"proLvalue1\":\"" + hardwareProline + "\",\"proLname1\":\"" + hardwareProlineName + "\",\"wkhour\":\"0\",\"ophour\":\"0\",\"ovhour\":\"0\",\"pro2names\":\"\"}]");
$("#serviceData").find("input[name=IsShowAll]").val(0);//设置为0
}
//支持类可选,根据选择的子任务的客户名称加载合同订单
$("#serviceData").find("input[name=ContractNo]").val("").attr("disabled", false);
//var conurl = "/Partial/ContractsList?Customer_Name=" + customerName + "&onclick=SelectContractSingle(this)";
//$("#ContractsListView").load(conurl);
$("#ContractsList_SearchForm").find("input[name=Customer_Name]").val(customerName);
$("#ContractsList_SearchForm").submit();
}
if (servicetype != "ZCL") {//非支持类
//合同订单,非支持类 (服务合同默认为对应合同号,产品合同默认二级订单号,借货合同默认合同号,营销需求默认合同号)
if (projectType == "服务合同" || projectType == "借货合同" || projectType == "营销需求")
{
$("#serviceData").find("input[name=ContractNo]").val(contract_No).attr("disabled", "disabled");
} else if (projectType == "产品合同")
{
$("#serviceData").find("input[name=ContractNo]").val(secondOrder_No).attr("disabled", "disabled");
}
}
//涉及服务
if (productline3id != "" && productline3id != null) {
$("#serviceData").find("input[name=serviceName]").val(productline3name).attr("disabled", "disabled");
}
$("#projectName").val(projectName);
$("#projectManager").val(projectManager);
$("#taskName").val(taskName);
$("#taskManager").val(taskManager);
$("#subTaskName").val(subTaskName);
$("#subTaskManager").val(subTaskManager);
$("#estimate_hours").val(estimate_hours);
$("#totalUseHours").val(totalUseHours);
$("#qualityMonitoringPoint").val(payContent);
$("#subTaskId").val(subTaskId);
$("#projectId").val(projectId);
$("#taskId").val(taskId);
$("#servicetype").val(servicetype);
$("#subTaskIdDes").val(subtaskidDes);
$("#SelectWorkHourTaskmodal").modal('hide');
//录入工时框显示
$("#addwkBody").show();
//判断该项目任务下的工时是否需要审批
JudgeWorkHourIsApprove(projectId, taskId);
}
//判断是否需要选择审核人,需要则加载审核人
function JudgeWorkHourIsApprove(projectId, taskId) {
$.ajax({
url: "/Projects_WorkHour/JudgeWorkHourIsApprove",
data: {
projectId: projectId, taskId: taskId
},
dataType: "json", type: "POST",
success: function (res) {
if (res.mes == "YES_NEEDCHOSE") {//需要选择审核人
$("#choseapprovePerson").show();
$("#chosedApproves").show();
$("#wkApprovers tbody").empty();
$("#isNeedChoseApprove").val("1");
//自动搜索
$("input[name=BenifitBranchName]").val(res.data);
$("#PwkApprover_SearchForm").submit();
} else if (res.mes == "YES_NOCHOSE")//不需要选择
{
$("#appointApproverDiv").show();
$("#appointApprover").text(res.data);
} else {//不需要审核
//用户添加成功显示判断
$("#isNeedApprove").val("NO");
}
},
error: function () { alert("此子任务不能继续录入工时"); }
});
}
//涉及项目显示
function Z_ShowContractPicker(obj) {
//记录当前点击的行数
var row = $(obj).parent().parent().index();
$("#contract_nowclickRowindex").val(row);
$("#contractmodal").modal('show');
$("#contractmodal").find("i[name=ischecked]").hide();//选中图标全部隐藏
}
//合同选择(多选)
function SelectContract(obj) {
var contractNo = $(obj).attr("contractNo");
var name = $(obj).attr("name");
//得到点击的行数
var rowIndex = parseInt($("#contract_nowclickRowindex").val()) + 1;
var nameInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(3) input:eq(1)");
var oldNameValue = nameInp.val();
//记录选中的contractNo
var contractNoInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(3) input:eq(0)");
var oldcontractNoValue = contractNoInp.val();
if (oldcontractNoValue.indexOf(contractNo) != -1) {//包含就是删除
$(obj).find("i[name=ischecked]").hide();// //选中图标的隐藏
if (oldcontractNoValue.indexOf("," + contractNo) != -1) {
//oldNameValue = oldNameValue.replace("," + name, '');
oldcontractNoValue = oldcontractNoValue.replace("," + contractNo, '');
oldNameValue = oldNameValue.replace("," + contractNo, '');
} else {
//oldNameValue = oldNameValue.replace(name, '');
oldcontractNoValue = oldcontractNoValue.replace(contractNo, '');
oldNameValue = oldNameValue.replace(contractNo, '');
}
nameInp.val(oldNameValue);
contractNoInp.val(oldcontractNoValue);
} else {//不包含就是增加
$(obj).find("i[name=ischecked]").show();// //选中图标的显示
if (oldNameValue.length > 0) {
//nameInp.val(oldNameValue + "," + name);
contractNoInp.val(oldcontractNoValue + "," + contractNo);
nameInp.val(oldcontractNoValue + "," + contractNo);
}
else {
//nameInp.val(name);
contractNoInp.val(contractNo);
nameInp.val(contractNo);
}
}
nameInp.attr("title", nameInp.val());
}
//合同选择(单选)
function SelectContractSingle(obj) {
var contractNo = $(obj).attr("contractNo");
//得到点击的行数
var rowIndex = parseInt($("#contract_nowclickRowindex").val()) + 1;
$("#serviceData tr:eq(" + rowIndex + ") td:eq(3) input:eq(0)").val(contractNo);
$("#contractmodal").modal('hide');
}
//产品线显示---isShowALl表示是否显示全部 1是0否
function Z_ShowProductLine(obj) {
//记录当前点击的行数
var row = $(obj).parent().parent().index();
$("#productline_nowclickRowindex").val(row);
//加载产品线的信息
var jsonStr = $(obj).parent().find("input[name=productline]").val();
var isShowALl = $(obj).parent().find("input[name=IsShowAll]").val();
//所有控件还原默认值(表头跳过)
$("#datatable tr:not(:first)").each(function () {
$(this).hide();
});
$("#datatable input[name=proIsChecked]").each(function () {
$(this).prop("checked", false);
});
$("#datatable input").each(function () {
$(this).val("0");
});
LoadProLine(jsonStr, isShowALl);
$("#productlinemodal").modal('show');
}
//产品线选择
function SelectProductLine() {
var nameVals = "";
var idVals = "";
var isFALSE = 0;//判断是否选择涉及产品(必选)
var wkhours = 0; var ovhours = 0; var ophours = 0;
var ths = $("#datatable").find("input[name=proIsChecked]:checked");
if (ths.length <= 0) {
alert("请选择产品线");
return;
}
$("#datatable").find("input[name=proIsChecked]").each(function () {
if ($(this).is(':checked')) {
var id1 = $(this).attr("id1");//一级产品value
var name1 = $(this).attr("name1");//一级产品name
var wkhour = $(this).parent().parent().find("#wkhour").val();
var ophour = $(this).parent().parent().find("#ophour").val();
var ovhour = $(this).parent().parent().find("#ovhour").val();
wkhours = parseFloat(wkhour) + parseFloat(wkhours);
ovhours = parseFloat(ovhour) + parseFloat(ovhours);
ophours = parseFloat(ophour) + parseFloat(ophours);
//涉及产品
var pro2names = "";
var procks = $(this).parent().parent().find("[name='proline2']");
procks.each(function () {
if ($(this).is(':checked')) {
var pro2name = $(this).attr("pro2name");
pro2names += pro2name + ",";
}
});
if (wkhour == "0")
{
isFALSE = 2;
return;
}
if (pro2names.length <= 0) {//涉及产品线
isFALSE = 1;
return;
}
nameVals += name1 + ",";
idVals += '{"proLvalue1":"' + id1 + '","proLname1":"' + name1 + '","wkhour":"' + wkhour +
'","ophour":"' + ophour + '","ovhour":"' + ovhour + '","pro2names":"' + pro2names + '"},';
}
});
if (isFALSE == 1) {
alert("请选择涉及产品");
return;
}
if (isFALSE == 2) {
alert("工作时长不能为0");
return;
}
nameVals = nameVals.substring(0, nameVals.length - 1);
idVals = '[' + idVals.substring(0, idVals.length - 1) + ']';
//得到点击的行数
var rowIndex = parseInt($("#productline_nowclickRowindex").val()) + 1;
//记录name
var nameInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(5) input:eq(1)");
//记录选中的id
var idInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(5) input:eq(0)");
nameInp.val(nameVals);
idInp.val(idVals);
nameInp.attr("title", nameInp.val());
//更新页面的时间
var whInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(7) input:eq(0)");
whInp.val(wkhours);
var opInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(8) input:eq(0)");
opInp.val(ophours);
var ovInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(9) input:eq(0)");
ovInp.val(ovhours);
var totalInp = $("#serviceData tr:eq(" + rowIndex + ") td:eq(10) input:eq(0)");
totalInp.val(wkhours);
//关闭模态窗
$("#productlinemodal").modal('hide');
}
//问题工单显示
function Z_ShowCaseNumPicker(obj) {
//记录当前点击的行数
var row = $(obj).parent().parent().index();
$("#caseNum_nowclickRowindex").val(row);
$("#caseNumtmodal").modal('show');
}
//问题工单选择
function SelectCasenum(obj) {
var id = $(obj).attr("id");
var name = $(obj).attr("name");
//得到点击的行数
var rowIndex = parseInt($("#caseNum_nowclickRowindex").val()) + 1;
$("#serviceData tr:eq(" + rowIndex + ") td:eq(6) input:eq(1)").val(name);
$("#serviceData tr:eq(" + rowIndex + ") td:eq(6) input:eq(0)").val(name);
$("#caseNumtmodal").modal('hide');
}
//显示审核人选择
function ShowApprovePerson() {
$("#pwkapproverPickermodal").modal('show');
$("#pwkapproverPickermodal").find("i[name=ischecked]").hide();//选中图标全部隐藏
}
//审核人员选择
function PwkapproverPicker(obj) {
var id = $(obj).data("id");
var name = $(obj).data("name");
var oldIdValue = $("#selectapprovePersonId").val();
if (oldIdValue.indexOf(id) != -1) {//包含就是删除
$(obj).parent().parent().find("i[name=ischecked]").hide();//选中图标的隐藏
if (oldIdValue.indexOf("," + id) != -1) {
oldIdValue = oldIdValue.replace("," + id, '');
} else {
oldIdValue = oldIdValue.replace(id, '');
}
$("#selectapprovePersonId").val(oldIdValue);
$("#approvePerson #" + id).remove();
} else {//不包含就是增加
$(obj).parent().parent().find("i[name=ischecked]").show();// //选中图标的显示
if (oldIdValue.length > 0) {
$("#selectapprovePersonId").val(oldIdValue + id + ",");
}
else {
$("#selectapprovePersonId").val(id + ",");
}
$("#approvePerson").append("<li id=" + id + "><i onclick=\"RemoveApprovePerson(" + id + ")\" class=\"fa fa-minus-square\" aria-hidden=\"true\" style=\"color:red;\"></i> " + name + "</li>");
}
}
//删除审核人员
function RemoveApprovePerson(id) {
var oldIdValue = $("#selectapprovePersonId").val();
if (oldIdValue.indexOf("," + id) != -1) {
oldIdValue = oldIdValue.replace("," + id, '');
} else {
oldIdValue = oldIdValue.replace(id, '');
}
$("#selectapprovePersonId").val(oldIdValue);
$("#approvePerson #" + id).remove();
}
//在产品线中录入工时,加班工时不能大于工作时长+在途时长
function OvhourWrite(obj) {
var wkhour = $(obj).parent().parent().find("#wkhour").val();
var ophour = $(obj).parent().parent().find("#ophour").val();
var ovhour = $(obj).parent().parent().find("#ovhour").val();
if (parseFloat(ovhour) > (parseFloat(ophour) + parseFloat(wkhour))) {
alert("加班时长不能大于工作时长+在途时长");
$(obj).parent().parent().find("#ovhour").val("0");
}
}
//直接录入工时,加班工时不能大于工作时长+在途时长
function OvhourWriteZJ(obj) {
var workhour = $(obj).parent().parent().find("#workhour").val();
var onpassagehour = $(obj).parent().parent().find("#onpassagehour").val();
var overhour = $(obj).parent().parent().find("#overhour").val();
if (parseFloat(overhour) > (parseFloat(onpassagehour) + parseFloat(workhour))) {
alert("加班时长不能大于工作时长+在途时长");
$(obj).parent().parent().find("#overhour").val("0");
}
}
//加载产品线信息,显示到页面
function LoadProLine(jsonStr,isShowALl) {
var jsonObj = $.parseJSON(jsonStr);
var tds = $("#datatable tr").each(function () {
var pro = $(this).find("td:eq(1)").text();//
if (isShowALl == 1) { $(this).show() }//显示全部
for (var i in jsonObj) {
//如果相等的话
if (jsonObj[i].proLname1 == pro) {
if (isShowALl == 0) { $(this).show() }//显示选中的
$(this).find("input[name=proIsChecked]").prop("checked", "checked");// //选中
//赋值工时相关信息
$(this).find("td:eq(3) input:eq(0)").val(jsonObj[i].wkhour);
$(this).find("td:eq(4) input:eq(0)").val(jsonObj[i].ophour);
$(this).find("td:eq(5) input:eq(0)").val(jsonObj[i].ovhour);
//涉及产品
var pro2names = jsonObj[i].pro2names;
$(this).find("td:eq(2) input[name=proline2]").each(function () {
var pro2nameAttr = $(this).attr("pro2name");
var nms = pro2names.split(',');
for (var i = 0; i < nms.length; i++) {
if (nms[i].length > 0 && nms[i] == pro2nameAttr) {
//选中
this.checked = true;
}
}
});
}
}
});
}
//工作时间输入逻辑处理
function WorkHourInput()
{
$("input[name=workhour]").keyup(function () {
var wk = $(this).val();
$(this).parent().parent().find("input[name=totalhour]").val(wk);
});
}