mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-23 20:44:58 +08:00
添加AIFlagTable表select、insert接口,页面业务逻辑变更 ✨
This commit is contained in:
parent
0979211766
commit
0b004be58f
|
@ -0,0 +1,46 @@
|
|||
import common from "./common.js";
|
||||
const app = common.app;
|
||||
const connection = common.connection;
|
||||
const m_get = common.m_get;
|
||||
const m_add = common.m_add;
|
||||
const nowTime = common.nowTime;
|
||||
|
||||
const getTable = () => app.post('/getaiflag', function (req, res) {
|
||||
const database = req.body.database;
|
||||
const table = `AIFlagTable`;
|
||||
const order = `ID`;
|
||||
const Clause = false;
|
||||
const start = ~~req.body.start;
|
||||
const end = ~~req.body.end;
|
||||
connection(database).query(m_get(table, Clause, order, start, end), function (error, results, fields) {
|
||||
if (error) {
|
||||
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
||||
// connection(database).connect();
|
||||
return res.status(500).send(error);
|
||||
} else {
|
||||
res.send(results);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const addTable = () => app.post('/addaiflag', (req, res) => {
|
||||
const database = req.body.database;
|
||||
const table = `AIFlagTable`;
|
||||
const key = 'Flag';
|
||||
// `name, region, area, house_type, phone, create_time, remark`;
|
||||
const values = Number(req.body.flag) ? 1 : 0; // ai给药 : 人工给药
|
||||
// `'${v.name}', '${v.region}', '${v.area}', '${v.house_type}', '${v.phone}', '${nowTime()}', '${remark}'`;
|
||||
connection(database).query(m_add(table, key, values), function (error, results, fields) {
|
||||
if (error) {
|
||||
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
||||
return res.status(500).send(error);
|
||||
} else {
|
||||
res.send(results);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
export default {
|
||||
getTable,
|
||||
addTable
|
||||
};
|
|
@ -11,6 +11,7 @@ const mysqlParams = {
|
|||
port: '3306',
|
||||
user: 'root',
|
||||
password: 'Xg137839',
|
||||
connectTimeout: 5000
|
||||
};
|
||||
// 连接 mysql 数据库
|
||||
const connection = (database) => {
|
||||
|
|
|
@ -14,7 +14,6 @@ const getTable = () => app.post('/getfeature', function (req, res) {
|
|||
connection(database).query(m_get(table, Clause, order, start, end), function (error, results, fields) {
|
||||
if (error) {
|
||||
console.log(`${nowTime()} 错误:${JSON.stringify(error)}`);
|
||||
// connection(database).connect();
|
||||
return res.status(500).send(error);
|
||||
} else {
|
||||
res.send(results);
|
||||
|
|
|
@ -6,6 +6,7 @@ import common from "./core/common.js";
|
|||
import featureTable from "./core/featureTable.js";
|
||||
import AIMedicineTable from "./core/AIMedicineTable.js";
|
||||
import doctorMedicineTable from "./core/doctorMedicineTable.js";
|
||||
import AIFlagTable from "./core/AIFlagTable.js";
|
||||
|
||||
// root/Gao!8636
|
||||
const app = common.app;
|
||||
|
@ -28,8 +29,11 @@ common.getDatabases();
|
|||
featureTable.getTable();
|
||||
AIMedicineTable.getTable();
|
||||
doctorMedicineTable.getTable();
|
||||
AIFlagTable.getTable();
|
||||
|
||||
AIMedicineTable.addTable();
|
||||
doctorMedicineTable.addTable();
|
||||
AIFlagTable.addTable();
|
||||
|
||||
// MedicineFeadbackInfoTable
|
||||
// TimingFeadbackInfoTable
|
||||
|
|
|
@ -198,6 +198,7 @@ const medicineCustom: any[] = [
|
|||
{ name: '阿托品', plus: 1, total: 100 },
|
||||
{ name: '罗库溴铵', plus: 0.1, total: 10 }
|
||||
];
|
||||
let isRunAIFlag = true;
|
||||
const database = ref('');
|
||||
const databaseOptions = ref([] as { value: string, label: string }[]);
|
||||
const messageSum = ref(10);
|
||||
|
@ -232,6 +233,22 @@ function initData() {
|
|||
} catch (error) { }
|
||||
|
||||
}
|
||||
// AIFlagTable 表2秒获取一次
|
||||
function getAIFlag() {
|
||||
setTimeout(() => {
|
||||
if (isRunAIFlag) {
|
||||
isRunAIFlag = false;
|
||||
post('/getaiflag', { database: database.value, start: 0, end: 1 }, (res: any) => {
|
||||
if (res.status === 200 && res.data.length > 0) {
|
||||
const flag = Boolean(res.data[0].Flag);
|
||||
if (isAIDose.value !== flag) getTableData(Boolean(res.data[0].Flag));
|
||||
}
|
||||
isRunAIFlag = true;
|
||||
});
|
||||
}
|
||||
getAIFlag();
|
||||
}, 2000);
|
||||
}
|
||||
function getFeatureTable() {
|
||||
featureTable.value = [];
|
||||
post('/getfeature', { database: database.value, start: 1, end: 50 }, (res: any) => {
|
||||
|
@ -341,28 +358,59 @@ function getMssageLog() {
|
|||
mssageList.value.push({ user: 'nurse', msg: '好的' });
|
||||
}
|
||||
function getTableData(e: boolean) {
|
||||
isStart.value = e;
|
||||
isAIDose.value = e;
|
||||
const url = e ? '/getaimedicine' : '/getdoctormedicine';
|
||||
tableData.value = [];
|
||||
post(url, { database: database.value, start: 0, end: 1 }, (res: any) => {
|
||||
if (res.status === 200) {
|
||||
if (res.data.length > 0) {
|
||||
let i = 0;
|
||||
for (let key in res.data[0]) {
|
||||
if (key !== 'ID' && key !== 'Phase' && key !== 'Time' && key !== 'TIME') {
|
||||
i++;
|
||||
tableData.value.push({ Phase: res.data[0].Phase, num: i, name: key, speed: res.data[0][key], total: medicineCustom.find(o => o.name === key)?.total, state: '正常' });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const defaultMedicine: string[] = ['丙泊酚', '舒芬太尼', '瑞芬太尼', '顺阿曲库胺', '尼卡地平', '艾司洛尔', '麻黄素', '阿托品'];
|
||||
defaultMedicine.forEach((item, index) => {
|
||||
tableData.value.push({ Phase: 1, num: index + 1, name: item, speed: 0, total: medicineCustom.find(o => o.name === item)?.total, state: '正常' });
|
||||
if (tableData.value.length > 0 && e === isAIDose.value) return;
|
||||
// 人工转ai 人工给药数据插到ai给药表
|
||||
let promise = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (e && tableDataStore.value.length > 0) {
|
||||
let key = `Phase`;
|
||||
let value = `${tableDataStore.value[0].Phase}`;
|
||||
tableDataStore.value.forEach(item => {
|
||||
key += `, ${item.name}`;
|
||||
value += `, ${item.speed}`;
|
||||
});
|
||||
post('/addaimedicine', { database: database.value, key, value }, (res: any) => {
|
||||
if (res.status === 200) {
|
||||
tableDataStore.value = JSON.parse(JSON.stringify(tableData.value));
|
||||
console.log('insert成功');
|
||||
}
|
||||
console.log('insert操作');
|
||||
resolve(true)
|
||||
});
|
||||
} else {
|
||||
resolve(false)
|
||||
}
|
||||
tableDataStore.value = JSON.parse(JSON.stringify(tableData.value));
|
||||
}
|
||||
})
|
||||
}
|
||||
promise().then((e: any) => {
|
||||
console.log(11)
|
||||
isStart.value = e;
|
||||
isAIDose.value = e;
|
||||
const url = e ? '/getaimedicine' : '/getdoctormedicine';
|
||||
tableData.value = [];
|
||||
console.log('应该是insert后');
|
||||
post(url, { database: database.value, start: 0, end: 1 }, (res: any) => {
|
||||
if (res.status === 200) {
|
||||
if (res.data.length > 0) {
|
||||
let i = 0;
|
||||
for (let key in res.data[0]) {
|
||||
if (key !== 'ID' && key !== 'Phase' && key !== 'Time' && key !== 'TIME') {
|
||||
i++;
|
||||
tableData.value.push({ Phase: res.data[0].Phase, num: i, name: key, speed: res.data[0][key], total: medicineCustom.find(o => o.name === key)?.total, state: '正常' });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const defaultMedicine: string[] = ['丙泊酚', '舒芬太尼', '瑞芬太尼', '顺阿曲库胺', '尼卡地平', '艾司洛尔', '麻黄素', '阿托品'];
|
||||
defaultMedicine.forEach((item, index) => {
|
||||
tableData.value.push({ Phase: 1, num: index + 1, name: item, speed: 0, total: medicineCustom.find(o => o.name === item)?.total, state: '正常' });
|
||||
});
|
||||
}
|
||||
tableDataStore.value = JSON.parse(JSON.stringify(tableData.value));
|
||||
}
|
||||
});
|
||||
post('/addaiflag', { database: database.value, flag: e ? 1 : 0 }, (res: any) => {
|
||||
console.log(res.status);
|
||||
})
|
||||
});
|
||||
}
|
||||
function keepFit(designWidth: number, designHeight: number, renderDomId: string) {
|
||||
|
@ -448,22 +496,22 @@ const tableItemConfirm = (e: any) => {
|
|||
type: 'success',
|
||||
});
|
||||
// 如果是ai药量表保存后同时在人工表中插入ai药量表数据
|
||||
if (isAIDose.value) {
|
||||
post('/adddoctormedicine', { database: database.value, key, value }, (res: any) => {
|
||||
if (res.status === 200) {
|
||||
ElMessage({
|
||||
message: '保存成功!',
|
||||
type: 'success',
|
||||
});
|
||||
getTableData(false); // 保存成功后切换为人工给药
|
||||
} else {
|
||||
ElMessage({
|
||||
message: JSON.stringify(res),
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// if (isAIDose.value) {
|
||||
// post('/adddoctormedicine', { database: database.value, key, value }, (res: any) => {
|
||||
// if (res.status === 200) {
|
||||
// ElMessage({
|
||||
// message: '保存成功!',
|
||||
// type: 'success',
|
||||
// });
|
||||
// getTableData(false); // 保存成功后切换为人工给药
|
||||
// } else {
|
||||
// ElMessage({
|
||||
// message: JSON.stringify(res),
|
||||
// type: 'error',
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
} else {
|
||||
ElMessage({
|
||||
message: JSON.stringify(res),
|
||||
|
@ -477,12 +525,14 @@ const tableItemCancel = (e: any) => {
|
|||
};
|
||||
|
||||
getDatabases();
|
||||
|
||||
getAIFlag();
|
||||
onMounted(() => {
|
||||
msgLogScrollBottom();
|
||||
getChartData();
|
||||
initScale();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
Loading…
Reference in New Issue
Block a user