layui.use(['form', 'layer', 'table', 'laytpl', 'laydate'], function () { var form = layui.form, layer = parent.layer === undefined ? layui.layer : top.layer, $ = layui.jquery, laytpl = layui.laytpl, table = layui.table; laydate = layui.laydate; var UserId = JSON.parse(window.sessionStorage.getItem("userInfo")).UserCode; var UserName = JSON.parse(window.sessionStorage.getItem("userInfo")).USERS_NAME; var count = 0; var pplName = "" var applyId = $.getUrlVar("applyId"); waitId = $.getUrlVar("waitId"); getApply = function () { $.ajax({ type: "post", url: "../../ashx/ZYCarApplyHandler.ashx", data: { Action: "List", id: applyId }, dataType: "json", success: function (res) { console.log(res.data); var applyData = res.data[0]; lId = applyData.ID; pplName = applyData.USERNAME; $("#username").val(applyData.USERNAME); $("#userphone").val(applyData.USERPHONE); $("#carnum").val(applyData.CARNUM); $("#starttime").val(applyData.STARTTIME); $("#finishtime").val(applyData.FINISHTIME); $("#userman").val(applyData.USERMAN); $("#dept").val(applyData.DEPT); $("#ridenum").val(applyData.RIDENUM); $("#ridemans").val(applyData.RIDEMANS); $("#ridepurpose").val(applyData.RIDEPURPOSE); $("#startpoint").val(applyData.STARTPOINT); $("#destination").val(applyData.DESTINATION); } }); } getWiteList = function () { $.ajax({ type: "post", url: "../../ashx/ZYCarApplyHandler.ashx", data: { Action: "getWaitList", id: applyId }, dataType: "json", success: function (res) { console.log(res.data); var waitData = res.data; countSum = waitData.length; waitData.forEach(function (obj, index, arr) { //countSum = index; console.log(index); var color = "", state = ""; var li = "
  • "; if (obj.STATE == 0) { li += ""; color = "black"; state = "等待处理" } else if (obj.STATE == 1) { li += ""; color = "blue"; state = "审批中"; sort = obj.SORT; } else if (obj.STATE == 2) { li += ""; color = "green"; state = "同意"; count++; } else if (obj.STATE == 3) { li += ""; color = "red"; state = "不同意" } li += "
    "; li += "

    【" + state + "】  审批人:" + obj.PPL_NAME + "

    "; if (waitId != null && waitId == obj.ID) { li += ""; li += "
    同意"; li += "不同意
    "; } else { if (obj.A_TIME != "") { li += "

    审批时间:" + obj.A_TIME + "

    "; li += "

    审批意见:" + obj.A_OPINION + "

    "; } } li += "
  • " $("#stepMsg").append(li); }); } }) } $(function () { getApply(); getWiteList(); }); agreeClick = function () { //load提交 var index = layer.msg('数据提交中,请稍候', { icon: 16, time: false, shade: 0.8 }); if (count < countSum) { isOver = "0"; } else { isOver = "1"; } layer.confirm('请问是否同意【' + pplName + '】的车辆申请', { icon: 1, title: '提示', btn: ['确定', '取消'] //按钮 }, function () { $.post("../../ashx/ZYCarApplyHandler.ashx", { Action: "editWait", leaveId: lId, //请假表ID waitId: waitId, //待办表ID state: "2", //同意状态 sort: sort, //审批顺序 a_opinion: $("#a_opinion").val(), //审批意见 isOver: isOver //是否审批结束 }, function (res) { layer.close(index); res = $.parseJSON(res); if (res.code == 1) { top.layer.msg(res.msg); parent.location.reload(); } else { layer.msg(res.msg); } }); layer.close(index); return false; }); } disagreeClick = function () { var index = layer.msg('数据提交中,请稍候', { icon: 16, time: false, shade: 0.8 }); if ((count + 1) < countSum) { isOver = "0"; } else { isOver = "1"; } layer.confirm('请问是否不同意【' + pplName + '】的车辆申请', { icon: 2, title: '提示', btn: ['确定', '取消'] //按钮 }, function () { $.post("../../ashx/ZYCarApplyHandler.ashx", { Action: "editWait", leaveId: lId, //请假表ID waitId: waitId, //待办表ID state: "3", //同意状态 sort: sort, //审批顺序 a_opinion: $("#a_opinion").val(), //审批意见 isOver: isOver //是否审批结束 }, function (res) { layer.close(index); res = $.parseJSON(res); if (res.code == 1) { top.layer.msg(res.msg); parent.location.reload(); } else { layer.msg(res.msg); } }); layer.close(index); return false; }); } })