From 0756bf12d10cf1b7f78c571de0a9ad69cbaeb7ca Mon Sep 17 00:00:00 2001
From: curtis <curtis@i-mps.com>
Date: 星期一, 30 三月 2026 14:24:17 +0800
Subject: [PATCH] fix: 更新內部引用方法參照

---
 uiOutput/DocList/DocList.ts |  123 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 123 insertions(+), 0 deletions(-)

diff --git a/uiOutput/DocList/DocList.ts b/uiOutput/DocList/DocList.ts
new file mode 100644
index 0000000..4aacad7
--- /dev/null
+++ b/uiOutput/DocList/DocList.ts
@@ -0,0 +1,123 @@
+import { ref, computed, onMounted } from 'vue';
+
+interface DocListItem {
+  formId: string;
+  docName: string;
+}
+
+export function useDocListLogic() {
+  // --- State Mapped from Delphi UI Components ---
+  
+  const searchText = ref<string>('');
+  const isCustomDoc = ref<boolean>(false);
+  const selectedIndex = ref<number>(-1);
+  const sortColumn = ref<number>(0);
+  const sortOrder = ref<'asc' | 'desc'>('asc');
+
+  // FormIDList: TStringList equivalent
+  // Sample data format from Pascal: 'FormID#@#DocName'
+  const formIDList = ref<string[]>([]);
+
+  // --- Computed ---
+
+  const filteredItems = computed(() => {
+    const items: DocListItem[] = formIDList.value
+      .filter(line => !searchText.value || line.toUpperCase().includes(searchText.value.toUpperCase()))
+      .map(line => {
+        const parts = line.split('#@#');
+        return {
+          formId: parts[0] || '',
+          docName: parts[1] || ''
+        };
+      });
+
+    // Sort items
+    items.sort((a, b) => {
+      let valA = sortColumn.value === 0 ? a.formId : a.docName;
+      let valB = sortColumn.value === 0 ? b.formId : b.docName;
+      
+      const comparison = valA.localeCompare(valB);
+      return sortOrder.value === 'asc' ? comparison : -comparison;
+    });
+
+    return items;
+  });
+
+  // --- Methods ---
+
+  const FormCreate = () => {
+    // PostMessage(Handle,WM_ACTIVATE,WA_CLICKACTIVE,0);
+    console.log('DocListForm created');
+    
+    // Mock initialization for demo
+    formIDList.value = [
+      'F001#@#測試文件一',
+      'F002#@#測試文件二',
+      'A003#@#合約書',
+      'B004#@#申請書'
+    ];
+  };
+
+  const OkBtClick = () => {
+    if (selectedIndex.value === -1 && !isCustomDoc.value) {
+      // Showmessage(_Msg('請選擇一個種類'));
+      alert('請選擇一個種類');
+      return;
+    }
+    console.log('Form confirmed:', selectedIndex.value !== -1 ? filteredItems.value[selectedIndex.value] : 'Custom');
+    closeForm('ok');
+  };
+
+  const CancelBtClick = () => {
+    closeForm('cancel');
+  };
+
+  const Edit1Change = () => {
+    // Logic handled by computed filteredItems
+    selectedIndex.value = -1;
+  };
+
+  const DocLVColumnClick = (index: number) => {
+    if (sortColumn.value === index) {
+      sortOrder.value = sortOrder.value === 'asc' ? 'desc' : 'asc';
+    } else {
+      sortColumn.value = index;
+      sortOrder.value = 'asc';
+    }
+  };
+
+  const DocLVDblClick = (index: number) => {
+    selectedIndex.value = index;
+    OkBtClick();
+  };
+
+  const selectItem = (index: number) => {
+    selectedIndex.value = index;
+  };
+
+  const closeForm = (result: string) => {
+    console.log(`DocListForm closing with result: ${result}`);
+  };
+
+  onMounted(() => {
+    FormCreate();
+  });
+
+  return {
+    // State
+    searchText,
+    isCustomDoc,
+    selectedIndex,
+    filteredItems,
+    sortColumn,
+    sortOrder,
+    
+    // Actions
+    OkBtClick,
+    CancelBtClick,
+    Edit1Change,
+    DocLVColumnClick,
+    DocLVDblClick,
+    selectItem
+  };
+}

--
Gitblit v1.8.0