webpackJsonp([72],{"IN/q":function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});a("E4LH");var r={props:["thresholdTypes"],data:function(){return{visible:!1,dataForm:{id:"",thresholdName:"",thresholdType:"",thresholdValue:"",farmId:""},dataRule:{farmId:[{required:!0,message:"牧场名称不能为空",trigger:"blur"}],thresholdType:[{required:!0,message:"参数名称不能为空",trigger:"blur"}],thresholdValue:[{required:!0,message:"参数阈值不能为空",trigger:"blur"}]},farmList:[],farmId:void 0}},methods:{init:function(t){var e=this;this.farmId="null"===this.$cookie.get("farmId")?void 0:parseInt(this.$cookie.get("farmId")),this.visible=!0,this.$nextTick(function(){e.$refs.dataForm.resetFields(),e.dataForm.farmId=e.dataForm.farmId||e.farmId||void 0}),this.dataForm.id=t||void 0,this.dataForm.id&&(console.log(this.dataForm.id),this.$http({url:this.$http.adornUrl("/management/thresholdManagement/info/"+this.dataForm.id),method:"get",params:this.$http.adornParams()}).then(function(t){var a=t.data;a&&0===a.code&&(console.log(a),e.dataForm.thresholdType=a.thresholdManagement.thresholdType,e.dataForm.thresholdValue=a.thresholdManagement.thresholdValue,e.dataForm.farmId=a.thresholdManagement.farmId)})),this.farmList=[];this.$http({url:this.$http.adornUrl("/management/farm/findAll"),method:"post"}).then(function(t){var a=t.data;a&&0===a.code&&a.all.forEach(function(t){var a={label:t.name,value:t.id};e.farmList.push(a)})})},dataFormSubmit:function(){var t=this;this.$refs.dataForm.validate(function(e){if(e){t.$http({url:t.$http.adornUrl("/management/thresholdManagement/"+(t.dataForm.id?"update":"save")),method:"post",data:t.$http.adornData({id:t.dataForm.id||void 0,thresholdType:t.dataForm.thresholdType,thresholdValue:t.dataForm.thresholdValue,farmId:t.dataForm.farmId,belongTo:{1:1,2:1,3:1,4:4,5:2,6:2,7:2,8:3,9:3}[t.dataForm.thresholdType.toString()]})}).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.$message.error(a.msg)})}})}}},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:"farmId"}},[a("el-select",{staticStyle:{width:"100%"},attrs:{disabled:t.farmId>0},model:{value:t.dataForm.farmId,callback:function(e){t.$set(t.dataForm,"farmId",e)},expression:"dataForm.farmId"}},t._l(t.farmList,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:"thresholdType"}},[a("el-select",{staticStyle:{width:"100%"},attrs:{disabled:t.farmId>0},model:{value:t.dataForm.thresholdType,callback:function(e){t.$set(t.dataForm,"thresholdType",e)},expression:"dataForm.thresholdType"}},t._l(t.thresholdTypes,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:"thresholdValue"}},[a("el-input",{model:{value:t.dataForm.thresholdValue,callback:function(e){t.$set(t.dataForm,"thresholdValue",e)},expression:"dataForm.thresholdValue"}})],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:[]},l=a("VU/8")(r,o,!1,null,null,null);e.default=l.exports}});