dataBase 服务器模块,处理五hostID 情况下的问题

增加错误提示功能
This commit is contained in:
任珮宇 2024-02-03 11:22:34 +08:00
parent ca4d49f745
commit 165a05baf9
2 changed files with 104 additions and 101 deletions

View File

@ -3,7 +3,8 @@
<a-row type="flex" :gutter="10"> <a-row type="flex" :gutter="10">
<a-col flex="335px"> <a-col flex="335px">
<span class="item-label">Database name</span> <span class="item-label">Database name</span>
<a-select style="width:180px" <a-select
style="width: 180px"
v-model="value.hostId" v-model="value.hostId"
placeholder="select..." placeholder="select..."
:filter-option="filterOption" :filter-option="filterOption"
@ -17,7 +18,8 @@
</a-col> </a-col>
<a-col flex="265px"> <a-col flex="265px">
<span class="item-label">Time</span> <span class="item-label">Time</span>
<a-select style="width:180px" <a-select
style="width: 180px"
v-model="timer" v-model="timer"
placeholder="select..." placeholder="select..."
show-arrow show-arrow
@ -39,63 +41,59 @@
<div class="monitor-search-btns"> <div class="monitor-search-btns">
<a-button class="monitor-search-btns-ant" @click="handleRefresh"> <a-button class="monitor-search-btns-ant" @click="handleRefresh">
<img class="icon-add" src="@/assets/images/global/reset-pwd.png" alt="" /> <img class="icon-add" src="@/assets/images/global/reset-pwd.png" alt="" />
<span style="margin-left: 10px;"> <span style="margin-left: 10px"> Refresh </span>
Refresh
</span>
</a-button> </a-button>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import moment from 'moment'; import moment from 'moment'
import dateFormat from '@/components/jeecg/JEasyCron/format-date' import dateFormat from '@/components/jeecg/JEasyCron/format-date'
import { getAction, postAction, httpAction, deleteAction } from '@/api/manage' import { getAction, postAction, httpAction, deleteAction } from '@/api/manage'
export default { export default {
props: { props: {
value: { value: {
type: Object, type: Object,
required: true required: true,
} },
}, },
data() { data() {
return { return {
timer: 1, timer: 1,
DbOptions: [], DbOptions: [],
timerOptions: [ timerOptions: [
{label: "1Hours",value: 1}, { label: '1Hours', value: 1 },
{label: "2Hours",value: 2}, { label: '2Hours', value: 2 },
{label: "3Hours",value: 3}, { label: '3Hours', value: 3 },
{label: "user-defined",value: 0}, { label: 'user-defined', value: 0 },
] ],
} }
}, },
created() { created() {
this.getBeforeHours(1) this.getBeforeHours(1)
}, },
mounted() { mounted() {
this.getDbList(); this.getDbList()
}, },
methods: { methods: {
getBeforeHours(num) { getBeforeHours(num) {
let currentTime = moment() let currentTime = moment()
let oneHourAgo = moment().subtract(num, 'hours'); let oneHourAgo = moment().subtract(num, 'hours')
this.value.start = oneHourAgo.format('YYYY-MM-DD HH:mm:ss') this.value.start = oneHourAgo.format('YYYY-MM-DD HH:mm:ss')
this.value.end = currentTime.format('YYYY-MM-DD HH:mm:ss') this.value.end = currentTime.format('YYYY-MM-DD HH:mm:ss')
}, },
moment, moment,
filterOption(input, option) { filterOption(input, option) {
return ( return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
);
}, },
getDbList() { getDbList() {
getAction("/sysDatabase/sourceList").then(res => { getAction('/sysDatabase/sourceList').then((res) => {
if (res.success) { if (res.success) {
const sourceId = this.$route.query.id const sourceId = this.$route.query.id
// urlsourceId // urlsourceId
if (sourceId) { if (sourceId) {
const find = res.result.find(item => item.sourceId == sourceId) const find = res.result.find((item) => item.sourceId == sourceId)
if (find) { if (find) {
this.value.hostId = find.hostId this.value.hostId = find.hostId
} }
@ -104,15 +102,16 @@ export default {
this.value.hostId = res.result[0].hostId this.value.hostId = res.result[0].hostId
} }
this.DbOptions = res.result.map(item => { this.DbOptions = res.result.map((item, index) => {
let str = `my${index}`
return { return {
label: item.sourceName, label: item.sourceName,
value: item.hostId value: item.hostId || str,
} }
}) })
this.$emit('change') this.$emit('change')
} else { } else {
this.$message.warning("This operation fails. Contact your system administrator") this.$message.warning('This operation fails. Contact your system administrator')
} }
}) })
}, },
@ -133,7 +132,7 @@ export default {
handleRefresh() { handleRefresh() {
this.$emit('refresh') this.$emit('refresh')
} },
}, },
} }
</script> </script>

View File

@ -363,7 +363,7 @@ export default {
methods: { methods: {
// //
async getData() { async getData() {
// const hide = this.$message.loading('loading...', 0) if (!this.queryParams.hostId.includes('my')) {
this.spinning = true this.spinning = true
try { try {
const { success, result, message } = await getAction('/systemMonitor/dbDetail', this.queryParams) const { success, result, message } = await getAction('/systemMonitor/dbDetail', this.queryParams)
@ -392,6 +392,10 @@ export default {
// hide() // hide()
this.spinning = false this.spinning = false
} }
} else {
this.$message.error('No monitoring information')
}
// const hide = this.$message.loading('loading...', 0)
}, },
// //
generateChart() { generateChart() {