diff --git a/src/modules/05_command/views/lists.vue b/src/modules/05_command/views/lists.vue index 5c38d9c9..9fd91076 100644 --- a/src/modules/05_command/views/lists.vue +++ b/src/modules/05_command/views/lists.vue @@ -31,7 +31,7 @@ const childTemplateDetailRef = ref | null>( null ); //ref components ข้อความต้นแบบ const childPageOrderRef = ref | null>(null); //ref components คำสั่ง - + // Tabs const tabs = ref([ { @@ -94,6 +94,14 @@ async function fetchCommandType() { const data = res.data.result; listOrder.value = data.commandTypes; maxPage.value = Math.ceil(data.total / pageSize.value); + + if (activeCommandId.value) { + listOrder.value.find((e: ListOrder) => { + if (e.id === activeCommandId.value) { + selectInbox(e); + } + }); + } }) .catch((err) => { messageError($q, err); @@ -147,7 +155,7 @@ function onDialogEdit(data: ListOrder) { name.value = data.name; status.value = data.isActive; category.value = data.commandSysId; - subtitle.value = data.subtitle ? data.subtitle :''; + subtitle.value = data.subtitle ? data.subtitle : ""; isEdit.value = true; isAttachment.value = data.isAttachment; dialogFormCommand.value = true; @@ -160,7 +168,7 @@ function closeDialog() { commandId.value = ""; isEdit.value = false; dialogFormCommand.value = false; - subtitle.value = '' + subtitle.value = ""; name.value = ""; status.value = false; category.value = ""; @@ -198,6 +206,10 @@ function onSubmit() { * เก็บ id list คำสั่งที่เลือก เพื่อใช้ class */ function selectInbox(data: ListOrder) { + store.currentTab = + !data.isAttachment && store.currentTab == "attachment" + ? "cover" + : store.currentTab; isAttachmentShow.value = data.isAttachment; activeCommandId.value = data.id; fetchDataCommandTypeId(data.id); @@ -214,9 +226,7 @@ async function fetchDataCommandTypeId(id: string) { .then(async (res) => { const data = res.data.result; dataTemplateDetail.value = data; - await Promise.all([ - childTemplateDetailRef?.value?.fetchData(data), - ]); + await Promise.all([childTemplateDetailRef?.value?.fetchData(data)]); }) .catch((err) => { messageError($q, err);