update
This commit is contained in:
@@ -1,119 +1,174 @@
|
||||
import {computed, ref} from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { minuteToStr } from '/@/utils/utils.ts';
|
||||
|
||||
export function sleepCharts() {
|
||||
function timeFormat(type, list) {
|
||||
const o = {
|
||||
week: 'MM-DD',
|
||||
month: 'MM-DD',
|
||||
year: 'MM',
|
||||
};
|
||||
if (list) {
|
||||
return list.map((item) => dayjs(item).format(o[type]));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
//时间转换
|
||||
export function formatStr({ list, len }) {
|
||||
let sum =
|
||||
list.reduce((all, cur) => {
|
||||
return all + cur;
|
||||
}, 0) / len;
|
||||
|
||||
return minuteToStr(sum);
|
||||
}
|
||||
|
||||
export function sleepCharts({ time, short, long, awake, type }) {
|
||||
return {
|
||||
grid: {
|
||||
top: '15%',
|
||||
left: '8%',
|
||||
right: '3%',
|
||||
bottom: '20%',
|
||||
left: '0%',
|
||||
right: '0%',
|
||||
bottom: '0%',
|
||||
containLabel: true,
|
||||
},
|
||||
tooltip: {
|
||||
show: true,
|
||||
trigger: 'axis',
|
||||
textStyle: {
|
||||
align: 'left', // 使用左对齐样式显示tooltip文本
|
||||
},
|
||||
},
|
||||
legend: {
|
||||
data: ['清醒', '浅睡', '深睡'],
|
||||
textStyle: {
|
||||
color: '#ffffff'
|
||||
color: '#ffffff',
|
||||
},
|
||||
top: 0,
|
||||
left: '55%',
|
||||
},
|
||||
color: ['#14B3F8', '#6D7BEB', '#5451DC'],
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
axisLabel: {
|
||||
color: '#ffffff'
|
||||
axisTick: {
|
||||
show: false,
|
||||
},
|
||||
data: ['0', '2', '4', '6', '8', '10', '12', '14', '16', '18', '20', '22'],
|
||||
axisLabel: {
|
||||
color: '#ffffff',
|
||||
formatter: (item, i) => {
|
||||
if (i == 0 || i == time.length - 1 || i == Math.floor(time.length / 2)) return item;
|
||||
},
|
||||
},
|
||||
data: timeFormat(type, time),
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
axisLabel: {
|
||||
color: '#ffffff'
|
||||
show: false,
|
||||
},
|
||||
axisLine: {
|
||||
show: false
|
||||
show: false,
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
color: '#696969'
|
||||
}
|
||||
}
|
||||
color: '#696969',
|
||||
},
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '清醒',
|
||||
type: 'bar',
|
||||
data: [
|
||||
2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3
|
||||
],
|
||||
data: awake,
|
||||
},
|
||||
{
|
||||
name: '浅睡',
|
||||
type: 'bar',
|
||||
data: [
|
||||
2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3
|
||||
],
|
||||
data: short,
|
||||
},
|
||||
{
|
||||
name: '深睡',
|
||||
type: 'bar',
|
||||
data: [
|
||||
2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3
|
||||
],
|
||||
}
|
||||
]
|
||||
data: long,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export function useHealth() {
|
||||
const healthData = ref([
|
||||
//步数
|
||||
export function useStep() {
|
||||
const stepData = ref([
|
||||
{
|
||||
name: '5000以下',
|
||||
value: '23',
|
||||
type: '1',
|
||||
type: 'lessThanFiveThousand',
|
||||
type_dictText: '恶性肿瘤',
|
||||
},
|
||||
{
|
||||
name: '5000~1w',
|
||||
value: '2',
|
||||
type: '2',
|
||||
type: 'fiveThousandToTenThousand',
|
||||
type_dictText: '其他',
|
||||
},
|
||||
{
|
||||
name: '1~1.5w',
|
||||
value: '34',
|
||||
type: '3',
|
||||
type: 'TenThousandToFifteenThousand',
|
||||
type_dictText: '其他',
|
||||
},
|
||||
{
|
||||
name: '1.5w~2w',
|
||||
value: '43',
|
||||
type: '3',
|
||||
type: 'FifteenToTwentyThousand',
|
||||
type_dictText: '其他',
|
||||
},
|
||||
{
|
||||
name: '2以上',
|
||||
value: '43',
|
||||
type: '3',
|
||||
type: 'TwentyThousandOrMore',
|
||||
type_dictText: '其他',
|
||||
},
|
||||
]);
|
||||
const getValue = computed(() => healthData.value.map((item) => item.value));
|
||||
const getName = computed(() => healthData.value.map((item) => item.name));
|
||||
|
||||
function setHealth(data) {
|
||||
data?.map((item1) => {
|
||||
healthData.value.map((item2) => {
|
||||
if (item1.type == item2.type) {
|
||||
item2.value = item1.count;
|
||||
}
|
||||
});
|
||||
function setStep(data) {
|
||||
stepData.value.map((item) => {
|
||||
item.value = data[item.type] || 0;
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
healthData,
|
||||
getValue,
|
||||
getName,
|
||||
setHealth,
|
||||
stepData,
|
||||
setStep,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const monitorColumns = [
|
||||
{
|
||||
title: '姓名',
|
||||
dataIndex: 'realName',
|
||||
key: 'realName',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'eventType_dictText',
|
||||
key: 'eventType_dictText',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '异常时间',
|
||||
dataIndex: 'warnTime',
|
||||
key: 'warnTime',
|
||||
align: 'center',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '定位',
|
||||
key: 'address',
|
||||
align: 'center',
|
||||
slots: { customRender: 'address' },
|
||||
width: 40,
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user