mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 04:54:58 +08:00
添加业务逻辑,每个两秒更新次ai给药表 🎨
This commit is contained in:
parent
f85e4229ce
commit
0eab881e3c
|
@ -201,6 +201,7 @@ const medicineCustom: any[] = [
|
|||
let featureTimer = 0;
|
||||
let ecgTimer = 0;
|
||||
let aiFlagTimer = 0;
|
||||
let medicineTimer = 0;
|
||||
|
||||
const database = ref('');
|
||||
const databaseOptions = ref([] as { value: string, label: string }[]);
|
||||
|
@ -253,37 +254,58 @@ function getAIFlag() {
|
|||
}
|
||||
}, 2000);
|
||||
}
|
||||
function getFeatureTable() {
|
||||
featureTable.value = [];
|
||||
post('/getfeature', { database: database.value, start: 1, end: 50 }, (res: any) => {
|
||||
if (res.status === 200) {
|
||||
featureTable.value = res.data.reverse();
|
||||
setTimeout(() => {
|
||||
chartDom1.value.chartSet();
|
||||
chartDom2.value.chartSet();
|
||||
chartDom3.value.chartSet();
|
||||
chartDom4.value.chartSet();
|
||||
}, 0);
|
||||
} else {
|
||||
ElMessage({
|
||||
message: res.message,
|
||||
type: 'error',
|
||||
function setTableData(res: any) {
|
||||
if (res.data.length > 0) {
|
||||
let i = 0;
|
||||
const ary: any = [];
|
||||
for (let key in res.data[0]) {
|
||||
if (key !== 'ID' && key !== 'Phase' && key !== 'Time' && key !== 'TIME') {
|
||||
i++;
|
||||
ary.push({ Phase: res.data[0].Phase, num: i, name: key, speed: res.data[0][key], total: medicineCustom.find(o => o.name === key)?.total, state: '正常' });
|
||||
}
|
||||
}
|
||||
tableData.value = ary;
|
||||
|
||||
} else {
|
||||
const defaultMedicine: string[] = ['丙泊酚', '舒芬太尼', '瑞芬太尼', '顺阿曲库胺', '尼卡地平', '艾司洛尔', '麻黄素', '阿托品'];
|
||||
const ary: any = [];
|
||||
defaultMedicine.forEach((item, index) => {
|
||||
ary.push({ Phase: 1, num: index + 1, name: item, speed: 0, total: medicineCustom.find(o => o.name === item)?.total, state: '正常' });
|
||||
});
|
||||
tableData.value = ary;
|
||||
}
|
||||
tableDataStore.value = JSON.parse(JSON.stringify(tableData.value));
|
||||
}
|
||||
// AIMedicineTable、DoctorMedicineTable 表2秒获取一次
|
||||
function getMedicine() {
|
||||
let isRunTimer = true;
|
||||
clearInterval(medicineTimer);
|
||||
setInterval(() => {
|
||||
if (isRunTimer && JSON.stringify(tableDataStore) === JSON.stringify(tableData) && isAIDose.value) {
|
||||
isRunTimer = false;
|
||||
const url = isAIDose.value ? '/getaimedicine' : '/getdoctormedicine';
|
||||
post(url, { database: database.value, start: 0, end: 1 }, (res: any) => {
|
||||
if (res.status === 200) {
|
||||
setTableData(res);
|
||||
}
|
||||
isRunTimer = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
// FeatureTable 表2秒获取一次
|
||||
function getChartData() {
|
||||
let isRunTimer = true; // 节流
|
||||
let isRunTimer = true;
|
||||
clearInterval(featureTimer);
|
||||
clearInterval(ecgTimer);
|
||||
setInterval(() => {
|
||||
if(isRunTimer) {
|
||||
if (isRunTimer) {
|
||||
getData()
|
||||
}
|
||||
}, 2000);
|
||||
setInterval(() => {
|
||||
chartDom4.value.updateChart(0, new Date());
|
||||
});
|
||||
}, 1000);
|
||||
function getData() {
|
||||
isRunTimer = false;
|
||||
post('/getfeature', { database: database.value, start: 0, end: 1 }, (res: any) => {
|
||||
|
@ -310,6 +332,25 @@ function getChartData() {
|
|||
});
|
||||
}
|
||||
}
|
||||
function getFeatureTable() {
|
||||
featureTable.value = [];
|
||||
post('/getfeature', { database: database.value, start: 1, end: 50 }, (res: any) => {
|
||||
if (res.status === 200) {
|
||||
featureTable.value = res.data.reverse();
|
||||
setTimeout(() => {
|
||||
chartDom1.value.chartSet();
|
||||
chartDom2.value.chartSet();
|
||||
chartDom3.value.chartSet();
|
||||
chartDom4.value.chartSet();
|
||||
}, 0);
|
||||
} else {
|
||||
ElMessage({
|
||||
message: res.message,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function getDatabases() {
|
||||
post('/getdatabases', {}, (res: any) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -371,24 +412,9 @@ 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: '正常' });
|
||||
});
|
||||
}
|
||||
tableDataStore.value = JSON.parse(JSON.stringify(tableData.value));
|
||||
setTableData(res);
|
||||
}
|
||||
});
|
||||
post('/addaiflag', { database: database.value, flag: e ? 1 : 0 }, (res: any) => {
|
||||
|
@ -508,10 +534,11 @@ const tableItemCancel = (e: any) => {
|
|||
};
|
||||
|
||||
getDatabases();
|
||||
// getAIFlag();
|
||||
onMounted(() => {
|
||||
msgLogScrollBottom();
|
||||
// getChartData();
|
||||
getChartData(); // 定时任务
|
||||
getAIFlag(); // 定时任务
|
||||
getMedicine(); // 定时任务
|
||||
initScale();
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user