<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. STLINK/V2下载器接线方法

    一.ST-LINK ST-LINK产品如下图所示: ST-LINK接口定义如下图所示 ST-LINK与stm32接线 使用SW接法只需要四根线: STM32 ST-LINK VCC(3.3V) TVC ...

  2. 自制一个发送验证码的10秒倒计时js效果

    <template>     <div class="conten1">         <input class="code"  ...

  3. 259k+ Star!这是我见过最全的开发者技术学习路线!

    大家好,我是 Java陈序员. 自从上班后,身体是一天不如一天了,也很少有时间可以去学习新技术了.程序员如果技术跟不上,很容易就被淘汰. 而碎片化的学习效率又不高,往往今天学了,明天就忘了.有时候更是 ...

  4. 一:大数据架构回顾-Lambda架构

    "我们正在从IT时代走向DT时代(数据时代).IT和DT之间,不仅仅是技术的变革,更是思想意识的变革,IT主要是为自我服务,用来更好地自我控制和管理,DT则是激活生产力,让别人活得比你好&q ...

  5. vue路由跳转的三种方式

    目录 1.router-link [实现跳转最简单的方法] 2.this.$router.push({ path:'/user'}) 3.this.$router.replace{path:'/' } ...

  6. vue特殊atribute-is

    1.解决dom内模板限制 有些 HTML 元素,诸如 <ul>.<ol>.<table> 和 <select>,对于哪些元素可以出现在其内部是有严格限制 ...

  7. 关于ESLint: Delete `␍`(prettier/prettier) 错误解决方案(3种)

    1.点击VSCode右下角LF/CRLF然后根据弹窗修改成LF即可 2.在.eslintrc.cjs中增加配置 "rules": { "prettier/prettier ...

  8. 启动vite和electron项目配置多个主进程

    推荐 concurrently 点击查看代码 "dev": "concurrently \"nodemon --exec electron . \" ...

  9. three.js 物体要使用光线投射技术,计算是否点击位置与物体有交叉

    原生 DOM 还用原生的 DOM 点击事件,要注意开启 pointerEvents CSS3DRenderer 是一个新的渲染器,需要在渲染循环调用并适配 labelRenderer.domEleme ...

  10. Centos7安装openJdk17

    yum 安装 安装 EPEL 软件源:使用以下命令安装 EPEL 软件源,它包含了 OpenJDK 17 的安装包. sudo yum install epel-release sudo yum in ...