1 line
5.7 KiB
JavaScript
1 line
5.7 KiB
JavaScript
|
webpackJsonp([32],{fKQd:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=a("mvHQ"),o=a.n(r),l={data:function(){return{visible:!1,dataForm:{id:"",plcName:"",port:"",address:"",frequence:"",dataFormat:"",autoConnect:!0,autoRead:!0,station:"",plcType:""},updataURL:"",options:[],options1:[],options2:[],model:0,dataRule:{plcName:[{required:!0,message:"设备名称不能为空",trigger:"blur"}],port:[{required:!0,message:"端口号不能为空",trigger:"blur"}],address:[{required:!0,message:"IP不能为空",trigger:"blur"}],frequence:[{required:!0,message:"读取频率不能为空",trigger:"blur"}],station:[{required:!0,message:"站号不能为空",trigger:"blur"}],plcType:[{required:!0,message:"设备型号不能为空",trigger:"change"}]}}},methods:{init:function(t,e){var a=this;switch(this.dataForm.id=t||"",this.model=0,e){case"Melsec":this.updataURL="MelsecPlc";break;case"Modbus":this.model=1,this.$http({url:this.$http.adornUrl("api/server/plcCreate/list-DataFormat"),method:"post"}).then(function(t){var e=t.data;e&&0===e.code&&(a.options2=e.data)}),this.updataURL="Modbus";break;case"Omron":this.updataURL="OmronPlc";break;default:this.model=2,this.updataURL="siemensPlc",this.$http({url:this.$http.adornUrl("api/server/plcCreate/list-siemensType"),method:"post"}).then(function(t){var e=t.data;e&&0===e.code&&(a.options=e.data)})}this.$http({url:this.$http.adornUrl("api/server/plcCreate/list-frequence"),method:"post"}).then(function(t){var e=t.data;e&&0===e.code&&(a.options1=e.data)}),this.visible=!0,this.$nextTick(function(){if(a.$refs.dataForm.resetFields(),a.dataForm.id){var t={current:1,id:a.dataForm.id,size:10};a.$http({url:a.$http.adornUrl("api/server/main-config/get"),method:"post",data:t}).then(function(t){var e=t.data;if(e&&0===e.code)if(a.dataForm=e.data,2===a.model)a.dataForm.plcType=a.dataForm.plcType.substring(7);else if(1===a.model){var r=JSON.parse(a.dataForm.paramJson).station;a.dataForm.station=JSON.parse(o()(r));var l=JSON.parse(a.dataForm.paramJson).dataFormat;a.dataForm.dataFormat=JSON.parse(o()(l))}})}})},dataFormSubmit:function(){var t=this;this.$refs.dataForm.validate(function(e){e&&t.$http({url:t.$http.adornUrl("api/server/plcCreate/update-"+t.updataURL),method:"post",data:t.$http.adornData(t.dataForm)}).then(function(e){var a=e.data;a&&0===a.code?t.$message({message:"操作成功",type:"success",duration:1500,onClose:function(){t.visible=!1,t.$emit("refreshDataList")}}):t.$message.error(a.msg)})})}}},s={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("el-dialog",{attrs:{title:"编辑PLC","close-on-click-modal":!1,visible:t.visible},on:{"update:visible":function(e){t.visible=e}}},[a("el-form",{ref:"dataForm",attrs:{model:t.dataForm,rules:t.dataRule,"label-width":"80px"},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:"plcName"}},[a("el-input",{attrs:{placeholder:"设备名称",clearable:""},model:{value:t.dataForm.plcName,callback:function(e){t.$set(t.dataForm,"plcName",e)},expression:"dataForm.plcName"}})],1),t._v(" "),2===t.model?a("el-form-item",{attrs:{label:"设备型号",prop:"plcType"}},[a("el-select",{attrs:{placeholder:"请选择设备型号"},model:{value:t.dataForm.plcType,callback:function(e){t.$set(t.dataForm,"plcType",e)},expression:"dataForm.plcType"}},t._l(t.options,function(t){return a("el-option",{key:t,attrs:{label:t,value:t}})}))],1):t._e(),t._v(" "),a("el-form-item",{attrs:{label:"IP",prop:"address"}},[a("el-input",{attrs:{placeholder:"IP",clearable:""},model:{value:t.dataForm.address,callback:function(e){t.$set(t.dataForm,"address",e)},expression:"dataForm.address"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"端口号",prop:"port"}},[a("el-input",{attrs:{placeholder:"端口号",clearable:""},model:{value:t.dataForm.port,callback:function(e){t.$set(t.dataForm,"port",e)},expression:"dataForm.port"}})],1),t._v(" "),1===t.model?a("el-form-item",{attrs:{label:"站号",prop:"station"}},[a("el-input"
|