!function(){function t(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,r){if(!t)return;if("string"==typeof t)return e(t,r);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return e(t,r)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r(null!==(r=t.parent.controls.upperLimit.value)&&void 0!==r?r:Number.MAX_VALUE)?{limit:!0}:null;return t.parent.controls.lowerLimit.setErrors(i),t.parent.controls.upperLimit.setErrors(i),i}},this._error=function(t){var e,r,i,a;switch(t.status){case 409:s._toastService.show(s._i18nService.translate("routes.material.safeties.error.conflict."+(null===(r=null===(e=t.error)||void 0===e?void 0:e.propertyName)||void 0===r?void 0:r.toLowerCase())));break;case 410:s._toastService.show(s._i18nService.translate("routes.material.safeties.error.gone."+(null===(a=null===(i=t.error)||void 0===i?void 0:i.propertyName)||void 0===a?void 0:a.toLowerCase()))),s._dialogRef.close({success:!1});break;case 422:s._toastService.show(s._i18nService.translate("shared.notification.fail"));break;default:s._dialogRef.close({success:!1})}},this.autocomplete=Object(z.a)(function(){var t=s._form.controls.code.value;(null==t?void 0:t.length)>=3?s._httpService.get("materials?code=".concat(t,"&limit=50")).then(function(t){s._materials=t.items}):s._materials&&(s._materials.length=0)},300),this.save=function(){return Object(l.a)(s,void 0,void 0,regeneratorRuntime.mark(function t(){var e,r,i=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=this._materials.find(function(t){return t.code==i._form.controls.code.value.code}))){t.next=19;break}if(r={material:e.id,lowerLimit:this._form.controls.lowerLimit.value,upperLimit:this._form.controls.upperLimit.value},t.t0=void 0,!this.id){t.next=10;break}return t.next=7,this._httpService.put("materials/safeties/"+this.id,r).catch(this._error);case 7:t.t1=t.sent,t.next=13;break;case 10:return t.next=12,this._httpService.post("materials/safeties",r).catch(this._error);case 12:t.t1=t.sent;case 13:if(t.t2=t.t1,t.t3=t.t0!==t.t2,!t.t3){t.next=17;break}this._toastService.show(this._i18nService.translate("shared.notification.success")),this._dialogRef.close({success:!0});case 17:t.next=20;break;case 19:this._toastService.show("\u7269\u6599\u4e0d\u5b58\u5728");case 20:case"end":return t.stop()}},t,this)}))},this.reGoods=function(){return Object(l.a)(s,void 0,void 0,regeneratorRuntime.mark(function t(){var e=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:this._materials=null,this._form.controls.code.setValue(null),this._httpService.get("materials?category="+this._form.controls.cat.value.id).then(function(t){e._materials=t.items});case 1:case"end":return t.stop()}},t,this)}))},this._httpService.join(this._httpService.get("materials")).then(function(t){s._materials=t[0].items.filter(function(t){return t.category<=3})}),this._form=this._formBuilder.group({cat:[null],code:[null,[g.u.required]],lowerLimit:[null,[this._validators]],upperLimit:[null,[this._validators]]}),e.item&&(this._httpService.get("materials/"+e.item.material).then(function(t){return s._materials=[t]}),this._form.controls.code.setValue(e.item.code),this._form.controls.lowerLimit.setValue(e.item.lowerLimit),this._form.controls.upperLimit.setValue(e.item.upperLimit))}return a(t,[{key:"ngOnInit",value:function(){}},{key:"form",get:function(){return this._form}},{key:"id",get:function(){var t;return null===(t=this._data.item)||void 0===t?void 0:t.id}},{key:"warehouse",get:function(){return this._data.warehouse}},{key:"materials",get:function(){return this._materials}},{key:"catList",get:function(){return this._catList}}]),t}()).\u0275fac=function(t){return new(t||tt)(u.Ob(C.a),u.Ob(g.d),u.Ob(m.a),u.Ob(f.a),u.Ob(p.a),u.Ob(C.g))},tt.\u0275cmp=u.Ib({type:tt,selectors:[["app-material-safety-edit"]],decls:30,vars:25,consts:[["mat-dialog-title",""],["mat-dialog-content",""],["autocomplete","off",3,"formGroup"],["formControlName","code","required",""],[3,"value",4,"ngFor","ngForOf"],["matInput","","type","number","min","0","formControlName","lowerLimit"],["matInput","","type","number","min","0","formControlName","upperLimit"],["mat-dialog-actions","","align","end"],["mat-button","","color","primary",3,"disabled","click"],["mat-button","","mat-dialog-close",""],[3,"value"]],template:function(t,e){1&t&&(u.Ub(0,"h2",0),u.Hc(1),u.gc(2,"translate"),u.Tb(),u.Ub(3,"div",1),u.Ub(4,"form",2),u.Ub(5,"mat-form-field"),u.Ub(6,"mat-label"),u.Hc(7),u.gc(8,"translate"),u.Tb(),u.Ub(9,"mat-select",3),u.Fc(10,Z,2,3,"mat-option",4),u.Tb(),u.Tb(),u.Ub(11,"mat-form-field"),u.Ub(12,"mat-label"),u.Hc(13),u.gc(14,"translate"),u.Tb(),u.Pb(15,"input",5),u.Tb(),u.Ub(16,"mat-form-field"),u.Ub(17,"mat-label"),u.Hc(18),u.gc(19,"translate"),u.Tb(),u.Pb(20,"input",6),u.Tb(),u.Tb(),u.Tb(),u.Ub(21,"div",7),u.Ub(22,"button",8),u.bc("click",function(){return e.save()}),u.Hc(23),u.gc(24,"uppercase"),u.gc(25,"translate"),u.Tb(),u.Ub(26,"button",9),u.Hc(27),u.gc(28,"uppercase"),u.gc(29,"translate"),u.Tb(),u.Tb()),2&t&&(u.Cb(1),u.Ic(u.hc(2,9,e.id?"shared.operation.edit":"shared.operation.add")),u.Cb(3),u.lc("formGroup",e.form),u.Cb(3),u.Ic(u.hc(8,11,"routes.material.code")),u.Cb(3),u.lc("ngForOf",e.materials),u.Cb(3),u.Ic(u.hc(14,13,"routes.material.safety.lower")),u.Cb(5),u.Ic(u.hc(19,15,"routes.material.safety.upper")),u.Cb(4),u.lc("disabled",e.form.invalid),u.Cb(1),u.Ic(u.hc(24,17,u.hc(25,19,"shared.dialog.ok"))),u.Cb(4),u.Ic(u.hc(28,21,u.hc(29,23,"shared.dialog.cancel"))))},directives:[C.h,C.e,g.v,g.o,g.g,v.b,v.e,_.a,g.n,g.f,g.t,w.m,W.b,g.r,g.c,C.c,b.a,C.d,y.o],pipes:[S.d,w.v],styles:[".mat-form-field[_ngcontent-%COMP%]{width:100%}.mat-option[_ngcontent-%COMP%] [_ngcontent-%COMP%]:first-child{margin-right:8px}.mat-option[_ngcontent-%COMP%] [_ngcontent-%COMP%]:last-child{margin-left:8px}.mat-dialog-actions[_ngcontent-%COMP%]{margin-right:-8px}"]}),tt),rt=n("FFMq"),it=n("hZOD"),at=["$crud"],nt=["$wh"];function ot(t,e){1&t&&(u.Hc(0),u.gc(1,"join"),u.gc(2,"field")),2&t&&u.Ic(u.ic(1,1,u.ic(2,4,e.$implicit.warehouse,"name")," + "))}var ct,lt,st,ut=[{path:"",component:V},{path:"category",component:J},{path:"safety",component:(ct=function(){function e(t,i){var a=this;r(this,e),this._dialogService=t,this._httpService=i,this.convertor=function(t){return t.items.forEach(function(t){return t.warehouse=t.warehouse.split(",").map(function(t){return a._warehouse[t]})}),t}}return a(e,[{key:"ngAfterViewInit",value:function(){return Object(l.a)(this,void 0,void 0,regeneratorRuntime.mark(function e(){var r,i=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._httpService.get("warehouses");case 2:r=e.sent,this._warehouse=r.items.reduce(function(t,e){return t[e.id]=e,t},{}),this._defination=[{id:"code",header:"routes.material.code",filter:{field:"text"}},{id:"name",header:"routes.material.name",filter:{field:"text"}},{id:"lowerLimit",header:"routes.material.safety.lower"},{id:"upperLimit",header:"routes.material.safety.upper"},{id:"unit",header:"routes.material.unit"},{id:"warehouse",header:"routes.material.safety.warehouse",template:this._warehouseColumn,filter:{field:"select",range:[{}].concat(t(r.items))}}],this._api="materials/safeties",this._template.edit=function(t){return Object(l.a)(i,void 0,void 0,regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._dialogService.open(et,{autoFocus:!t,data:{item:t,warehouse:Object.values(this._warehouse)}});case 2:if(e.t0=e.sent,!e.t0){e.next=5;break}this._template.refresh();case 5:case"end":return e.stop()}},e,this)}))};case 4:case"end":return e.stop()}},e,this)}))}},{key:"defination",get:function(){return this._defination}},{key:"api",get:function(){return this._api}}]),e}(),ct.\u0275fac=function(t){return new(t||ct)(u.Ob(d.a),u.Ob(m.a))},ct.\u0275cmp=u.Ib({type:ct,selectors:[["app-material-safety"]],viewQuery:function(t,e){var r;1&t&&(u.Oc(at,!0),u.Oc(nt,!0)),2&t&&(u.tc(r=u.cc())&&(e._template=r.first),u.tc(r=u.cc())&&(e._warehouseColumn=r.first))},decls:4,vars:3,consts:[[3,"defination","api","convertor"],["$crud",""],["$wh",""]],template:function(t,e){1&t&&(u.Ub(0,"crud-template",0,1),u.Fc(2,ot,3,7,"ng-template",null,2,u.Gc),u.Tb()),2&t&&u.lc("defination",e.defination)("api",e.api)("convertor",e.convertor)},directives:[h.a],pipes:[rt.a,it.a],styles:[""]}),ct)}],dt=((lt=function t(){r(this,t)}).\u0275mod=u.Mb({type:lt}),lt.\u0275inj=u.Lb({factory:function(t){return new(t||lt)},imports:[[c.h.forChild(ut)],c.h]}),lt),mt=n("95ze"),ft=((st=function t(){r(this,t)}).\u0275mod=u.Mb({type:st}),st.\u0275inj=u.Lb({factory:function(t){return new(t||st)},imports:[[o.a,dt,mt.a]]}),st)}}])}();