webpackJsonp([62],{OGMY:function(t,e,a){var n=a("tFo7");"string"==typeof n&&(n=[[t.i,n,""]]),n.locals&&(t.exports=n.locals);a("rjj0")("060c3711",n,!0)},T1p7:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=a("fZjL"),i=a.n(n),r=a("BO1k"),o=a.n(r),l=a("Xxa5"),s=a.n(l),d=a("exGp"),c=a.n(d),u={data:function(){return{dataForm:{key:""},dataList:[{id:"",number:"",phNumber:"",name:""}],pageIndex:1,pageSize:10,totalPage:0,dataListLoading:!1,selectionDataList:[],visible:!1,form:{id:"",pigstyId:"",number:"",unitId:""},pigstyList:[],pighouseList:[],phSelectedList:[],unitList:[],unitSelectedList:[],dataRule:{pigstyId:[{required:!0,message:"所属猪舍不能为空",trigger:"blur"}],unitId:[{required:!0,message:"单元编号不能为空",trigger:["blur","change"]}]}}},activated:function(){this.getDataList()},methods:{getDataList:function(){var t,e=this;this.dataListLoading=!0,this.$http({url:this.$http.adornUrl("/management/period/list"),method:"get",params:this.$http.adornParams({page:1,limit:10,keyword:this.dataForm.key||void 0,pigstyId:this.dataForm.pigstyId||void 0,unitId:this.dataForm.unitId||void 0})}).then((t=c()(s.a.mark(function t(a){var n,i,r=a.data;return s.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.$http({url:e.$http.adornUrl("/management/pigsty/findAll"),method:"get",params:e.$http.adornParams({})});case 2:return(n=t.sent).data.all&&(e.pigstyList=n.data.all),e.phSelectedList=e.pigstyList,t.next=7,e.$http({url:e.$http.adornUrl("/management/unit/findAll"),method:"get",params:e.$http.adornParams({})});case 7:(i=t.sent).data.all&&(e.unitList=i.data.all),e.unitSelectedList=e.unitList,r&&0===r.code?(e.dataList=r.page.list,e.totalPage=r.page.totalCount):(e.dataList=[],e.totalPage=0),e.dataListLoading=!1;case 12:case"end":return t.stop()}},t,e)})),function(e){return t.apply(this,arguments)}))},selectFocus:function(t){var e=this,a="unit"===t?"unit":"unitDialog";this["unit"===t?"dataForm":"form"].pigstyId||(this.$message.error("请先选择猪舍"),setTimeout(function(){e.$refs[a].blur()},10))},clearAll:function(){this.dataForm.key="",this.dataForm.pigstyId="",this.dataForm.unitId=""},sizeChangeHandle:function(t){this.pageSize=t,this.pageIndex=1,this.getDataList()},currentChangeHandle:function(t){this.pageIndex=t,this.getDataList()},addOrUpdateHandle:function(t){if(this.visible=!0,t){this.form.id=t.id;var e=!0,a=!1,n=void 0;try{for(var r,l=o()(i()(this.form));!(e=(r=l.next()).done);e=!0){var s=r.value;this.form[s]=t[s]}}catch(t){a=!0,n=t}finally{try{!e&&l.return&&l.return()}finally{if(a)throw n}}}this.phSelectedList=this.pigstyList,this.unitSelectedList=this.unitList},selectionChangeHandle:function(t){var e=this;this.selectionDataList=[],t.forEach(function(t){e.selectionDataList.push(t.id)})},deleteHandle:function(t){var e=this;this.$confirm("确定删除栏期?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(function(){t&&e.selectionDataList.push(t),e.selectionDataList.length<=0||e.$http({url:e.$http.adornUrl("/management/period/delete"),method:"post",data:e.$http.adornData(e.selectionDataList,!1)}).then(function(t){if(console.log(t),0===t.data.code){e.resetForm(),e.$message({message:"成功删除栏期",type:"success",duration:1e3}),e.totalPage-=e.selectionDataList.length;var a=Math.ceil(e.totalPage/e.pageSize);e.pageIndex=e.pageIndex>a?a:e.pageIndex,e.pageIndex=e.pageIndex<1?a:e.pageIndex}else e.$message.error("删除栏期失败");e.selectionDataList=[]})}).catch(function(){})},formSubmit:function(){var t=this;this.form.id?this.$refs.form.validate(function(e){e&&t.$http({url:t.$http.adornUrl("/management/period/update"),method:"post",data:t.$http.adornData({id:t.form.id,farmId:parseInt(t.$cookie.get("formFarmId")),pigstyId:t.form.pigstyId,unitId:t.form.unitId,number:t.form.number},!1)}).then(function(e){if(0===e.data.code)t.resetForm(),t.visible=!1,t.$message({message:"成功修改栏期信息",type:"success",duration:1e3});else{if(600===e.data.code){var a=e.data.msg.split("-");return void t.$message({message:'栏期编号
'+a[0]+"
已经存在!",type:"error",duration:1e3,dangerouslyUseHTMLString:!0})}t.$message.error(e.datanmsg)}})}):this.$refs.form.validate(function(e){e&&t.$http({url:t.$http.adornUrl("/management/period/save"),method:"post",data:t.$http.adornData({farmId:parseInt(t.$cookie.get("formFarmId")),unitId:t.form.unitId,pigstyId:t.form.pigstyId},!1)}).then(function(e){if(0===e.data.code){t.totalPage++;var a=Math.ceil(t.totalPage/t.pageSize);t.pageIndex=t.pageIndex'+n[0]+" 已经存在!",type:"error",duration:1e3,dangerouslyUseHTMLString:!0})}t.$message.error(e.data.msg)}})})},resetForm:function(){for(var t in this.form)this.form[t]="";this.getDataList()},cancel:function(){this.visible=!1,this.form.id&&this.resetForm()},validComplete:function(t){for(var e in t&&delete this.form.id,console.log(this.form),this.form)if(!this.form[e].toString())return!1;return!0},confirmComplete:function(t){return!!this.validComplete(t)||(this.$confirm("请输入完整","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(function(){console.log("牧场输入不完整")}).catch(function(){}),!1)},validInput:function(){return!/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\_\-]/g.test(this.form.number)},confirmInput:function(){return!!this.validInput()||(this.$confirm("只允许输入中英文、数字、-与_","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(function(){console.log("单元序号输入不合法")}).catch(function(){}),!1)},getchange:function(t){console.log(t)}},watch:{"dataForm.pigstyId":{handler:function(t,e){e&&(this.dataForm.unitId=""),this.unitSelectedList=this.unitList.filter(function(e){return e.pigstyId===t})}},"form.pigstyId":{handler:function(t,e){e&&(this.form.unitId=""),this.unitSelectedList=this.unitList.filter(function(e){return e.pigstyId===t})}}}},m={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"bunit"},[a("el-container",[a("el-header",[a("div",{staticClass:"rect rect-form"},[a("el-form",{attrs:{inline:!0,model:t.dataForm,size:"mini"},nativeOn:{keyup:function(e){if(!("button"in e)&&t._k(e.keyCode,"enter",13,e.key,"Enter"))return null;t.getDataList()}}},[a("el-form-item",{staticStyle:{width:"140px"}},[a("el-select",{staticStyle:{width:"100%"},attrs:{placeholder:"猪舍"},model:{value:t.dataForm.pigstyId,callback:function(e){t.$set(t.dataForm,"pigstyId",e)},expression:"dataForm.pigstyId"}},t._l(t.phSelectedList,function(t){return a("el-option",{key:t.id,attrs:{label:t.number,value:t.id}})}))],1),t._v(" "),a("el-form-item",{staticStyle:{width:"140px"}},[a("el-select",{ref:"unit",staticStyle:{width:"100%"},attrs:{placeholder:"单元"},on:{focus:function(e){t.selectFocus("unit")}},model:{value:t.dataForm.unitId,callback:function(e){t.$set(t.dataForm,"unitId",e)},expression:"dataForm.unitId"}},t._l(t.unitSelectedList,function(t){return a("el-option",{key:t.id,attrs:{label:t.number,value:t.id}})}))],1),t._v(" "),a("el-form-item",{staticStyle:{width:"180px"}},[a("el-input",{attrs:{placeholder:"栏期编号",clearable:""},model:{value:t.dataForm.key,callback:function(e){t.$set(t.dataForm,"key",e)},expression:"dataForm.key"}})],1),t._v(" "),a("el-form-item",[a("el-button",{attrs:{icon:"el-icon-search"},on:{click:function(e){t.getDataList()}}},[t._v("查 询")])],1),t._v(" "),a("el-form-item",[a("el-button",{attrs:{icon:"el-icon-circle-close"},on:{click:function(e){t.clearAll()}}},[t._v("清 空")])],1)],1)],1)]),t._v(" "),a("el-main",[a("div",{staticClass:"rect rect-table"},[a("el-form",{attrs:{inline:"",size:"mini"}},[a("el-form-item",[a("el-button",{attrs:{icon:"el-icon-plus"},on:{click:function(e){t.addOrUpdateHandle()}}},[t._v("\n 新 增\n ")])],1)],1),t._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.dataListLoading,expression:"dataListLoading"}],staticStyle:{width:"100%"},attrs:{height:"540",data:t.dataList,size:"mini",border:"",stripe:"","header-cell-style":{background:"rgb(245,245,245)",color:"#000",height:"45px",fontSize:"13px",fontWeight:"normal",borderBottom:"1px solid #ccc"},"cell-style":{color:"#888",fontSize:"13px"}},on:{"selection-change":t.selectionChangeHandle}},[a("el-table-column",{attrs:{type:"selection","header-align":"center",align:"center",width:"50"}}),t._v(" "),a("el-table-column",{attrs:{prop:"number","header-align":"center",align:"center",label:"栏期编号"}}),t._v(" "),a("el-table-column",{attrs:{prop:"unitName","header-align":"center",align:"center",label:"单元"}}),t._v(" "),a("el-table-column",{attrs:{prop:"pigstyName","header-align":"center",align:"center",label:"猪舍"}})],1),t._v(" "),a("div",{staticClass:"block"},[a("el-pagination",{attrs:{"current-page":t.pageIndex,"page-sizes":[10,20,30,50,100],"page-size":t.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:t.totalPage},on:{"size-change":t.sizeChangeHandle,"current-change":t.currentChangeHandle}})],1),t._v(" "),a("el-dialog",{attrs:{title:t.form.id?"修改":"新增","close-on-click-modal":!1,visible:t.visible,width:"600px"},on:{"update:visible":function(e){t.visible=e},close:t.cancel}},[a("el-form",{ref:"form",staticStyle:{"margin-left":"20px",width:"500px"},attrs:{model:t.form,"label-width":"80px",rules:t.dataRule,size:"mini"},nativeOn:{keyup:function(e){if(!("button"in e)&&t._k(e.keyCode,"enter",13,e.key,"Enter"))return null;t.formSubmit()}}},[a("el-form-item",{attrs:{label:"猪舍",prop:"pigstyId"}},[a("el-select",{staticStyle:{width:"100%"},attrs:{placeholder:"请选择所属猪舍"},model:{value:t.form.pigstyId,callback:function(e){t.$set(t.form,"pigstyId",e)},expression:"form.pigstyId"}},t._l(t.phSelectedList,function(t){return a("el-option",{key:t.id,attrs:{label:t.number,value:t.id}})}))],1),t._v(" "),a("el-form-item",{attrs:{label:"单元",prop:"unitId"}},[a("el-select",{ref:"unitDialog",staticStyle:{width:"100%"},attrs:{placeholder:"单元"},on:{focus:function(e){t.selectFocus()}},model:{value:t.form.unitId,callback:function(e){t.$set(t.form,"unitId",e)},expression:"form.unitId"}},t._l(t.unitSelectedList,function(t){return a("el-option",{key:t.id,attrs:{label:t.number,value:t.id}})}))],1)],1),t._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{size:"small"},on:{click:t.cancel}},[t._v("关闭")]),t._v(" "),a("el-button",{attrs:{size:"small",type:"primary"},on:{click:function(e){t.formSubmit()}}},[t._v("确定")])],1)],1)],1)])],1)],1)},staticRenderFns:[]};var p=a("VU/8")(u,m,!1,function(t){a("OGMY")},"data-v-521926b2",null);e.default=p.exports},tFo7:function(t,e,a){(t.exports=a("FZ+f")(!1)).push([t.i,"\n.rect[data-v-521926b2] {\r\n background-color: #fff;\r\n padding: 30px 15px;\r\n border-radius: 5px;\r\n border: 1px solid #e8e8e8;\n}\n.rect-form[data-v-521926b2] {\r\n padding-bottom: 10px;\n}\n.rect-table[data-v-521926b2] {\r\n margin-top: 20px;\n}\n.demo-table-expand[data-v-521926b2] {\r\n font-size: 0;\r\n margin-left: 40px;\n}\n.demo-table-expand label[data-v-521926b2] {\r\n width: 90px;\r\n color: #99a9bf;\n}\n.demo-table-expand .el-form-item[data-v-521926b2] {\r\n margin-right: 0;\r\n margin-bottom: 0;\r\n width: 80%;\n}\n.el-table .height[data-v-521926b2] {\r\n background: rgba(254, 254, 254, 0.5);\n}\n[data-v-521926b2].el-table--mini td, .el-table--mini th[data-v-521926b2] {\r\n padding: 3px 0 !important;\r\n height: 20px !important;\n}\n[data-v-521926b2].el-checkbox__input.is-checked+.el-checkbox__label {\r\n color: rgb(24,144,255);\r\n background-color: rgb(24,144,255);\r\n border-color: rgb(24,144,255);\n}\n[data-v-521926b2].el-table .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner[data-v-521926b2] {\r\n background-color: rgb(24,144,255);\r\n border-color: rgb(24,144,255);\n}\n[data-v-521926b2].el-table .el-checkbox__inner:hover {\r\n border-color: rgb(24,144,255);\n}\n[data-v-521926b2].el-table .el-checkbox__input.is-focus .el-checkbox__inner {\r\n border-color: rgb(24,144,255);\n}\n[data-v-521926b2].el-table #select .cell .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner[data-v-521926b2] {\r\n background-color: rgb(24,144,255);\r\n border-color: rgb(24,144,255);\n}\r\n",""])}});