心电图模块 修改

This commit is contained in:
lxd 2024-11-27 10:15:40 +08:00
parent 06521f4d32
commit a6ca475896

View File

@ -2,9 +2,8 @@
<div>
<!-- <button @click="moveCanvas('left')">左边-左移</button>
<button @click="moveCanvas('right')">左边-右移</button>-->
<sb />
<div class="container">
<BB>
<div id="canvas-container">
<canvas ref="leftCanvas" id="leftCanvas" width="21" height="600"></canvas>
<canvas ref="bottomCanvas" id="bottomCanvas" width="1140" height="600"></canvas>
@ -15,9 +14,8 @@
height="600"
@mousedown="handleMouseDown($event, 'L')"
></canvas>
</div>
</BB>
<div id="canvas-container1">
<canvas ref="rightCanvas" id="rightCanvas" width="21" height="600"></canvas>
<canvas ref="bottomCanvas1" id="bottomCanvas1" width="1140" height="600"></canvas>
@ -30,8 +28,42 @@
></canvas>
</div>
</div>
<el-slider v-model="sliderValue" :min="0" :max="50" :step="1" @input="handleSliderChange" />
<span class="myrtip"
>{{ '&nbsp;走速:' + convert(suduratio, 0) + 'mm/s ' }}
{{ '&nbsp;振幅:' + convert(lineratio, 1) + 'mm/mv ' }} {{ '&nbsp;报告模式6X2' }}</span
>
<div @click="preventClick">
<el-slider
v-model="sliderValue"
:min="0"
:max="50"
:step="1"
@input="handleSliderChange"
:show-tooltip="false"
/>
</div>
</div>
<!--纠错功能-->
<el-dialog v-model="isdialog" title="导联纠错" width="600" @close="close">
<div>
<el-checkbox-group v-model="transfer" :min="0" :max="2" class="mycheckbox-group">
<el-checkbox
v-for="city in transferleads"
:key="city"
:label="city"
:value="city"
class="mycheckbox-item"
@change="checkboxchage"
>
{{ city }}
</el-checkbox>
</el-checkbox-group>
</div>
<div style="margin-top: 10px">
<el-button type="primary" @click="clickdl" :disabled="checkes">交换导联</el-button>
<el-button type="primary" @click="recovery()">恢复正常</el-button>
</div>
</el-dialog>
</template>
<script setup>
@ -44,7 +76,9 @@ import BB from './ECGBB.vue'
//json
const text = ref()
const sliderValue = ref(0) //
//
const emits = defineEmits(['update:value'])
const lineratio1 = ref(0.05) //线
const previousValue = ref(0) //
const swipeDirection = ref('') //
//
@ -59,6 +93,16 @@ const url = ref()
const ctx = ref(null)
const isVertical = ref(false) // 线true false
const lastPoint = ref(null) //
const isdialog = ref(false) //
const transfer = ref() //
const checkes = ref(true) //
//
const beatArray1 = ref([])
const beatArray2 = ref([]) //
let offset = 0
const spacing = 20
function handleMouseDown(event, type) {
if (type === 'L') {
@ -94,39 +138,63 @@ function calculateDistance(x1, y1, x2, y2) {
function drawLineAndDistance(point1, point2) {
//ctx.value.clearRect(0, 0, topCanvas.value.width, topCanvas.value.height); //
//线
if (Math.abs(point2.x - point1.x) <= 20) {
point2.x = point1.x
lineTo(point1.x, point1.y, point2.x, point2.y,1)
} else if (Math.abs(point2.y - point1.y) <= 20) {//
point2.y = point1.y
lineTo(point1.x, point1.y, point2.x, point2.y,0)
} else {
lastPoint.value = null
}
}
function lineTo(x, y, x1, y1, type) {
//
ctx.value.fillStyle = 'black'
ctx.value.beginPath()
ctx.value.arc(point1.x, point1.y, 1, 0, 2 * Math.PI)
ctx.value.arc(x, y, 1, 0, 2 * Math.PI)
ctx.value.fill()
ctx.value.beginPath()
ctx.value.arc(point2.x, point2.y, 1, 0, 2 * Math.PI)
ctx.value.arc(x1, y1, 1, 0, 2 * Math.PI)
ctx.value.fill()
// 线
ctx.value.beginPath()
ctx.value.moveTo(point1.x, point1.y)
ctx.value.lineTo(point2.x, point2.y)
ctx.value.moveTo(x, y)
ctx.value.lineTo(x1, y1)
ctx.value.strokeStyle = 'black'
ctx.value.lineWidth = 1
ctx.value.stroke()
//
const distance = calculateDistance(point1.x, point1.y, point2.x, point2.y)
const distance = calculateDistance(x, y, x1,y1)
const ms = (25.4 / 96) * (25 / 1000) * distance
ctx.value.font = '11px Arial'
ctx.value.fillStyle = 'black'
ctx.value.fillText(`距离: ${distance.toFixed(2)}px`, point1.x + 10, point1.y - 10)
if (type === 1) {
ctx.value.fillText(`距离: ${ms.toFixed(2)}ms`, x + 5, y +30)
} else {
ctx.value.fillText(`距离: ${ms.toFixed(2)}ms`, x + 10, y - 10)
}
}
/*鼠标绘制相关*/
const handleSliderChange = (value) => {
//
const difference = value - previousValue.value
const swipeDifference = Math.abs(difference)
console.log('滑动差值' + swipeDifference)
if (value > previousValue.value) {
swipeDirection.value = '右滑' //
moveCanvas('left')
moveCanvas('left', swipeDifference)
} else if (value < previousValue.value) {
swipeDirection.value = '左滑' //
moveCanvas('right')
moveCanvas('right', swipeDifference)
} else {
swipeDirection.value = '未滑动' //
}
@ -136,7 +204,7 @@ const handleSliderChange = (value) => {
//
onMounted(async () => {
console.log('挂载完成' + infoParams.Isgrid)
console.log('挂载完成')
// topCanvas.value = document.getElementById('topCanvas');
})
@ -164,6 +232,7 @@ nextTick(() => {
}
fetchData()
})
//
const fetchData = async () => {
try {
@ -200,25 +269,126 @@ const infoParams = defineProps({
examId: String,
Isgrid: Number,
Ismeasure: Number,
Isfd: Boolean
Isfd: Boolean,
lineratio: Number,
suduratio: Number,
isrefresh: Boolean,
iscorrect: Boolean
})
// // 使 watch parentValue
// watch(
// () => infoParams.Isgrid,
// (newValue, oldValue) => {
// console.log(`Isgrid ${oldValue} ${newValue}`)
// }
// )
//
watch(
[() => infoParams.Isgrid, () => infoParams.Ismeasure],
([newIsGridValue, newAnotherValue], [oldIsGridView, oldAnotherValue]) => {
[
() => infoParams.Isgrid,
() => infoParams.Ismeasure,
() => infoParams.lineratio,
() => infoParams.suduratio,
() => infoParams.isrefresh,
() => infoParams.iscorrect
],
(
[newIsGridValue, newAnotherValue, newlineratio, newsuduratio, newisrefresh, newiniscorrect],
[oldIsGridView, oldAnotherValue, oldlineratio, oldsuduratio, oldisrefresh, oldiscorrect]
) => {
// isGrid
if (newIsGridValue !== oldIsGridView) {
console.log(`isGrid 从 ${oldIsGridView} 变化到 ${newIsGridValue}`)
//
Repaint()
}
// anotherValue
if (newAnotherValue !== oldAnotherValue) {
//
}
//
if (newlineratio !== oldlineratio) {
Repaint()
}
//
if (newsuduratio !== oldsuduratio) {
Repaint()
}
//
if (newisrefresh !== oldisrefresh) {
console.log(newisrefresh)
Repaint()
}
//
if (newiniscorrect !== oldiscorrect) {
isdialog.value = newiniscorrect
}
}
)
//
function recovery() {
transfer.value = []
beatArray1.value = beatArray2.value.slice()
Repaint()
}
//
function checkboxchage() {
checkes.value = transfer.value.length === 2 ? false : true
}
//
function clickdl() {
const one = transfer.value[0]
const two = transfer.value[1]
const oneindex = transferleads.indexOf(one)
const twoindex = transferleads.indexOf(two)
swapElements(oneindex, twoindex)
Repaint()
}
//
const swapElements = (index1, index2) => {
//
if (
index1 < 0 ||
index2 < 0 ||
index1 >= beatArray1.value.length ||
index2 >= beatArray1.value.length
) {
console.log('索引超出数组范围')
return
}
//
const temp = beatArray1.value[index1]
beatArray1.value[index1] = beatArray1.value[index2]
beatArray1.value[index2] = temp
}
//
function close() {
isdialog.value = false
transfer.value = []
emits('update:value', isdialog.value)
}
//
const lineratioMap = {
0.012: '2.5',
0.025: '5',
0.05: '10',
0.1: '20',
0.2: '40'
}
const suduratioMap = {
0.2: '5',
0.4: '10',
0.5: '12.5',
1: '25',
2: '50'
}
function convert(command, type) {
if (type === 0) {
return suduratioMap[command] || null
} else {
return lineratioMap[command] || null
}
}
//
function Repaint() {
eliminate(leftCanvas.value)
eliminate(rightCanvas.value)
eliminate(bottomCanvas.value)
@ -227,17 +397,6 @@ watch(
eliminate(topCanvas1.value)
Bottom()
}
// anotherValue
if (newAnotherValue !== oldAnotherValue) {
console.log(`anotherValue 从 ${oldAnotherValue} 变化到 ${newAnotherValue}`)
//
}
}
)
//
let beatArray1 = []
let offset = 0
const spacing = 20
//
const leads = [
@ -255,6 +414,7 @@ const leads = [
'LEAD_V6'
]
const transferleads = ['I', 'II', 'III', 'avR', 'avL', 'avF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']
//
const lead_name = ['I', 'II', 'III', 'aVR', 'aVL', 'aVF']
@ -263,20 +423,24 @@ const rlead_name = ['V1', 'V2', 'V3', 'V4', 'V5', 'V6']
//
function handleFileChange() {
const json = JSON.parse(text.value)
leads.forEach((lead, index) => {
const value = json[lead].trim()
const commaSeparatedValue = value.replace(/\s+/g, ',')
const numberArray = commaSeparatedValue.split(',').map(Number)
beatArray1.push(numberArray)
beatArray1.value.push(numberArray)
})
beatArray2.value = beatArray1.value.slice()
}
//
function moveCanvas(direction) {
function moveCanvas(direction, count) {
const xoffset = count === 1 ? 1 : count
if (direction === 'left') {
if (offset !== -20 * 40) offset -= spacing
if (offset !== -20 * 60) offset -= spacing * xoffset
} else if (direction === 'right') {
if (offset !== 0) offset += spacing
if (offset !== 0) offset += spacing * xoffset
}
// if (direction === 'left') {
@ -302,17 +466,17 @@ function drawBottomCanvas() {
if (infoParams.Isgrid === 1) {
lbackcanvas(leftCanvas.value)
rbackcanvas(rightCanvas.value)
drawMultipleLines(bottomCanvas.value, beatArray1)
drawMultipleLines(bottomCanvas1.value, beatArray1)
drawMultipleLines(bottomCanvas.value, beatArray1.value)
drawMultipleLines(bottomCanvas1.value, beatArray1.value)
}
begin(leftCanvas.value, beatArray1)
beginr(rightCanvas.value, beatArray1)
begin(leftCanvas.value, beatArray1.value)
beginr(rightCanvas.value, beatArray1.value)
}
//
function drawTopCanvas() {
drawMultipleLinesl(topCanvas.value, beatArray1)
drawMultipleLinesr(topCanvas1.value, beatArray1)
drawMultipleLinesl(topCanvas.value, beatArray1.value)
drawMultipleLinesr(topCanvas1.value, beatArray1.value)
}
//
function lbackcanvas(c_canvas) {
@ -483,11 +647,11 @@ function drawLine1(c_canvas, beatArray, offset, index) {
if (index <= 5) {
if (beatArray.length > 0) {
const firstX = 0
const firstY = 50 - beatArray[0] * 0.025 + offset
const firstY = 50 - beatArray[0] * infoParams.lineratio + offset
ctx.moveTo(firstX, firstY)
for (let i = 0; i < beatArray.length - 1; i++) {
const x2 = 0 + (i + 1) / 10
const y2 = 50 - beatArray[i + 1] * 0.025 + offset
const x2 = (0 + (i + 1) / 10) * infoParams.suduratio
const y2 = 50 - beatArray[i + 1] * infoParams.lineratio + offset
ctx.lineTo(x2, y2)
}
ctx.stroke()
@ -497,11 +661,11 @@ function drawLine1(c_canvas, beatArray, offset, index) {
if (index > 5) {
if (beatArray.length > 0) {
const firstX = 0
const firstY = 50 - beatArray[0] * 0.025 + offset
const firstY = 50 - beatArray[0] * infoParams.lineratio + offset
ctx.moveTo(firstX, firstY)
for (let i = 0; i < beatArray.length - 1; i++) {
const x2 = 0 + (i + 1) / 10
const y2 = 50 - beatArray[i + 1] * 0.025 + offset
const x2 = (0 + (i + 1) / 10) * infoParams.suduratio
const y2 = 50 - beatArray[i + 1] * infoParams.lineratio + offset
ctx.lineTo(x2, y2)
}
ctx.stroke()
@ -519,7 +683,7 @@ function drawLine1(c_canvas, beatArray, offset, index) {
width: 100%;
overflow-x: auto;
overflow-y: hidden;
height: 600px;
height: 100%;
max-width: 3920px;
}
#canvas-container,
@ -559,5 +723,20 @@ function drawLine1(c_canvas, beatArray, offset, index) {
canvas {
position: absolute;
}
.myrtip {
display: flex;
flex-direction: row-reverse;
margin-right: 30px;
}
.mycheckbox-group {
display: flex;
flex-wrap: wrap;
}
.mycheckbox-item {
margin-left: 5px;
margin-right: 30px; /* 根据需要调整间距 */
margin-bottom: 10px; /* 根据需要调整间距 */
width: 30px;
}
/* 添加其他样式 */
</style>