mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2026-06-12 15:51:46 +08:00
🐛 刷新页面服务报错,页面table数据切换库不刷新问题解决
This commit is contained in:
parent
e2ee5867c6
commit
89bb3dd6d4
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import mysql from "mysql";
|
import mysql from "mysql";
|
||||||
|
import Client from 'easymysql';
|
||||||
/**
|
/**
|
||||||
* 401 需要跳转登录验证
|
* 401 需要跳转登录验证
|
||||||
* 500 接口错误
|
* 500 接口错误
|
||||||
|
|
@ -25,6 +26,8 @@ const con = mysql.createConnection({
|
||||||
...mysqlParams
|
...mysqlParams
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 查询数据方法 SELECT * FROM table
|
// 查询数据方法 SELECT * FROM table
|
||||||
const m_get = (table, Clause, order, start, end) => {
|
const m_get = (table, Clause, order, start, end) => {
|
||||||
return `SELECT * FROM ${table} ${Clause ? 'WHERE ' + Clause : ``} ORDER BY ${order || `ID`} DESC ${!end ? `` : `LIMIT ` + start + `,` + end};`
|
return `SELECT * FROM ${table} ${Clause ? 'WHERE ' + Clause : ``} ORDER BY ${order || `ID`} DESC ${!end ? `` : `LIMIT ` + start + `,` + end};`
|
||||||
|
|
@ -76,31 +79,37 @@ const dateFormater = (formater, time) => {
|
||||||
|
|
||||||
// 获取数据库列表
|
// 获取数据库列表
|
||||||
const getDatabases = () => app.post('/getdatabases', function (req, res) {
|
const getDatabases = () => app.post('/getdatabases', function (req, res) {
|
||||||
con.connect();
|
// con.connect();
|
||||||
con.query("SHOW DATABASES", function (error, results, fields) {
|
con.query("SHOW DATABASES", function (error, results, fields) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
||||||
return res.status(500).send(error);
|
return res.status(500).send(error);
|
||||||
} else {
|
} else {
|
||||||
res.send(results);
|
res.send(results);
|
||||||
|
// con.end();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
con.end();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 公共查询方法
|
// 公共查询方法
|
||||||
const mysqlQuery = (res, database, sql) => {
|
const mysqlQuery = (res, database, sql) => {
|
||||||
if(!database) return res.status(500).send('database is ' + database);
|
if (!database) return res.status(500).send('database is ' + database);
|
||||||
connection(database).connect();
|
try {
|
||||||
|
// connection(database).connect();
|
||||||
connection(database).query(sql, (error, results, fields) => {
|
connection(database).query(sql, (error, results, fields) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
// console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
||||||
return res.status(500).send(error);
|
return res.status(500).send(error);
|
||||||
} else {
|
} else {
|
||||||
res.send(results);
|
res.send(results);
|
||||||
|
// connection(database).end();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connection(database).end();
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return res.status(500).send('连接失败', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,7 @@ import AIMedicineTable from "./core/AIMedicineTable.js";
|
||||||
import doctorMedicineTable from "./core/doctorMedicineTable.js";
|
import doctorMedicineTable from "./core/doctorMedicineTable.js";
|
||||||
import AIFlagTable from "./core/AIFlagTable.js";
|
import AIFlagTable from "./core/AIFlagTable.js";
|
||||||
|
|
||||||
// root/Gao!8636
|
|
||||||
const app = common.app;
|
const app = common.app;
|
||||||
const connection = common.connection;
|
|
||||||
const nowTime = common.nowTime;
|
const nowTime = common.nowTime;
|
||||||
|
|
||||||
//配置ajax跨域请求
|
//配置ajax跨域请求
|
||||||
|
|
@ -24,6 +22,15 @@ app.use(bodyParser.json());
|
||||||
|
|
||||||
app.listen(3001, () => console.log('服务启动! ' + nowTime()));
|
app.listen(3001, () => console.log('服务启动! ' + nowTime()));
|
||||||
|
|
||||||
|
common.con.connect();
|
||||||
|
common.con.query("SHOW DATABASES", function (error, results, fields) {
|
||||||
|
if (error) {
|
||||||
|
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
||||||
|
} else {
|
||||||
|
common.connection(results[results.length-1].Database).connect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
common.getDatabases();
|
common.getDatabases();
|
||||||
featureTable.getTable();
|
featureTable.getTable();
|
||||||
AIMedicineTable.getTable();
|
AIMedicineTable.getTable();
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@
|
||||||
<el-table-column prop="num" label="票号" width="40" align="center" />
|
<el-table-column prop="num" label="票号" width="40" align="center" />
|
||||||
<el-table-column prop="name" label="药物名称" align="center" />
|
<el-table-column prop="name" label="药物名称" align="center" />
|
||||||
<el-table-column prop="speed" label="速度(ml/h)" width="100" />
|
<el-table-column prop="speed" label="速度(ml/h)" width="100" />
|
||||||
<el-table-column prop="total" label="累计药量(ml)" width="100" >
|
<el-table-column prop="total" label="累计药量(ml)" width="100">
|
||||||
<template #default="scope">—</template>
|
<template #default="scope">—</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="state" label="工作状态" width="70" align="center" />
|
<el-table-column prop="state" label="工作状态" width="70" align="center" />
|
||||||
|
|
@ -238,6 +238,8 @@ function initData() {
|
||||||
isAIDose.value = false;
|
isAIDose.value = false;
|
||||||
unusual.value = [];
|
unusual.value = [];
|
||||||
mssageList.value = [];
|
mssageList.value = [];
|
||||||
|
tableData.value = [];
|
||||||
|
tableDataStore.value = [];
|
||||||
getFeatureTable();
|
getFeatureTable();
|
||||||
getMssageLog();
|
getMssageLog();
|
||||||
getTableData(isAIDose.value);
|
getTableData(isAIDose.value);
|
||||||
|
|
@ -313,7 +315,9 @@ function getChartData() {
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
try {
|
||||||
chartDom4.value.updateChart(0, new Date());
|
chartDom4.value.updateChart(0, new Date());
|
||||||
|
} catch (error) { }
|
||||||
}, 1000);
|
}, 1000);
|
||||||
function getData() {
|
function getData() {
|
||||||
isRunTimer = false;
|
isRunTimer = false;
|
||||||
|
|
@ -834,10 +838,12 @@ onMounted(() => {
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
&>.left-box {
|
&>.left-box {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 200px;
|
width: 200px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
.unusual-title {
|
.unusual-title {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -848,6 +854,7 @@ onMounted(() => {
|
||||||
border: 1px dashed #C1C1C1;
|
border: 1px dashed #C1C1C1;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.unusual-box {
|
.unusual-box {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100% - 45px);
|
height: calc(100% - 45px);
|
||||||
|
|
@ -869,6 +876,7 @@ onMounted(() => {
|
||||||
&>.right-box {
|
&>.right-box {
|
||||||
width: calc(100% - 205px);
|
width: calc(100% - 205px);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
.video-box {
|
.video-box {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -1010,5 +1018,4 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}</style>
|
||||||
</style>
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user