1 |
- var msSystemInfoFormVm=new Vue({el:"#msSystemInfoForm",data:function(){var n=this;return{msConfig:{},entity:{id:GetQueryString("id")||"",sysCode:"",sysName:"",sysDesc:"",sysDomain:"",rootPath:"",valid:"1",authType:"02",authCode:"",maxAppInstanceNum:99999},tempAuth:{authType:"",authCode:""},fieldDictTypeMap:{sysDomain:"ms_system_biz_domain",valid:"y_n",authType:"ms_sys_auth_type"},pageDictMap:{},editType:GetQueryString("editType"),rules:{sysCode:[{required:!0,message:"系统简称不能为空",trigger:"blur"},{max:50,message:"长度不能超过 50 个字符",trigger:"change"},{validator:function(e,t,i){-1!==t.indexOf(".")?i(new Error(e.name+'不能包含字符"."')):i()},name:"系统简称",trigger:"change"},{validator:function(e,t,i){t&&(n.entity.sysCode=t.toUpperCase());var a=n.urlPrefix+"/uniqueCodeValidator?id="+(n.entity.id||"-1")+"&systemCode="+n.entity.sysCode,r="校验系统简称是否重复";axios.get(a).then(function(e){"T"===getDataFromAxiosResponse(e,r).data?i():i(new Error("填写的系统简称已存在,请重新输入"))}).catch(function(e){axiosErrorTips(e,r+"异常")})},trigger:"blur"}],sysName:[{required:!0,message:"系统名称不能为空",trigger:"blur"},{max:100,message:"长度不能超过 100 个字符",trigger:"blur"}],sysDesc:[{max:1e3,message:"长度不能超过 1000 个字符",trigger:"blur"}],sysDomain:[{required:!0,message:"命名空间不能为空",trigger:"blur"},{max:100,message:"长度不能超过 100 个字符",trigger:"change"}],rootPath:[{required:!0,message:"根路径不能为空",trigger:"blur"},{validator:function(e,t,i){var a=new RegExp(/^\/(([a-z0-9-._~]|%[a-f0-9]|[!$&'()*+,;=:@])+\/)*([a-z0-9-._~]|%[a-f0-9]|[!$&'()*+,;=:@])+$/g);100<t.length?i(new Error(e.name+"长度不得超过100字符")):a.test(t)?i():i(new Error(e.name+"必须以/开头,必须符合URI规则"))},name:"根路径",trigger:"change"},{validator:function(e,t,i){t&&(n.entity.rootPath=t.toLowerCase());var a=n.urlPrefix+"/uniqueRootValidator?id="+(n.entity.id||"-1")+"rootPath="+n.entity.rootPath,r="校验根路径是否重复";axios.get(a).then(function(e){"T"===getDataFromAxiosResponse(e,r).data?i():i(new Error("填写的根路径已存在,请重新输入"))}).catch(function(e){axiosErrorTips(e,r+"异常")})},trigger:"blur"}],valid:[{max:10,message:"长度不能超过 10 个字符",trigger:"change"}],authCode:[{required:!0,message:"授权码不能为空",trigger:"blur"},{max:100,message:"长度不能超过 100 个字符",trigger:"change"}],maxAppInstanceNum:[{required:!0,message:"最大服务实例数不能为空",trigger:"change"},{validator:checkNumber,max:5,precision:0,name:"最大服务实例数",trigger:"change",acceptPositive:!1}]}}},computed:{urlPrefix:function(){return this.msConfig.gatewayRoute+this.msConfig.adminPath+"/platman/msSystemInfo"},isViewing:function(){return"view"===this.editType}},methods:{initFormData:function(){var e,i,a=this,t=this.entity.id;t&&(e=this.urlPrefix+"/getMsSystemInfoList?id="+t,i="获取微服务系统信息",axios.get(e).then(function(e){var t=getDataFromAxiosResponse(e,i);t.list&&t.list[0]&&(a.entity=t.list[0])}).catch(function(e){axiosErrorTips(e,i+"异常")}))},getDictByField:function(e){return this.pageDictMap[this.fieldDictTypeMap[e]]},setDefaultRootPath:function(e){this.entity.rootPath="/"+e.currentTarget.value.toLowerCase()},generateNewCode:function(){var i=this;function e(){var e=i.urlPrefix+"/newSystemAuthCode?&authType="+i.entity.authType+"&sysCode="+i.entity.sysCode,t="获取系统授权码";axios.get(e).then(function(e){i.entity.authCode=getDataFromAxiosResponse(e,t).data}).catch(function(e){axiosErrorTips(e,t+"异常")})}i.entity.sysCode&&i.entity.authType?i.entity.authCode?direwolfCommonConfirm({message:"授权信息变更后需及时告知系统租户,确定继续吗?",title:"变更提醒"},e):e():direwolfCommonTips("warning","系统简称及授权码类型不能为空")},handleAuthTypeDropVisible:function(e){e&&(this.tempAuth={authType:this.entity.authType,authCode:this.entity.authCode})},handleAuthTypeChange:function(){var e=this;direwolfCommonConfirm({message:"授权信息变更后需及时告知系统租户,确定继续吗?",title:"变更提醒"},function(){e.entity.authCode=null},function(){e.entity.authCode=e.tempAuth.authCode,e.entity.authType=e.tempAuth.authType})}},beforeCreate:function(){},created:function(){var t=this;t.msConfig=(new ProjectConfig).platmanServiceConfig,checkPagePermission(t.urlPrefix+"/checkMsSystemInfoFormPermission");var i="获取字典信息";axios.get(dictUrl+"ms_system_biz_domain,y_n,user_status,ms_sys_auth_type").then(function(e){t.pageDictMap=getDataFromAxiosResponse(e,i).data,t.initFormData()}).catch(function(e){axiosErrorTips(e,i+"异常")})},mounted:function(){var t=this;window.doSubmit=function(e){return eleFormSubmit({vueIns:t,info:"保存微服务系统信息",formRef:"msSystemInfoForm",saveUrl:t.urlPrefix+"/save",callback:e}),!1}}});
|