-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdemo.js
1 lines (1 loc) · 13.4 KB
/
demo.js
1
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},abnormalData={};!function(t,a){function e(){a(t).resize(function(){abnormalData.$abnormalTable.setGridWidth(a(".content-title").width()),abnormalData.$abnormalTable.parents(".ui-jqgrid-bdiv").css({"overflow-x":"hidden"})}),abnormalData.init=function(){this.createTable(this.$abnormalTable,"json",this.abnormalColModelBill,this.$abnormalPager),this.$abnormalTable.jqGrid("setLabel","rn","序号",{"text-align":"left"},""),this.bindEvent()},abnormalData.$abnormalTable=a("#abnormal-table"),abnormalData.$abnormalPager=a("#abnormal-pager"),abnormalData.layer=null;var e="",i="";abnormalData.createLayer=function(){if(this.layer)return void(this.layer.choiceGuide=!1);this.layer={},this.layer.choiceGuide=!1,this.layer.guideData=null,this.layer.guideTips=!0,this.layer.$textName=a("#text-name"),this.layer.$textSpec=a("#text-spec"),this.layer.$textUnit=a("#text-unit"),this.layer.$textNumber=a("#text-number"),this.layer.$textRoom=a("#text-room"),this.layer.$textCabinet=a("#text-cabinet"),this.layer.$textGrade=a("#text-grade"),this.layer.$textSubject=a("#text-subject"),this.layer.$textUser=a("#text-user"),this.layer.$textCount=a("#text-count"),this.layer.$textUnitPrice=a("#text-unit-price"),this.layer.$textSum=a("#text-sum"),this.layer.$textTagCode=a("#text-tag-code"),this.layer.$textOrigin=a("#text-origin"),this.layer.$textDate=a("#text-date"),this.layer.$reviseCount=a("#revise-count"),this.layer.$reviseMoney=a("#revise-money"),this.layer.$reviseGuide=a("#revise-guide"),this.layer.$allItems=a("#all-items"),this.layer.guideDiv=null,this.layer.subData={abnormalCardId:"",amount:0,code:"",handleStatus:20,inventoryCatalogId:"",orgId:"",quantity:0},this.layer.initData=function(t){this.rowData=t,this.subData.amount=t["inventory.amount"],this.subData.code=t["inventory.code"],this.subData.orgId=t["inventory.unitId"],this.subData.quantity=t.quantity,this.subData.abnormalCardId=t.id,this.subData.inventoryCatalogId=t.inventoryCatalogId,this.$textName.html(t["inventory.name"]).attr("title",t["inventory.name"]),this.$textSpec.html(t["inventory.spec"]).attr("title",t["inventory.spec"]),this.$textUnit.html(t["inventory.uom"]).attr("title",t["inventory.uom"]),this.$textNumber.html(t["inventory.code"]).attr("title",t["inventory.code"]),this.$textRoom.html(t["inventory.buildingName"]).attr("title",t["inventory.buildingName"]),this.$textCabinet.html(t["inventory.cabinetName"]).attr("title",t["inventory.cabinetName"]),this.$textGrade.html(t.stageName).attr("title",t.stageName),this.$textSubject.html(t.subjectName).attr("title",t.subjectName),this.$textUser.html(t.usageName).attr("title",t.usageName),this.$textCount.html(t.quantity).attr("title",t.quantity),this.$textUnitPrice.html(t["inventory.price"]).attr("title",t["inventory.price"]),this.$textSum.html(t["inventory.amount"]).attr("title",t["inventory.amount"]),this.$textTagCode.html(t["inventory.barcode"]).attr("title",t["inventory.barcode"]),this.$textOrigin.html(t["inventory.equipSourceName"]).attr("title",t["inventory.equipSourceName"]),this.$textDate.html(t["inventory.purchaseDate"]).attr("title",t["inventory.purchaseDate"]),this.$reviseCount.html("数量:"+t.quantity),this.$reviseMoney.html("金额:"+t["inventory.amount"]);var a=[];a.push(t["inventory.code"]),a.push(t["inventory.name"]),a.push(t["inventory.uom"]),a.push(t["inventory.spec"]);var e="目录:";e+=a.filter(function(t){return t}).join(","),this.$reviseGuide.html(e).attr("title",e)},this.layer.clearData=function(){this.$textName.html("").attr("title",""),this.$textSpec.html("").attr("title",""),this.$textUnit.html("").attr("title",""),this.$textNumber.html("").attr("title",""),this.$textRoom.html("").attr("title",""),this.$textCabinet.html("").attr("title",""),this.$textGrade.html("").attr("title",""),this.$textSubject.html("").attr("title",""),this.$textCount.html("").attr("title",""),this.$textUnitPrice.html("").attr("title",""),this.$textSum.html("").attr("title",""),this.$textTagCode.html("").attr("title",""),this.$textOrigin.html("").attr("title",""),this.$textDate.html("").attr("title",""),this.$reviseCount.html("数量:"),this.$reviseMoney.html("金额:"),this.$reviseGuide.html("目录:").attr("title","目录:")},this.layer.getGuide=function(t){var a={queryStr:t};publicAjaxRequest.verification(ajaxURL+"/eeg/guideCatalogue/guid-default",a,"get",util.resCallback(function(t){"object"===(void 0===t?"undefined":_typeof(t))&&Array.isArray(t.data)&&(t.data.forEach(function(t){var a=[];a.push(t.code),a.push(t.name),a.push(t.uom),a.push(t.spec),t.label=a.filter(function(t){return t}).join(","),t.titleLabel="编号:"+t.code+", 名称:"+t.name+", 单位:"+t.uom+", 规格:"+t.spec}),abnormalData.layer.autoComplete("auto-div","all-items",t.data))}))},this.layer.$allItems.on("mouseover",function(){if(a(this).val()&&abnormalData.layer.choiceGuide&&!a(this).is(":focus")){var t="";t+='<p class="abnormal-tips">编号:'+abnormalData.layer.guideData.code+"</p>",t+='<p class="abnormal-tips">名称:'+abnormalData.layer.guideData.name+"</p>",t+='<p class="abnormal-tips">单位:'+abnormalData.layer.guideData.uom+"</p>",t+='<p class="abnormal-tips">规格:'+abnormalData.layer.guideData.spec+"</p>",abnormalData.layer.guideTips&&(layer.tips(t,"#all-items",{tips:[3,"#ddd"],tipsMore:!1,time:0}),abnormalData.layer.guideTips=!1)}}),this.layer.$allItems.on("mouseout",function(){abnormalData.layer.guideTips=!0,layer.closeAll("tips")}),this.layer.$allItems.on("focus",function(){abnormalData.layer.guideTips=!0,layer.closeAll("tips")}),this.layer.$allItems.on("blur",function(){if(abnormalData.layer.guideTips=!0,layer.closeAll("tips"),abnormalData.layer.choiceGuide){var t=[];t.push(abnormalData.layer.guideData.code),t.push(abnormalData.layer.guideData.name),t.push(abnormalData.layer.guideData.uom),t.push(abnormalData.layer.guideData.spec);var e=t.filter(function(t){return t}).join(",");a(this).val(e)}else a(this).val("")}),this.layer.$allItems.keyup(function(){var t=abnormalData.layer.$allItems.val();t&&t.length<31?abnormalData.layer.getGuide(t):t.length>30&&(util.tip.warn("不得超过30个字符"),abnormalData.layer.$allItems.val(t.slice(0,30)))}),this.layer.autoComplete=function(n,l,r){if(a("#"+l).val()!==e||""===e){var o=a("#"+n),s=r||[];if(e=a("#"+l).val(),0===s.length)return void o.hide();o.empty(),s.forEach(function(t){var e=t.label,n=a("<div>").attr("id",t.id).attr("title",t.titleLabel).addClass("item-div");n.html(e).appendTo(o),n.mouseover(function(){""!==i&&o.children('div[id="'+i+'"]').css("background-color","white"),i=a(this).attr("id"),a(this).css("background-color","#ebebeb")}),n.mouseout(function(){a(this).css("background-color","white")}),n.click(function(){var t=o.hide().children('div[id="'+i+'"]').text();abnormalData.layer.subData.inventoryCatalogId=i;var e=s.filter(function(t){return t.id===i});e.length>0&&(abnormalData.layer.subData.code=e[0].code,abnormalData.layer.subData.inventoryCatalogId=e[0].id,abnormalData.layer.choiceGuide=!0,abnormalData.layer.guideData=e[0]),i="",a("#"+l).val(t)})}),s.length>0?o.show():(o.hide(),i="")}document.onclick=function(e){var i=e||t.event;(i.srcElement||i.target).id!==l&&a("#"+n).is(":visible")&&a("#"+n).css("display","none")}}},abnormalData.bindEvent=function(){this.$abnormalTable.on("click",".btn-revise",this.reviseBtnEvent)},abnormalData.reviseBtnEvent=function(){abnormalData.createLayer();var t=a(this).data("rowid"),e=abnormalData.$abnormalTable.jqGrid("getRowData",t);abnormalData.layer.initData(e),layer.open({type:1,title:"数据修正",area:["760px","460px"],content:a("#layer-reviseData"),btn:["确定","取消"],success:function(){},yes:function(t){var e=void 0;if(a('[name="solution"]').each(function(){a(this)[0].checked&&(e=a(this).val())}),0===Number(e))abnormalData.layer.subData.handleStatus=30;else{var i=!1;if(a(".abnormal-checkbox").each(function(){a(this)[0].checked&&(i=!0)}),!i)return void util.tip.warn("请先修正数据");abnormalData.layer.subData.handleStatus=20;var n=[];if(a("input.abnormal-checkbox").each(function(){a(this)[0].checked&&n.push(a(this).val())}),n.includes("1")&&!abnormalData.layer.choiceGuide)return util.tip.warn("请选择目录"),!1;if(n.indexOf("0")>-1){var l=a('input[name="count"]').val(),r=a('input[name="money"]').val();if(!l)return util.tip.warn("请输入数量"),!1;if(l<0)return util.tip.warn("数量不能小于0"),a('input[name="count"]').val(0),!1;if(l>5e5)return util.tip.warn("数量不能大于50万"),a('input[name="count"]').val(0),!1;if(!r)return util.tip.warn("请输入金额"),!1;if(r<0)return util.tip.warn("金额不能小于0"),a('input[name="money"]').val(0),!1;if(r>1e7)return util.tip.warn("金额不能大于1000万"),a('input[name="money"]').val(0),!1;abnormalData.layer.subData.quantity=l,abnormalData.layer.subData.amount=r}}publicAjaxRequest.verification(ajaxURL+"/dmg/abnormalcard/dispose",JSON.stringify(abnormalData.layer.subData),"POST",util.resCallback(function(t){util.tip.success("操作成功!"),abnormalData.$abnormalTable.trigger("reloadGrid")}),!0),layer.closeAll("page")},end:function(){abnormalData.clearLayerData()}}),abnormalData.bindRadioEvent(),abnormalData.bindCheckboxEvent()},abnormalData.bindRadioEvent=function(){a('[name="solution"]').on("click",this.clickRadioEvent)};var n={};n.$items=a('[name="items"]'),n.$allItems=a("input.all-items"),n.$count=a('input[name="count"]'),n.$money=a('input[name="money"]'),n.$warnCount=a("#count-warn"),n.$warnMoney=a("#money-warn"),n.$count.keyup(function(){a(this).val(a(this).val().replace(/[^\d.]/g,"")),a(this).val()>5e5?(a(this).val(0),n.$warnCount.html("数量不能大于50万")):n.$warnCount.html("")}),n.$money.keyup(function(){a(this).val(a(this).val().replace(/[^\d.]/g,"")),a(this).val()>1e7?(a(this).val(0),n.$warnMoney.html("金额不能大于1000万")):n.$warnMoney.html("")}),abnormalData.clickRadioEvent=function(){"1"===a(this).val()?(n.$items.removeAttr("disabled"),n.$items.each(function(){a(this).prop("checked","checked")}),n.$allItems.removeAttr("disabled"),n.$count.removeAttr("disabled"),n.$money.removeAttr("disabled")):(n.$items.attr("disabled","disabled"),n.$allItems.attr("disabled","disabled"),n.$count.attr("disabled","disabled"),n.$money.attr("disabled","disabled"))},abnormalData.clickCheckBox=function(){"1"===a(this).val()?a(this)[0].checked?n.$allItems.removeAttr("disabled"):(n.$allItems.val(""),n.$allItems.attr("disabled","disabled")):a(this)[0].checked?(a('.abnormal-checkbox[value="0"]').each(function(){a(this).prop("checked","checked")}),n.$count.removeAttr("disabled"),n.$money.removeAttr("disabled")):(a('.abnormal-checkbox[value="0"]').each(function(){a(this).removeAttr("checked")}),n.$count.attr("disabled","disabled").val(""),n.$money.attr("disabled","disabled").val(""))},abnormalData.bindCheckboxEvent=function(){a('[name="items"]').on("click",this.clickCheckBox)},abnormalData.clearLayerData=function(){this.layer.clearData(),a(":radio[name='solution'][value='1']").prop("checked","checked"),a("input[name='code'] ").removeAttr("disabled").val(""),n.$count.removeAttr("disabled").val(""),n.$money.removeAttr("disabled").val(""),a("input.abnormal-checkbox").each(function(){a(this).removeAttr("disabled").prop("checked","checked")})},abnormalData.abnormalColModelBill=[{label:"标签码",name:"inventory.barcode",sortable:!1,hidden:!0},{label:"设备来源",name:"inventory.equipSourceName",sortable:!1,hidden:!0},{label:"采购日期",name:"inventory.purchaseDate",sortable:!1,hidden:!0},{label:"房间",name:"inventory.buildingName",sortable:!1,hidden:!0},{label:"柜子",name:"inventory.cabinetName",sortable:!1,hidden:!0},{label:"用户",name:"inventory.unitId",sortable:!1,hidden:!0},{label:"id",name:"id",sortable:!1,hidden:!0},{label:"inventoryCatalogId",name:"inventoryCatalogId",sortable:!1,hidden:!0},{label:"编号",name:"inventory.code",sortable:!1,width:8},{label:"名称",name:"inventory.name",sortable:!1,width:12},{label:"规格型号",name:"inventory.spec",sortable:!1,width:15},{label:"单位",name:"inventory.uom",width:7,sortable:!1},{label:"学段",name:"stageName",width:7,sortable:!1,hidden:!0},{label:"科目",name:"subjectName",width:8,sortable:!1,align:"center",formatter:function(t,a,e){return e.stageName+e.subjectName}},{label:"用途",name:"usageName",sortable:!1,width:8,align:"center"},{label:"数量",name:"quantity",width:6,align:"right",sortable:!1},{label:"单价",name:"inventory.price",width:6,align:"right",sortable:!1},{label:"金额",name:"inventory.amount",width:8,align:"right",sortable:!1},{label:"状态",name:"handleStatusStr",width:6,align:"center",sortable:!1,formatter:function(t,a,e){return"<span>"+e.handleStatusStr+"</span>"}},{label:"操作",name:"oper",align:"center",width:5,sortable:!1,title:!1,formatter:function(t,a,e){return'<a class="a-pointer btn-revise marginLR" data-rowid="'+a.rowId+'">修正</a>'}}],abnormalData.createTable=function(e,i,n){e.jqGrid({url:ajaxURL+"/dmg/abnormalcard/list",datatype:i,type:"get",width:a(".content-wrapper").width(),height:a(t).height()-294,styleUI:"Bootstrap",colModel:n,multiselect:!1,sortable:!1,viewrecords:!0,forceFit:!0,pagerpos:"center",recordpos:"right",rownumbers:!0,rowNum:99999,rowList:["10","15","20","25"],loadBeforeSend:function(t){publicAjaxRequest.getToken(t)},prmNames:{rows:"pageSize",page:"pageNo"},jsonReader:{root:"data",id:"id",records:"data.count",repeatitems:!1},loadError:function(t){401===t.status?publicAjaxRequest.delToken():"timeout"===t.statusText&&layer.msg("网络连接超时")}})},abnormalData.init()}main(e)}(window,jQuery);