|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useState, useMemo } from 'react';
|
|
|
|
|
|
|
+import React, { useState, useMemo, useEffect } from 'react';
|
|
|
import { Select, Button, Space, message } from 'antd';
|
|
import { Select, Button, Space, message } from 'antd';
|
|
|
import { showNotImplemented } from '@/utils/notificationHelper';
|
|
import { showNotImplemented } from '@/utils/notificationHelper';
|
|
|
import { useAppSelector } from '@/states/store';
|
|
import { useAppSelector } from '@/states/store';
|
|
@@ -8,6 +8,7 @@ const PrintControl: React.FC = () => {
|
|
|
const [selectedNode, setSelectedNode] = useState<string>('');
|
|
const [selectedNode, setSelectedNode] = useState<string>('');
|
|
|
const [selectedSize, setSelectedSize] = useState<string>('14IN×17IN');
|
|
const [selectedSize, setSelectedSize] = useState<string>('14IN×17IN');
|
|
|
const [isPrinting, setIsPrinting] = useState(false);
|
|
const [isPrinting, setIsPrinting] = useState(false);
|
|
|
|
|
+ const [canPrint, setCanPrint] = useState<boolean>(false);
|
|
|
|
|
|
|
|
// 获取当前胶片信息
|
|
// 获取当前胶片信息
|
|
|
const activeFilm = useAppSelector((state) => {
|
|
const activeFilm = useAppSelector((state) => {
|
|
@@ -24,12 +25,20 @@ const PrintControl: React.FC = () => {
|
|
|
{ value: 'node1', label: 'TestPrinter' },
|
|
{ value: 'node1', label: 'TestPrinter' },
|
|
|
// { value: 'node2', label: '打印节点2' },
|
|
// { value: 'node2', label: '打印节点2' },
|
|
|
];
|
|
];
|
|
|
|
|
+ // 检查当前胶片是否有图像
|
|
|
|
|
+ const checkIfCanPrint = () => {
|
|
|
|
|
+ const hasImages = activeFilm?.hasImage(activeFilm.images)
|
|
|
|
|
+ console.log(`开始计算有效图像数量 ${hasImages}`)
|
|
|
|
|
+ if (activeFilm && activeFilm.hasImage(activeFilm.images)) {
|
|
|
|
|
+ setCanPrint(true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setCanPrint(false);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- const filmSizes = [
|
|
|
|
|
- { value: '14IN×17IN', label: '14IN×17IN' },
|
|
|
|
|
- { value: '14IN×14IN', label: '14IN×14IN' },
|
|
|
|
|
- { value: '17IN×17IN', label: '17IN×17IN' },
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ checkIfCanPrint();
|
|
|
|
|
+ }, [activeFilm,activeFilm?.images]);
|
|
|
|
|
|
|
|
const handleLocalPrint = async () => {
|
|
const handleLocalPrint = async () => {
|
|
|
if (isPrinting) {
|
|
if (isPrinting) {
|
|
@@ -37,6 +46,11 @@ const PrintControl: React.FC = () => {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!canPrint) {
|
|
|
|
|
+ message.warning('当前胶片上没有图像,无法打印');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
setIsPrinting(true);
|
|
setIsPrinting(true);
|
|
|
|
|
|
|
@@ -75,6 +89,14 @@ const PrintControl: React.FC = () => {
|
|
|
const handleDicomPrint = () => {
|
|
const handleDicomPrint = () => {
|
|
|
showNotImplemented('DICOM打印');
|
|
showNotImplemented('DICOM打印');
|
|
|
};
|
|
};
|
|
|
|
|
+ const filmSizes = [
|
|
|
|
|
+ { value: '14IN×17IN', label: '14IN×17IN' },
|
|
|
|
|
+ { value: '14IN×14IN', label: '14IN×14IN' },
|
|
|
|
|
+ { value: '17IN×17IN', label: '17IN×17IN' },
|
|
|
|
|
+ ];
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ checkIfCanPrint();
|
|
|
|
|
+ }, [activeFilm]);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div>
|
|
<div>
|
|
@@ -117,7 +139,7 @@ const PrintControl: React.FC = () => {
|
|
|
type="primary"
|
|
type="primary"
|
|
|
block
|
|
block
|
|
|
onClick={handleLocalPrint}
|
|
onClick={handleLocalPrint}
|
|
|
- disabled={!selectedNode}
|
|
|
|
|
|
|
+ disabled={!canPrint}
|
|
|
>
|
|
>
|
|
|
本地打印
|
|
本地打印
|
|
|
</Button>
|
|
</Button>
|