2024-01-25 15:59:08 +07:00
|
|
|
<script setup lang="ts">
|
2024-07-25 11:06:43 +07:00
|
|
|
import { ref, watch } from "vue";
|
2024-01-25 15:59:08 +07:00
|
|
|
import { useQuasar } from "quasar";
|
2024-07-25 11:06:43 +07:00
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* importType
|
|
|
|
|
*/
|
2024-01-25 15:59:08 +07:00
|
|
|
import type { QTableProps } from "quasar";
|
2024-08-01 12:12:28 +07:00
|
|
|
import type { HistoryPostType } from "@/modules/02_organization/interface/index/Main";
|
2024-01-26 15:20:32 +07:00
|
|
|
|
2024-07-25 11:06:43 +07:00
|
|
|
/**
|
|
|
|
|
* importComponrnts
|
|
|
|
|
*/
|
2024-01-25 15:59:08 +07:00
|
|
|
import DialogHeader from "@/components/DialogHeader.vue";
|
2024-01-26 15:20:32 +07:00
|
|
|
|
2024-07-25 11:06:43 +07:00
|
|
|
/**
|
|
|
|
|
* importStore
|
|
|
|
|
*/
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* use
|
|
|
|
|
*/
|
|
|
|
|
const $q = useQuasar();
|
|
|
|
|
const mixin = useCounterMixin();
|
|
|
|
|
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
|
2024-01-25 15:59:08 +07:00
|
|
|
|
2024-07-25 11:06:43 +07:00
|
|
|
/**
|
|
|
|
|
* props
|
|
|
|
|
*/
|
2024-01-31 17:27:12 +07:00
|
|
|
const modal = defineModel<boolean>("history", { required: true });
|
|
|
|
|
const type = defineModel<number>("type", { required: true });
|
|
|
|
|
const orgId = defineModel<string>("orgId", { required: true });
|
2024-01-25 15:59:08 +07:00
|
|
|
|
2024-07-25 11:06:43 +07:00
|
|
|
/**
|
|
|
|
|
* ข้อมุล Table
|
|
|
|
|
*/
|
2024-01-31 17:27:12 +07:00
|
|
|
const rows = ref<HistoryPostType[]>([]);
|
2024-01-25 15:59:08 +07:00
|
|
|
const columns = ref<QTableProps["columns"]>([
|
2024-01-26 15:20:32 +07:00
|
|
|
{
|
|
|
|
|
name: "no",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ลำดับ",
|
|
|
|
|
sortable: false,
|
|
|
|
|
field: "no",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "orgRevisionName",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ชื่อโครงสร้าง",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "orgRevisionName",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-01-31 17:27:12 +07:00
|
|
|
name: "name",
|
2024-01-26 15:20:32 +07:00
|
|
|
align: "left",
|
2024-01-31 17:27:12 +07:00
|
|
|
label: "",
|
2024-01-26 15:20:32 +07:00
|
|
|
sortable: true,
|
2024-01-31 17:27:12 +07:00
|
|
|
field: "name",
|
2024-01-26 15:20:32 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
2024-01-31 17:27:12 +07:00
|
|
|
|
2024-01-26 15:20:32 +07:00
|
|
|
{
|
2024-01-31 17:27:12 +07:00
|
|
|
name: "lastUpdatedAt",
|
2024-01-26 15:20:32 +07:00
|
|
|
align: "left",
|
2024-01-31 17:27:12 +07:00
|
|
|
label: "วันที่แก้ไข",
|
2024-01-26 15:20:32 +07:00
|
|
|
sortable: true,
|
2024-01-31 17:27:12 +07:00
|
|
|
field: "lastUpdatedAt",
|
2024-01-26 15:20:32 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
const visibleColumns = ref<string[]>([
|
|
|
|
|
"no",
|
2024-01-31 17:27:12 +07:00
|
|
|
"name",
|
2024-01-26 15:20:32 +07:00
|
|
|
"orgRevisionName",
|
2024-01-31 17:27:12 +07:00
|
|
|
"lastUpdatedAt",
|
2024-01-26 15:20:32 +07:00
|
|
|
]);
|
|
|
|
|
|
2024-07-25 11:06:43 +07:00
|
|
|
/**
|
|
|
|
|
* function เรียกข้อมูล ประวัติหน่วยงาน,ประวัติส่วนราชการ
|
|
|
|
|
*/
|
2024-01-31 17:27:12 +07:00
|
|
|
function postData() {
|
|
|
|
|
showLoader();
|
2024-01-26 17:20:57 +07:00
|
|
|
http
|
2024-01-31 17:27:12 +07:00
|
|
|
.post(config.API.organizationHistoryPostNew, {
|
|
|
|
|
id: orgId.value,
|
|
|
|
|
type: type.value,
|
|
|
|
|
})
|
|
|
|
|
.then((res) => {
|
|
|
|
|
const dataList = res.data.result;
|
2024-01-31 17:54:34 +07:00
|
|
|
const dataMap = dataList.map((item: HistoryPostType) => ({
|
2024-01-31 17:27:12 +07:00
|
|
|
id: item.id ? item.id : "-",
|
|
|
|
|
name: item.name ? item.name : "-",
|
2024-07-25 11:06:43 +07:00
|
|
|
lastUpdatedAt: item.lastUpdatedAt
|
|
|
|
|
? date2Thai(item.lastUpdatedAt as Date, false, true)
|
|
|
|
|
: "-",
|
2024-01-31 17:27:12 +07:00
|
|
|
orgRevisionName: item.orgRevisionName ? item.orgRevisionName : "-",
|
|
|
|
|
}));
|
2024-01-31 17:54:34 +07:00
|
|
|
rows.value = dataMap;
|
2024-01-31 17:27:12 +07:00
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
messageError($q, e);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2024-01-26 15:20:32 +07:00
|
|
|
}
|
2024-07-25 11:06:43 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* callback function เมื่อ modal = true เรียกข้อมูล ประวัติหน่วยงาน,ประวัติส่วนราชการ
|
|
|
|
|
*/
|
2024-01-26 15:20:32 +07:00
|
|
|
watch(
|
2024-01-31 17:27:12 +07:00
|
|
|
() => modal.value,
|
2024-01-26 15:20:32 +07:00
|
|
|
() => {
|
2024-01-31 17:27:12 +07:00
|
|
|
if (modal.value == true) {
|
|
|
|
|
postData();
|
2024-01-26 15:20:32 +07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-01-25 15:59:08 +07:00
|
|
|
</script>
|
|
|
|
|
<template>
|
|
|
|
|
<template>
|
2024-01-31 17:27:12 +07:00
|
|
|
<q-dialog v-model="modal" persistent>
|
2024-01-25 15:59:08 +07:00
|
|
|
<q-card style="min-width: 40vw">
|
2024-01-31 17:27:12 +07:00
|
|
|
<DialogHeader
|
2024-01-31 17:54:34 +07:00
|
|
|
:tittle="type == 0 ? `ประวัติหน่วยงาน` : `ประวัติส่วนราชการ`"
|
2024-01-31 17:27:12 +07:00
|
|
|
:close="() => (modal = false)"
|
|
|
|
|
/>
|
2024-01-26 15:20:32 +07:00
|
|
|
<q-separator />
|
|
|
|
|
|
|
|
|
|
<q-card-section>
|
|
|
|
|
<div class="row q-col-gutter-sm">
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<d-table
|
|
|
|
|
ref="table"
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:rows="rows"
|
2024-01-26 15:29:48 +07:00
|
|
|
row-key="orgRevisionId"
|
2024-01-26 15:20:32 +07:00
|
|
|
flat
|
|
|
|
|
bordered
|
|
|
|
|
:paging="true"
|
|
|
|
|
dense
|
|
|
|
|
class="custom-header-table"
|
|
|
|
|
:visible-columns="visibleColumns"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:header="props">
|
|
|
|
|
<q-tr :props="props">
|
|
|
|
|
<q-th
|
|
|
|
|
v-for="col in props.cols"
|
|
|
|
|
:key="col.name"
|
|
|
|
|
:props="props"
|
|
|
|
|
style="color: #000000; font-weight: 500"
|
|
|
|
|
>
|
2024-01-31 17:27:12 +07:00
|
|
|
<span
|
|
|
|
|
v-if="col.name === 'name'"
|
|
|
|
|
class="text-weight-medium"
|
|
|
|
|
>
|
2024-01-31 17:54:34 +07:00
|
|
|
{{ type === 0 ? "ชื่อหน่วยงาน" : "ส่วนราชการ" }}
|
2024-01-31 17:27:12 +07:00
|
|
|
</span>
|
|
|
|
|
|
2024-01-26 15:20:32 +07:00
|
|
|
<span class="text-weight-medium">{{ col.label }}</span>
|
|
|
|
|
</q-th>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:body="props">
|
|
|
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
|
|
|
<q-td
|
|
|
|
|
v-for="col in props.cols"
|
|
|
|
|
:key="col.name"
|
|
|
|
|
:props="props"
|
|
|
|
|
>
|
|
|
|
|
<div v-if="col.name == 'no'">
|
|
|
|
|
{{ props.rowIndex + 1 }}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-else-if="col.name == 'orgRevisionIsCurrent'">
|
|
|
|
|
<q-icon
|
2024-01-31 17:27:12 +07:00
|
|
|
:name="
|
|
|
|
|
props.row.orgRevisionIsCurrent == true
|
|
|
|
|
? 'mdi-check'
|
|
|
|
|
: ''
|
|
|
|
|
"
|
|
|
|
|
:color="
|
|
|
|
|
props.row.orgRevisionIsCurrent == true
|
|
|
|
|
? 'positive'
|
|
|
|
|
: ''
|
|
|
|
|
"
|
2024-01-26 15:20:32 +07:00
|
|
|
class="text-h5"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else-if="col.name == 'orgRevisionIsDraft'">
|
|
|
|
|
<q-icon
|
2024-01-31 17:27:12 +07:00
|
|
|
:name="
|
|
|
|
|
props.row.orgRevisionIsDraft == true
|
|
|
|
|
? 'mdi-check'
|
|
|
|
|
: ''
|
|
|
|
|
"
|
|
|
|
|
:color="
|
|
|
|
|
props.row.orgRevisionIsDraft == true
|
|
|
|
|
? 'positive'
|
|
|
|
|
: ''
|
|
|
|
|
"
|
2024-01-26 15:20:32 +07:00
|
|
|
class="text-h5"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-01-25 15:59:08 +07:00
|
|
|
|
2024-01-26 15:20:32 +07:00
|
|
|
<div v-else>
|
|
|
|
|
{{ col.value }}
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
</d-table>
|
2024-01-25 15:59:08 +07:00
|
|
|
</div>
|
2024-01-26 15:20:32 +07:00
|
|
|
</div>
|
|
|
|
|
</q-card-section>
|
2024-01-25 15:59:08 +07:00
|
|
|
</q-card>
|
|
|
|
|
</q-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|