$(function() { getbaseList(); $("#baseForm").keydown(function(e) { keycode = e.which || e.keyCode; if (keycode == 13) { search(); } }); $(".form_datetime").datetimepicker({ format : 'yyyy-mm-dd hh:ii' }); $('#addBtn').on('click', function(e) { // 通知浏览器不要执行与事件关联的默认动作 e.preventDefault(); cleanForm(); JY.Model.edit("auDiv", "新增", function() { if (JY.Validate.form("auForm")) { var that = $(this); JY.Ajax.doRequest("auForm", bonuspath + '/backstage/scrap/add', null, function(data) { that.dialog("close"); JY.Model.info(data.resMsg, function() { search(); }); }); } }); }); }); 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) { if (init == 1) $(".pageNum").val(1); JY.Model.loading(); JY.Ajax .doRequest( "baseForm", bonuspath + '/backstage/scrap/findByPage', null, 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]; html += ""; html += ""; html += "" + (i + leng + 1) + ""; html += ""+ JY.Object.notEmpty(l.repairNum) + ""; html += ""+ JY.Object.notEmpty(l.machinesName) + ""; html += ""+ JY.Object.notEmpty(l.model) + ""; html += ""+ JY.Object.notEmpty(l.machinesNum) + ""; html += ""+ JY.Object.notEmpty(l.price) + ""; html += ""+ JY.Object.notEmpty(l.prices) + ""; html += ""+ JY.Object.notEmpty(l.collarProject) + ""; html += ""+ JY.Object.notEmpty(l.deviceNum) + ""; html += ""+ JY.Object.notEmpty(l.scrpReason) + ""; if(l.batchStatus == '' || l.batchStatus == null){ html += ""; }else if(l.batchStatus == 2 || l.batchStatus =='2'){ html += "待报废"; }else{ html += ""; } html += rowFunction(l.deviceNum); 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(deviceNum) { var h = ""; h += ""; h += ""; h += ""; h += ""; return h; } // 批量删除 $('#delBatchBtn').on('click', function(e) { // 通知浏览器不要执行与事件关联的默认动作 e.preventDefault(); var chks = []; $('#baseTable input[name="ids"]:checked').each(function() { chks.push($(this).val()); }); if (chks.length == 0) { JY.Model.info("您没有选择任何内容!"); } else { JY.Model.confirm("确认要删除选中的数据吗?", function() { JY.Ajax.doRequest(null, bonuspath + '/backstage/scrap/delBatch', { chks : chks.toString() }, function(data) { JY.Model.info(data.resMsg, function() { search(); }); }); }); } }); function check(deviceNum) { cleanForm(); JY.Ajax.doRequest(null, bonuspath + '/backstage/scrap/find', { deviceNum : deviceNum }, function(data) { setForm(data); JY.Model.check("auDiv"); }); } function setForm(data) { var l = data.obj; $("#auForm input[name$='scrapId']").val(l.scrapId); $("#auForm input[name$='scrapName']").val(JY.Object.notEmpty(l.scrapName)); $("#auForm input[name$='scrapNum']").val(JY.Object.notEmpty(l.scrapNum)); } function cleanForm() { JY.Tags.isValid("auForm", "1"); JY.Tags.cleanForm("auForm"); $("#auForm input[name$='scrapId']").val('0');// 上级资源 $("#auForm input[name$='scrapName']").val(''); $("#auForm input[name$='scrapNum']").val(''); hideRole(); } function hideRole() { $("#roleContent").fadeOut("fast"); preisShow = false; } function search() { $("#searchBtn").trigger("click"); } function edit(id) { cleanForm(); JY.Ajax.doRequest(null, bonuspath + '/backstage/scrap/find', { scrapId : id }, function(data) { setForm(data); JY.Model.edit("auDiv", "修改", function() { if (JY.Validate.form("auForm")) { var that = $(this); JY.Ajax.doRequest("auForm", bonuspath + '/backstage/scrap/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/scrap/del', { scrapId : id }, function(data) { JY.Model.info(data.resMsg, function() { search(); }); }); }); }