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