curtis
13小時前 713024ccb5056e76bcfc9389664981da68a5139f
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { ref, onMounted } from 'vue';
 
interface OldCase {
  id: string;
  year: string;
  type: string;
  isOld: string;
}
 
interface DocGroup {
  text: string;
  checked: boolean;
  pages: string[];
}
 
export function useOldCaseInfoLogic() {
  // --- State Mapped from Delphi UI Components ---
  
  const currentPage = ref<'CaseInfo' | 'View'>('CaseInfo');
  const oldCases = ref<OldCase[]>([]);
  const selectedCaseIndex = ref<number>(-1);
  
  const docGroups = ref<DocGroup[]>([]);
  const selectedGroupIndex = ref<number>(-1);
  
  const previewImage = ref<string>('');
 
  // --- Methods ---
 
  const FormCreate = () => {
    console.log('OldCaseInfoForm created');
    // Mock data for OldCaseLV
    oldCases.value = [
      { id: 'CASE2023001', year: '2023', type: 'HLN', isOld: 'Y' },
      { id: 'CASE2022045', year: '2022', type: 'HLN', isOld: 'Y' },
      { id: 'CASE2024012', year: '2024', type: 'NORMAL', isOld: 'N' }
    ];
  };
 
  const LoadBtClick = () => {
    if (selectedCaseIndex.value === -1) {
      alert('請先選擇一個案件編號');
      return;
    }
    
    console.log('Loading case:', oldCases.value[selectedCaseIndex.value].id);
    currentPage.value = 'View';
    
    // Mock doc groups loading
    docGroups.value = [
      { text: '身份證{正本}-1', checked: false, pages: ['assets/DocList.png'] },
      { text: '申請書{複本}-2', checked: false, pages: ['assets/CB_IMGPSScanImp.png', 'assets/DocPrt.png'] },
      { text: '財力證明{附件}-1', checked: false, pages: ['assets/ErrList.png'] }
    ];
  };
 
  const ImportBtClick = () => {
    const selected = docGroups.value.filter(g => g.checked);
    if (selected.length === 0) {
      alert('請至少選擇一個要引用之文件');
      return;
    }
    console.log('Importing groups:', selected);
    closeForm('ok');
  };
 
  const ExitBtClick = () => {
    currentPage.value = 'CaseInfo';
  };
 
  const OldExitBtClick = () => {
    closeForm('cancel');
  };
 
  const CheckListBox1Click = (index: number) => {
    selectedGroupIndex.value = index;
    if (docGroups.value[index].pages.length > 0) {
      previewImage.value = docGroups.value[index].pages[0];
    }
  };
 
  const selectCase = (index: number) => {
    selectedCaseIndex.value = index;
  };
 
  const setThumbnailAsPreview = (url: string) => {
    previewImage.value = url;
  };
 
  const closeForm = (result: string) => {
    console.log(`OldCaseInfoForm closing with result: ${result}`);
  };
 
  onMounted(() => {
    FormCreate();
  });
 
  return {
    // State
    currentPage,
    oldCases,
    selectedCaseIndex,
    docGroups,
    selectedGroupIndex,
    previewImage,
    
    // Actions
    LoadBtClick,
    ImportBtClick,
    ExitBtClick,
    OldExitBtClick,
    CheckListBox1Click,
    selectCase,
    setThumbnailAsPreview
  };
}