<template>
<div style="float:left;width: 100%; margin-left: 0">
<el-row >
<el-col :span=4>
<el-input placeholder="请输入服务名" v-model='form.app' clearable size="medium" @change="query"></el-input>
</el-col>
<el-col :span=4 :offset=1>
<el-input placeholder="请输入实例名" v-model='form.instanceId' clearable size="medium" @change="query"></el-input>
</el-col>
<el-col :span=4 :offset=1>
<el-select v-model="form.status" placeholder="请选择实例状态">
<el-option
v-for="item in statusOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-col>

<el-col :span="2">
<el-button ref="query" type="primary" icon="el-icon-check" @click="query" size="medium">查询</el-button>
</el-col>
</el-row>
<div style="margin-top:20px">
<el-table
:data="tableData"
height="700"
stripe
style="width: 100%">
<el-table-column label="服务名" prop="app" sortable width="100"></el-table-column>
<el-table-column label="实例名" prop="instanceId" sortable width="100"></el-table-column>
<el-table-column label="实例状态" prop="status" sortable width="180"></el-table-column>
<el-table-column label="运行状态" prop="status" sortable width="180"></el-table-column>
<!-- <el-table-column label="修改原因" prop="reason" width="250"></el-table-column>-->
<el-table-column align="right" width="200">
<template #header>
<el-input v-model="search" size="mini" placeholder="API"></el-input>
</template>
<template #default="scope">
<el-button size="mini" @click="isolution(scope.$index, scope.row)" icon="el-icon-delete" type="primary" :disabled="!$root.writeFlag"
>隔离</el-button>
<el-button size="mini" @click="recover(scope.$index, scope.row)" icon="el-icon-plus" type="primary" :disabled="!$root.writeFlag"
>恢复</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[30, 50, 100, 200, 500, 1000]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="pageTogal">
</el-pagination>
</div>
</div>
</template>
<script>import { post } from '../../api/request'
import Cookies from 'js-cookies/src/cookies'
export default {
name: 'IsolutionInstance',
data () {
return {
pageTogal: 0,
currentPage: 1,
pageSize: 50,
disabled: true,
tableData: [],
tableDataCache: [],
filterData: ['total', 'currentPage', 'pageSize'],
form: {
app: '',
instanceId: '',
status: '',
userName: '',
reason: ''
},
statusOptions: [
{
value: '',
label: 'ALL'
},
{
value: 'UP',
label: 'UP'
},
{
value: 'OUT_OF_SERVICE',
label: 'OUT_OF_SERVICE'
}
]
}
},
created () {
this.disabled = !(this.$root.envFlag && this.$root.writeFlag)
post('/api/instance/apps', this.form).then((result) => {
console.log(result)
if (result.list != null) {
this.pageTogal = result.list.length
this.tableDataCache = result.list
this.tableData = this.tableDataCache.slice(0, this.pageSize)
this.currentPage = 1
}
})
},
methods: {
handleSizeChange (val) {
this.pageSize = val
this.tableData = this.tableDataCache.slice(0, this.pageSize)
this.currentPage = 1
console.log(`每页 ${val} 条`)
},
handleCurrentChange (val) {
window.scrollTo(0, 0)
this.tableData = this.tableDataCache.slice((val - 1) * this.pageSize, val * this.pageSize)
console.log(`当前页: ${val}`)
},
recordFormat (item) {
for (let i = 0; i < this.filterData.length; i++) {
if (item.indexOf(this.filterData[i]) !== -1) {
return
}
}
var htmlStr = ''
if (item.includes('^')) {
htmlStr = '<font color="red">' + item.replaceAll('^', '') + '</font>' + '<br>'
} else {
htmlStr = item + '<br>'
}
return htmlStr
},
query () {
// this.$refs.query.icon = 'el-icon-loading'
post('/api/instance/apps', this.form).then((result) => {
console.log(result)
try {
if (result.list != null) {
this.pageTogal = result.list.length
this.tableDataCache = result.list
this.tableData = this.tableDataCache.slice(0, this.pageSize)
this.currentPage = 1
// this.$refs.query.icon = 'el-icon-check'
}
} catch (e) {
// this.$refs.query.icon = 'el-icon-close'
}
})
},
isolution (index, row) {
this.rowToForm(row)
this.$confirm('操作将导致实例下线,是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
post('/api/instance/isolution', this.form).then((result) => {
console.log(result)
if (result.code === '200') {
this.$message({ type: 'info', message: '隔离成功' })
this.query()
} else {
this.$message({ type: 'error', message: '隔离失败' })
}
})
}).catch(() => {
this.$message({ type: 'info', message: '操作已取消' })
Cookies.removeItem('reason')
})
},
recover (index, row) {
this.rowToForm(row)
this.$confirm('操作将导致实例下线,是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
post('/api/instance/recover', this.form).then((result) => {
console.log(result)
if (result.code === '200') {
this.$message({ type: 'info', message: '恢复成功' })
this.query()
} else {
this.$message({ type: 'error', message: '恢复失败' })
}
})
}).catch(() => {
this.$message({ type: 'info', message: '操作已取消' })
Cookies.removeItem('reason')
})
},
rowToForm (row) {
this.form.status = row.status
this.form.app = row.app
this.form.instanceId = row.instanceId
}
}
}
</script>

<style scoped>

</style>

Isolution的更多相关文章

  1. spring独立事务分析

    最近在ssm框架的项目中需要用到独立事务的实现,找了半天,搜集了以下理论知识为实现做准备.事务管理器为datasource (1)Spring在transactiondefinition接口中规定了7 ...

  2. 代码 | 自适应大邻域搜索系列之(3) - Destroy和Repair方法代码实现解析

    前言 上一篇文章中我们具体解剖了ALNS类的具体代码实现过程,不过也留下了很多大坑.接下来的文章基本都是"填坑"了,把各个模块一一展现解析给大家.不过碍于文章篇幅等原因呢,也不会每 ...

  3. 代码 | 自适应大邻域搜索系列之(4) - Solution定义和管理的代码实现解析

    前言 上一篇讲解了destroy和repair方法的具体实现代码,好多读者都在喊酸爽和得劲儿--今天这篇就讲点简单的,关于solution的定义和管理的代码实现,让大家回回神吧--哈哈. 01 总体概 ...

  4. 代码 | 自适应大邻域搜索系列之(2) - ALNS算法主逻辑结构解析

    00 前言 在上一篇推文中,教大家利用了ALNS的lib库求解了一个TSP问题作为实例.不知道你萌把代码跑起来了没有.那么,今天咱们再接再厉.跑完代码以后,小编再给大家深入讲解具体的代码内容.大家快去 ...

  5. 代码 | 用ALNS框架求解一个TSP问题 - 代码详解

    写在前面 前面好多篇文章,我们总算是把整个ALNS的代码框架给大家说明白了.不知道大家对整个框架了解了没有.不过打铁要趁热,心急了要吃热豆腐.今天就来实战一下,教大家怎么用ALNS的代码框架,求解一个 ...

  6. 代码 | 自适应大邻域搜索系列之(7) - 局部搜索LocalSearch的代码解析

    前言 好了小伙伴们我们又见面了,咳咳没错还是我.不知道你萌接连被这么多篇代码文章刷屏是什么感受,不过,酸爽归酸爽.今天咱们依然讲代码哈~不过今天讲的依然很简单,关于局部搜索LocalSearch的代码 ...

  7. 代码 | 自适应大邻域搜索系列之(6) - 判断接受准则SimulatedAnnealing的代码解析

    前言 前面三篇文章对大家来说应该很简单吧?不过轻松了这么久,今天再来看点刺激的.关于判断接受准则的代码.其实,判断接受准则有很多种,效果也因代码而异.今天介绍的是模拟退火的判断接受准则.那么,相关的原 ...

随机推荐

  1. 【CDS技术揭秘系列 01】阿里云CDS-OSS容灾大揭秘

    ​简介: 本文主要阐述 CDS 产品中 OSS 服务在容灾方面的部署形态以及实现的其本原理. 容灾功能可以保证用户一份数据在多个地方存在冗余备份,当某个机房出现极端异常(比如物理损毁)情况下,数据也不 ...

  2. 模仿Spring实现一个类管理容器

    ​简介: 项目的初衷是独立作出一个成熟的有特色的IOC容器,但由于过程参考Spring太多,而且也无法作出太多改进,于是目的变为以此项目作为理解Spring的一个跳板,与网上的一些模仿Spring的框 ...

  3. SpringBoot中几种好用的代码生成器(基于Mybatis-plus生成entity、mapper、xml等)

    前言 熟悉Spring框架的同学一定都知道MVC开发模式吧,控制器(Controller).业务类(Service).持久层(Repository).数据库映射(Mapper).各种DO类构成了我们服 ...

  4. python3生成随机单词或者语句

    pip install RandomWords Random words: >>> from random_words import RandomWords >>> ...

  5. Python使用HTMLTestRunner运行所有用例并产生报告

    #coding:utf-8import unittestimport osimport sysimport HTMLTestRunnercase_path = os.path.join(os.path ...

  6. ElasticView 是一款用来监控elasticsearch状态和操作elasticsearch索引的web可视化工具。

    ElasticView 是一款用来监控elasticsearch状态和操作elasticsearch索引的web可视化工具. 它由golang开发而成,具有部署方便,占用内存小等优点 es连接树管理( ...

  7. Java手机号校验规则最新

    一.最新的Java手机号校验规则 在Java中,进行手机号校验通常使用正则表达式(Regex)来匹配手机号的格式.以下是一个基于当前(截至2024年)中国手机号规则的校验方法: 中国手机号通常以数字1 ...

  8. 高效C#编程:通过智能线程池管理提升性能

    前言 C#编程中,线程池(Thread Pool)是一个重要的概念,它允许开发者更有效地管理和利用系统资源.通过线程池,我们可以避免频繁地创建和销毁线程,从而减少系统开销并提高程序的响应速度和吞吐量. ...

  9. 利用英特尔 Gaudi 2 和至强 CPU 构建经济高效的企业级 RAG 应用

    检索增强生成 (Retrieval Augmented Generation,RAG) 可将存储在外部数据库中的新鲜领域知识纳入大语言模型以增强其文本生成能力.其提供了一种将公司数据与训练期间语言模型 ...

  10. 多进程池Flask实战应用

    多进程池Flask实战应用 import json import math import flask from concurrent.futures import ProcessPoolExecuto ...