curtis
21小時前 0653c25c49805b2850a8a68b2b80722b5b05570e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { ref, onMounted } from 'vue';
 
interface PrintItem {
  id: string;
  text: string;
  checked: boolean;
}
 
export function useDocPrtLogic() {
  // --- State Mapped from Delphi UI Components ---
  
  const items = ref<PrintItem[]>([]);
  const selectedIndex = ref<number>(-1);
 
  // --- Methods ---
 
  const FormCreate = () => {
    // PostMessage(Handle,WM_ACTIVATE,WA_CLICKACTIVE,0);
    console.log('PrintForm created');
    
    // Mock data
    items.value = Array.from({ length: 20 }, (_, i) => ({
      id: (i + 1).toString(),
      text: `影像檔 ${i + 1}.jpg`,
      checked: false
    }));
  };
 
  const SelecAllBtClick = () => {
    items.value.forEach(item => item.checked = true);
  };
 
  const EraseBtClick = () => {
    items.value.forEach(item => item.checked = false);
  };
 
  const ExitBtClick = () => {
    closeForm('cancel');
  };
 
  const PrtBtClick = () => {
    const selected = items.value.filter(i => i.checked);
    if (selected.length === 0) {
      alert('請至少選擇一張影像進行列印');
      return;
    }
    console.log('Printing items:', selected);
    closeForm('ok');
  };
 
  const CheckListBox1Click = (index: number) => {
    selectedIndex.value = index;
  };
 
  const ListBox1Click = (index: number) => {
    selectedIndex.value = index;
  };
 
  const closeForm = (result: string) => {
    console.log(`PrintForm closing with result: ${result}`);
  };
 
  onMounted(() => {
    FormCreate();
  });
 
  return {
    // State
    items,
    selectedIndex,
    
    // Actions
    SelecAllBtClick,
    EraseBtClick,
    ExitBtClick,
    PrtBtClick,
    CheckListBox1Click,
    ListBox1Click
  };
}