1 |
- webpackJsonp([90],{CoTw:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=a("Xxa5"),n=a.n(i),r=a("exGp"),s=a.n(r),l={data:function(){return{visible:!1,dataForm:{id:"",eartag:"",pigstyId:"",unitId:"",pigIds:[]},dataRule:{eartag:[{required:!0,message:"耳标不能为空",trigger:"blur"}],pigstyId:[{required:!0,message:"栋舍不能为空",trigger:"blur"}],unitId:[{required:!0,message:"单元不能为空",trigger:"blur"}]},gender:[{value:"公",label:"公"},{value:"母",label:"母"}],pigstyList:[],unitList:[],unitSelectedList:[],periodList:[],periodSelectedList:[],healthStatus:[{value:!0,label:"健康"},{value:!1,label:"不健康"}],originPlaceList:[],outFenceStatus:[{value:0,label:"育肥"},{value:1,label:"出栏"}]}},methods:{init:function(t){var e,a=this;this.visible=!0,this.dataForm.id="",this.$nextTick(function(){a.$refs.dataForm.resetFields(),console.log(t);var e=[],i=[];a.dataForm.pigIds=[],t.forEach(function(t){e.push(t.id),a.dataForm.pigIds.push(t.id),i.push(t.eartag)}),a.dataForm.id=e.join(),a.dataForm.eartag=i.join()}),this.$http({url:this.$http.adornUrl("/management/pigsty/findAll"),method:"get",params:this.$http.adornParams({})}).then((e=s()(n.a.mark(function t(e){var i,r,s,l=e.data;return n.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return a.pigstyList=[],i=[],l.all&&(i=l.all),i.forEach(function(t){var e={value:t.id,label:t.number};a.pigstyList.push(e)}),a.unitList=[],r=[],t.next=8,a.$http({url:a.$http.adornUrl("/management/unit/findAll"),method:"get",params:a.$http.adornParams({})});case 8:(s=t.sent).data.all&&(r=s.data.all),r.forEach(function(t){var e={value:t.id,label:t.number,pigstyId:t.pigstyId,farmId:t.farmId};a.unitList.push(e)}),a.unitSelectedList=a.unitList;case 12:case"end":return t.stop()}},t,a)})),function(t){return e.apply(this,arguments)}))},pigstyChange:function(t){this.unitSelectedList=this.unitList.filter(function(e){return e.pigstyId===t}),console.log(this.unitList),console.log(this.unitSelectedList)},ifPigsty:function(){this.dataForm.pigstyId||(this.$message.error("请先选择猪舍"),this.dataForm.unitId="")},dataFormSubmit:function(){var t=this;this.$refs.dataForm.validate(function(e){e&&t.$http({url:t.$http.adornUrl("/management/yearpigbase/transferPeriod"),method:"post",data:t.$http.adornData({pigIds:t.dataForm.pigIds,unitId:t.dataForm.unitId},!1)}).then(function(e){var a=e.data;a&&0===a.code?(t.visible=!1,t.$emit("refreshDataList"),t.$message({message:"操作成功",type:"success",duration:1500}),t.visible=!1):t.$message.error(a.msg)})})},changeBirth:function(t){var e=this,a=new Date(t);(new Date).getTime()-a.getTime()<0&&this.$confirm("出生日期有误","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(function(){e.dataForm.birthday="",console.log("还没出生呢...")}).catch(function(){})}},watch:{"dataForm.pigstyId":{handler:function(t,e){e&&(this.dataForm.unitId="",this.dataForm.periodId="",this.unitSelectedList=this.unitList.filter(function(e){return e.pigstyId===t}),this.periodSelectedList=this.periodList.filter(function(e){return e.pigstyId===t}))}}}},o={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("el-dialog",{attrs:{title:t.dataForm.id?"修改":"新增","close-on-click-modal":!1,visible:t.visible,width:"600px"},on:{"update:visible":function(e){t.visible=e}}},[a("el-form",{ref:"dataForm",staticStyle:{"margin-left":"20px",width:"500px"},attrs:{model:t.dataForm,rules:t.dataRule,"label-width":"80px",size:"mini"},nativeOn:{keyup:function(e){if(!("button"in e)&&t._k(e.keyCode,"enter",13,e.key,"Enter"))return null;t.dataFormSubmit()}}},[a("el-form-item",{attrs:{label:"耳标",prop:"eartag"}},[a("el-input",{attrs:{type:"textarea",rows:2,placeholder:"每个耳标之间用英文逗号隔开,最多可以添加50头猪",disabled:!!t.dataForm.id},model:{value:t.dataForm.eartag,callback:function(e){t.$set(t.dataForm,"eartag",e)},expression:"dataForm.eartag"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"猪舍",prop:"pigstyId"}},[a("el-select",{staticStyle:{width:"100%"},on:{change:t.pigstyChange},model:{value:t.dataForm.pigstyId,callback:function(e){t.$set(t.dataForm,"pigstyId",e)},expression:"dataForm.pigstyId"}},t._l(t.pigstyList,function(t){return a("el-option",{key:t.value,attrs:{label:t.label,value:t.value}})}))],1),t._v(" "),a("el-form-item",{attrs:{label:"单元",prop:"unitId"}},[a("el-select",{staticStyle:{width:"100%"},on:{change:function(e){t.ifPigsty("unitId")}},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.value,attrs:{label:t.label,value:t.value}})}))],1)],1),t._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{size:"mini"},on:{click:function(e){t.visible=!1}}},[t._v("关闭")]),t._v(" "),a("el-button",{attrs:{size:"mini",type:"primary"},on:{click:function(e){t.dataFormSubmit()}}},[t._v("确定")])],1)],1)},staticRenderFns:[]},d=a("VU/8")(l,o,!1,null,null,null);e.default=d.exports}});
|