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