diff --git a/src/axios/index.js b/src/axios/index.js index 180a88c..e63d6af 100644 --- a/src/axios/index.js +++ b/src/axios/index.js @@ -7,11 +7,17 @@ export const get = (url, params, success) => { axios.get(HOST + url, params) .then(res => { success(res); - }); + }) + .catch(err => { + success(err); + });; }; export const post = (url, params, success) => { axios.post(HOST + url, params) .then(res => { success(res); + }) + .catch(err => { + success(err); }); -}; \ No newline at end of file +}; diff --git a/src/views/remote-manage/remote-manage.vue b/src/views/remote-manage/remote-manage.vue index a21b832..54ccbfd 100644 --- a/src/views/remote-manage/remote-manage.vue +++ b/src/views/remote-manage/remote-manage.vue @@ -187,10 +187,6 @@ const chartDom1 = ref(), msgLog = ref(), unusualMsg = ref(); -const databaseOptions: { value: string, label: string }[] = [ - { value: 'zhangxinhe', label: 'zhangxinhe' }, - { value: '数据模拟20231109185403', label: '模拟数据库' } -]; const medicineCustom: any[] = [ { name: '丙泊酚', plus: 0.5, total: 50 }, { name: '舒芬太尼', plus: 1, total: 100 }, @@ -203,6 +199,7 @@ const medicineCustom: any[] = [ { name: '罗库溴铵', plus: 0.1, total: 10 } ]; const database = ref('数据模拟20231109185403'); +const databaseOptions = ref([] as { value: string, label: string }[]); const messageSum = ref(10); const userName = ref('admin'); const setDatabaseDialog = ref(false); @@ -237,7 +234,7 @@ function initData() { } function getFeatureTable() { featureTable.value = []; - post('/getfeature', { database: database.value, start: 1, end: 100 }, (res: any) => { + post('/getfeature', { database: database.value, start: 1, end: 50 }, (res: any) => { if (res.status === 200) { featureTable.value = res.data.reverse(); setTimeout(() => { @@ -246,6 +243,12 @@ function getFeatureTable() { chartDom3.value.chartSet(); chartDom4.value.chartSet(); }, 0); + }else{ + console.log(res); + ElMessage({ + message: res.message, + type: 'error', + }); } }); } @@ -304,6 +307,20 @@ function getChartData() { } } +function getDatabases() { + post('/getdatabases', {}, (res: any) => { + if (res.status === 200) { + console.log(res); + databaseOptions.value = []; + const hideDatabase = ['information_schema', 'mysql', 'performance_schema']; + res.data.forEach((item: any, index: number) => { + if(!hideDatabase.some(e => e === item.Database)) databaseOptions.value.push({value: item.Database, label: item.Database}); + }) + database.value = databaseOptions.value[0].label; + initData(); + } + }); +} function msgLogScrollBottom() { msgLog.value.scrollTo({ top: msgLog.value.scrollHeight, @@ -461,7 +478,7 @@ const tableItemCancel = (e: any) => { e.row.speed = tableDataStore.value[e.$index].speed; }; -initData(); +getDatabases(); onMounted(() => { msgLogScrollBottom();