$(function() { // agreementInfo(); layui.use('laydate', function(){ var laydate = layui.laydate; //日期时间选择器 laydate.render({ elem: '#startTime', done:function (data) { var endTime=$("#endTime").val(); if(data>endTime && endTime!=''){ layer.msg("开始时间不能大于结束时间"); $("#startTime").val(''); } } }); laydate.render({ elem: '#endTime', done:function (data) { var startTime=$("#startTime").val(); if(data 0) { var leng = (pageNum - 1) * pageSize; for (var i = 0; i < results.length; i++) { var l = results[i]; html += ""; html += ""; html += "" + (i + leng + 1) + ""; html += ""+ JY.Object.notEmpty(l.applyNumber) + ""; html += ""+ JY.Object.notEmpty(l.operationTime) + ""; html += ""+ JY.Object.notEmpty(l.leaseCompany) + ""; html += ""+ JY.Object.notEmpty(l.leaseProject) + ""; html += ""+ JY.Object.notEmpty(l.maType) + ""; html += ""+ JY.Object.notEmpty(l.maModel) + ""; html += ""+ JY.Object.notEmpty(l.outNum) + ""; html += ""+ JY.Object.notEmpty(l.customerSrep) + ""; if(l.isApproval==0 || l.isApproval=='0'){ html += "未批准"; }else if(l.isApproval==1 || l.isApproval=='1'){ html += "批准通过"; }else{ html += "批准驳回"; } html += rowFunction(l.taskId,l.maModelId,l.isApproval,l.outNum,l.mTaskId,l.storageNum,l.applyNumber,l.phone); html += ""; } $("#baseTable tbody").append(html); JY.Page.setPage("baseForm", "pageing", pageSize,pageNum, totalRecord, "getbaseList"); } else { html += "没有相关数据"; $("#baseTable tbody").append(html); $("#pageing ul").empty();// 清空分页 } JY.Model.loadingClose(); }); } function rowFunction(taskId,maModelId,isApproval,outNum,mTaskId,storageNum,applyNumber,phone) { var h = ""; h += ""; h += ""; h += ""; h += ""; return h; } function backShowChenkStatus(){ var ids = ''; $('input[type=checkbox]:checked').each(function(){ var taskId = $(this).val(); var maModelId = $(this).next().val(); var outNum = $(this).next().next().val(); var storageNum = $(this).next().next().next().val(); var maType = $(this).next().next().next().next().val(); var maModel = $(this).next().next().next().next().next().val(); console.log("taskId=",taskId); console.log("maModelId=",maModelId); console.log("outNum=",outNum); console.log("storageNum=",storageNum); if(storageNum == undefined){ }else{ if(parseInt(storageNum) >= parseInt(outNum)){ var allId = taskId+","+maModelId+","+outNum; console.log("allId=",allId); ids += allId+"-"; if(taskId === "on"){ ids = ""; } }else{ JY.Model.info(maType+"-"+maModel+"当前库存:"+storageNum+"小于出库数:"+outNum); } } console.log("ids=",ids); }) return ids; /*var ad = $('input[type=checkbox]:checked').map(function() { return this.value }).get(); allId = ad; console.log("allId=",allId);*/ } function findMsgDataList() { var list = new Array(); $('input[type=checkbox]:checked').each(function(){ var applyNumber = $(this).next().next().next().next().next().next().val(); var phone = $(this).next().next().next().next().next().next().next().val(); if(applyNumber != undefined){ var str=applyNumber+"-"+phone; list.push(str); } console.log("list=",list); }) list = Array.from(new Set(list)); console.log("list=",list); return list; } function cancelCheck(taskId,maModelId,mTaskId) { JY.Model.confirm("确认审核驳回吗?", function() { JY.Ajax.doRequest(null, bonuspath + '/backstage/out/rejectApproval', { taskId:taskId, maModelId:maModelId, mTaskId:mTaskId }, function(data) { JY.Model.info(data.resMsg, function() { search(); getbaseList(1); }); }); }); } function cancelCheck(taskId,maModelId,mTaskId) { JY.Model.edit("auDiv", "审核驳回", function() { var that = $(this); if (JY.Validate.form("auForm")) { var approvalRemark = $("#remarks").val(); JY.Model.confirm("确认审核驳回吗?", function() { JY.Ajax.doRequest(null, bonuspath + '/backstage/out/rejectApproval', { taskId:taskId, maModelId:maModelId, mTaskId:mTaskId, approvalRemark:approvalRemark }, function(data) { JY.Model.info(data.resMsg, function() { search(); getbaseList(1); }); }); }); } that.dialog("close"); }); } /** * @author 守约 * @date 2020-10-12 * @function 生成字符串数组 * @returns */ function getIdsString(){ var idsArr = []; var idsStr = ""; for ( var property in ids){ if(idsStr == ""){ idsStr = property; } else { idsStr += ","+property; } idsArr.push(idsStr); } return idsArr; } function batchAudit() { var idsStr = backShowChenkStatus(); var list=findMsgDataList(); //var idsStr = getIdsString(); if(idsStr == "" ){ layer.msg("请选择想要批准的信息!",{icon:7,time:2000}); return; } console.log("idsStr=",idsStr); var idx = layer.msg('批准申请提交中,请稍等...', { icon: 16 ,shade: 0.01 ,time:'-1' }); var data = { ids:idsStr } $.ajax({ type:'POST', url:bonuspath+'/backstage/out/batchAuditApproval', async:true, data:data, success:function(data) { data = JSON.parse(data); layer.msg("批准提交成功!",{icon:1,time:2000},function(){ for(var i=0;i= parseInt(outNum)){ JY.Model.confirm("确认批准吗?", function() { JY.Ajax.doRequest(null, bonuspath + '/backstage/out/isApproval', { taskId:taskId, maModelId:maModelId, outNum:outNum, mTaskId:mTaskId }, function(data) { JY.Model.info(data.resMsg, function() { var msg="领料单号:"+applyNumber+"已通过审批。"; findMsg(phone,msg); search(); getbaseList(1); }); }); }); }else{ JY.Model.info("当前库存:"+storageNum+"小于出库数:"+outNum); } } function setForm(data) { var l = data.obj; $("#auForm input[name$='id']").val(l.id); $("#auForm input[name$='contractNumber']").val(JY.Object.notEmpty(l.contractNumber)); $("#auForm input[name$='startTime']").val(JY.Object.notEmpty(l.startTime)); $("#auForm input[name$='leaseTerm']").val(JY.Object.notEmpty(l.leaseTerm)); $("#auForm input[name$='advanceCharge']").val(JY.Object.notEmpty(l.advanceCharge)); $("#auForm input[name$='authorizingPerson']").val(JY.Object.notEmpty(l.authorizingPerson)); $("#auForm input[name$='authorizingPhone']").val(JY.Object.notEmpty(l.authorizingPhone)); $("#auForm input[name$='remark']").val(JY.Object.notEmpty(l.remark)); } function cleanForm() { JY.Tags.isValid("auForm", "1"); JY.Tags.cleanForm("auForm"); $("#auForm input[name$='id']").val('0');// 上级资源 $("#auForm input[name$='projectName']").val(''); $("#auForm input[name$='startTime']").val(''); $("#auForm input[name$='leaseTerm']").val(''); $("#auForm input[name$='advanceCharge']").val(''); $("#auForm input[name$='authorizingPerson']").val(''); $("#auForm input[name$='authorizingPhone']").val(''); $("#auForm input[name$='remark']").val(''); hideRole(); } function search() { $("#searchBtn").trigger("click"); } function edit(id) { console.info("id="+id); cleanForm(); console.info("id="+id); JY.Ajax.doRequest(null, bonuspath + '/backstage/agreement/find', { id : id }, function(data) { setForm(data); JY.Model.edit("auDiv", "修改", function() { if (JY.Validate.form("auForm")) { var that = $(this); JY.Ajax.doRequest("auForm", bonuspath + '/backstage/agreement/update', null, function(data) { that.dialog("close"); JY.Model.info(data.resMsg, function() { search(); }); }); } }); }); } function del(id) { JY.Model.confirm("确认删除吗?", function() { JY.Ajax.doRequest(null, bonuspath + '/backstage/agreement/del', { id : id }, function(data) { JY.Model.info(data.resMsg, function() { search(); }); }); }); } function details(id){ localStorage.setItem("taskId",id); //iframe层-父子操作 layer.open({ type: 2, title:['协议明细','background-color: #27A3D9;color:#fff'], shadeClose:true, shade:false, maxmin: true, area: ['1000px', '600px'], content:bonuspath + '/backstage/agreementDetails/list' }); } function findBranchOffice(){ JY.Ajax.doRequest("auForm",bonuspath +'/backstage/company/getCompany',{},function(data){ $("#branchOffice").html(""); var results = data.obj.list; html=""; if(results!=null&&results.length>0){ for(var i=0;i"+l.name+""; } $("#branchOffice").append(html); }else{ html+="";; $("#branchOffice").append(html); } }); } function findUnit(companyId){ JY.Ajax.doRequest("auForm",bonuspath +'/backstage/company/getUnit',{companyId:companyId},function(data){ $("#leaseCompany").html(""); var results = data.obj.list; html=""; if(results!=null&&results.length>0){ for(var i=0;i"+l.name+""; } $("#leaseCompany").append(html); }else{ html+="";; $("#leaseCompany").append(html); } }); } function findProjectType(companyId){ localStorage.setItem("companyId",companyId); JY.Ajax.doRequest("auForm",bonuspath +'/backstage/project/getProjectType',{},function(data){ $("#projectType").html(""); var results = data.obj.list; html=""; if(results!=null&&results.length>0){ for(var i=0;i"+l.name+""; } $("#projectType").append(html); }else{ html+="";; $("#projectType").append(html); } }); } function findProjectName(typeId){ var companyId = localStorage.getItem("companyId"); JY.Ajax.doRequest("auForm",bonuspath +'/backstage/project/getProjectName',{companyId : companyId,typeId:typeId},function(data){ $("#projectName").html(""); var results = data.obj.list; html=""; if(results!=null&&results.length>0){ for(var i=0;i"+l.name+""; } $("#projectName").append(html); }else{ html+="";; $("#projectName").append(html); } }); } //附件图片上传、查看 function updAgreeListPic(id){ localStorage.setItem("updAgreeId",id); localStorage.setItem("bonuspath",bonuspath); //iframe层-父子操作 layer.open({ type: 2, title:['附件图片上传','background-color: #438EB9;color:#fff'], shadeClose:true, shade:false, maxmin: true, area: ['800px', '430px'], content: bonuspath+'/backstage/agreement/updAgreeListPic' }); } function readAgreePic(id){ localStorage.setItem("readAgreeId",id); localStorage.setItem("bonuspath",bonuspath); //iframe层-父子操作 layer.open({ type: 2, title:['附件图片查看','background-color: #438EB9;color:#fff'], shadeClose:true, shade:false, maxmin: true, area: ['800px', '430px'], content: bonuspath+'/backstage/agreement/readAgreePic' }); }