remove old sys

This commit is contained in:
Warunee Tamkoo 2024-11-21 13:56:50 +07:00
parent 00db6b6619
commit 1f76194664
254 changed files with 88 additions and 98844 deletions

View file

@ -41,7 +41,7 @@ async function fetchDataProfile(data: DataProfile) {
fetchCheckAvatar(data.profileId);
}
profile.id = data.profileId;
profile.fullName = `${data.rank ? data.rank : data.prefix ?? ""}${data.firstName ?? ""} ${
profile.fullName = `${data.prefix ?? ""}${data.firstName ?? ""} ${
data.lastName ?? ""
} `;

View file

@ -1,980 +0,0 @@
<!-- card ผลการประเมนการปฏราชการ -->
<template>
<q-card flat bordered class="col-12 q-px-lg q-pa-md">
<q-form ref="myForm">
<ProfileTable
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
:add="clickAdd"
name="ผลการประเมินการปฏิบัติราชการ"
icon="mdi-clipboard-text"
:statusEdit="statusEdit"
>
<template #columns="props">
<q-tr :props="props">
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
@click="selectData(props)"
class="cursor-pointer"
>
<div v-if="col.name == 'date'" class="table_ellipsis">
{{ date2Thai(col.value) }}
</div>
<div v-else-if="col.name == 'name'" class="table_ellipsis">
{{ textPoint(props.row.pointSum) }}
{{ textRangePoint(props.row.pointSum) }}
</div>
<div v-else class="table_ellipsis">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</ProfileTable>
</q-form>
</q-card>
<!-- popup Edit window-->
<q-dialog v-model="modal" persistent>
<q-card style="width: 600px">
<q-form ref="myForm">
<DialogHeader
tittle="ผลการประเมินการปฏิบัติราชการ"
:close="clickClose"
/>
<q-separator />
<q-card-section class="q-p-sm">
<div
class="row col-12 items-center q-col-gutter-x-xs q-col-gutter-y-xs"
>
<div class="col-xs-12 col-sm-12 col-md-12">
<datepicker
menu-class-name="modalfix"
:readonly="!edit"
v-model="date"
:locale="'th'"
autoApply
:enableTimePicker="false"
@update:modelValue="clickEditRow"
week-start="0"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
:borderless="!edit"
:model-value="date2Thai(date)"
:rules="[(val:string) => !!val || `${'กรุณาเลือกวันที่ได้รับ'}`]"
hide-bottom-space
:label="`${'วันที่ได้รับ'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
:style="
edit
? 'color: var(--q-primary)'
: 'color: var(--q-grey)'
"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<!-- <div class="col-6">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="point"
:rules="[(val:string) => !!val || `${'กรุณากรอกคะแนน'}`]"
hide-bottom-space
:label="`${'คะแนน'}`"
@update:modelValue="clickEditRow"
type="number"
/>
</div> -->
<div class="col-6">
<q-input
input-class="text-right"
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="point1Total"
:rules="[(val:string) => !!val || `${'กรุณากรอกส่วนที่1 (คะแนน)'}`]"
hide-bottom-space
:label="`${'ส่วนที่1 (คะแนน)'}`"
@update:modelValue="clickEditRow"
type="number"
/>
</div>
<div class="col-6">
<q-input
input-class="text-right"
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="point1"
:rules="[
(val:string) => !!val || `${'กรุณากรอกผลประเมินส่วนที่1 (คะแนน)'}`,
]"
hide-bottom-space
:label="`${'ผลประเมินส่วนที่1 (คะแนน)'}`"
@update:modelValue="clickEditRow"
type="number"
/>
</div>
<div class="col-6">
<q-input
input-class="text-right"
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="point2Total"
:rules="[(val:string) => !!val || `${'กรุณากรอกส่วนที่2 (คะแนน)'}`]"
hide-bottom-space
:label="`${'ส่วนที่2 (คะแนน)'}`"
@update:modelValue="clickEditRow"
type="number"
/>
</div>
<div class="col-6">
<q-input
input-class="text-right"
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="point2"
:rules="[
(val:string) => !!val || `${'กรุณากรอกผลประเมินส่วนที่2 (คะแนน)'}`,
]"
hide-bottom-space
:label="`${'ผลประเมินส่วนที่2 (คะแนน)'}`"
@update:modelValue="clickEditRow"
type="number"
/>
</div>
<div class="col-6">
<q-input
input-class="text-right"
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="pointSumTotal"
:rules="[(val:string) => !!val || `${'กรุณากรอกผลรวม (คะแนน)'}`]"
hide-bottom-space
:label="`${'ผลรวม (คะแนน)'}`"
@update:modelValue="clickEditRow"
type="number"
/>
</div>
<div class="col-6">
<q-input
input-class="text-right"
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="pointSum"
:rules="[
(val:string) => !!val || `${'กรุณากรอกผลประเมินรวม (คะแนน)'}`,
]"
hide-bottom-space
:label="`${'ผลประเมินรวม (คะแนน)'}`"
@update:modelValue="clickEditRow"
type="number"
/>
</div>
<div class="text-subtitle2 col-12 row items-center">
<q-space></q-space>
ผลการประเม:
<div class="text-bold items-center q-px-sm">
{{ textPoint(pointSum) }}
</div>
{{ textRangePoint(pointSum) }}
</div>
<!-- <div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="name"
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อแบบประเมิน'}`]"
hide-bottom-space
:label="`${'ชื่อแบบประเมิน'}`"
@update:modelValue="clickEditRow"
/>
</div> -->
</div>
</q-card-section>
<q-separator />
<DialogFooter
:cancel="clickCancel"
:edit="clickEdit"
:save="clickSave"
:validate="validateData"
:clickNext="clickNext"
:clickPrevious="clickPrevious"
:clickDelete="clickDelete"
v-model:editvisible="edit"
v-model:next="next"
v-model:previous="previous"
v-model:modalEdit="modalEdit"
/>
</q-form>
</q-card>
</q-dialog>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div
v-if="col.name == 'date' || col.name == 'createdAt'"
class="table_ellipsis"
>
{{ date2Thai(col.value) }}
</div>
<div v-else-if="col.name == 'name'" class="table_ellipsis">
{{ textPoint(props.row.pointSum) }}
{{ textRangePoint(props.row.pointSum) }}
</div>
<div v-else class="table_ellipsis">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import { onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useProfileDataStore } from "@/modules/04_registry/store";
import ProfileTable from "@/modules/04_registry/components/Table.vue";
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
import DialogFooter from "@/modules/04_registry/components/DialogFooter.vue";
import { useQuasar } from "quasar";
import type {
RequestItemsObject,
DataProps,
} from "@/modules/04_registry/interface/request/Assessment";
import type { ResponseObject } from "@/modules/04_registry/interface/response/Assessment";
import type { DataOption } from "@/modules/04_registry/interface/index/Main";
import HistoryTable from "@/components/TableHistory.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
const props = defineProps({
statusEdit: {
type: Boolean,
required: true,
},
profileType: {
type: String,
required: true,
},
});
const $q = useQuasar();
const store = useProfileDataStore();
const { profileData, changeProfileColumns } = store;
const mixin = useCounterMixin();
const { date2Thai, success, dateToISO, messageError, showLoader, hideLoader } =
mixin;
const route = useRoute();
const id = ref<string>("");
const name = ref<string>();
const point1Total = ref<number>();
const point1 = ref<number>();
const point2Total = ref<number>();
const point2 = ref<number>();
const pointSumTotal = ref<number>();
const pointSum = ref<number>();
const date = ref<Date>(new Date());
const myForm = ref<any>(); //form data input
const edit = ref<boolean>(false); // dialog
const modal = ref<boolean>(false); //modal add detail
const modalEdit = ref<boolean>(false); //modal
const rawItem = ref<RequestItemsObject>(); // row
const rowIndex = ref<number>(0); //index row
const previous = ref<boolean>(); //
const next = ref<boolean>(); //
const editRow = ref<boolean>(false); //
const rowsHistory = ref<RequestItemsObject[]>([]); //select data history
const tittleHistory = ref<string>("ประวัติแก้ไขผลการประเมินการปฏิบัติราชการ"); //
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const checkValidate = ref<boolean>(false); //validate data
const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const rows = ref<RequestItemsObject[]>([]);
const filter = ref<string>(""); //search data table
const visibleColumns = ref<String[]>([]);
profileData.assessment.columns.length == 0
? (visibleColumns.value = [
"point1Total",
"point1",
"point2Total",
"point2",
"pointSumTotal",
"pointSum",
"name",
"date",
])
: (visibleColumns.value = profileData.assessment.columns);
const columns = ref<QTableProps["columns"]>([
{
name: "date",
align: "left",
label: "วันที่ได้รับ",
sortable: true,
field: "date",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "point1Total",
align: "left",
label: "ส่วนที่1 (คะแนน)",
sortable: true,
field: "point1Total",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "point1",
align: "left",
label: "ผลประเมินส่วนที่1 (คะแนน)",
sortable: true,
field: "point1",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "point2Total",
align: "left",
label: "ส่วนที่2 (คะแนน)",
sortable: true,
field: "point2Total",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "point2",
align: "left",
label: "ผลประเมินส่วนที่2 (คะแนน)",
sortable: true,
field: "point2",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "pointSumTotal",
align: "left",
label: "ผลรวม (คะแนน)",
sortable: true,
field: "pointSumTotal",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "pointSum",
align: "left",
label: "ผลประเมินรวม (คะแนน)",
sortable: true,
field: "pointSum",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "name",
align: "left",
label: "ผลประเมิน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "point1Total",
align: "left",
label: "ส่วนที่1 (คะแนน)",
sortable: true,
field: "point1Total",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "point1",
align: "left",
label: "ผลประเมินส่วนที่1 (คะแนน)",
sortable: true,
field: "point1",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "point2Total",
align: "left",
label: "ส่วนที่2 (คะแนน)",
sortable: true,
field: "point2Total",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "point2",
align: "left",
label: "ผลประเมินส่วนที่2 (คะแนน)",
sortable: true,
field: "point2",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "pointSumTotal",
align: "left",
label: "ผลรวม (คะแนน)",
sortable: true,
field: "pointSumTotal",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "pointSum",
align: "left",
label: "ผลประเมินรวม (คะแนน)",
sortable: true,
field: "pointSum",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "name",
align: "left",
label: "ผลประเมิน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "createdFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "left",
label: "วันที่แก้ไข",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"point1Total",
"point1",
"point2Total",
"point2",
"pointSumTotal",
"pointSum",
"name",
"date",
"createdFullName",
"createdAt",
]);
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeProfileColumns("assessment", count);
});
onMounted(async () => {
await fetchData();
});
const fetchData = async () => {
if (profileId.value) {
showLoader();
await http
.get(config.API.profileAssessmentId(profileId.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: ResponseObject) => {
rows.value.push({
id: e.id,
name: e.name,
point1Total: e.point1Total,
point1: e.point1,
point2Total: e.point2Total,
point2: e.point2,
pointSumTotal: e.pointSumTotal,
pointSum: e.pointSum,
date: new Date(e.date),
createdAt: new Date(e.createdAt),
createdFullName: e.createdFullName,
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
};
/**
* กดดอมลกอนหน
*/
const clickPrevious = async () => {
edit.value = false;
rowIndex.value -= 1;
await getData();
await checkRowPage();
};
/**
* กดดอมลตอไป
*/
const clickNext = async () => {
edit.value = false;
rowIndex.value += 1;
await getData();
await checkRowPage();
};
/**
* กดดอมลตอไป
*/
const getData = () => {
const row = rows.value[rowIndex.value];
name.value = row.name;
point1Total.value = row.point1Total;
point1.value = row.point1;
point2Total.value = row.point2Total;
point2.value = row.point2;
pointSumTotal.value = row.pointSumTotal;
pointSum.value = row.pointSum;
date.value = row.date;
id.value = row.id;
};
/**
* เชคปมดอม อน อไป าตองแสดงไหม
*/
const checkRowPage = () => {
editRow.value = false;
next.value = true;
previous.value = true;
if (rowIndex.value + 1 >= rows.value.length) {
next.value = false;
}
if (rowIndex.value - 1 < 0) {
previous.value = false;
}
};
/**
* กดปมแกไขใน dialog
*/
const clickEdit = () => {
editRow.value = false;
next.value = false;
previous.value = false;
};
/**
* กดปมเพมดานบน table
*/
const clickAdd = async () => {
editRow.value = false;
await addData();
};
/**
* กดบนทกใน dialog
*/
const clickSave = async () => {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
if (modalEdit.value) {
await editData();
} else {
await saveData();
}
}
});
};
/**
* นทกเพมขอม
*/
const saveData = async () => {
if (profileId.value) {
showLoader();
await http
.post(config.API.profileAssessmentId(profileId.value), {
id: id.value,
name: name.value,
point1Total: point1Total.value,
point1: point1.value,
point2Total: point2Total.value,
point2: point2.value,
pointSumTotal: pointSumTotal.value,
pointSum: pointSum.value,
date: dateToISO(date.value),
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
}
};
/**
* นทกแกไขขอม
*/
const editData = async () => {
showLoader();
await http
.put(config.API.profileAssessmentId(id.value), {
id: id.value,
name: name.value,
point1Total: point1Total.value,
point1: point1.value,
point2Total: point2Total.value,
point2: point2.value,
pointSumTotal: pointSumTotal.value,
pointSum: pointSum.value,
date: dateToISO(date.value),
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* ลบลบขอม
*/
const clickDelete = async () => {
$q.dialog({
title: `ลบข้อมูล`,
message: `ต้องการทำการลบข้อมูลนี้ใช่หรือไม่?`,
cancel: "ยกเลิก",
ok: "ยืนยัน",
persistent: true,
})
.onOk(async () => {
showLoader();
await http
.delete(config.API.profileAssessmentId(id.value))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
})
.onCancel(async () => {
await fetchData();
});
};
/**
* กดป dialog
*/
const clickClose = async () => {
if (editRow.value == true) {
$q.dialog({
title: `ข้อมูลมีการแก้ไข`,
message: `ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?`,
cancel: "ยกเลิก",
ok: "ยืนยัน",
persistent: true,
}).onOk(async () => {
modal.value = false;
next.value = false;
previous.value = false;
});
} else {
modal.value = false;
next.value = false;
previous.value = false;
}
};
/**
* กดเลอกขอมลทจะแกไข
* @param props props ใน row เลอก
*/
const selectData = async (props: DataProps) => {
modalEdit.value = true;
modal.value = true;
edit.value = false;
rawItem.value = props.row;
rowIndex.value = props.rowIndex;
name.value = props.row.name;
point1Total.value = props.row.point1Total;
point1.value = props.row.point1;
point2Total.value = props.row.point2Total;
point2.value = props.row.point2;
pointSumTotal.value = props.row.pointSumTotal;
pointSum.value = props.row.pointSum;
date.value = props.row.date;
id.value = props.row.id;
await checkRowPage();
};
/**
* กดปมเพมบน table
*/
const addData = () => {
modalEdit.value = false;
modal.value = true;
edit.value = true;
name.value = "";
point1Total.value = 0;
point1.value = 0;
point2Total.value = 0;
point2.value = 0;
pointSumTotal.value = 0;
pointSum.value = 0;
date.value = new Date();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
if (editRow.value == true) {
$q.dialog({
title: `ข้อมูลมีการแก้ไข`,
message: `ยืนยันยกเลิกการแก้ไขใช่หรือไม่?`,
cancel: "ยกเลิก",
ok: "ยืนยัน",
persistent: true,
}).onOk(async () => {
edit.value = false;
await checkRowPage();
await getData();
});
} else {
edit.value = false;
await checkRowPage();
}
};
/**
* เชความการแกไขขอม
*/
const clickEditRow = () => {
editRow.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsObject) => {
tittleHistory.value = "ประวัติแก้ไขผลการประเมินการปฏิบัติราชการ";
modalHistory.value = true;
showLoader();
await http
.get(config.API.profileAssessmentHisId(row.id))
.then((res) => {
let data = res.data.result;
rowsHistory.value = [];
data.map((e: ResponseObject) => {
rowsHistory.value.push({
id: e.id,
name: e.name,
point1Total: e.point1Total,
point1: e.point1,
point2Total: e.point2Total,
point2: e.point2,
pointSumTotal: e.pointSumTotal,
pointSum: e.pointSum,
date: new Date(e.date),
createdAt: new Date(e.createdAt),
createdFullName: e.createdFullName,
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* validate input ใน dialog
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
/**
* class ดรปแบบแสดงระหวางขอมลทแกไขหรอแสดงเฉยๆ
* @param val อม input สำหรบแกไขหรอไม
*/
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
const textRangePoint = (val: number | undefined) => {
if (val == undefined) val = -1;
if (val >= 0 && val <= 60) return "(ต่ำกว่าร้อยละ 60)";
if (val >= 60 && val <= 69) return "(ร้อยละ 60 69)";
if (val >= 70 && val <= 79) return "(ร้อยละ 70 79)";
if (val >= 80 && val <= 89) return "(ร้อยละ 80 89)";
if (val >= 90 && val <= 100) return "(ร้อยละ 90 - 100)";
else return "";
};
const textPoint = (val: number | undefined) => {
if (val == undefined) val = -1;
if (val >= 0 && val <= 60) return "ต้องปรับปรุง";
if (val >= 60 && val <= 69) return "พอใช้";
if (val >= 70 && val <= 79) return "ดี";
if (val >= 80 && val <= 89) return "ดีมาก";
if (val >= 90 && val <= 100) return "ดีเด่น";
else return "-";
};
</script>
<style lang="scss">
.modalfix {
position: fixed !important;
}
</style>

View file

@ -1,854 +0,0 @@
<!-- tab ปฏ หนาปฏนวนหย -->
<template>
<div class="q-mt-md">
<div class="row q-gutter-sm q-pb-sm main-content">
<div class="demo-app-main">
<!-- แสดงปฏ -->
<FullCalendar
ref="fullCalendar"
class="demo-app-calendar"
:options="calendarOptions"
>
<template v-slot:eventContent="arg">
<b>{{ arg.timeText }}</b>
<i>{{ arg.event.title }}</i>
<q-tooltip style="font-size: 15px">{{ arg.event.title }}</q-tooltip>
</template>
</FullCalendar>
</div>
</div>
<div class="row q-col-gutter-md">
<div class="items-center row">
<q-icon color="blue" name="mdi-circle" class="q-mr-sm" />
นทำงาน 5
</div>
<div class="items-center row">
<q-icon color="orange" name="mdi-circle" class="q-mr-sm" />
นทำงาน 6
</div>
</div>
</div>
<!-- modal เพมวนหย -->
<q-dialog v-model="modalAdd" persistent>
<q-card style="min-width: 550px">
<q-form ref="formDate" @submit.prevent.stop="onSubmit">
<q-card-section class="row items-center q-pa-sm">
<div class="text-bold" v-if="showEdit">แก้ไขวันหยุด</div>
<div class="text-bold" v-else>เพิ่มวันหยุด</div>
<q-space />
<q-btn
icon="close"
unelevated
round
dense
v-close-popup
style="color: #ff8080; background-color: #ffdede"
/>
</q-card-section>
<q-separator />
<q-card-section class="q-p-md row q-gutter-y-md">
<div class="row col-12">
<div class="col-12" v-if="!showEdit">
{{ dateThaiRange(dateRange) }}
</div>
<datepicker
v-else
:readonly="!edit"
v-model="dateRange"
:locale="'th'"
autoApply
range
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
dense
label="วันที่"
:borderless="!edit"
:model-value="dateThaiRange(dateRange)"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<q-input
:class="getClass(edit)"
hide-bottom-space
:outlined="edit"
label="คำอธิบาย"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="name"
autogrow
:rules="[(val:string) => (val && val.length > 0) || '']"
/>
<q-option-group
v-if="showEdit == false"
v-model="category"
:options="categoryOptions"
color="primary"
inline
/>
</q-card-section>
<q-separator />
<q-card-actions align="right" class="text-primary">
<q-btn
v-if="showEdit && edit"
flat
color="red"
@click="cancelClick()"
label="ยกเลิกแก้ไข"
>
<!-- icon="mdi-undo"
<q-tooltip>ยกเล</q-tooltip> -->
</q-btn>
<q-btn
v-if="showEdit && edit"
unelevated
color="red"
@click="deleteClick()"
label="ลบวันหยุด"
>
<!-- icon="mdi-delete"
<q-tooltip>ลบ</q-tooltip> -->
</q-btn>
<q-btn
v-if="edit"
unelevated
color="public"
label="บันทึก"
type="submit"
>
<!-- icon="mdi-content-save-outline"
<q-tooltip>นท</q-tooltip> -->
</q-btn>
<q-btn
v-if="!edit"
outline
color="primary"
@click="editClick"
label="แก้ไขข้อมูล"
>
<!-- icon="mdi-pencil-outline"
<q-tooltip>แกไขขอม</q-tooltip> -->
</q-btn>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
<!-- modal ลบวนหย -->
<q-dialog v-model="modalDelete" persistent>
<q-card style="min-width: 550px">
<q-card-section class="row items-center q-pb-xs">
<div class="text-bold">องการลบขอมลนหรอไม?</div>
<q-space />
<q-btn
icon="close"
unelevated
round
dense
v-close-popup
style="color: #ff8080; background-color: #ffdede"
/>
</q-card-section>
<q-separator />
<q-card-section class="row items-center">
<div class="q-pr-md">
<q-avatar
icon="mdi-trash-can-outline"
font-size="25px"
size="lg"
color="red-1"
text-color="red"
/>
</div>
<div class="col text-dark">
<span>อมลทกำลงถกลบนจะมผลใชงานทนท</span>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="ยกเลิก" flat color="grey-8" @click="cancelClick" />
<q-btn label="ตกลง" color="primary" @click="deleteData" />
</q-card-actions>
</q-card>
</q-dialog>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { onMounted, ref, watch } from "vue";
import FullCalendar from "@fullcalendar/vue3";
import dayGridPlugin from "@fullcalendar/daygrid";
import timeGridPlugin from "@fullcalendar/timegrid";
import interactionPlugin from "@fullcalendar/interaction";
import allLocales from "@fullcalendar/core/locales-all";
import listPlugin from "@fullcalendar/list";
import http from "@/plugins/http";
import config from "@/app.config";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import type {
RequestItemsObject,
DataDateRowObject,
DataDateAddObject,
} from "@/modules/01_metadata/interface/request/Calendar";
const props = defineProps({
dateYear: {
//filter
type: Number,
default: () => new Date().getFullYear(),
},
dateMonth: {
//filter
type: Number,
default: () => new Date().getMonth(),
},
refreshData: {
// main refresh data
type: Boolean,
required: true,
},
fetchDataSummaryCalendar: {
//
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin(); //
const { success, dateToISO, date2Thai, messageError, showLoader, hideLoader } =
mixin;
const $q = useQuasar(); // noti quasar
const modalAdd = ref<boolean>(false); //modal
const modalDelete = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //modal
const showEdit = ref<boolean>(false); // event
const name = ref<string>(""); //
const type = ref<string>(""); //
const isSpecial = ref<boolean>(true); //
const id = ref<string>(""); //id
const fullCalendar = ref<any>(); //ref calendar
const dateRange = ref<[Date, Date]>([new Date(), new Date()]); //
const formDate = ref<any>(); //ref validate
const category = ref<string>("all");
const categoryOptions = ref<any>([
{
label: "ทั้งหมด",
value: "all",
},
{
label: "ทำงาน 5 วัน",
value: "normal",
},
{
label: "ทำงาน 6 วัน",
value: "6days",
},
]);
const dataHistory = ref<RequestItemsObject[]>([]);
const dataNormalRaw = ref<RequestItemsObject[]>([]);
const dataSixDaysRaw = ref<RequestItemsObject[]>([]);
/**
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/
onMounted(async () => {
hideLoader();
const calen = fullCalendar.value.getApi();
const date = new Date(props.dateYear, props.dateMonth);
calen.gotoDate(date);
await fetchData();
});
/**
* props(นเดอนปเลอก) ตอนอพเดท าฏนใหพเดทใหม
*/
watch(props, async (count, prevCount) => {
const calen = fullCalendar.value.getApi();
const date = new Date(props.dateYear, props.dateMonth);
calen.gotoDate(date);
await fetchData();
});
/**
* เลอกคาปฏนในชองวาง
* @param selectInfo าทเลอกในฏ
*/
const handleDateSelect = async (selectInfo: any) => {
edit.value = true;
category.value = "all";
selectInfo.start;
const checkNormalDate = dataNormalRaw.value.filter(
(r: RequestItemsObject) =>
dateToISO(new Date(r.holidayDate)) == dateToISO(selectInfo.start)
);
const checkSixDaysDate = dataSixDaysRaw.value.filter(
(r: RequestItemsObject) =>
dateToISO(new Date(r.holidayDate)) == dateToISO(selectInfo.start)
);
if (checkNormalDate.length == 0 || checkSixDaysDate.length == 0) {
name.value = "";
isSpecial.value = true;
dateRange.value = [
selectInfo.startStr,
new Date(
new Date(selectInfo.endStr).setDate(
new Date(selectInfo.endStr).getDate() - 1
)
),
];
showEdit.value = false;
modalAdd.value = true;
}
};
/**
* เลอกค event ในปฏ
* @param selectInfo าทเลอกในฏ
*/
const handleEventClick = async (selectInfo: any) => {
modalAdd.value = true;
edit.value = false;
showEdit.value = true;
name.value = selectInfo.event.title;
type.value = selectInfo.event.id;
isSpecial.value = true;
id.value = selectInfo.event.groupId;
dataHistory.value = selectInfo.event.extendedProps.dataRangeRow;
dateRange.value = [
selectInfo.event.startStr,
selectInfo.event.endStr == ""
? selectInfo.event.startStr
: dateToISO(
new Date(
new Date(selectInfo.event.endStr).setDate(
new Date(selectInfo.event.endStr).getDate() - 1
)
)
),
];
};
/**
* กดปมแกไขใหแสดง modal แกไข
*/
const editClick = async () => {
showEdit.value = true;
edit.value = true;
};
/**
* กดปมลบใหแสดง modal ลบ
*/
const deleteClick = async () => {
modalDelete.value = true;
};
/**
* มยกเลกใหอนกลบไป modal เลอกแกไขหรอลบ
*/
const cancelClick = async () => {
modalDelete.value = false;
modalAdd.value = true;
edit.value = false;
};
/**
* option calendar
*/
const calendarOptions = ref<any>({
plugins: [
dayGridPlugin,
timeGridPlugin,
interactionPlugin, // needed for dateClick
listPlugin,
],
headerToolbar: null,
selectable: true,
select: handleDateSelect,
eventClick: handleEventClick,
locale: "th",
locales: allLocales,
height: "100%",
eventColor: "#e4f3ff",
eventTextColor: "#50a5fc",
eventBorderColor: "#50a5fc",
events: <any>[],
firstDay: 0,
});
/**
* มบนทกขอมลวนหย
*/
const onSubmit = async () => {
if (showEdit.value === true) {
await editData();
} else {
await addDate();
}
};
/**
* fetch นหยดในปฏ
*/
const fetchData = async () => {
calendarOptions.value.events = [];
showLoader();
await http
.get(
config.API.listHolidayHistoryYearMonth(
props.dateYear,
props.dateMonth + 1
)
)
.then((res) => {
const dataNormal = res.data.result.normal;
const dataSixDays = res.data.result.sixDays;
const dateStart = ref<Date | null>();
const firstEvent = ref<boolean>(true);
const dateRow = ref<DataDateRowObject[]>([]);
dataNormalRaw.value = res.data.result.normal;
dataSixDaysRaw.value = res.data.result.sixDays;
dataNormal.map((e: RequestItemsObject, index: number) => {
dateRow.value.push({
holidayDate: new Date(e.holidayDate),
name: e.name,
isSpecial: true,
id: e.id,
});
if (
index == dataNormal.length - 1 ||
dataNormal[index + 1].name != e.name ||
(dataNormal[index + 1].name == e.name &&
dateToISO(new Date(dataNormal[index + 1].holidayDate)) !=
dateToISO(
new Date(
new Date(e.holidayDate).setDate(
new Date(e.holidayDate).getDate() + 1
)
)
))
) {
firstEvent.value = true;
calendarOptions.value.events.push({
id: "normal",
groupId: e.id,
title:
dateToISO(new Date(e.holidayDate)) ==
dateToISO(new Date(e.originalDate))
? e.name
: `ชดเชย ${e.name}`,
start: dateStart.value ? dateStart.value : new Date(e.holidayDate),
end: new Date(
new Date(e.holidayDate).setDate(
new Date(e.holidayDate).getDate() + 1
)
),
isSpecial: true,
allDay: true,
dataRangeRow: dateRow.value,
backgroundColor: "#CCE5FF",
textColor: "#0080FF",
});
dateStart.value = null;
dateRow.value = [];
} else if (firstEvent.value == true) {
firstEvent.value = false;
dateStart.value = new Date(e.holidayDate);
}
});
dataSixDays.map((e: RequestItemsObject, index: number) => {
dateRow.value.push({
holidayDate: new Date(e.holidayDate),
name: e.name,
isSpecial: true,
id: e.id,
});
if (
index == dataSixDays.length - 1 ||
dataSixDays[index + 1].name != e.name ||
(dataSixDays[index + 1].name == e.name &&
dateToISO(new Date(dataSixDays[index + 1].holidayDate)) !=
dateToISO(
new Date(
new Date(e.holidayDate).setDate(
new Date(e.holidayDate).getDate() + 1
)
)
))
) {
firstEvent.value = true;
calendarOptions.value.events.push({
id: "sixdays",
groupId: e.id,
title:
dateToISO(new Date(e.holidayDate)) ==
dateToISO(new Date(e.originalDate))
? e.name
: `ชดเชย ${e.name}`,
start: dateStart.value ? dateStart.value : new Date(e.holidayDate),
end: new Date(
new Date(e.holidayDate).setDate(
new Date(e.holidayDate).getDate() + 1
)
),
isSpecial: true,
allDay: true,
dataRangeRow: dateRow.value,
backgroundColor: "#FFE5CC",
textColor: "#FF8000",
});
dateStart.value = null;
dateRow.value = [];
} else if (firstEvent.value == true) {
firstEvent.value = false;
dateStart.value = new Date(e.holidayDate);
}
});
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await props.fetchDataSummaryCalendar();
});
};
/**
* นทกแกไขวนหย
*/
const editData = async () => {
await formDate.value.validate().then(async (result: boolean) => {
if (result) {
const dataEdit = ref<DataDateAddObject[]>([]);
let i = 0;
const dateStart = ref<Date>(dateRange.value[0]);
do {
i = i + 1;
dataEdit.value.push({
year: new Date(dateStart.value).getFullYear(),
holidayDate: dateToISO(new Date(dateStart.value)),
name: name.value,
isSpecial: true,
});
dateStart.value = new Date(
new Date(dateStart.value).setDate(
new Date(dateStart.value).getDate() + 1
)
);
} while (new Date(dateStart.value) <= new Date(dateRange.value[1]));
const _dataHistory = ref<RequestItemsObject[]>([]);
dataHistory.value.map((e: RequestItemsObject, index: number) => {
_dataHistory.value.push({
...e,
holidayDate: dateToISO(new Date(e.holidayDate)),
});
});
showLoader();
await http
.post(config.API.listHolidayHistoryEdit(type.value), {
history: _dataHistory.value,
updated: dataEdit.value,
})
.then((res) => {
modalAdd.value = false;
success($q, "แก้ไขข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
}
});
};
/**
* นทกเพมวนหย
*/
const addDate = async () => {
await formDate.value.validate().then(async (result: boolean) => {
if (result) {
const dataAdd = ref<DataDateAddObject[]>([]);
let i = 0;
const dateStart = ref<Date>(dateRange.value[0]);
do {
i = i + 1;
dataAdd.value.push({
year: new Date(dateStart.value).getFullYear(),
holidayDate: dateToISO(new Date(dateStart.value)),
name: name.value,
isSpecial: true,
});
dateStart.value = new Date(
new Date(dateStart.value).setDate(
new Date(dateStart.value).getDate() + 1
)
);
} while (new Date(dateStart.value) <= new Date(dateRange.value[1]));
showLoader();
await http
.post(config.API.listHolidayHistoryAdd(category.value), dataAdd.value)
.then((res) => {
modalAdd.value = false;
success($q, "เพิ่มข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
}
});
};
/**
* ลบขอมลวนหย
*/
const deleteData = async () => {
modalDelete.value = false;
const dataDelete = ref<DataDateAddObject[]>([]);
let i = 0;
const dateStart = ref<Date>(dateRange.value[0]);
do {
i = i + 1;
dataDelete.value.push({
year: new Date(dateStart.value).getFullYear(),
holidayDate: dateToISO(new Date(dateStart.value)),
name: name.value,
isSpecial: true,
});
dateStart.value = new Date(
new Date(dateStart.value).setDate(new Date(dateStart.value).getDate() + 1)
);
} while (new Date(dateStart.value) <= new Date(dateRange.value[1]));
showLoader();
await http
.post(config.API.listHolidayHistoryDelete(type.value), dataDelete.value)
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
modalAdd.value = false;
await fetchData();
});
};
/**
* แปลงชวงวนทา2คาเปนวนเดยวกนจะโชววนเดยวแตาไมเทากนจะแสดงเปนชวง
* @param val วงวนท
*/
const dateThaiRange = (val: [Date, Date]) => {
if (val === null) {
} else if (date2Thai(val[0]) === date2Thai(val[1])) {
return `${date2Thai(val[0])}`;
} else {
return `${date2Thai(val[0])} - ${date2Thai(val[1])} `;
}
};
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
</script>
<style scope lang="scss">
.main-content {
height: 70vh;
}
.color-main {
color: #18a259;
}
.padding-content {
padding: 10px;
}
.demo-app-main {
flex-grow: 1;
/* padding: 3em; */
}
.fc {
/* the calendar root */
max-width: 1100px;
margin: 0 auto;
background-color: white;
border-radius: 10px;
}
.fc-day-today {
background-color: rgb(255, 255, 255) !important;
}
// .fc-day-sun {
// background-color: rgba(207, 205, 205, 0.177) !important;
// width: 80px;
// }
// .fc-day-sat {
// background-color: rgba(207, 205, 205, 0.177) !important;
// width: 80px;
// }
.fc-day-today .fc-daygrid-day-number {
display: flex;
justify-content: center;
align-items: center;
/* border: 2px solid #17a259; */
border-radius: 50%;
height: 25px;
width: 25px;
font-weight: bold;
color: white !important;
background: #17a259;
}
.fc-day-today .fc-daygrid-day-frame {
padding: 5%;
}
.fc .fc-button-group > .fc-button {
color: black;
background-color: #fafafa;
border: none;
}
.fc .fc-button-group > .fc-button:active {
color: white;
background-color: #22a15e;
border: none;
}
.fc .fc-button-group > .fc-button.fc-button-active {
color: white;
background-color: #22a15e;
border: none;
}
.fc-header-toolbar {
background-color: white;
padding: 0px 10px 0px 10px;
border-radius: 10px 10px 0px 0px;
}
.fc .fc-scrollgrid-liquid > thead {
background-color: #f8f8f8;
}
.dp-custom-cell {
border-radius: 50%;
}
.dp__today {
border: 1px solid var(--q-primary);
}
.dp__range_end,
.dp__range_start,
.dp__active_date {
background: var(--q-primary);
color: var(--dp-primary-text-color);
}
.datepicker .q-field__label {
padding-left: 5px;
}
.datepicker .q-field__messages {
padding-left: 20px;
}
.datepicker .q-field__native {
padding-left: 5px;
color: var(--q-primary) !important;
}
.datepicker .q-field__prepend {
padding-left: 6px;
}
.datepicker .q-field__append {
padding-right: 6px;
}
.datepicker .q-field__after {
display: flex;
justify-content: flex-end;
align-items: center;
font-weight: 500;
}
.fc .fc-popover {
z-index: 6000;
}
.fc-direction-ltr .fc-daygrid-event.fc-event-end,
.fc-direction-rtl .fc-daygrid-event.fc-event-start {
cursor: pointer;
}
.subName {
display: flex;
justify-content: flex-end;
align-items: center;
font-weight: 500;
}
.subInput {
display: flex;
align-items: center;
}
.fc-event {
overflow: hidden;
border-color: transparent !important;
font-weight: 500;
}
.fc-event-main {
text-align: center;
}
.fc-direction-ltr .fc-daygrid-event.fc-event-end,
.fc-direction-rtl .fc-daygrid-event.fc-event-start {
padding-left: 0px;
}
</style>

View file

@ -1,580 +0,0 @@
<!-- tab รายการ หนาปฏนวนหย -->
<template>
<q-card class="q-mt-md" flat bordered>
<!-- list รายการนหย -->
<q-tabs
dense
v-model="currentTab"
indicator-color="primary"
active-color="primary bg-teal-1"
class="text-body2 text-grey-7"
>
<q-tab
v-for="tab in tabs"
:key="tab.value"
v-on:click="changeTab(tab.value)"
:label="tab.label"
:name="tab.value"
class="q-py-xs col-6 row"
/>
</q-tabs>
<q-table
ref="table"
flat
bordered
class="custom-header-table"
virtual-scroll
:rows="calendarData"
:columns="columns"
dense
:rows-per-page-options="[0]"
hide-header
>
<template v-slot:body="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'week'" class="">
{{ dayThaiRange(props.row.dateRange) }}
</div>
<div v-else-if="col.name == 'holidayDate'" class="">
{{ dateThaiRange(props.row.dateRange) }}
</div>
<div v-else class="my-table-details">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
flat
round
color="grey"
@click.stop
size="10px"
icon="more_vert"
>
<q-menu>
<q-list>
<q-item
clickable
v-close-popup
@click="editCalendar(props.row)"
>
<q-item-section>
<q-item-label>แกไขวนหย</q-item-label>
</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
@click="deleteClick(props.row)"
>
<q-item-section>
<q-item-label>ลบวนหย</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-td>
</q-tr>
</template>
</q-table>
</q-card>
<!-- modal เพมวนหย -->
<q-dialog v-model="modalAdd" persistent>
<q-card style="min-width: 550px">
<q-form ref="formDate" @submit.prevent.stop="editData">
<q-card-section class="row items-center q-pb-xs">
<div class="text-bold">แกไขวนหย</div>
<q-space />
<q-btn
icon="close"
unelevated
round
dense
v-close-popup
style="color: #ff8080; background-color: #ffdede"
/>
</q-card-section>
<q-separator />
<q-card-section class="q-p-sm">
<div class="row col-12 q-col-gutter-sm">
<div class="col-2 subName">
<label>เลอกวนท</label>
</div>
<div class="col-10">
<datepicker
v-model="dateAdd"
:locale="'th'"
autoApply
range
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
outlined
dense
class="full-width datepicker"
:model-value="dateThaiRange(dateAdd)"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
</div>
<div class="row col-12 q-col-gutter-sm">
<div class="col-2 subName">
<label>คำอธบาย</label>
</div>
<div class="col-10">
<q-input
dense
borderless
class="full-width datepicker q-pb-none"
v-model="name"
type="textarea"
:rules="[(val:string) => (val && val.length > 0) || '']"
/>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right" class="text-primary">
<q-btn unelevated label="บันทึก" color="public" type="submit">
<!-- icon="mdi-content-save-outline"
<q-tooltip>นท</q-tooltip> -->
</q-btn>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
<!-- modal ลบวนหย -->
<q-dialog v-model="modalDelete" persistent>
<q-card style="min-width: 550px">
<q-card-section class="row items-center q-pb-xs">
<div class="text-bold">องการลบขอมลนหรอไม?</div>
<q-space />
<q-btn
icon="close"
unelevated
round
dense
v-close-popup
style="color: #ff8080; background-color: #ffdede"
/>
</q-card-section>
<q-separator />
<q-card-section class="row items-center">
<div class="q-pr-md">
<q-avatar
icon="mdi-trash-can-outline"
font-size="25px"
size="lg"
color="red-1"
text-color="red"
/>
</div>
<div class="col text-dark">
<span>อมลทกำลงถกลบนจะมผลใชงานทนท</span>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="ตกลง" color="primary" @click="deleteConfirm" />
</q-card-actions>
</q-card>
</q-dialog>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import type {
RequestItemsObject,
DataDateRowObject,
DataDateAddObject,
DataDateListsObject,
TabsObject,
} from "@/modules/01_metadata/interface/request/Calendar";
const props = defineProps({
dateYear: {
//filter
type: Number,
required: true,
},
refreshData: {
// main refresh data
type: Boolean,
required: true,
},
fetchDataSummaryCalendar: {
//
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin(); //
const {
success,
dateToISO,
dateMonth2Thai,
weekThai,
messageError,
showLoader,
hideLoader,
} = mixin;
const $q = useQuasar(); // noti quasar
const calendarData = ref<DataDateListsObject[]>([]); //data
const modalAdd = ref<boolean>(false); //modal
const modalDelete = ref<boolean>(false); //modal
const name = ref<string>(""); //
const isSpecial = ref<boolean>(true); //
const dateAdd = ref<[Date, Date]>([new Date(), new Date()]); //
const rowData = ref<DataDateListsObject>(); //data row
const formDate = ref<any>(); //ref validate
const currentTab = ref<string>("normal"); // tab
const tabs = ref<TabsObject[]>([
{ label: "ทำงานจันทร์-ศุกร์ (5 วัน)", value: "normal" },
{ label: "ทำงานจันทร์-เสาร์ (6 วัน)", value: "6day" },
]); //tab
//columns
const columns = ref<any>([
{
name: "week",
align: "left",
label: "-",
sortable: true,
field: "week",
style: "font-size: 15px",
},
{
name: "holidayDate",
align: "left",
label: "-",
sortable: true,
field: "holidayDate",
style: "font-size: 15px",
},
{
name: "detail",
align: "left",
label: "-",
sortable: true,
field: "detail",
style: "font-size: 15px",
},
]);
/**
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/
onMounted(async () => {
await fetchData();
});
/**
* props(นปเลอก และเพมหรอแกไข) ตอนอพเดท าฏนใหพเดทใหม
*/
watch(props, async (count, prevCount) => {
await fetchData();
});
/**
* กดปมแกไขวนหย
* @param val data นหยดท row
*/
const editCalendar = async (val: DataDateListsObject) => {
rowData.value = val;
dateAdd.value = [val.dateRange[0], val.dateRange[1]];
name.value = val.detail;
isSpecial.value = true;
modalAdd.value = true;
};
/**
* กดปมลบวนหย
* @param val data นหยดท row
*/
const deleteClick = async (val: DataDateListsObject) => {
rowData.value = val;
modalDelete.value = true;
};
/**
* fetch นหยดในรายการ
*/
const fetchData = async () => {
calendarData.value = [];
showLoader();
await http
.get(config.API.listHolidayHistoryYear(props.dateYear))
.then((res) => {
let data = res.data.result.normal;
if (currentTab.value == "6day") {
data = res.data.result.sixDays;
}
const dateStart = ref<Date | null>();
const firstEvent = ref<boolean>(true);
const dateRow = ref<DataDateRowObject[]>([]);
data.map((e: RequestItemsObject, index: number) => {
dateRow.value.push({
holidayDate: new Date(e.holidayDate),
name: e.name,
isSpecial: true,
id: e.id,
});
if (
index == data.length - 1 ||
data[index + 1].name != e.name ||
(data[index + 1].name == e.name &&
dateToISO(new Date(data[index + 1].holidayDate)) !=
dateToISO(
new Date(
new Date(e.holidayDate).setDate(
new Date(e.holidayDate).getDate() + 1
)
)
))
) {
firstEvent.value = true;
calendarData.value.push({
id: e.id,
dateRange: [
dateStart.value ? dateStart.value : new Date(e.holidayDate),
new Date(e.holidayDate),
],
dataRangeRow: dateRow.value,
detail:
dateToISO(new Date(e.holidayDate)) ==
dateToISO(new Date(e.originalDate))
? e.name
: `ชดเชย ${e.name}`,
isSpecial: true,
});
dateStart.value = null;
dateRow.value = [];
} else if (firstEvent.value == true) {
firstEvent.value = false;
dateStart.value = new Date(e.holidayDate);
}
});
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await props.fetchDataSummaryCalendar();
});
};
/**
* ลบขอมลวนหย
*/
const deleteConfirm = async () => {
modalDelete.value = false;
const dataDelete = ref<DataDateAddObject[]>([]);
if (rowData.value != null) {
await rowData.value.dataRangeRow.map((e: DataDateRowObject) => {
dataDelete.value.push({
year: new Date(e.holidayDate).getFullYear(),
holidayDate: dateToISO(e.holidayDate),
name: e.name,
isSpecial: true,
});
});
} else {
return;
}
showLoader();
await http
.post(
config.API.listHolidayHistoryDelete(currentTab.value),
dataDelete.value
)
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* นทกแกไขวนหย
*/
const editData = async () => {
await formDate.value.validate().then(async (result: boolean) => {
if (result) {
const dataEdit = ref<DataDateAddObject[]>([]);
let i = 0;
const dateStart = ref<Date>(dateAdd.value[0]);
do {
i = i + 1;
dataEdit.value.push({
year: new Date(dateStart.value).getFullYear(),
holidayDate: dateToISO(new Date(dateStart.value)),
name: name.value,
isSpecial: true,
});
dateStart.value = new Date(
new Date(dateStart.value).setDate(
new Date(dateStart.value).getDate() + 1
)
);
} while (new Date(dateStart.value) <= new Date(dateAdd.value[1]));
const _dataHistory = ref<DataDateAddObject[]>([]);
if (rowData.value != null) {
rowData.value.dataRangeRow.map(
(e: DataDateRowObject, index: number) => {
_dataHistory.value.push({
year: new Date(e.holidayDate).getFullYear(),
holidayDate: dateToISO(e.holidayDate),
name: e.name,
isSpecial: true,
});
}
);
}
showLoader();
await http
.post(config.API.listHolidayHistoryEdit(currentTab.value), {
history: _dataHistory.value,
updated: dataEdit.value,
})
.then((res) => {
modalAdd.value = false;
success($q, "แก้ไขข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
} else {
}
});
};
/**
* เปลยน tab นหยดตามประเภท
* @param tab tab ประเภทวนหยดทเลอก
*/
const changeTab = async (tab: string) => {
currentTab.value = tab;
await fetchData();
};
/**
* แปลงชวงวนทา2คาเปนวนเดยวกนจะโชววนเดยวแตาไมเทากนจะแสดงเปนชวง
* @param val วงวนท
*/
const dateThaiRange = (val: [Date, Date]) => {
if (val === null) {
return "";
} else if (dateMonth2Thai(val[0], true) === dateMonth2Thai(val[1], true)) {
return `${dateMonth2Thai(val[0], true)}`;
} else {
return `${dateMonth2Thai(val[0], true)} - ${dateMonth2Thai(val[1], true)}`;
}
};
/**
* แปลงชวงวนทา2คาเปนวนเดยวกนจะโชววนเดยวแตาไมเทากนจะแสดงเปนชวง(เชนวนจนทร -นศกร)
* @param val วงวนท
*/
const dayThaiRange = (val: [Date, Date]) => {
if (val === null) {
} else if (dateToISO(val[0]) == dateToISO(val[1])) {
return `${weekThai(new Date(val[0]).getDay())}`;
} else {
return `${weekThai(new Date(val[0]).getDay())} - ${weekThai(
new Date(val[1]).getDay()
)}`;
}
};
</script>
<style lang="scss">
.custom-header-table {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
.my-table-details {
white-space: -moz-pre-wrap !important;
/* Mozilla, since 1999 */
white-space: -webkit-pre-wrap;
/* Chrome & Safari */
white-space: -pre-wrap;
/* Opera 4-6 */
white-space: -o-pre-wrap;
/* Opera 7 */
white-space: pre-wrap;
/* CSS3 */
word-wrap: break-word;
/* Internet Explorer 5.5+ */
word-break: break-all;
white-space: normal;
}
.table_ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: wrap;
max-width: 250px;
}
</style>

View file

@ -1,198 +0,0 @@
<template>
<q-dialog :model-value="modal" persistent>
<q-card style="min-width: 700px">
<q-form ref="myForm">
<div class="row items-center q-pa-sm">
<div class="row">
<div class="text-bold">{{ tittle }}</div>
</div>
<q-space />
<q-btn
icon="close"
unelevated
round
dense
style="color: #ff8080; background-color: #ffdede"
size="12px"
@click="close"
/>
</div>
<q-separator />
<div class="q-pa-sm">
<!-- header บน table นหา แสดงคอลมน (status nornmalData true) -->
<div class="col-12 row q-pb-sm">
<q-select
hide-bottom-space
@update:model-value="updateHistory"
outlined
dense
lazy-rules
borderless
:model-value="history"
:label="`${'ชื่อเครื่องราชฯ'}`"
emit-value
map-options
option-label="publishedDate"
:options="optionsHistory"
option-value="id"
/>
<q-space />
<div class="items-center" style="display: flex">
<!-- นหาขอความใน table -->
<q-input
standout
dense
:model-value="inputfilter"
ref="filterRef"
@update:model-value="updateInput"
outlined
debounce="300"
placeholder="ค้นหา"
style="max-width: 200px"
class="q-ml-sm"
>
<template v-slot:append>
<q-icon v-if="inputfilter == ''" name="search" />
<q-icon
v-if="inputfilter !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template>
</q-input>
<!-- แสดงคอลมนใน table -->
<q-select
:model-value="inputvisible"
@update:model-value="updateVisible"
:display-value="$q.lang.table.columns"
multiple
outlined
dense
:options="attrs.columns"
options-dense
option-value="name"
map-options
emit-value
style="min-width: 140px"
class="gt-xs q-ml-sm"
/>
</div>
</div>
<q-table
ref="table"
flat
bordered
class="custom-header-table"
v-bind="attrs"
virtual-scroll
:virtual-scroll-sticky-size-start="48"
dense
:pagination-label="paginationLabel"
:pagination="initialPagination"
:rows-per-page-options="[0]"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
</q-tr>
</template>
<!-- สำหรบเรยกใช template วขางนอก -->
<template #body="props">
<slot v-bind="props" name="columns"></slot>
</template>
</q-table>
</div>
<q-separator />
</q-form>
</q-card>
</q-dialog>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { ref, useAttrs } from "vue";
import type { Pagination } from "@/modules/01_metadata/interface/index/Main";
const attrs = ref<any>(useAttrs());
const filterRef = ref<any>(null);
const initialPagination = ref<Pagination>({
rowsPerPage: 0,
});
const props = defineProps({
tittle: String,
inputfilter: String,
history: String,
inputvisible: Array,
modal: Boolean,
optionsHistory: Array,
updateHistory: {
type: Function,
default: () => console.log("not function"),
},
});
const emit = defineEmits([
"update:inputfilter",
"update:inputvisible",
"update:modal",
"update:history",
]);
const updateInput = (value: string | number | null) => {
emit("update:inputfilter", value);
};
const updateVisible = (value: []) => {
emit("update:inputvisible", value);
};
const close = () => {
emit("update:modal", false);
};
const updateHistory = (value: string) => {
emit("update:history", value);
props.updateHistory();
};
const paginationLabel = (start: string, end: string, total: string) => {
return start + "-" + end + " ใน " + total;
};
// reset X
const resetFilter = () => {
emit("update:inputfilter", "");
filterRef.value.focus();
};
</script>
<style lang="scss">
.icon-color {
color: #4154b3;
}
.custom-header-table {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>

View file

@ -1,986 +0,0 @@
<!-- tab อเครองราช หนาจดการขอมลหล/อมลเครองราชอสรยาภรณ -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'insigniaType'" class="">
{{ col.value == null ? "" : col.value.name }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td
key="level"
:props="props"
v-if="props.row.level !== undefined"
>
<div class="">
{{ props.row.level }}
</div>
</q-td>
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val:string) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val:string) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="shortName"
:props="props"
v-if="props.row.shortName !== undefined"
>
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.shortName"
dense
lazy-rules
hide-bottom-space
:rules="[
(val:string) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val:string) =>
checkDupDataShortName(val) ||
'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="insigniaType"
:props="props"
v-if="props.row.shortName !== undefined"
>
<q-select
:options="insigniaTypeOption"
outlined
@update:model-value="clickEditRow"
v-model="props.row.insigniaType"
dense
lazy-rules
hide-bottom-space
option-label="name"
option-value="id"
:rules="[(val:string) => val || 'กรุณาเลือกลำดับชั้นเครื่องราชฯ']"
/>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td key="note" :props="props" v-if="props.row.note !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.note"
dense
lazy-rules
autofocus
hide-bottom-space
></q-input>
</q-td>
<q-td auto-width>
<div class="row">
<q-btn
:disable="props.row.level <= 1"
flat
dense
size="12px"
icon="mdi-menu-up"
style="
padding-top: 0em;
padding-right: 0.5em;
padding-bottom: 0em;
padding-left: 0.5em;
min-height: 0em;
"
@click="directionItem(props.row, 'up')"
/>
<q-btn
:disable="props.row.level >= rows.length"
flat
dense
size="12px"
icon="mdi-menu-down"
style="
padding-top: 0em;
padding-right: 0.5em;
padding-bottom: 0em;
padding-left: 0.5em;
min-height: 0em;
"
@click="directionItem(props.row, 'down')"
/>
</div>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'insigniaType'" class="">
{{ col.value == null ? "" : col.value.name }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/insignia/Insignia";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/insignia/Insignia";
import type { DataOption } from "@/modules/01_metadata/interface/index/Main";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getInsignia, dataInsignia } = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขชื่อเครื่องราชฯ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const insigniaTypeOption = ref<DataOption[]>([]); //
const columns = ref<QTableProps["columns"]>([
{
name: "level",
align: "left",
label: "ลำดับ",
sortable: true,
field: "level",
headerStyle: "font-size: 14px; width:0px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "name",
align: "left",
label: "ชื่อเครื่องราชฯ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "shortName",
align: "left",
label: "ชื่อย่อ",
sortable: true,
field: "shortName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "insigniaType",
align: "left",
label: "ลำดับชั้นเครื่องราชฯ",
sortable: true,
field: "insigniaType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.insignia.class.columns.length == 0
? (visibleColumns.value = [
"level",
"name",
"shortName",
"insigniaType",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
])
: (visibleColumns.value = manageData.insignia.class.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "level",
align: "left",
label: "ลำดับ",
sortable: true,
field: "level",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "name",
align: "left",
label: "ชื่อเครื่องราชฯ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "shortName",
align: "left",
label: "ชื่อย่อ",
sortable: true,
field: "shortName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "insigniaType",
align: "left",
label: "ลำดับชั้นเครื่องราชฯ",
sortable: true,
field: "insigniaType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"level",
"name",
"shortName",
"insigniaType",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(6, "class", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getInsignia(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
updateData.value = false;
rows.value = result.data;
rows.value.sort(
(
firstItem: RequestItemsHistoryObject,
secondItem: RequestItemsHistoryObject
) => firstItem.level - secondItem.level
);
// const data = rows.value;
// let option: DataOption[] = [];
// data.map((r: RequestItemsHistoryObject) => {
// option.push({ id: r.id.toString(), name: r.name.toString() });
// });
// insigniaTypeOption.value = option;
fetchinsigniaType();
updateData.value = true;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listInsigniaHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// shortName: e.shortName,
// level: e.level,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// insigniaType: e.insigniaType,
// note: e.note,
// });
// });
// rows.value.sort(
// (
// firstItem: RequestItemsHistoryObject,
// secondItem: RequestItemsHistoryObject
// ) => firstItem.level - secondItem.level
// );
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchinsigniaType();
// });
};
/**
* รายการลำดบเครองราชฯ
*/
const fetchinsigniaType = async () => {
showLoader();
await http
.get(config.API.insigniaType)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: RequestItemsHistoryObject) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
insigniaTypeOption.value = option;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
updateData.value = false;
hideLoader();
});
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listInsigniaPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
level: i.level,
name: i.name,
shortName: i.shortName,
insigniaType: i.insigniaType,
note: i.note,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listInsigniaHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listInsigniaPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" &&
(f.name == "" || f.shortName == "") // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
shortName: "",
level: rows.value[rows.value.length - 1].level + 1,
note: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
shortName: e.shortName,
level: e.level,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
insigniaType: e.insigniaType,
}));
showLoader();
await http
.post(config.API.listInsigniaHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* เชคชอยอซำกบขอมลทอยแล
* @param val input อย
*/
const checkDupDataShortName = (val: string) => {
const filterShortNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.shortName == val
); //
if (filterShortNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
/**
* ายลำด data
* @param row าใน row
* @param type ายตำแหนงแบบไหน up= down=ลง
*/
const directionItem = (row: RequestItemsHistoryObject, type: string) => {
clickEditRow();
if (type === "up") {
rows.value[
rows.value.findIndex((object: RequestItemsHistoryObject) => {
return object === row;
})
].level -= 1;
rows.value[
rows.value.findIndex((object: RequestItemsHistoryObject) => {
return object === row;
}) - 1
].level += 1;
} else {
rows.value[
rows.value.findIndex((object: RequestItemsHistoryObject) => {
return object === row;
})
].level += 1;
rows.value[
rows.value.findIndex((object: RequestItemsHistoryObject) => {
return object === row;
}) + 1
].level -= 1;
}
rows.value.sort(
(
firstItem: RequestItemsHistoryObject,
secondItem: RequestItemsHistoryObject
) => firstItem.level - secondItem.level
);
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,666 +0,0 @@
<!-- tab ลำดบชนเครองราชฯ หนาจดการขอมลหล/อมลเครองราชอสรยาภรณ -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val:string) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val:string) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/insignia/InsigniaType";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/insignia/InsigniaType";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getInsigniaType, dataInsigniaType } =
store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขลำดับชั้นเครื่องราชฯ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ลำดับชั้นเครื่องราชฯ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.insignia.type.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.insignia.type.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ลำดับชั้นเครื่องราชฯ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(6, "type", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getInsigniaType(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listInsigniaTypeHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listInsigniaTypePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listInsigniaTypeHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listInsigniaTypePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listInsigniaTypeHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,657 +0,0 @@
<!-- tab หนวยงานตนสงก หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/Agency";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/Agency";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns } = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขหน่วยงานต้นสังกัด"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "หน่วยงานต้นสังกัด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.agency.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.organization.agency.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "หน่วยงานต้นสังกัด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "agency", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async () => {
await props.fetchDataComponent();
rows.value.splice(0);
showLoader();
await http
.get(config.API.listOrganizationAgencyHistory)
.then((res) => {
let data = res.data.result;
version.value = data.version; // published= draft=
idVersion.value = data.id; // id mongodb
data.items.map((e: RequestItemsHistoryObject) => {
rows.value.push({
id: e.id,
name: e.name,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
lastUpdateFullName: e.lastUpdateFullName,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateUserId: e.lastUpdateUserId,
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
updateData.value = false;
hideLoader();
});
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationAgencyPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationAgencyHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationAgencyPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
*
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* @param publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listOrganizationAgencyHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData();
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,669 +0,0 @@
<!-- tab หมายเลขโทรสาร หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/Fax";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/Fax";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getOrganizationFax,
dataOrganizationFax,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขหมายเลขโทรสาร"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "หมายเลขโทรสาร",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.fax.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.organization.fax.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "หมายเลขโทรสาร",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "fax", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getOrganizationFax(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listOrganizationFaxHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationFaxPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationFaxHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationFaxPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listOrganizationFaxHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,658 +0,0 @@
<!-- tab วนราชการตนสงก หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/GovernmentAgency";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/GovernmentAgency";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns } = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขส่วนราชการต้นสังกัด"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ส่วนราชการต้นสังกัด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.governmentAgency.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.organization.governmentAgency.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ส่วนราชการต้นสังกัด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "governmentAgency", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async () => {
await props.fetchDataComponent();
rows.value.splice(0);
showLoader();
await http
.get(config.API.listOrganizationGovernmentAgencyHistory)
.then((res) => {
let data = res.data.result;
version.value = data.version; // published= draft=
idVersion.value = data.id; // id mongodb
data.items.map((e: RequestItemsHistoryObject) => {
rows.value.push({
id: e.id,
name: e.name,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
lastUpdateFullName: e.lastUpdateFullName,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateUserId: e.lastUpdateUserId,
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
updateData.value = false;
hideLoader();
});
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationGovernmentAgencyPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationGovernmentAgencyHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationGovernmentAgencyPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(
config.API.listOrganizationGovernmentAgencyHistoryId(idVersion.value),
{
id: idVersion.value,
version: "draft",
items: rows.value,
}
)
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData();
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,667 +0,0 @@
<!-- tab ระดบของหนวยงาน/วนราชการ หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/Level";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/Level";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getOrganizationLevel,
dataOrganizationLevel,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขระดับของหน่วยงาน/ส่วนราชการ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ระดับของหน่วยงาน/ส่วนราชการ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.level.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.organization.level.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ระดับของหน่วยงาน/ส่วนราชการ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "level", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getOrganizationLevel(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listOrganizationLevelHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationLevelPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationLevelHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationLevelPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listOrganizationLevelHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,703 +0,0 @@
<!-- tab อหนวยงาน หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td key="note" :props="props" v-if="props.row.note !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.note"
dense
lazy-rules
autofocus
hide-bottom-space
></q-input>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/Organization";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/Organization";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getOrganization, dataOrganization } =
store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขชื่อหน่วยงาน/ส่วนราชการ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ชื่อหน่วยงาน/หน่วยงานต้นสังกัด/ส่วนราชการต้นสังกัด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.organization.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
])
: (visibleColumns.value = manageData.organization.organization.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ชื่อหน่วยงาน/หน่วยงานต้นสังกัด/ส่วนราชการต้นสังกัด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "organization", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getOrganization(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listOrganizationOrganizationHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// note: e.note,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationOrganizationPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
note: i.note,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationOrganizationHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationOrganizationPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
note: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listOrganizationOrganizationHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,825 +0,0 @@
<!-- tab อยอหนวยงาน หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td
key="agencyCode"
:props="props"
v-if="props.row.agencyCode !== undefined"
>
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.agencyCode"
dense
lazy-rules
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(props.row) || 'ข้อมูลนี้มีอยู่แล้วในระบบ',
]"
></q-input>
</q-td>
<q-td
key="governmentCode"
:props="props"
v-if="props.row.governmentCode !== undefined"
>
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.governmentCode"
dense
lazy-rules
hide-bottom-space
:rules="[
(val) =>
checkDupDataName(props.row) || 'ข้อมูลนี้มีอยู่แล้วในระบบ',
]"
></q-input>
</q-td>
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-form ref="myForm3">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(props.row) ||
'ข้อมูลนี้มีอยู่แล้วในระบบ',
]"
></q-input>
</q-form>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td key="note" :props="props" v-if="props.row.note !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.note"
dense
lazy-rules
autofocus
hide-bottom-space
></q-input>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/ShortName";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/ShortName";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getOrganizationShortName,
dataOrganizationShortName,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขตัวย่อหน่วยงาน/ส่วนราชการ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "agencyCode",
align: "left",
label: "หน่วยงานต้นสังกัด",
sortable: true,
field: "agencyCode",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "governmentCode",
align: "left",
label: "ส่วนราชการต้นสังกัด",
sortable: true,
field: "governmentCode",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "name",
align: "left",
label: "ตัวย่อหน่วยงาน/ส่วนราชการ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.shortName.columns.length == 0
? (visibleColumns.value = [
"agencyCode",
"governmentCode",
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
])
: (visibleColumns.value = manageData.organization.shortName.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "agencyCode",
align: "left",
label: "หน่วยงานต้นสังกัด",
sortable: true,
field: "agencyCode",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "governmentCode",
align: "left",
label: "ส่วนราชการต้นสังกัด",
sortable: true,
field: "governmentCode",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "name",
align: "left",
label: "ตัวย่อหน่วยงาน/ส่วนราชการ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"agencyCode",
"governmentCode",
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "shortName", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getOrganizationShortName(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listOrganizationShortNameHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// agencyCode: e.agencyCode,
// governmentCode: e.governmentCode,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// note: e.note,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationShortNamePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
agencyCode: i.agencyCode,
governmentCode: i.governmentCode,
name: i.name,
note: i.note,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationShortNameHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationShortNamePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" &&
(f.agencyCode == "" || f.name == "") // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
agencyCode: "",
governmentCode: "",
name: "",
note: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
agencyCode: e.agencyCode,
governmentCode: e.governmentCode,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listOrganizationShortNameHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชครหสซำกบขอมลทอยแล
* @param val input วนราชการตนสงก
*/
const checkDupDataGovernmentCode = (gCode: string, aCode: string) => {
if (gCode == null || gCode == "") return true;
const filterCodeNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.governmentCode == gCode && f.agencyCode == aCode
); //
if (filterCodeNull.length > 1) {
return false;
}
return true;
};
/**
* เชคชอยอซำกบขอมลทอยแล
* @param val input อย
*/
const checkDupDataName = (row: any) => {
const filterShortNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.name == row.name &&
f.governmentCode == row.governmentCode &&
f.agencyCode == row.agencyCode
); //
if (filterShortNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,669 +0,0 @@
<!-- tab สถานะของหนวยงาน/วนราชการ หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/Status";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/Status";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getOrganizationStatus,
dataOrganizationStatus,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขสถานะของหน่วยงาน/ส่วนราชการ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สถานะของหน่วยงาน/ส่วนราชการ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.status.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.organization.status.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สถานะของหน่วยงาน/ส่วนราชการ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "status", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getOrganizationStatus(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listOrganizationStatusHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationStatusPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationStatusHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationStatusPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listOrganizationStatusHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,671 +0,0 @@
<!-- tab หมายเลขโทรศพทดตอจากภายนอก หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/TelExternal";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/TelExternal";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getOrganizationTelExternal,
dataOrganizationTelExternal,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>(
"ประวัติแก้ไขหมายเลขโทรศัพท์ที่ติดต่อจากภายนอก"
); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.telExternal.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.organization.telExternal.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "telExternal", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getOrganizationTelExternal(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listOrganizationTelExternalHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationTelExternalPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationTelExternalHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationTelExternalPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listOrganizationTelExternalHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,671 +0,0 @@
<!-- tab หมายเลขโทรศพทดตอจากภายใน หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/TelInternal";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/TelInternal";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getOrganizationTelInternal,
dataOrganizationTelInternal,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>(
"ประวัติแก้ไขหมายเลขโทรศัพท์ที่ติดต่อจากภายใน"
); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.telInternal.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.organization.telInternal.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "telInternal", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getOrganizationTelInternal(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listOrganizationTelInternalHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationTelInternalPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationTelInternalHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationTelInternalPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listOrganizationTelInternalHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,669 +0,0 @@
<!-- tab ประเภทของหนวยงาน/วนราชการ หนาจดการขอมลหล/อมลโครงสรางหนวยงาน -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/organization/Type";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/organization/Type";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getOrganizationType,
dataOrganizationType,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขประเภทของหน่วยงาน/ส่วนราชการ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ประเภทของหน่วยงาน/ส่วนราชการ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.organization.type.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.organization.type.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ประเภทของหน่วยงาน/ส่วนราชการ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(2, "type", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getOrganizationType(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listOrganizationTypeHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listOrganizationTypePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listOrganizationTypeHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listOrganizationTypePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listOrganizationTypeHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,668 +0,0 @@
<!-- tab กลมเลอด หนาจดการขอมลหล/อมลเกยวกบบคคล -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true" class="items-center">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
counter
maxlength="2"
>
<template v-slot:hint> วอกษร </template></q-input
>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/person/Blood";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/person/Blood";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getBlood, dataBlood } = store;
const rows = ref<RequestItemsHistoryObject[]>(dataBlood.data); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขกลุ่มเลือด"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "กลุ่มเลือด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px;",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.person.blood.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.person.blood.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "กลุ่มเลือด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(1, "blood", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getBlood(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listBloodGroupHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listBloodGroupPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listBloodGroupHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listBloodGroupPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listBloodGroupHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,727 +0,0 @@
<!-- tab เขต/อำเภอ หนาจดการขอมลหล/อมลเกยวกบบคคล -->
<template>
<div class="row items-center q-mb-sm q-mr-md q-ml-sm">
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="goToManage()"
>
<q-tooltip>กล</q-tooltip>
</q-btn>
<div class="text-h6 text-dark text-weight-bold">การจดการขอมลเขต</div>
<q-space />
<q-breadcrumbs class="text-grey" active-color="blue">
<template v-slot:separator>
<q-icon size="1.2em" name="chevron_right" color="blue" />
</template>
<q-breadcrumbs-el to="/metadata" label="การจัดการข้อมูลจังหวัด" />
<q-breadcrumbs-el label="การจัดการข้อมูลเขต" />
</q-breadcrumbs>
</div>
<q-form ref="myForm">
<q-card flat bordered class="row col-12">
<div class="col-xs-12">
<div class="q-mt-sm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:nextPageVisible="true"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
@click="clickRow(props.row.id)"
>
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
<q-icon
size="30px"
color="grey-7"
name="chevron_right"
@click="clickRow(props.row.id)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td
key="name"
:props="props"
v-if="props.row.name !== undefined"
>
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) =>
(val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) ||
'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="
props.row.id === '00000000-0000-0000-0000-000000000000'
"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="
props.row.id !== '00000000-0000-0000-0000-000000000000'
"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</div>
</div>
</q-card>
</q-form>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/person/District";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/person/District";
import HistoryTable from "@/components/TableHistory.vue";
import { useRoute, useRouter } from "vue-router";
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, changeManageCurrentTab } = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขเขต/อำเภอ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const router = useRouter();
const route = useRoute();
const provinceName = ref<string>("กรุงเทพมหานคร"); //
const provinceId = ref<string | string[]>(route.params.province); // Id
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "เขต/อำเภอ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.person.district.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.person.district.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "เขต/อำเภอ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(1, "district", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async () => {
rows.value.splice(0);
showLoader();
await http
.get(config.API.listDistrictHistoryId(provinceId.value))
.then((res) => {
let data = res.data.result;
version.value = data.version; // published= draft=
idVersion.value = data.id; // id mongodb
provinceName.value = data.provinceName.result;
data.items.map((e: RequestItemsHistoryObject) => {
rows.value.push({
id: e.id,
name: e.name,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
lastUpdateFullName: e.lastUpdateFullName,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateUserId: e.lastUpdateUserId,
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
updateData.value = false;
hideLoader();
});
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listDistrictPublishedHistory(provinceId.value))
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listDistrictHistoryId(provinceId.value))
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listProvincePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listDistrictHistoryId(idVersion.value), {
id: idVersion.value,
provinceId: provinceId.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData();
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
/**
* งกนกดเลอก row ไหนจะเปลยนหนาไปหาเขตทงหมดในจงหวดทกดเลอก
*/
const clickRow = (val: string) => {
router.push(`/metadata/province/${provinceId.value}/${val}`);
};
/**
* งกนยอนกลบไปหนาจดการขอมลหล
*/
const goToManage = async () => {
await changeManageCurrentTab(1, "person_province");
router.push("/metadata");
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,665 +0,0 @@
<!-- tab ระดบการศกษา หนาจดการขอมลหล/อมลเกยวกบบคคล -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true" class="items-center">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/person/Education";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/person/Education";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getEducation, dataEducation } = store;
const rows = ref<RequestItemsHistoryObject[]>(dataEducation.data); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขระดับการศึกษา"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ระดับการศึกษา",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.person.education.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.person.education.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ระดับการศึกษา",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(1, "education", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getEducation(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listEducationLevelHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listEducationLevelPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listEducationLevelHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listEducationLevelPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listEducationLevelHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,664 +0,0 @@
<!-- tab เพศ หนาจดการขอมลหล/อมลเกยวกบบคคล -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true" class="items-center">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
style="width: 150px"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/person/Gender";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/person/Gender";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getGender, dataGender } = store;
const rows = ref<RequestItemsHistoryObject[]>(dataGender.data); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขเพศ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "เพศ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.person.gender.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.person.gender.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "เพศ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(1, "gender", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getGender(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listGenderHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listGenderPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listGenderHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listGenderPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listGenderHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,660 +0,0 @@
<!-- tab คำนำหนาช หนาจดการขอมลหล/อมลเกยวกบบคคล -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true" class="items-center">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/person/Prefix";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/person/Prefix";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getPrefix, dataPrefix } = store;
const rows = ref<RequestItemsHistoryObject[]>(dataPrefix.data); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขคำนำหน้าชื่อ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "คำนำหน้าชื่อ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.person.prefix.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.person.prefix.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "คำนำหน้าชื่อ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(1, "prefix", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
// rows.value = [];
const result = await getPrefix(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPrefixHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
await http
.get(config.API.listPrefixPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
// showLoader();
await http
.delete(config.API.listPrefixHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
// showLoader();
await http
.get(config.API.listPrefixPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
// showLoader();
await http
.post(config.API.listPrefixHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(true); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,682 +0,0 @@
<!-- tab งหว หนาจดการขอมลหล/อมลเกยวกบบคคล -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
:nextPageVisible="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
@click="clickRow(props.row.id)"
>
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
<q-icon
size="30px"
color="grey-8"
name="chevron_right"
@click="clickRow(props.row.id)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true" class="items-center">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/person/Province";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/person/Province";
import HistoryTable from "@/components/TableHistory.vue";
import { useRouter } from "vue-router";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getProvince, dataProvince } = store;
const rows = ref<RequestItemsHistoryObject[]>(dataProvince.data); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขจังหวัด"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const router = useRouter();
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "จังหวัด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.person.province.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.person.province.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "จังหวัด",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(1, "province", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getProvince(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listProvinceHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
// showLoader();
await http
.get(config.API.listProvincePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listProvinceHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listProvincePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listProvinceHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData();
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
/**
* งกนกดเลอก row ไหนจะเปลยนหนาไปหาเขตทงหมดในจงหวดทกดเลอก
*/
const clickRow = (val: string) => {
router.push(`/metadata/province/${val}`);
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,663 +0,0 @@
<!-- tab สถานภาพ หนาจดการขอมลหล/อมลเกยวกบบคคล -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true" class="items-center">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/person/Relationship";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/person/Relationship";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getRelationship, dataRelationship } =
store;
const rows = ref<RequestItemsHistoryObject[]>(dataRelationship.data); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขสถานภาพ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สถานภาพ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.person.relationship.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.person.relationship.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สถานภาพ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(1, "relationship", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getRelationship(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listRelationshipHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listRelationshipPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listRelationshipHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listRelationshipPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listRelationshipHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData();
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,662 +0,0 @@
<!-- tab ศาสนา หนาจดการขอมลหล/อมลเกยวกบบคคล -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true" class="items-center">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/person/Religion";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/person/Religion";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getReligion, dataReligion } = store;
const rows = ref<RequestItemsHistoryObject[]>(dataReligion.data); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขศาสนา"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ศาสนา",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.person.religion.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.person.religion.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ศาสนา",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(1, "religion", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getReligion(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listReligionHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listReligionPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listReligionHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listReligionPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listReligionHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData();
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,785 +0,0 @@
<!-- tab แขวง/ตำบล หนาจดการขอมลหล/อมลเกยวกบบคคล -->
<template>
<div class="row items-center q-mb-sm q-mr-md q-ml-sm">
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="goToProvince()"
>
<q-tooltip>กล</q-tooltip>
</q-btn>
<div class="text-h6 text-dark text-weight-bold">
การจดการขอมลแขวง/ตำบล
</div>
<q-space />
<q-breadcrumbs class="text-grey" active-color="blue">
<template v-slot:separator>
<q-icon size="1.2em" name="chevron_right" color="blue" />
</template>
<q-breadcrumbs-el to="/metadata" label="การจัดการข้อมูลจังหวัด" />
<q-breadcrumbs-el
@click="goToProvince()"
class="cursor-pointer"
label="การจัดการข้อมูลเขต"
/>
<q-breadcrumbs-el label="การจัดการข้อมูลแขวง/ตำบล" />
</q-breadcrumbs>
</div>
<q-card flat bordered class="row col-12">
<div class="col-xs-12">
<div class="q-mt-sm">
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td
key="name"
:props="props"
v-if="props.row.name !== undefined"
>
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) =>
(val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) ||
'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="zipCode"
:props="props"
v-if="props.row.zipCode !== undefined"
>
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.zipCode"
dense
lazy-rules
hide-bottom-space
:rules="[
(val) =>
(val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
color="green"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="
props.row.id === '00000000-0000-0000-0000-000000000000'
"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="
props.row.id !== '00000000-0000-0000-0000-000000000000'
"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
</div>
</q-card>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/person/SubDistrict";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/person/SubDistrict";
import HistoryTable from "@/components/TableHistory.vue";
import { useRoute, useRouter } from "vue-router";
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, changeManageCurrentTab } = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขแขวง/ตำบล"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const router = useRouter();
const route = useRoute();
const districtName = ref<string>("เขตพระนคร"); //
const provinceId = ref<string | string[]>(route.params.province); // Id
const districtId = ref<string | string[]>(route.params.district); // Id
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "แขวง/ตำบล",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "zipCode",
align: "left",
label: "รหัสไปรษณีย์",
sortable: true,
field: "zipCode",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.person.subDistrict.columns.length == 0
? (visibleColumns.value = [
"name",
"zipCode",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.person.subDistrict.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "แขวง/ตำบล",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "zipCode",
align: "left",
label: "รหัสไปรษณีย์",
sortable: true,
field: "zipCode",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"zipCode",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(1, "subDistrict", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async () => {
rows.value.splice(0);
showLoader();
await http
.get(
config.API.listSubDistrictHistoryProvinceId(
provinceId.value,
districtId.value
)
)
.then((res) => {
let data = res.data.result;
version.value = data.version; // published= draft=
idVersion.value = data.id; // id mongodb
districtName.value = data.districtName.result;
data.items.map((e: RequestItemsHistoryObject) => {
rows.value.push({
id: e.id,
name: e.name,
zipCode: e.zipCode,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
lastUpdateFullName: e.lastUpdateFullName,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateUserId: e.lastUpdateUserId,
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
updateData.value = false;
hideLoader();
});
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listSubDistrictPublishedHistory(districtId.value))
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
zipCode: i.zipCode,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listSubDistrictHistoryId(districtId.value))
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listProvincePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" &&
(f.name == "" || f.zipCode == "") // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
zipCode: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
zipCode: e.zipCode,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listSubDistrictHistoryId(idVersion.value), {
id: idVersion.value,
districtId: districtId.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* เชครหสไปรษณำกบขอมลทอยแล
* @param val input รหสไปรษณ
*/
const checkDupDataZipCode = (val: string) => {
const filterZipCodeNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.zipCode == val
); //
if (filterZipCodeNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData();
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
/**
* งกนยอนกลบไปหนาจดการขอมลหล
*/
const goToManage = () => {
changeManageCurrentTab(1, "person_province");
router.push("/metadata");
};
/**
* งกนยอนกลบไปหนาจดการเขต
*/
const goToProvince = () => {
router.push(`/metadata/province/${provinceId.value}`);
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,667 +0,0 @@
<!-- tab อตำแหนงทางการบรหาร หนาจดการขอมลหล/อมลตำแหนงของขาราชการกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/position/Executive";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/position/Executive";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionExecutive,
dataPositionExecutive,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขชื่อตำแหน่งทางการบริหาร"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ชื่อตำแหน่งทางการบริหาร",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.position.executive.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.position.executive.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ชื่อตำแหน่งทางการบริหาร",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(3, "executive", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionExecutive(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionExecutiveHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionExecutivePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionExecutiveHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionExecutivePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionExecutiveHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData();
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,706 +0,0 @@
<!-- tab านทางการบรหาร หนาจดการขอมลหล/อมลตำแหนงของขาราชการกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td key="note" :props="props" v-if="props.row.note !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.note"
dense
lazy-rules
autofocus
hide-bottom-space
></q-input>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/position/ExecutiveSide";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/position/ExecutiveSide";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionExecutiveSide,
dataPositionExecutiveSide,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขด้านทางการบริหาร"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ด้านทางการบริหาร",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.position.executiveSide.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
])
: (visibleColumns.value = manageData.position.executiveSide.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ด้านทางการบริหาร",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(3, "executiveSide", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionExecutiveSide(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionExecutiveSideHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// note: e.note,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionExecutiveSidePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
note: i.note,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionExecutiveSideHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionExecutiveSidePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
note: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionExecutiveSideHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData();
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,843 +0,0 @@
<!-- tab ระด หนาจดการขอมลหล/อมลตำแหนงของขาราชการกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td
key="level"
:props="props"
v-if="props.row.level !== undefined"
>
<div class="">
{{ props.row.level }}
</div>
</q-td>
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="shortName"
:props="props"
v-if="props.row.shortName !== undefined"
>
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.shortName"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataShortName(val) ||
'ชื่อย่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<div class="row">
<q-btn
:disable="props.row.level <= 1"
flat
dense
size="12px"
icon="mdi-menu-up"
style="
padding-top: 0em;
padding-right: 0.5em;
padding-bottom: 0em;
padding-left: 0.5em;
min-height: 0em;
"
@click="directionItem(props.row, 'up')"
/>
<q-btn
:disable="props.row.level >= rows.length"
flat
dense
size="12px"
icon="mdi-menu-down"
style="
padding-top: 0em;
padding-right: 0.5em;
padding-bottom: 0em;
padding-left: 0.5em;
min-height: 0em;
"
@click="directionItem(props.row, 'down')"
/>
</div>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/position/Level";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/position/Level";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getPositionLevel, dataPositionLevel } =
store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขระดับ"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "level",
align: "left",
label: "ลำดับ",
sortable: true,
field: "level",
headerStyle: "font-size: 14px; width:0px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "name",
align: "left",
label: "ระดับ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "shortName",
align: "left",
label: "ชื่อย่อ",
sortable: true,
field: "shortName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.position.level.columns.length == 0
? (visibleColumns.value = [
"level",
"name",
"shortName",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.position.level.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "level",
align: "left",
label: "ลำดับ",
sortable: true,
field: "level",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "name",
align: "left",
label: "ระดับ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "shortName",
align: "left",
label: "ชื่อย่อ",
sortable: true,
field: "shortName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"level",
"name",
"shortName",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(3, "level", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionLevel(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionLevelHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// level: e.level,
// name: e.name,
// shortName: e.shortName,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// rows.value.sort(
// (
// firstItem: RequestItemsHistoryObject,
// secondItem: RequestItemsHistoryObject
// ) => firstItem.level - secondItem.level
// );
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionLevelPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
level: i.level,
name: i.name,
shortName: i.shortName,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionLevelHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionLevelPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
level: rows.value[rows.value.length - 1].level + 1,
name: "",
shortName: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
level: e.level,
name: e.name,
shortName: e.shortName,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionLevelHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* เชคชอยอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataShortName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.shortName == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
/**
* ายลำด data
* @param row าใน row
* @param type ายตำแหนงแบบไหน up= down=ลง
*/
const directionItem = async (row: RequestItemsHistoryObject, type: string) => {
await clickEditRow();
if (type === "up") {
rows.value[
rows.value.findIndex((object: RequestItemsHistoryObject) => {
return object === row;
})
].level -= 1;
rows.value[
rows.value.findIndex((object: RequestItemsHistoryObject) => {
return object === row;
}) - 1
].level += 1;
} else {
rows.value[
rows.value.findIndex((object: RequestItemsHistoryObject) => {
return object === row;
})
].level += 1;
rows.value[
rows.value.findIndex((object: RequestItemsHistoryObject) => {
return object === row;
}) + 1
].level -= 1;
}
rows.value.sort(
(
firstItem: RequestItemsHistoryObject,
secondItem: RequestItemsHistoryObject
) => firstItem.level - secondItem.level
);
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,667 +0,0 @@
<!-- tab สายงาน หนาจดการขอมลหล/อมลตำแหนงของขาราชการกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/position/Line";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/position/Line";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getPositionLine, dataPositionLine } =
store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขสายงาน"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สายงาน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.position.line.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.position.line.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สายงาน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(3, "line", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionLine(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionLineHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionLinePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionLineHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionLinePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionLineHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,705 +0,0 @@
<!-- tab อตำแหน หนาจดการขอมลหล/อมลตำแหนงของขาราชการกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td key="note" :props="props" v-if="props.row.note !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.note"
dense
lazy-rules
autofocus
hide-bottom-space
></q-input>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/position/Path";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/position/Path";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getPositionPath, dataPositionPath } =
store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขชื่อตำแหน่ง"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ชื่อตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.position.path.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
])
: (visibleColumns.value = manageData.position.path.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ชื่อตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(3, "path", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionPath(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionPathHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// note: e.note,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionPathPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
note: i.note,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionPathHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData();
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionPathPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
note: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionPathHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,708 +0,0 @@
<!-- tab าน/สาขา หนาจดการขอมลหล/อมลตำแหนงของขาราชการกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td key="note" :props="props" v-if="props.row.note !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.note"
dense
lazy-rules
autofocus
hide-bottom-space
></q-input>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/position/PathSide";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/position/PathSide";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionPathSide,
dataPositionPathSide,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขด้าน/สาขา"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ด้าน/สาขา",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.position.pathSide.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
])
: (visibleColumns.value = manageData.position.pathSide.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ด้าน/สาขา",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(3, "pathSide", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionPathSide(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionSideHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// note: e.note,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionSidePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
note: i.note,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionSideHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionSidePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
note: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionSideHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,670 +0,0 @@
<!-- tab สถานะของตำแหน หนาจดการขอมลหล/อมลตำแหนงของขาราชการกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/position/Status";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/position/Status";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionStatus,
dataPositionStatus,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขสถานะของตำแหน่ง"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สถานะของตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.position.status.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.position.status.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สถานะของตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(3, "status", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionStatus(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionStatusHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionStatusPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionStatusHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionStatusPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionStatusHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,666 +0,0 @@
<!-- tab ประเภทตำแหน หนาจดการขอมลหล/อมลตำแหนงของขาราชการกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/position/Type";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/position/Type";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const { manageData, changeManageColumns, getPositionType, dataPositionType } =
store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขประเภทตำแหน่ง"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ประเภทตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.position.type.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.position.type.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ประเภทตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(3, "type", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionType(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionTypeHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionTypePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionTypeHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionTypePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionTypeHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,669 +0,0 @@
<!-- tab กลมงาน หนาจดการขอมลหล/อมลตำแหนงของลกจางกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/positionEmployee/Group";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/positionEmployee/Group";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionEmployeeGroup,
dataPositionEmployeeGroup,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขกลุ่มงาน"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "กลุ่มงาน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.positionEmployee.group.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.positionEmployee.group.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "กลุ่มงาน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(4, "group", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionEmployeeGroup(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionEmployeeGroupHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeeGroupPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionEmployeeGroupHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeeGroupPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionEmployeeGroupHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,669 +0,0 @@
<!-- tab ระดบชนงาน หนาจดการขอมลหล/อมลตำแหนงของลกจางกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/positionEmployee/Level";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/positionEmployee/Level";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionEmployeeLevel,
dataPositionEmployeeLevel,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขระดับชั้นงาน"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ระดับชั้นงาน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.positionEmployee.level.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.positionEmployee.level.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ระดับชั้นงาน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(4, "level", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionEmployeeLevel(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionEmployeeLevelHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeeLevelPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionEmployeeLevelHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeeLevelPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionEmployeeLevelHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,669 +0,0 @@
<!-- tab สายงาน หนาจดการขอมลหล/อมลตำแหนงของลกจางกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/positionEmployee/Line";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/positionEmployee/Line";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionEmployeeLine,
dataPositionEmployeeLine,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขสายงาน"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สายงาน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.positionEmployee.line.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.positionEmployee.line.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สายงาน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(4, "line", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionEmployeeLine(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionEmployeeLineHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeeLinePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionEmployeeLineHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeeLinePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionEmployeeLineHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,707 +0,0 @@
<!-- tab อตำแหน หนาจดการขอมลหล/อมลชอตำแหนงของลกจางกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td key="note" :props="props" v-if="props.row.note !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.note"
dense
lazy-rules
autofocus
hide-bottom-space
></q-input>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/positionEmployee/Position";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/positionEmployee/Position";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionEmployee,
dataPositionEmployee,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขชื่อตำแหน่ง"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ชื่อตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.positionEmployee.position.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
])
: (visibleColumns.value = manageData.positionEmployee.position.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ชื่อตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(4, "position", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionEmployee(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionEmployeePositionHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// note: e.note,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeePositionPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
note: i.note,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionEmployeePositionHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeePositionPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
note: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionEmployeePositionHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,711 +0,0 @@
<!-- tab านของตำแหน หนาจดการขอมลหล/อมลตำแหนงของลกจางกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td key="note" :props="props" v-if="props.row.note !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.note"
dense
lazy-rules
autofocus
hide-bottom-space
></q-input>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/positionEmployee/PositionSide";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/positionEmployee/PositionSide";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionEmployeeSide,
dataPositionEmployeeSide,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขด้านของตำแหน่ง"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ด้านของตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.positionEmployee.positionSide.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
])
: (visibleColumns.value = manageData.positionEmployee.positionSide.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ด้านของตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
"note",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(4, "positionSide", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionEmployeeSide(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionEmployeePositionSideHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// note: e.note,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeePositionSidePublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
note: i.note,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionEmployeePositionSideHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeePositionSidePublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
note: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(
config.API.listPositionEmployeePositionSideHistoryId(idVersion.value),
{
id: idVersion.value,
version: "draft",
items: rows.value,
}
)
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData();
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,669 +0,0 @@
<!-- tab สถานะของตำแหน หนาจดการขอมลหล/อมลตำแหนงของลกจางกรงเทพมหานคร -->
<template>
<div>
<q-form ref="myForm">
<data-table
:rows="rows"
:columns="columns"
:filter="filter"
:visible-columns="visibleColumns"
v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns"
v-model:editvisible="edit"
:add="clickAdd"
:edit="clickEdit"
:save="clickSave"
:deleted="clickDelete"
:cancel="clickCancel"
:publish="clickPublish"
:validate="validateData"
:publicData="version === 'published'"
:updateData="updateData"
:history="true"
>
<template #columns="props">
<q-tr :props="props" v-if="edit == false">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon
v-else
name="mdi-check"
color="positive"
class="text-h5"
/>
</div>
<div v-else-if="col.name == 'createdAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
<q-tr :props="props" v-if="edit == true">
<q-td key="name" :props="props" v-if="props.row.name !== undefined">
<q-input
class=""
outlined
@update:model-value="clickEditRow"
v-model="props.row.name"
dense
lazy-rules
autofocus
hide-bottom-space
:rules="[
(val) => (val && val.length > 0) || 'กรุณากรอกข้อมูลให้ครบ',
(val) =>
checkDupDataName(val) || 'ชื่อซ้ำกันกับข้อมูลที่มีอยู่แล้ว',
]"
></q-input>
</q-td>
<q-td
key="createdAt"
:props="props"
v-if="props.row.createdAt !== undefined"
>
<div class="">
{{ textDate(props.row.createdAt) }}
</div>
</q-td>
<q-td key="lastUpdatedAt" :props="props">
<div class="">
{{ textDate(props.row.lastUpdatedAt) }}
</div>
</q-td>
<q-td
key="lastUpdateFullName"
:props="props"
v-if="props.row.lastUpdateFullName !== undefined"
class=""
>
{{ props.row.lastUpdateFullName }}
</q-td>
<q-td
key="isActive"
:props="props"
v-if="props.row.isActive !== undefined"
>
<q-toggle
v-model="props.row.isActive"
dense
size="34px"
color="positive"
@update:model-value="clickEditRow"
/>
</q-td>
<q-td auto-width>
<q-btn
v-if="props.row.id === '00000000-0000-0000-0000-000000000000'"
color="red"
flat
dense
round
size="14px"
icon="mdi-trash-can-outline"
@click="clickDeleteRow(props.row)"
/>
<q-btn
v-if="props.row.id !== '00000000-0000-0000-0000-000000000000'"
color="info"
flat
dense
round
size="14px"
icon="mdi-history"
@click="clickHistory(props.row)"
/>
</q-td>
</q-tr>
</template>
</data-table>
</q-form>
</div>
<HistoryTable
:rows="rowsHistory"
:columns="columnsHistory"
:filter="filterHistory"
:visible-columns="visibleColumnsHistory"
v-model:modal="modalHistory"
v-model:inputfilter="filterHistory"
v-model:inputvisible="visibleColumnsHistory"
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'isActive'" class="">
<q-icon
v-if="col.value == false"
name="mdi-close"
color="red"
class="text-h5"
/>
<q-icon v-else name="mdi-check" color="positive" class="text-h5" />
</div>
<div v-else-if="col.name == 'lastUpdatedAt'" class="">
{{ textDate(col.value) }}
</div>
<div v-else class="">
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</HistoryTable>
</template>
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { onMounted, ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
import type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
} from "@/modules/01_metadata/interface/request/positionEmployee/Status";
import type { ResponseHistoryObject } from "@/modules/01_metadata/interface/response/positionEmployee/Status";
import HistoryTable from "@/components/TableHistory.vue";
const props = defineProps({
fetchDataComponent: {
type: Function,
default: () => console.log("not function"),
},
});
const mixin = useCounterMixin();
const { success, dateText, messageError, showLoader, hideLoader } = mixin;
const store = useManageDataStore();
const {
manageData,
changeManageColumns,
getPositionEmployeeStatus,
dataPositionEmployeeStatus,
} = store;
const rows = ref<RequestItemsHistoryObject[]>([]); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history
const rawHistory = ref<RequestItemsHistoryObject[]>([]); //raw data history
const tittleHistory = ref<string>("ประวัติแก้ไขสถานะของตำแหน่ง"); //
const myForm = ref<any>(null); //ref
const filter = ref<string>(""); //search data table
const filterHistory = ref<string>(""); //search data table history
const modalHistory = ref<boolean>(false); //modal
const edit = ref<boolean>(false); //
const idVersion = ref<string>(""); //id data mongodb
const version = ref<string>("published"); // published= draft=
const updateData = ref<boolean>(false); //
const checkValidate = ref<boolean>(false);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สถานะของตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "createdAt",
align: "center",
label: "วันที่สร้าง",
sortable: true,
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<String[]>([]);
manageData.positionEmployee.status.columns.length == 0
? (visibleColumns.value = [
"name",
"createdAt",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
])
: (visibleColumns.value = manageData.positionEmployee.status.columns);
const columnsHistory = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "สถานะของตำแหน่ง",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdatedAt",
align: "center",
label: "วันที่แก้ไข",
sortable: true,
field: "lastUpdatedAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "lastUpdateFullName",
align: "left",
label: "ผู้ดำเนินการ",
sortable: true,
field: "lastUpdateFullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "isActive",
align: "left",
label: "สถานะ",
sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumnsHistory = ref<String[]>([
"name",
"lastUpdatedAt",
"lastUpdateFullName",
"isActive",
]);
/**
* เมอเขาหนานจะเรยกฟงชนนอน(get list data)
*/
onMounted(async () => {
await fetchData();
await fetchHistory();
});
watch(visibleColumns, async (count: String[], prevCount: String[]) => {
await changeManageColumns(4, "status", count);
});
/**
* แจงเตอนขอมลในกรณ success
*/
const $q = useQuasar();
/**
* งก get data าส
*/
const fetchData = async (load: boolean = false) => {
await props.fetchDataComponent();
const result = await getPositionEmployeeStatus(false, load);
version.value = result.version; // published= draft=
idVersion.value = result.idversion; // id mongodb
rows.value = result.data;
updateData.value = false;
// rows.value.splice(0);
// showLoader();
// await http
// .get(config.API.listPositionEmployeeStatusHistory)
// .then((res) => {
// let data = res.data.result;
// version.value = data.version; // published= draft=
// idVersion.value = data.id; // id mongodb
// data.items.map((e: RequestItemsHistoryObject) => {
// rows.value.push({
// id: e.id,
// name: e.name,
// createdAt: e.createdAt,
// lastUpdatedAt: e.lastUpdatedAt,
// lastUpdateFullName: e.lastUpdateFullName,
// isActive: e.isActive,
// createdFullName: e.createdFullName,
// createdUserId: e.createdUserId,
// lastUpdateUserId: e.lastUpdateUserId,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// updateData.value = false;
// hideLoader();
// });
};
/**
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeeStatusPublishedHistory)
.then((res) => {
const data = res.data.result;
rawHistory.value = [];
if (data.length > 0) {
data.map((e: RequestItemsPublishHistoryObject) => {
e.items.map((i: RequestItemsHistoryObject) => {
rawHistory.value.push({
createdAt: i.createdAt,
createdFullName: i.createdFullName,
createdUserId: i.createdUserId,
id: i.id,
isActive: i.isActive,
lastUpdateFullName: i.lastUpdateFullName,
lastUpdateUserId: i.lastUpdateUserId,
lastUpdatedAt: i.lastUpdatedAt,
name: i.name,
});
});
});
}
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
};
/**
* งก clear data แบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
showLoader();
await http
.delete(config.API.listPositionEmployeeStatusHistory)
.then((res) => {
success($q, "ลบข้อมูลร่างสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchHistory();
await fetchData(true);
});
};
/**
* งกนเผยแพรแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const publishedData = async () => {
showLoader();
await http
.get(config.API.listPositionEmployeeStatusPublished)
.then((res) => {
success($q, "เผยแพร่ข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(true);
});
};
/**
* งกนเพมขอม
*/
const clickAdd = async () => {
const filterRowNull = rows.value.filter(
(f: RequestItemsHistoryObject) =>
f.id === "00000000-0000-0000-0000-000000000000" && f.name == "" // array
);
if (filterRowNull.length == 0) {
//
rows.value.push({
createdAt: new Date(),
createdFullName: "",
createdUserId: "",
id: "00000000-0000-0000-0000-000000000000",
isActive: true,
lastUpdateFullName:
keycloak.tokenParsed == null ? "" : keycloak.tokenParsed.name,
lastUpdateUserId: "",
lastUpdatedAt: new Date(),
name: "",
});
updateData.value = true;
}
};
/**
* งกนบนทกแบบราง
* เมอเรยก api เสรจแลวจะ get data มาใหม
* publish เมอบนทกแบบรางแลวจะเผยแพรเลยไหม true=นทกและเผยแพร false=นทกอยางเดยว
*/
const save = async (publish: boolean) => {
await validateData();
if (checkValidate.value == false) return;
rows.value.map((e: ResponseHistoryObject) => ({
// data backend
id: e.id,
createdAt: e.createdAt,
lastUpdatedAt: e.lastUpdatedAt,
name: e.name,
isActive: e.isActive,
createdFullName: e.createdFullName,
createdUserId: e.createdUserId,
lastUpdateFullName: e.lastUpdateFullName,
lastUpdateUserId: e.lastUpdateUserId,
}));
showLoader();
await http
.post(config.API.listPositionEmployeeStatusHistoryId(idVersion.value), {
id: idVersion.value,
version: "draft",
items: rows.value,
})
.then(async (res) => {
if (publish === false) {
success($q, "บันทึกข้อมูลร่างสำเร็จ");
await fetchData(); // get data
} else {
await publishedData(); //
}
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
await fetchData(true);
});
};
/**
* เชคชอซำกบขอมลทอยแล
* @param val input
*/
const checkDupDataName = (val: string) => {
const filterNameNull = rows.value.filter(
(f: RequestItemsHistoryObject) => f.name == val
); //
if (filterNameNull.length > 1) {
return false;
}
return true;
};
/**
* งกนปมแกไข ให get data มาใหม
*/
const clickEdit = async () => {
await fetchData(true);
};
/**
* งกนปมบนทกแบบราง
*/
const clickSave = async () => {
await save(false);
await fetchData(true);
};
/**
* งกนปมลบแบบราง
*/
const clickDelete = async () => {
await clearPublishedData();
await fetchData(true);
};
/**
* งกนปมยกเลกการแกไขขอม
*/
const clickCancel = async () => {
edit.value = false;
await fetchData(true);
};
/**
* งกนปมเผยแพรอม
* เชคขอมลกอนวาใน array กรอกขอมลครบไหมถาครบกใหเผยแพรได
* าคาใน array ไมอมลใน row จะใหนทกได
*/
const clickPublish = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
await save(true);
}
});
} else {
await save(true);
}
};
/**
* งกนปมลบ row data
* @param val data ใน row จะลบ
*/
const clickDeleteRow = (val: RequestItemsHistoryObject) => {
rows.value = rows.value.filter((x: RequestItemsHistoryObject) => x !== val);
updateData.value = true;
};
/**
* งกนเช input ามการแกไขหรอย
*/
const clickEditRow = () => {
myForm.value.validate(false);
updateData.value = true;
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsHistoryObject) => {
modalHistory.value = true;
rowsHistory.value = rawHistory.value.filter(
(f: RequestItemsHistoryObject) => f.id == row.id
);
};
/**
* งกนแปลง date เปนภาษาไทย
* @param value นท type datetime จะแปลงเปนไทย
*/
const textDate = (value: Date) => {
return dateText(value);
};
/**
* validate component
*/
const validateData = async () => {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
</script>
<style>
/* สีของnoti */
.my-notif-class {
background: rgba(33, 186, 69, 0.5) !important;
color: #008f17 !important;
}
</style>

View file

@ -1,10 +0,0 @@
interface Pagination {
rowsPerPage: number;
}
interface DataOption {
id: string;
name: string;
}
export type { Pagination, DataOption };

View file

@ -1,77 +0,0 @@
interface DataNumObject {
id: number;
count: number;
name: string;
color: string;
}
interface DataDateAddObject {
year: number;
holidayDate: Date | string;
name: string;
isSpecial: boolean;
}
interface DataDateMonthObject {
month: number;
year: number;
}
//ข้อมูล
interface RequestItemsObject {
createdAt?: Date;
createdFullName: string;
createdUserId: string;
holidayDate: Date | string;
id: string;
isSpecial: boolean;
lastUpdateFullName: string;
lastUpdateUserId: string;
lastUpdatedAt?: Date;
name: string;
originalDate: Date;
}
interface DataDateRowObject {
holidayDate: Date;
name: string;
isSpecial: boolean;
id: string;
}
interface DataDateListsObject {
id: string;
dateRange: [Date, Date];
dataRangeRow: DataDateRowObject[];
detail: string;
isSpecial: boolean;
}
//columns
interface Columns {
[index: number]: {
name: string;
align?: string;
label: string;
sortable?: boolean;
field: string | ((row: any) => any);
headerStyle?: string;
style?: string;
};
}
interface TabsObject {
label: string;
value: string;
}
export type {
DataNumObject,
DataDateAddObject,
DataDateMonthObject,
RequestItemsObject,
DataDateRowObject,
DataDateListsObject,
Columns,
TabsObject,
};

View file

@ -1,14 +0,0 @@
interface DataSumCalendarObject {
id: number;
monthFull: String;
count: number;
color: String;
}
interface DataListsObject {
id: number;
count: number;
name: string;
}
export type { DataSumCalendarObject, DataListsObject };

View file

@ -1,39 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
shortName: String;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,42 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
level: number;
name: string;
shortName: String;
insigniaType?: any;
note: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,39 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
note: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,41 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
agencyCode: String;
governmentCode: String;
name: string;
note: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,47 +0,0 @@
import type { StringifyOptions } from "querystring";
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
//ข้อมูลประวัติแก้ไข
interface ResponseHistoryObject {
createdFullName: String;
lastUpdateFullName: String;
name: String;
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,39 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
zipCode: String;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,39 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
note: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,40 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
level: number;
name: string;
shortName: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,39 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
note: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,39 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
note: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,39 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
note: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,39 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
note: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,38 +0,0 @@
//ข้อมูลประวัติแก้ไข
interface RequestItemsPublishHistoryObject {
id: string;
items: RequestItemsHistoryObject[];
publishedDate: string;
}
//ข้อมูล
interface RequestItemsHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type {
RequestItemsHistoryObject,
RequestItemsPublishHistoryObject,
Columns,
};

View file

@ -1,18 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
level: number;
name: String;
shortName: String;
insigniaType?: any;
note: string;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,15 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
note: string;
}
export type { ResponseHistoryObject };

View file

@ -1,17 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
agencyCode: String;
governmentCode: String;
name: String;
note: string;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,14 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
}
export type { ResponseHistoryObject };

View file

@ -1,15 +0,0 @@
//ข้อมูล
interface ResponseHistoryObject {
createdAt?: Date;
createdFullName: String;
createdUserId: String;
id: String;
isActive: Boolean;
lastUpdateFullName: String;
lastUpdateUserId: String;
lastUpdatedAt?: Date;
name: String;
zipCode: String;
}
export type { ResponseHistoryObject };

Some files were not shown because too many files have changed in this diff Show more