msServiceInfoList.js 5.9 KB

1
  1. var defaultParams={sysId:"b71b215c48d74632b4d282f83b910118",status:"",serviceCode:"",serviceName:"",swaggerUrl:"",limit:5,offset:0,order:"",sort:""},lib=window.getDirewolfLibrary(),msServiceInfoListContentVm=new Vue({el:"#msServiceInfoListContent",data:function(){return{searchParams:JSON.parse(JSON.stringify(defaultParams)),dictMap:{status:"ms_service_status"},pageDictMap:{},msServiceInfoTablePage:{},msSysList:[],pageLoading:!1,sysLoading:!1,msServiceCodeList:[],serviceLoading:!1,msServiceInfoTableLoading:!1,editType:GetQueryString("editType")}},computed:{inViewMode:function(){return"view"===this.editType||!(this.hasPermission("toggleServiceStatus")&&this.hasPermission("del"))},formBaseUrl:function(){return getRelativePath()+"msServiceInfoForm.html?editType="},requestPrefix:function(){return this.msConfig.gatewayRoute+this.msConfig.adminPath}},methods:{hasPermission:function(e){return lib.$$utils.permission.hasPermission("platman:msServiceInfo:"+e)},getDictByField:function(e){return this.pageDictMap[this.dictMap[e]]},refreshTable:function(){var s=this,e=s.requestPrefix+"/platman/msServiceInfo/getMsServiceInfoList?"+jsonToSpringBinder(this.searchParams);s.msServiceInfoTableLoading=!0,lib.$$utils.axiosRequest(e,"获取微服务信息记录").then(function(e){s.msServiceInfoTablePage=e,s.msServiceInfoTableLoading=!1})},resetSearchParam:function(){this.searchParams=JSON.parse(JSON.stringify(defaultParams)),this.refreshTable()},handleRowClick:function(e,s,i){eleTableClickSelection(this.$refs.msServiceInfoTable,e,i)},handleTableSizeChange:function(e){this.searchParams.limit=e,this.refreshTable()},handleTableCurrentChange:function(e){this.searchParams.offset=this.searchParams.limit*(e-1),this.refreshTable()},handleSortChange:function(e){null===e.prop||null===e.order?(this.searchParams.sort=defaultParams.sort,this.searchParams.order=defaultParams.order):("sysName"===e.prop?this.searchParams.sort="sysId":this.searchParams.sort=e.prop,this.searchParams.order=e.order.split("ending")[0]),this.refreshTable()},viewSelectedMsServiceInfo:function(e){var s=this.formBaseUrl+"view&id="+e.id;openDialogView("查看微服务信息",s,{width:"800px",height:"360px"})},handleSwaggerUrlClick:function(e){e||direwolfCommonTips("warning","文档地址未提供")},viewUsableInstancesDetail:function(e){0!==e.usableInstanceCount?this.viewInstancesDetail(e,"UP"):direwolfCommonTips("warning","指定微服务没有可用的实例")},viewUnusableInstancesDetail:function(e){0!==e.unusableInstanceCount?this.viewInstancesDetail(e,"OTHERS"):direwolfCommonTips("warning","指定微服务没有不可用的实例")},viewInstancesDetail:function(e,s){var i=getRelativePath()+"msServiceInstance.html?editType="+(this.inViewMode?"view":"edit")+"&serviceCode="+e.serviceCode+"&status="+s;openDialogView("查看微服务实例",i,{width:"800px",height:"500px"})},handleSysParamFocus:function(){this.getSysListByUser("")},getSysListByUser:function(e,i){var t=this,s=t.requestPrefix+"/platman/msSystemAdmin/listSystemByCurrentUser?sysName="+e,n="获取系统列表";t.sysLoading=!0,axios.get(s).then(function(e){var s;t.sysLoading=!1,t.msSysList=getDataFromAxiosResponse(e,n).data,i&&(s=t.msSysList[0],t.searchParams.sysId=s.id,t.searchParams.sysName=s.sysName,t.refreshTable())}).catch(function(e){axiosErrorTips(e,n+"异常")})},handleServiceParamFocus:function(){this.getServiceListByUser("")},getServiceListByUser:function(e){var s=this,i=s.requestPrefix+"/platman/msServiceInfo/getMsServiceInfoList?sysId="+s.searchParams.sysId+"&serviceCode="+e,t="获取服务列表";s.serviceLoading=!0,axios.get(i).then(function(e){s.serviceLoading=!1,s.msServiceCodeList=getDataFromAxiosResponse(e,t).list}).catch(function(e){axiosErrorTips(e,t+"异常")})},offlineService:function(){var i=this,t=i.$refs.msServiceInfoTable.selection;0!==t.length?"OUT_OF_SERVICE"!==t[0].status?direwolfCommonConfirm({message:"确定将勾选的服务禁用吗?",title:"禁用提醒"},function(){var e=i.requestPrefix+"/platman/msServiceInfo/status/"+t[0].serviceCode+"?status=OUT_OF_SERVICE",s="禁用服务";axios.get(e).then(function(e){getDataFromAxiosResponse(e,s,!0),i.refreshTable()}).catch(function(e){axiosErrorTips(e,s+"异常")})}):direwolfCommonTips("warning","所选择的服务已经不可用"):direwolfCommonTips("warning","请选择要禁用的服务")},onlineService:function(){var s=this,i=s.$refs.msServiceInfoTable.selection;0!==i.length?"UP"!==i[0].status?direwolfCommonConfirm({message:"确定将勾选的服务启用吗?",title:"启用提醒"},function(){var e=s.requestPrefix+"/platman/msServiceInfo/status/"+i[0].serviceCode+"?status=UP";axiosRequest(e,"启用服务").then(function(e){e&&"success"===e.type&&(direwolfCommonTips("success","启用服务成功。由于实例缓存刷新需要时间,请等待30秒再查看新的实例状态"),s.refreshTable())})}):direwolfCommonTips("warning","所选择的服务已经是可用状态"):direwolfCommonTips("warning","请选择要启用的服务")},deleteServiceRecord:function(){var i=this,e=i.$refs.msServiceInfoTable.selection;0!==e.length?direwolfCommonConfirm({message:"数据删除后不可恢复,确定继续删除吗?",title:"删除提醒"},function(){var s="";e.forEach(function(e){e.id&&(s+=e.id+",")}),1<s.length&&(s=s.substr(0,s.length-1),axiosRequest(i.requestPrefix+"/platman/msServiceInfo/deleteAll?ids="+s,"批量微服务信息","POST").then(function(e){e&&"success"===e.type&&(direwolfCommonTips("success","删除服务信息成功"),i.refreshTable())}))}):direwolfCommonTips("warning","请选择要删除的服务")}},created:function(){var s=this;s.msConfig=(new ProjectConfig).platmanServiceConfig,checkPagePermission(s.requestPrefix+"/platman/msServiceInfo/checkMsServiceInfoListPermission"),s.pageLoading=!1;var i="获取字典信息";axios.get(dictUrl+"ms_service_status").then(function(e){s.pageDictMap=getDataFromAxiosResponse(e,i).data,s.getSysListByUser("",!0)}).catch(function(e){axiosErrorTips(e,i+"异常")})},mounted:function(){}});