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
|
};
|
}
|