var batchsId; var buyTime; $(function() { batchsId = localStorage.getItem("batchId"); buyTime = localStorage.getItem("buyTime"); getbaseList(); $("#baseForm").keydown(function(e) { keycode = e.which || e.keyCode; if (keycode == 13) { search(); } }); document.getElementById('firstName').addEventListener('change',function(){ findSecondName(this.value); },false); document.getElementById('secondName').addEventListener('change',function(){ findParentName(this.value); },false); document.getElementById('parentName').addEventListener('change',function(){ findModel(this.value); },false); $('#addBtn').on('click', function(e) { // 通知浏览器不要执行与事件关联的默认动作 e.preventDefault(); cleanForm(); findFirstName(); findVender(); JY.Model.edit("auDiv", "新增", function() { if (JY.Validate.form("auForm")) { var that = $(this); $("#batchId").val(batchsId); var company = $("#company").val(); JY.Ajax.doRequest("auForm", bonuspath + '/backstage/inputDetails/add', {batchStatus:1}, function(data) { that.dialog("close"); JY.Model.info(data.resMsg, function() { var batchId = data.obj.batchId; var type = data.obj.model; var machinesNum = data.obj.machineNums; var batchStatus = data.obj.batchStatus; var vender = data.obj.vender; search(); // var type = data.obj.parentId; for(var i = 1; i <= parseInt(machinesNum);i++){ var isFixedAssets; var isTrack; var isCheck; var cycleNum; var remark; batchAddMachines(company,batchId,type,machinesNum,vender,batchStatus, isFixedAssets,isTrack,isCheck,buyTime,cycleNum,remark); } }); }); } }); }); }); function selectPerson(){ //iframe层-父子操作 layer.open({ type: 2, title:['完善通知信息','background-color: #438EB9;color:#fff'], shadeClose:true, shade:false, maxmin: true, area: ['800px', '430px'], content: bonuspath+'/backstage/user/select' }); } function batchAddMachines(company,batchId,type,machinesNum,vender,batchStatus,isFixedAssets,isTrack,isCheck,buyTime,cycleNum,remark){ JY.Ajax.doRequest(null,bonuspath +'/backstage/machine/add', { taskId : batchId, type : type, machinesNum :machinesNum, venderName : vender, batchStatus : batchStatus, isFixedAssets : 0, isTrack : 1, //跟踪 isCheck : 1, //需要检验 buyTime : buyTime, equipmentState : 1, outInNum : 0, remarks : '无', deviceNum:company },function(data){ }); } function emptyRole() { $("#orgName").prop("value", ""); $("#auForm input[name$='orgId']").prop("value", "0"); } var preisShow = false;// 窗口是否显示 function showRole() { if (preisShow) { hideRole(); } else { var obj = $("#orgName"); var offpos = $("#orgName").position(); $("#orgContent").css({ left : offpos.left + "px", top : offpos.top + obj.heith + "px" }).slideDown("fast"); preisShow = true; } } var hideRole = function() { $("#orgContent").fadeOut("fast"); preisShow = false; } function clickRole(e, treeId, treeNode) { var check = (treeNode && !treeNode.isParent); if (check) { var zTree = $.fn.zTree.getZTreeObj("orgTree"), nodes = zTree .getSelectedNodes(), v = "", n = "", o = "", p = ""; for (var i = 0, l = nodes.length; i < l; i++) { v += nodes[i].name + ",";// 获取name值 n += nodes[i].id + ",";// 获取id值 o += nodes[i].other + ",";// 获取自定义值 var pathNodes = nodes[i].getPath(); for (var y = 0; y < pathNodes.length; y++) { p += pathNodes[y].name + "/";// 获取path/name值 } } if (v.length > 0) v = v.substring(0, v.length - 1); if (n.length > 0) n = n.substring(0, n.length - 1); if (o.length > 0) o = o.substring(0, o.length - 1); if (p.length > 0) p = p.substring(0, p.length - 1); $("#orgName").val(p); $("#auForm input[name$='orgId']").prop("value", n); hideRole(); } } function getbaseList(init) { $(".pageNum").val(1); JY.Model.loading(); JY.Ajax.doRequest("baseForm",bonuspath + '/backstage/inputDetails/findByPage',{batchId:batchsId}, function(data) { $("#baseTable tbody").empty(); var obj = data.obj; var list = obj.list; var results = list.results; var permitBtn = obj.permitBtn; var pageNum = list.pageNum, pageSize = list.pageSize, totalRecord = list.totalRecord; var html = ""; if (results != null && results.length > 0) { var leng = (pageNum - 1) * pageSize; for (var i = 0; i < results.length; i++) { var l = results[i]; if(l.batchStatus >= 2){ $("#selectPersonBtn").attr("disabled","disabled"); } html += ""; html += ""; html += "" + (i + leng + 1) + ""; html += ""+ JY.Object.notEmpty(l.machineType) + ""; html += ""+ JY.Object.notEmpty(l.model) + ""; html += ""+ JY.Object.notEmpty(l.machineNums) + ""; if(l.picUrl == '' || l.picUrl == null){ html += "上传图片"; }else{ html += "查看图片"; } /*if(l.isFixedAssets == '' || l.isFixedAssets == null){ html += "转固定资产"; }else if(l.isFixedAssets == '1' || l.isFixedAssets == 1){ html += "是"; }else if(l.isFixedAssets == '0' || l.isFixedAssets == 0){ html += "固定资产"; }else{ html += "固定资产"; }*/ if(l.batchStatus == '' || l.batchStatus == null){ html += ""; }else if(l.batchStatus == 1 || l.batchStatus =='1'){ html += "待通知"; }else if(l.batchStatus == 2 || l.batchStatus =='2'){ html += "待检验"; }else if(l.batchStatus == 3 || l.batchStatus =='3'){ html += "待打印"; }else if(l.batchStatus == 4 || l.batchStatus =='4'){ html += "待入库"; }else if(l.batchStatus == 5 || l.batchStatus =='5'){ html += "已入库"; }else{ html += ""; } console.info("maTypeId="+l.maTypeId); html += rowFunction(l.batchId,l.maTypeId); 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(id,maTypeId) { var h = ""; h += ""; h += ""; h += ""; h += ""; return h; } function check(id,maTypeIds) { cleanAcceptForm(); JY.Ajax.doRequest(null, bonuspath + '/backstage/inputDetails/find', { batchId : id, maTypeId:maTypeIds }, function(data) { setAcceptForm(data); JY.Model.check("acceptDiv"); }); } function setForm(data) { var l = data.obj; $("#auForm input[name$='id']").val(l.id); $("#auForm input[name$='batchId']").val(l.batchId); $("#auForm input[name$='model']").val(JY.Object.notEmpty(l.model)); $("#auForm input[name$='machinesNum']").val(JY.Object.notEmpty(l.machinesNum)); $("#auForm input[name$='outNum']").val(JY.Object.notEmpty(l.outNum)); $("#auForm input[name$='invoiceNum']").val(JY.Object.notEmpty(l.invoiceNum)); $("#auForm input[name$='invoiceUrl']").val(JY.Object.notEmpty(l.invoiceUrl)); $("#auForm input[name$='machinesUrl']").val(JY.Object.notEmpty(l.machinesUrl)); $("#auForm input[name$='batchStatus']").val(JY.Object.notEmpty(l.batchStatus)); } function cleanForm() { JY.Tags.isValid("auForm", "1"); JY.Tags.cleanForm("auForm"); $("#auForm input[name$='id']").val('0');// 上级资源 $("#auForm input[name$='model']").val(''); $("#auForm input[name$='machinesNum']").val(''); $("#auForm input[name$='outNum']").val(''); $("#auForm input[name$='invoiceNum']").val(''); $("#auForm input[name$='invoiceUrl']").val(''); $("#auForm input[name$='machinesUrl']").val(''); $("#auForm input[name$='batchStatus']").val(''); hideRole(); } function setAcceptForm(data) { var l = data.obj; $("#models").html(JY.Object.notEmpty(l.model)); $("#machineTypes").html(JY.Object.notEmpty(l.machineType)); $(".machinesNums").html(JY.Object.notEmpty(l.machineNums)); $("#venders").html(JY.Object.notEmpty(l.vender)); } function cleanAcceptForm() { $("#models").html(''); $("#machineTypes").html(''); $(".machinesNums").html(''); $("#venders").html(''); } function hideRole() { $("#roleContent").fadeOut("fast"); preisShow = false; } function search() { $("#searchBtn").trigger("click"); } function uploadInvoice(id){ localStorage.setItem("updDocId",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+'/updInvoice.jsp' }); } function readInvoice(id){ localStorage.setItem("InvoiceId",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+'/readInvoice.jsp' }); } function updMachinesPic(id,batchId){ localStorage.setItem("updPicId",id); localStorage.setItem("taskId",batchId); 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/inputDetails/machinesPic' }); } function readMachinesPic(id,batchId){ localStorage.setItem("readPicId",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/inputDetails/readMachinesPic' }); } function edit(id,maTypeIds) { cleanAcceptsForm(); JY.Ajax.doRequest(null, bonuspath + '/backstage/accept/find', { batchId : id, maTypeId:maTypeIds }, function(data) { setAcceptsForm(data); JY.Model.edit("auAcceptDiv", "修改", function() { if (JY.Validate.form("auAcceptForm")) { var that = $(this); JY.Ajax.doRequest("auAcceptForm", bonuspath + '/backstage/accept/add', {taskId:id,maTypeId:maTypeId}, function(data) { that.dialog("close"); JY.Model.info(data.resMsg, function() { search(); }); }); } }); }); } var maTypeId; function setAcceptsForm(data){ alert(JSON.stringify(data)); var l = data.obj; if(l.isTest == "1"){ $(".exteriorCheck").css("display","none"); }else{ $(".testCheck").css("display","none"); } maTypeId = l.maTypeId; $("#machineType").val(JY.Object.notEmpty(l.machineType)); $("#modelType").val(JY.Object.notEmpty(l.model)); $("#auAcceptForm input[name$='checkNum']").val(JY.Object.notEmpty(l.checkNum)); if(l.exteriorCheck == "1") { $('#exteriorCheck1').prop('checked',true); } if(l.exteriorCheck == "0") { $('#exteriorCheck0').prop('checked',true); } if(l.setestCheckx == "1") { $('#testCheck1').prop('checked',true); } if(l.testCheck == "0") { $('#testCheck0').prop('checked',true); } $("#checkConclusion").val(JY.Object.notEmpty(l.checkConclusion)); } function cleanAcceptsForm(){ $("#auAcceptForm input[name$='taskId']").val(""); $("#auAcceptForm input[name$='maTypeId']").val(""); $("#auAcceptForm input[name$='checkNum']").val(""); $("#auAcceptForm input[name$='machineType']").val(""); $("#auAcceptForm input[name$='model']").val(""); $('#exteriorCheck1').prop('checked',true); $('#testCheck1').prop('checked',true); $("#auAcceptForm input[name$='checkConclusion']").val(""); } function del(id) { JY.Model.confirm("确认删除吗?", function() { JY.Ajax.doRequest(null, bonuspath + '/backstage/new/delById', { batchId : id }, function(data) { JY.Model.info(data.resMsg, function() { search(); }); }); }); } function findFirstName(){ JY.Ajax.doRequest("auForm",bonuspath +'/backstage/machineType/findFirstName',{parentId:0},function(data){ $("#firstName").html(""); var results = data.obj; var html=""; if(results!=null&&results.length>0){ for(var i=0;i"+l.name+""; } $("#firstName").append(html); }else{ html+="";; $("#firstName").append(html); } }); } function findSecondName(parentId){ JY.Ajax.doRequest("auForm",bonuspath +'/backstage/machineType/findFirstName',{parentId:parentId},function(data){ $("#secondName").html(""); var results = data.obj; var html=""; if(results!=null&&results.length>0){ for(var i=0;i"+l.name+""; } $("#secondName").append(html); }else{ html+="";; $("#secondName").append(html); } }); } function findParentName(parentId){ JY.Ajax.doRequest("auForm",bonuspath +'/backstage/machineType/findFirstName',{parentId:parentId},function(data){ $("#parentName").html(""); var results = data.obj; var html=""; if(results!=null&&results.length>0){ for(var i=0;i"+l.name+""; } $("#parentName").append(html); }else{ html+="";; $("#parentName").append(html); } }); } function findModel(parentId){ JY.Ajax.doRequest("auForm",bonuspath +'/backstage/machineType/findFirstName',{parentId:parentId},function(data){ $("#model").html(""); var results = data.obj; var html=""; if(results!=null&&results.length>0){ for(var i=0;i"+l.name+""; } $("#model").append(html); }else{ html+="";; $("#model").append(html); } }); } function findVender(){ JY.Ajax.doRequest("auForm",bonuspath +'/backstage/vender/findVender',{},function(data){ $("#vender").html(""); var results = data.obj; var html=""; if(results!=null&&results.length>0){ for(var i=0;i"+l.name+""; } $("#vender").append(html); }else{ html+="";; $("#vender").append(html); } }); }