Commit 432b5b0e authored by 王晓铜's avatar 王晓铜

修改监控bug

parent 2d759c40
...@@ -423,7 +423,6 @@ export default { ...@@ -423,7 +423,6 @@ export default {
} }
} }
}) })
console.log('保存信息', this.caseForm)
}, },
// 取消按钮 // 取消按钮
cancelCaseFrom() { cancelCaseFrom() {
......
...@@ -11,19 +11,20 @@ ...@@ -11,19 +11,20 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="SQL脚本:" prop="sql"> <el-form-item label="SQL脚本:" prop="sql">
<div style="border:1.5px solid #DCDCDC"> <div style="border:1.5px solid #DCDCDC;width:90%;">
<codemirror ref="editQuerySQL" v-model="sqlMonitorForm.sql" :options="cmOptions"></codemirror> <codemirror ref="editQuerySQL" v-model="sqlMonitorForm.sql" :options="cmOptions" @focus="testFoucs">
</codemirror>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item style="margin-left:1000px"> <el-form-item style="margin-left:1000px">
<el-button type="primary" icon="el-icon-caret-right" @click="executeSqlBtn">执行</el-button> <el-button type="primary" size="mini" icon="el-icon-caret-right" @click="executeSqlBtn">执行</el-button>
<el-button type="primary" icon="el-icon-message-solid" @click="setPoliceBtn">设置报警</el-button> <el-button type="primary" size="mini" icon="el-icon-message-solid" @click="setPoliceBtn">设置报警</el-button>
</el-form-item> </el-form-item>
<el-form-item style="margin-left:-80px"> <el-form-item style="margin-left:-80px">
<!-- 动态绑定表格数据 --> <!-- 动态绑定表格数据 -->
<el-table :data="sqlList" border style="font-size:8px;" <el-table id="tabId" :data="sqlList" border style="font-size:8px;"
:header-cell-style="{background:'#eee',color:'#606266'}" v-if="isShow"> :header-cell-style="{background:'#eee',color:'#606266'}" v-if="isShow" ref="tabRef">
<af-table-column v-for="(val, key) in columnArr" :label="val" :prop="val" :key="key" class="table-dynamic"> <af-table-column v-for="(val, key) in columnArr" :label="val" :prop="val" :key="key" :fontRate='fontRate'>
</af-table-column> </af-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>
...@@ -108,7 +109,7 @@ export default { ...@@ -108,7 +109,7 @@ export default {
data() { data() {
return { return {
cmOptions: { cmOptions: {
tabSize: 4, tabSize: 6,
lineNumbers: true, lineNumbers: true,
line: true, line: true,
indentWithTabs: true, indentWithTabs: true,
...@@ -199,47 +200,63 @@ export default { ...@@ -199,47 +200,63 @@ export default {
trigger: 'blur' trigger: 'blur'
} }
] ]
}, }
tableWidth: ''
} }
}, },
watch: {
tableWidth: 'getTableWidth'
},
// 接收列表页面传递的参数 // 接收列表页面传递的参数
activated() { // activated() {
var data = this.$route.query.data // this.DialogVisible = false
// console.log('rrr', data) // var data = this.$route.query.data
if (data === 'add') { // console.log('rrr', data)
this.sqlMonitorForm = {} // if (data === 'add') {
this.sqlMonitorForm.status = 1 // this.isShow = false
} else { // this.sqlMonitorForm = {}
this.sqlMonitorForm.id = data.id // this.sqlMonitorForm.status = 1
this.sqlMonitorForm.dingText = data.dingText // this.sqlMonitorForm.sql = ''
this.sqlMonitorForm.dingUrl = data.dingUrl // } else {
this.sqlMonitorForm.dsId = data.dsId // this.isShow = false
this.sqlMonitorForm.serviceName = data.serviceName // this.sqlMonitorForm.id = data.id
this.sqlMonitorForm.sql = data.sql // this.sqlMonitorForm.dingText = data.dingText
this.sqlMonitorForm.status = data.status // this.sqlMonitorForm.dingUrl = data.dingUrl
this.sqlMonitorForm.taskCron = data.taskCron // this.sqlMonitorForm.dsId = data.dsId
this.sqlMonitorForm.taskName = data.taskName // this.sqlMonitorForm.serviceName = data.serviceName
} // this.sqlMonitorForm.sql = data.sql
}, // this.sqlMonitorForm.status = data.status
// this.sqlMonitorForm.taskCron = data.taskCron
// this.sqlMonitorForm.taskName = data.taskName
// }
// },
created() { created() {
this.getSqlMonitorDataSource() this.getSqlMonitorDataSource()
}, this.$bus.$on('data', (row) => {
mounted() { console.log('rrr', row)
var editor = this.$refs.editQuerySQL.codemirror if (row !== null) {
editor.on('cursorActivity', function () { if (row === 'add') {
editor.showHint() this.isShow = false
this.sqlMonitorForm = {}
this.sqlMonitorForm.status = 1
this.sqlMonitorForm.sql = ''
} else {
this.isShow = false
this.sqlMonitorForm.id = row.id
this.sqlMonitorForm.dingText = row.dingText
this.sqlMonitorForm.dingUrl = row.dingUrl
this.sqlMonitorForm.dsId = row.dsId
this.sqlMonitorForm.serviceName = row.serviceName
this.sqlMonitorForm.sql = row.sql
this.sqlMonitorForm.status = row.status
this.sqlMonitorForm.taskCron = row.taskCron
this.sqlMonitorForm.taskName = row.taskName
}
}
}) })
}, },
methods: { methods: {
getTableWidth() { testFoucs() {
for (let i = 0; i < document.getElementsByClassName('table-dynamic').length; i++) { var editor = this.$refs.editQuerySQL.codemirror
var item = document.getElementsByClassName('table-dynamic')[i] editor.on('cursorActivity', function () {
console.log(item) editor.showHint()
} })
}, },
// 获取数据源列表 // 获取数据源列表
getSqlMonitorDataSource() { getSqlMonitorDataSource() {
...@@ -302,7 +319,6 @@ export default { ...@@ -302,7 +319,6 @@ export default {
getMonitorStrategy() { getMonitorStrategy() {
getMonitorStrategy().then((resp) => { getMonitorStrategy().then((resp) => {
this.taskCronList = resp.data.data this.taskCronList = resp.data.data
console.log('ww', this.taskCronList)
}) })
}, },
// 获取服务列表 // 获取服务列表
...@@ -315,34 +331,49 @@ export default { ...@@ -315,34 +331,49 @@ export default {
saveSqlMonitorFrom() { saveSqlMonitorFrom() {
this.sqlMonitorForm.owner = this.getUserName this.sqlMonitorForm.owner = this.getUserName
this.sqlMonitorForm.taskClass = 'SqlMonitorHandler' this.sqlMonitorForm.taskClass = 'SqlMonitorHandler'
// 编辑接口 this.$refs.sqlMonitorFormRef.validate((valid) => {
if (this.sqlMonitorForm.id) { if (!valid) {
editSqlMonitor(this.sqlMonitorForm).then((resp) => { return false
if (resp.data.businessCode === '0000') { } else {
this.$message.success('编辑成功!') // 编辑接口
this.$router.push({ if (this.sqlMonitorForm.id) {
path: `/monitor/sqlMonitorList`, editSqlMonitor(this.sqlMonitorForm).then((resp) => {
query: { data: 'refresh' } if (resp.data.businessCode === '0000') {
this.$message.success('编辑成功!')
this.DialogVisible = false
this.$router.push({
path: `/monitor/sqlMonitorList`
})
this.sendResh()
} else {
return this.$message.error(resp.data.msg)
}
}) })
} else { } else {
return this.$message.error(resp.data.msg) // 添加接口
} addSqlMonitor(this.sqlMonitorForm).then((resp) => {
}) if (resp.data.businessCode === '0000') {
} else { this.$message.success('添加成功!')
// 添加接口 this.DialogVisible = false
addSqlMonitor(this.sqlMonitorForm).then((resp) => { this.$router.push({
if (resp.data.businessCode === '0000') { path: `/monitor/sqlMonitorList`
this.$message.success('添加成功!') })
this.$router.push({ this.sendResh()
path: `/monitor/sqlMonitorList`, } else {
query: { data: 'refresh' } return this.$message.error(resp.data.msg)
}
}) })
} else {
return this.$message.error(resp.data.msg)
} }
}) }
} })
// 添加接口 },
// 刷新列表
sendResh() {
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
this.$bus.$emit('refresh')
})
} }
} }
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<p v-if="scope.row.taskCron==='0 0 10 ? * 2'">每周一上午10点执行一次</p> <p v-if="scope.row.taskCron==='0 0 10 ? * 2'">每周一上午10点执行一次</p>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="sql" width="150px"> <el-table-column label="sql" width="80px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-popover placement="top-start" title="sql" width="50" trigger="hover" :content="scope.row.sql"> <el-popover placement="top-start" title="sql" width="50" trigger="hover" :content="scope.row.sql">
<div slot="reference" style="color:#409EFF">SQL</div> <div slot="reference" style="color:#409EFF">SQL</div>
...@@ -88,15 +88,19 @@ export default { ...@@ -88,15 +88,19 @@ export default {
} }
}, },
// 接收参数 // 接收参数
activated() { // activated() {
var data = this.$route.query.data // var data = this.$route.query.data
if (data === 'refresh') { // if (data === 'refresh') {
this.getSqlMonitorList() // this.getSqlMonitorList()
} // }
}, // },
created() { created() {
this.getSqlMonitorList() this.getSqlMonitorList()
this.getServiceList() this.getServiceList()
// 接收参数
this.$bus.$on('refresh', () => {
this.getSqlMonitorList()
})
}, },
methods: { methods: {
// 获取sql监控列表 // 获取sql监控列表
...@@ -113,19 +117,28 @@ export default { ...@@ -113,19 +117,28 @@ export default {
// 添加按钮 // 添加按钮
addSqlMonitor() { addSqlMonitor() {
this.$router.push({ this.$router.push({
path: `/monitor/addSqlMonitor`, path: `/monitor/addSqlMonitor`
query: { // query: {
data: 'add' // data: 'add'
} // }
})
this.$nextTick(function () {
// DOM 现在更新了
var row = 'add'
this.$bus.$emit('data', row)
}) })
}, },
// 编辑按钮 // 编辑按钮
openEditMonitorDialog(row) { openEditMonitorDialog(row) {
this.$router.push({ this.$router.push({
path: `/monitor/addSqlMonitor`, path: `/monitor/addSqlMonitor`
query: { // query: {
data: row // data: row
} // }
})
this.$nextTick(function () {
// DOM 现在更新了
this.$bus.$emit('data', row)
}) })
}, },
// 获取服务列表 // 获取服务列表
...@@ -153,7 +166,7 @@ export default { ...@@ -153,7 +166,7 @@ export default {
delSqlMonitor(row) delSqlMonitor(row)
.then((resp) => { .then((resp) => {
if (resp.data.businessCode === '0000') { if (resp.data.businessCode === '0000') {
this.$message.success(resp.data.msg) this.$message.success('删除成功!')
this.getSqlMonitorList() this.getSqlMonitorList()
} else { } else {
this.$message.error(resp.data.msg) this.$message.error(resp.data.msg)
...@@ -187,7 +200,6 @@ export default { ...@@ -187,7 +200,6 @@ export default {
formData.set('taskId', row.id) formData.set('taskId', row.id)
formData.set('status', 1) formData.set('status', 1)
isEnableSqlMonitor(formData).then((resp) => { isEnableSqlMonitor(formData).then((resp) => {
console.log('999', resp)
if (resp.data.businessCode === '0000') { if (resp.data.businessCode === '0000') {
this.getSqlMonitorList() this.getSqlMonitorList()
return this.$message.success(resp.data.msg) return this.$message.success(resp.data.msg)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment