diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index f9a7faf4b..6e76818e3 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -12,5 +12,6 @@ export default { orgSetDateTime:(id:string) => `${organization}/set/publish/${id}`, organizationHistoryNew: `${organization}/history`, + organizationHistoryPostNew: `${organization}/history/publish`, organizationShortName: `${organization}/sort`, }; diff --git a/src/modules/02_organizationalNew/components/DialogHistory.vue b/src/modules/02_organizationalNew/components/DialogHistory.vue index 51e7e8f12..3fd4484ad 100644 --- a/src/modules/02_organizationalNew/components/DialogHistory.vue +++ b/src/modules/02_organizationalNew/components/DialogHistory.vue @@ -3,7 +3,7 @@ import { ref, reactive, watch } from "vue"; import { useQuasar } from "quasar"; import { useCounterMixin } from "@/stores/mixin"; import type { QTableProps } from "quasar"; -import type { HistoryType } from "@/modules/02_organizationalNew/interface/index/Main"; +import type { HistoryPostType } from "@/modules/02_organizationalNew/interface/index/Main"; import DialogHeader from "@/components/DialogHeader.vue"; import Modal from "@/modules/05_placement/components/AppointEmployee/Modal.vue"; @@ -12,15 +12,14 @@ import { getDateMeta } from "@fullcalendar/core/internal"; import http from "@/plugins/http"; import config from "@/app.config"; -const props = defineProps({ - modal: Boolean, - close: Function, -}); +const modal = defineModel("history", { required: true }); +const type = defineModel("type", { required: true }); +const orgId = defineModel("orgId", { required: true }); const $q = useQuasar(); const mixin = useCounterMixin(); const { showLoader, hideLoader, messageError, date2Thai } = mixin; -const rows = ref([]); +const rows = ref([]); const columns = ref([ { @@ -41,6 +40,16 @@ const columns = ref([ headerStyle: "font-size: 14px", style: "font-size: 14px", }, + { + name: "name", + align: "left", + label: "", + sortable: true, + field: "name", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { name: "lastUpdatedAt", align: "left", @@ -50,79 +59,55 @@ const columns = ref([ headerStyle: "font-size: 14px", style: "font-size: 14px", }, - { - name: "orgRevisionIsCurrent", - align: "center", - label: "โครงสร้างที่ใช้อยู่", - sortable: false, - field: "orgRevisionIsCurrent", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "orgRevisionIsDraft", - align: "center", - label: "โครงสร้างแบบร่าง", - sortable: false, - field: "orgRevisionIsDraft", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "orgRevisionCreatedAt", - align: "left", - label: "วันเริ่มใช้โครงสร้าง", - sortable: true, - field: "orgRevisionCreatedAt", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, ]); const visibleColumns = ref([ "no", + "name", "orgRevisionName", - "orgRevisionIsCurrent", - "orgRevisionIsDraft", - "orgRevisionCreatedAt", + "lastUpdatedAt", ]); -function getDate() { - showLoader() +function postData() { + showLoader(); http - .get(config.API.organizationHistoryNew) - .then((res)=>{ - const dataList = res.data.result - dataList.map((item:HistoryType)=>( - { - orgRevisionId:item.orgRevisionId ? item.orgRevisionId:'-', - orgRevisionName:item.orgRevisionName ? item.orgRevisionName:'-', - orgRevisionIsCurrent:item.orgRevisionIsCurrent ? item.orgRevisionIsCurrent:'-', - orgRevisionIsDraft:item.orgRevisionIsDraft ? item.orgRevisionIsDraft:'-', - orgRevisionCreatedAt:item.orgRevisionCreatedAt ? date2Thai(item.orgRevisionCreatedAt as Date):'-', - } - )) - rows.value = dataList - }).catch((e)=>{ - messageError($q,e) - }) - .finally(()=>{ - hideLoader() - }) + .post(config.API.organizationHistoryPostNew, { + id: orgId.value, + type: type.value, + }) + .then((res) => { + const dataList = res.data.result; + dataList.map((item: HistoryPostType) => ({ + id: item.id ? item.id : "-", + name: item.name ? item.name : "-", + lastUpdatedAt: item.lastUpdatedAt ? date2Thai(item.lastUpdatedAt,false,true) : "-", + orgRevisionName: item.orgRevisionName ? item.orgRevisionName : "-", + })); + rows.value = dataList; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); } watch( - () => props.modal, + () => modal.value, () => { - if (props.modal == true) { - getDate(); + if (modal.value == true) { + postData(); } } );