Merge branch 'develop' into devTee

This commit is contained in:
setthawutttty 2024-03-19 12:27:07 +07:00
commit a5c9952eb0
7 changed files with 380 additions and 469 deletions

View file

@ -4,7 +4,7 @@ import { useRoute } from "vue-router";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { QTableProps, QForm } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import HistoryTable from "@/components/TableHistory.vue";
@ -13,13 +13,17 @@ import type {
DataOption,
DataOptionInsignia,
InsigniaOps,
Pagination,
} from "@/modules/04_registryNew/interface/index/Main";
import type {
RequestItemsObject,
Columns,
DataProps,
FormData,
} from "@/modules/04_registryNew/interface/request/Insignia";
import type {
ResponseObject,
ResponseInsigniaObject,
ResponseInsigniaType,
} from "@/modules/04_registryNew/interface/response/Insignia";
import type { ResponseObject as Insignia } from "@/modules/07_insignia/interface/response/Main";
const $q = useQuasar();
const route = useRoute();
@ -27,35 +31,17 @@ const mixin = useCounterMixin();
const {
date2Thai,
success,
dateToISO,
messageError,
typeChangeName,
dialogMessage,
showLoader,
hideLoader,
messageError,
dialogConfirm,
dialogRemove,
} = mixin;
const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const insigniaData = reactive<{
id: string;
isActive: boolean;
year: number | null;
receiveDate: Date | string | null;
insigniaId: string;
insigniaType: string;
no: string;
issue: string;
volumeNo: string;
volume: string;
section: string;
page: string;
dateAnnounce: Date | null | string;
refCommandNo: string;
refCommandDate: Date | null | string;
note: string;
}>({
const insigniaData = reactive<FormData>({
id: "",
isActive: true,
year: 0,
@ -75,7 +61,7 @@ const insigniaData = reactive<{
});
const editRow = ref<boolean>(false);
const myForm = ref<any>();
const myForm = ref<QForm>();
const isEdit = ref<boolean>(false);
const modal = ref<boolean>(false);
const modeView = ref<string>("table");
@ -92,7 +78,7 @@ const OpsFilter = ref<InsigniaOps>({
insigniaOptions: [],
});
const rows = ref<any>([]);
const rows = ref<ResponseObject[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "year",
@ -102,6 +88,7 @@ const columns = ref<QTableProps["columns"]>([
field: "year",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => v + 543,
},
{
name: "receiveDate",
@ -111,6 +98,7 @@ const columns = ref<QTableProps["columns"]>([
field: "receiveDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -122,6 +110,7 @@ const columns = ref<QTableProps["columns"]>([
field: "insigniaId",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => Ops.value.insigniaOptions.find((r) => r.id === v)?.name,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -130,9 +119,10 @@ const columns = ref<QTableProps["columns"]>([
align: "left",
label: "ลำดับชั้น",
sortable: true,
field: "insigniaType",
field: "insignia",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => v.name,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -210,6 +200,7 @@ const columns = ref<QTableProps["columns"]>([
field: "dateAnnounce",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -232,6 +223,7 @@ const columns = ref<QTableProps["columns"]>([
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -256,8 +248,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "year",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
format: (v) => v + 543,
},
{
name: "receiveDate",
@ -267,6 +258,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "receiveDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -275,9 +267,10 @@ const columnsHistory = ref<QTableProps["columns"]>([
align: "left",
label: "ชื่อเครื่องราชฯ",
sortable: true,
field: "insignia",
field: "insigniaId",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => Ops.value.insigniaOptions.find((r) => r.id === v)?.name,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -286,9 +279,10 @@ const columnsHistory = ref<QTableProps["columns"]>([
align: "left",
label: "ลำดับชั้น",
sortable: true,
field: "insigniaType",
field: "insignia",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => v.name,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -366,6 +360,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "dateAnnounce",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -388,6 +383,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -410,6 +406,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "createdAt",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -449,220 +446,110 @@ const visibleColumnsHistory = ref<String[]>([
"createdAt",
]);
const formFilter = reactive({
page: 1,
pageSize: 10,
keyword: "",
});
const pagination = ref({
page: formFilter.page,
rowsPerPage: formFilter.pageSize,
});
async function fetchData() {
if (profileId.value) {
showLoader();
await http
.get(config.API.profileNewInsignByProfileId(profileId.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
data.map((e: any) => {
rows.value.push({
id: e.id,
insigniaId: e.insigniaId,
insigniaType: e.insigniaType,
year: e.year,
no: e.no,
issue: e.issue,
volumeNo: e.volumeNo,
volume: e.volume,
section: e.section,
page: e.page,
receiveDate: e.receiveDate,
dateAnnounce: e.dateAnnounce,
refCommandNo: e.refCommandNo,
refCommandDate: e.refCommandDate,
createdFullName: e.createdFullName,
createdAt: e.createdAt,
note: e.note,
});
});
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
// store.isLoad++;
});
if (!profileId.value) return;
showLoader();
try {
const res = await http.get(
config.API.profileNewInsignByProfileId(profileId.value)
);
console.log(res.data.result);
rows.value = res.data.result;
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}
async function fetchInsignia() {
showLoader();
await http
.get(config.API.insignia)
.then((res) => {
const data = res.data.result;
let option: DataOptionInsignia[] = [];
data.map((r: any) => {
option.push({
id: r.id.toString(),
name: r.name.toString() + ` (${r.shortName})`,
typeName:
r.insigniaType == null ? null : r.insigniaType.name.toString(),
});
});
Ops.value.insigniaOptions = option;
OpsFilter.value.insigniaOptions = option;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
// store.isLoad++;
});
}
try {
const res = await http.get(config.API.insigniaOrg);
async function saveData() {
if (profileId.value) {
showLoader();
await http
.post(config.API.profileNewInsign, {
profileId: profileId.value,
isActive: insigniaData.isActive,
year: insigniaData.year,
no: insigniaData.no,
volume: insigniaData.volume,
section: insigniaData.section,
page: insigniaData.page,
receiveDate: dateToISO(insigniaData.receiveDate as Date),
insigniaId: insigniaData.insigniaId,
insigniaType: insigniaData.insigniaType,
dateAnnounce: insigniaData.dateAnnounce
? dateToISO(insigniaData.dateAnnounce as Date)
: null,
issue: insigniaData.issue,
volumeNo: insigniaData.volumeNo,
refCommandDate:
insigniaData.refCommandDate == null
? null
: dateToISO(insigniaData.refCommandDate as Date),
refCommandNo: insigniaData.refCommandNo,
// note: note.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
const data = res.data.result;
let option: DataOptionInsignia[] = [];
data.map((r: Insignia) => {
option.push({
id: r.id.toString(),
name: r.name.toString() + ` (${r.shortName})`,
typeName: r.insigniaTypeName.toString(),
});
});
Ops.value.insigniaOptions = option;
OpsFilter.value.insigniaOptions = option;
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}
async function editData() {
showLoader();
await http
.patch(config.API.profileNewInsignById(insigniaData.id), {
profileId: profileId.value,
isActive: insigniaData.isActive,
year: insigniaData.year,
no: insigniaData.no,
volume: insigniaData.volume,
section: insigniaData.section,
page: insigniaData.page,
receiveDate: dateToISO(insigniaData.receiveDate as Date),
insigniaId: insigniaData.insigniaId,
insigniaType: insigniaData.insigniaType,
dateAnnounce: insigniaData.dateAnnounce
? dateToISO(insigniaData.dateAnnounce as Date)
: null,
issue: insigniaData.issue,
volumeNo: insigniaData.volumeNo,
refCommandDate:
insigniaData.refCommandDate == null
? null
: dateToISO(insigniaData.refCommandDate as Date),
refCommandNo: insigniaData.refCommandNo,
// note: note.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
async function addEditData(editStatus: boolean = false) {
if (!profileId.value) return;
const url = editStatus
? config.API.profileNewInsignById(insigniaData.id)
: config.API.profileNewInsign;
const method = editStatus ? "patch" : "post";
const reqBody: RequestItemsObject = {
profileId: profileId.value,
isActive: insigniaData.isActive,
year: insigniaData.year,
no: insigniaData.no,
volume: insigniaData.volume,
section: insigniaData.section,
page: insigniaData.page,
receiveDate: insigniaData.receiveDate,
insigniaId: insigniaData.insigniaId,
dateAnnounce: insigniaData.dateAnnounce,
issue: insigniaData.issue,
volumeNo: insigniaData.volumeNo,
refCommandDate: insigniaData.refCommandDate,
refCommandNo: insigniaData.refCommandNo,
note: insigniaData.note,
};
try {
await http[method](url, reqBody);
success($q, "บันทึกข้อมูลสำเร็จ");
await fetchData();
} catch (e) {
messageError($q, e);
} finally {
hideLoader();
}
}
async function clickDelete(dataId: string) {
$q.dialog({
title: `ลบข้อมูล`,
message: `ต้องการทำการลบข้อมูลนี้ใช่หรือไม่?`,
cancel: "ยกเลิก",
ok: "ยืนยัน",
persistent: true,
})
.onOk(async () => {
showLoader();
await http
.delete(config.API.profileNewInsignById(dataId))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
modal.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData();
});
})
.onCancel(async () => {
await fetchData();
});
try {
await http.delete(config.API.profileNewInsignById(dataId));
success($q, "ลบข้อมูลสำเร็จ");
await fetchData();
modal.value = false;
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}
function onClickOpenDialog(editStatus: boolean = false, props?: any) {
function onClickOpenDialog(editStatus: boolean = false, row?: ResponseObject) {
modal.value = true;
editRow.value = false;
isEdit.value = editStatus;
if (editStatus && props) {
isEdit.value = editStatus;
insigniaData.id = props.row.id;
insigniaData.year = props.row.year == 0 ? 0 : props.row.year;
insigniaData.receiveDate = props.row.receiveDate;
insigniaData.insigniaId = props.row.insigniaId;
insigniaData.insigniaType = props.row.insigniaType;
insigniaData.no = props.row.no;
insigniaData.issue = props.row.issue;
insigniaData.volumeNo = props.row.volumeNo;
insigniaData.volume = props.row.volume;
insigniaData.section = props.row.section;
insigniaData.page = props.row.page;
insigniaData.dateAnnounce =
props.row.dateAnnounce == "-" ? "" : props.row.dateAnnounce;
insigniaData.refCommandNo = props.row.refCommandNo;
insigniaData.refCommandDate =
props.row.refCommandDate == "-" ? null : props.row.refCommandDate;
insigniaData.note = props.note;
if (editStatus && row) {
Object.assign(insigniaData, row);
insigniaData.year = row.year == 0 ? 0 : row.year;
insigniaData.dateAnnounce = row.dateAnnounce as Date;
insigniaData.refCommandDate = row.refCommandDate as Date;
} else {
isEdit.value = editStatus;
insigniaData.id = "";
insigniaData.year = 0;
insigniaData.receiveDate = "";
insigniaData.receiveDate = null;
insigniaData.insigniaId = "";
insigniaData.insigniaType = "";
insigniaData.no = "";
@ -689,65 +576,44 @@ async function clickClose() {
}).onOk(async () => {
modal.value = false;
editRow.value = false;
// next.value = false;
// previous.value = false;
});
} else {
modal.value = false;
// next.value = false;
// previous.value = false;
}
}
async function clickHistory(row: RequestItemsObject) {
async function clickHistory(row: ResponseObject) {
modalHistory.value = true;
// showLoader();
// await http
// .get(config.API.profileInsignHisId(row.id))
// .then((res) => {
// let data = res.data.result;
// rowsHistory.value = [];
// data.map((e: ResponseObject) => {
// rowsHistory.value.push({
// id: e.id,
// insignia: e.insignia,
// insigniaId: e.insigniaId,
// insigniaType: e.insigniaType,
// year: e.year,
// no: e.no,
// issue: e.issue,
// volumeNo: e.volumeNo,
// volume: e.volume,
// section: e.section,
// page: e.page,
// receiveDate: new Date(e.receiveDate),
// dateAnnounce: new Date(e.dateAnnounce),
// refCommandNo: e.refCommandNo,
// refCommandDate:
// e.refCommandDate == null ? null : new Date(e.refCommandDate),
// createdFullName: e.createdFullName,
// createdAt: new Date(e.createdAt),
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
filterSearch.value = "";
showLoader();
try {
const res = await http.get(config.API.profileNewInsignHisById(row.id));
rowsHistory.value = res.data.result;
} catch (e) {
messageError($q, e);
} finally {
hideLoader();
}
}
function onSubmit() {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
isEdit.value ? await editData() : await saveData();
modal.value = false;
}
});
dialogConfirm(
$q,
async () => {
myForm.value?.validate().then(async (result: boolean) => {
if (result) {
addEditData(isEdit.value);
modal.value = false;
}
});
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
function filterSelector(val: any, update: Function, refData: string) {
function filterSelector(val: string, update: Function, refData: string) {
switch (refData) {
case "insigniaOptions":
update(() => {
@ -763,7 +629,7 @@ function filterSelector(val: any, update: Function, refData: string) {
watch(
() => insigniaData.insigniaId,
(count: string, prevCount: string) => {
() => {
const insigniaTypeFilter = Ops.value.insigniaOptions.filter(
(r: DataOptionInsignia) => r.id === insigniaData.insigniaId
);
@ -875,34 +741,24 @@ onMounted(async () => {
class="cursor-pointer"
:key="col.name"
:props="props"
@click="onClickOpenDialog(true, props)"
>
<div
v-if="
col.name == 'receiveDate' ||
col.name == 'dateAnnounce' ||
col.name == 'refCommandDate'
"
class="table_ellipsis"
>
{{ col.value == null ? "-" : date2Thai(col.value) }}
</div>
<div v-else-if="col.name == 'year'" class="table_ellipsis">
{{ col.value + 543 }}
</div>
<div v-else-if="col.name == 'insignia'" class="table_ellipsis">
{{
col.value
? (Ops.insigniaOptions.find((r) => r.id === col.value) || {})
.name
: "-"
}}
</div>
<div v-else class="table_ellipsis">
<div class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td auto-width>
<q-btn
flat
dense
round
class="q-mr-xs"
size="14px"
color="primary"
icon="edit"
@click="onClickOpenDialog(true, props.row)"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
<q-btn
flat
dense
@ -914,17 +770,19 @@ onMounted(async () => {
>
<q-tooltip>ประวแกไขเครองราชอสรยาภรณ</q-tooltip>
</q-btn>
<q-btn
<!-- <q-btn
flat
dense
round
size="14px"
color="red"
icon="mdi-delete"
@click="clickDelete(props.row.id)"
@click="
dialogRemove($q, async () => await clickDelete(props.row.id))
"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-btn> -->
</q-td>
</q-tr>
</template>
@ -940,7 +798,7 @@ onMounted(async () => {
round
color="primary"
icon="mdi-pencil-outline"
@click="onClickOpenDialog(true, props)"
@click="onClickOpenDialog(true, props.row)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
@ -968,32 +826,7 @@ onMounted(async () => {
</q-item-section>
<q-item-section class="text-dark">
<q-item-label
v-if="
col.name == 'receiveDate' ||
col.name == 'dateAnnounce' ||
col.name == 'refCommandDate'
"
>
{{ col.value ? date2Thai(col.value) : "-" }}
</q-item-label>
<q-item-label v-else-if="col.name == 'year'">
{{ col.value + 543 }}
</q-item-label>
<q-item-label
v-else-if="col.name == 'insignia'"
class="table_ellipsis"
>
{{
col.value
? (
Ops.insigniaOptions.find((r) => r.id === col.value) ||
{}
).name
: "-"
}}
</q-item-label>
<q-item-label v-else>
<q-item-label>
{{ col.value ? col.value : "-" }}
</q-item-label>
</q-item-section>
@ -1113,7 +946,7 @@ onMounted(async () => {
:label="`${'ชื่อเครื่องราชฯ'}`"
:options="Ops.insigniaOptions"
:rules="[(val:string) => !!val || `${'กรุณาเลือกชื่อเครื่องราชฯ'}`]"
@filter="(inputValue:any,
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'insigniaOptions'
) "
@update:modelValue="() => (editRow = true)"
@ -1289,7 +1122,7 @@ onMounted(async () => {
:model-value="
date2Thai(insigniaData.refCommandDate as Date)
"
@clear="insigniaData.refCommandDate = ''"
@clear="insigniaData.refCommandDate = null"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
@ -1347,21 +1180,7 @@ onMounted(async () => {
<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 == 'receiveDate' ||
col.name == 'dateAnnounce' ||
col.name == 'createdAt' ||
col.name == 'refCommandDate'
"
class="table_ellipsis"
>
{{ col.value ? date2Thai(col.value) : "-" }}
</div>
<div v-else-if="col.name == 'year'" class="table_ellipsis">
{{ col.value ? col.value + 543 : "-" }}
</div>
<div v-else class="table_ellipsis">
<div class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>
</q-td>

View file

@ -1,10 +1,11 @@
<script setup lang="ts">
import { ref, reactive, watch, onMounted } from "vue";
import moment from "moment";
import dialogHeader from "@/components/DialogHeader.vue";
import type { QTableProps } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useRoute } from "vue-router";
import type { RequestItemsObject } from "@/modules/04_registryNew/interface/request/Education";
import type { ResponseObject } from "@/modules/04_registryNew/interface/response/Education";
import { QForm, useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
@ -52,7 +53,10 @@ const columns = ref<QTableProps["columns"]>([
align: "left",
label: "ตั้งแต่",
sortable: true,
field: "startDate",
field: (v) =>
v.isDate
? date2Thai(v.startDate)
: new Date(v.startDate).getFullYear() + 543,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -63,7 +67,8 @@ const columns = ref<QTableProps["columns"]>([
align: "left",
label: "ถึง",
sortable: true,
field: "endDate",
field: (v) =>
v.isDate ? date2Thai(v.endDate) : new Date(v.endDate).getFullYear() + 543,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -75,6 +80,7 @@ const columns = ref<QTableProps["columns"]>([
label: "วันที่สำเร็จการศึกษา",
sortable: true,
field: "finishDate",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -88,6 +94,7 @@ const columns = ref<QTableProps["columns"]>([
field: "isEducation",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => (v === true ? "ใช่" : "ไม่ใช่"),
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -192,8 +199,8 @@ const columns = ref<QTableProps["columns"]>([
},
]);
const rows = ref<any>([]);
const historyRows = ref<any>([]);
const rows = ref<ResponseObject[]>([]);
const historyRows = ref<ResponseObject[]>([]);
const editId = ref<string>("");
const route = useRoute();
const id = ref<string>(route.params.id.toString());
@ -205,25 +212,7 @@ const educationOption = ref([
]);
const historyDialog = ref<boolean>(false);
const educationData = reactive<{
educationLevel: string;
institute: string;
startYear: number;
endYear: number;
finishDate: Date;
startDate: Date;
endDate: Date;
isEducation: boolean | null;
degree: string;
field: string;
fundName: string;
gpa: string;
country: string;
other: string;
duration: string;
durationYear: number | null;
note: string;
}>({
const educationData = reactive<RequestItemsObject>({
educationLevel: "",
institute: "",
startYear: new Date().getFullYear(),
@ -351,7 +340,6 @@ async function fetchData(id: string) {
.get(config.API.profileNewEducationByProfileId(id))
.then(async (res) => {
rows.value = res.data.result;
console.log(rows.value);
})
.catch((err) => {
messageError($q, err);
@ -360,13 +348,13 @@ async function fetchData(id: string) {
hideLoader();
});
}
async function fetchHistoryData(id: string) {
showLoader();
await http
.get(config.API.profileNewEducationHisByEducationId(id))
.then(async (res) => {
historyRows.value = res.data.result;
console.log(historyRows.value);
})
.catch((err) => {
messageError($q, err);
@ -377,7 +365,6 @@ async function fetchHistoryData(id: string) {
}
async function addData() {
console.log(educationData.durationYear);
await http
.post(config.API.profileNewEducation, {
profileId: id.value,
@ -467,7 +454,6 @@ watch(
() => isDate.value,
() => {
if (isDate.value === "false") {
console.log(educationData.startDate);
educationData.startYear = +educationData.startDate
.toString()
.slice(11, 15);
@ -628,52 +614,49 @@ onMounted(async () => {
</template>
<template v-slot:body="props" v-if="mode === 'table'">
<q-tr :props="props" class="cursor-pointer">
<q-td
v-for="col in props.cols"
:key="col.id"
@click="
() => {
dialogStatus = 'edit';
editId = props.row.id;
isDate = props.row.isDate ? 'true' : 'false';
educationData.educationLevel = props.row.educationLevel;
educationData.institute = props.row.institute;
educationData.finishDate = props.row.finishDate;
educationData.startDate = props.row.startDate;
educationData.endDate = props.row.endDate;
educationData.isEducation = props.row.isEducation;
educationData.degree = props.row.degree;
educationData.field = props.row.field;
educationData.fundName = props.row.fundName;
educationData.gpa = props.row.gpa;
educationData.country = props.row.country;
educationData.other = props.row.other;
educationData.duration = props.row.duration;
educationData.durationYear = props.row.durationYear;
educationData.note = props.row.note;
educationData.startYear = +props.row.startDate.slice(0, 4);
educationData.endYear = +props.row.endDate.slice(0, 4);
dialog = true;
}
"
>
<div v-if="col.name === 'startDate' || col.name === 'endDate'">
<div v-if="props.row.isDate">{{ date2Thai(col.value) }}</div>
<div v-else>
{{ +col.value.slice(0, 4) + 543 }}
</div>
</div>
<div v-else-if="col.name === 'finishDate'">
{{ col.value ? date2Thai(col.value) : "-" }}
</div>
<div v-else-if="col.name === 'isEducation'">
{{ col.value === true ? "ใช่" : "ไม่ใช่" }}
</div>
<div v-else>
<q-td v-for="col in props.cols" :key="col.id">
<div>
{{ col.value === "" ? "-" : col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="edit"
flat
dense
round
class="q-mr-xs"
size="14px"
icon="edit"
clickable
@click="
() => {
dialogStatus = 'edit';
editId = props.row.id;
isDate = props.row.isDate ? 'true' : 'false';
educationData.educationLevel = props.row.educationLevel;
educationData.institute = props.row.institute;
educationData.finishDate = props.row.finishDate;
educationData.startDate = props.row.startDate;
educationData.endDate = props.row.endDate;
educationData.isEducation = props.row.isEducation;
educationData.degree = props.row.degree;
educationData.field = props.row.field;
educationData.fundName = props.row.fundName;
educationData.gpa = props.row.gpa;
educationData.country = props.row.country;
educationData.other = props.row.other;
educationData.duration = props.row.duration;
educationData.durationYear = props.row.durationYear;
educationData.note = props.row.note;
educationData.startYear = +props.row.startDate.slice(0, 4);
educationData.endYear = +props.row.endDate.slice(0, 4);
dialog = true;
}
"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
color="info"
flat
@ -692,7 +675,7 @@ onMounted(async () => {
flat
dense
round
size="12px"
size="14px"
icon="mdi-delete"
clickable
@click.stop="
@ -747,13 +730,16 @@ onMounted(async () => {
round
color="blue"
icon="history"
@click="historyDialog = true"
@click="
() => (fetchHistoryData(props.row.id), (historyDialog = true))
"
>
<q-tooltip>ประวแกไขประวการศกษา</q-tooltip>
</q-btn>
</q-card-actions>
<q-separator />
<div class="row">
{{ console.log(props) }}
<div class="col-3 q-pa-sm label-color">ระดบการศกษา</div>
<div class="col-4 q-pa-sm">{{ props.cols[0].value }}</div>
<div class="col-2 q-pa-sm label-color">สถานศกษา</div>
@ -761,24 +747,19 @@ onMounted(async () => {
<div class="col-12">
<div :class="`row bg-color`">
<div class="col-3 q-pa-sm label-color">งแต</div>
<div v-if="props.row.isDate" class="col-4 q-pa-sm">
{{ date2Thai(props.cols[2].value) }}
</div>
<div v-else class="col-4 q-pa-sm">
{{ +props.cols[2].value.slice(0, 4) + 543 }}
<div class="col-4 q-pa-sm">
{{ props.cols[2].value }}
</div>
<div class="col-2 q-pa-sm label-color"></div>
<div v-if="props.row.isDate" class="col-3 q-pa-sm">
{{ date2Thai(props.cols[3].value) }}
</div>
<div v-else class="col-3 q-pa-sm">
{{ +props.cols[3].value.slice(0, 4) + 543 }}
<div class="col-3 q-pa-sm">
{{ props.cols[3].value }}
</div>
</div>
</div>
<div class="col-3 q-pa-sm label-color">นทสำเรจการศกษา</div>
<div class="col-9 q-pa-sm">
{{ date2Thai(props.cols[4].value) }}
{{ props.cols[4].value }}
</div>
<div class="col-12">
<div :class="`row bg-color`">
@ -1070,9 +1051,11 @@ onMounted(async () => {
dense
lazy-rules
:model-value="date2Thai(educationData.finishDate)"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่ได้รับ'}`]"
:rules="[
(val) => !!val || `${'กรุณาเลือกวันที่สำเร็จการศึกษา'}`,
]"
hide-bottom-space
:label="`${'วันที่ได้รับ'}`"
:label="`${'วันที่สำเร็จการศึกษา'}`"
>
<template v-slot:prepend>
<q-icon
@ -1097,6 +1080,9 @@ onMounted(async () => {
:options="educationOption"
option-value="value"
option-label="label"
:rules="[
(val) => !!val || `${'กรุณาเลือกวุฒิการศึกษาในตำแหน่ง'}`,
]"
label="เป็นวุฒิการศึกษาในตำแหน่ง"
/>
</div>
@ -1170,6 +1156,7 @@ onMounted(async () => {
outlined
v-model="educationData.duration"
label="ระยะเวลา"
:rules="[(val) => !!val || `${'กรุณากรอกระยะเวลา'}`]"
bg-color="white"
dense
/>
@ -1179,6 +1166,9 @@ onMounted(async () => {
outlined
v-model="educationData.durationYear"
label="ระยะเวลาหลักสูตร (ปี)"
:rules="[
(val) => !!val || `${'กรุณากรอกระยะเวลาหลักสูตร (ปี)'}`,
]"
bg-color="white"
type="number"
dense
@ -1280,7 +1270,7 @@ onMounted(async () => {
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props" v-if="mode === 'table'">
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id">
<div

View file

@ -0,0 +1,22 @@
interface RequestItemsObject {
educationLevel: string;
institute: string;
startYear: number;
endYear: number;
finishDate: Date;
startDate: Date;
endDate: Date;
isEducation: boolean | null;
degree: string;
field: string;
fundName: string;
gpa: string;
country: string;
other: string;
duration: string;
durationYear: number | null;
note: string;
}
export type { RequestItemsObject };

View file

@ -1,40 +1,38 @@
interface DataProps {
row: RequestItemsObject;
rowIndex: number;
interface RequestItemsObject {
profileId: string;
isActive: boolean;
year: number;
no: string;
volume: string;
section: string;
page: string;
receiveDate: Date | null;
insigniaId: string;
dateAnnounce: Date | null;
issue: string;
volumeNo: string;
refCommandDate: Date | null;
refCommandNo: string;
note: string;
}
//ข้อมูล
interface RequestItemsObject {
interface FormData {
id: string;
insigniaType: string;
insignia: string;
insigniaId: string;
isActive: boolean;
year: number;
receiveDate: Date | null;
insigniaId: string;
insigniaType: string;
no: string;
issue: string;
volumeNo: string;
volume: string;
section: string;
page: string;
receiveDate: Date;
dateAnnounce: Date|string|null;
dateAnnounce: Date | null;
refCommandNo: string;
refCommandDate: Date | null|string;
createdFullName: string;
createdAt: Date;
refCommandDate: Date | null;
note: string;
}
//columns
interface Columns {
[index: number]: {
name: String;
align: String;
label: String;
sortable: Boolean;
field: String;
headerStyle: String;
style: String;
};
}
export type { RequestItemsObject, Columns, DataProps };
export type { RequestItemsObject, FormData };

View file

@ -0,0 +1,34 @@
//ข้อมูล
interface ResponseObject {
createdAt: Date
createdFullName: string
createdUserId: string
educationLevel: string;
institute: string;
startYear: number;
endYear: number;
finishDate: Date;
startDate: Date;
endDate: Date;
isEducation: boolean | null;
degree: string;
field: string;
fundName: string;
gpa: string;
country: string;
other: string;
duration: string;
durationYear: number | null;
note: string;
isActive: boolean
isDate: boolean
positionPath: string
positionPathId : string
profileId: string
lastUpdateFullName: string
lastUpdateUserID: string
lastUpdatedAt: Date
}
export type { ResponseObject };

View file

@ -1,22 +1,58 @@
//ข้อมูล
interface ResponseObject {
id: string;
insigniaType: string;
insignia: string;
insigniaId: string;
createdAt: string;
createdUserId: Date | string;
lastUpdatedAt: Date | string;
lastUpdateUserId: string;
createdFullName: string;
lastUpdateFullName: string;
profileId: string;
isActive: boolean;
year: number;
no: string;
issue: string;
volumeNo: string;
volume: string;
section: string;
page: string;
receiveDate: Date;
dateAnnounce: Date;
receiveDate: Date | string;
insigniaId: string;
insignia: ResponseInsigniaObject;
dateAnnounce: Date | string;
issue: string;
volumeNo: string;
refCommandDate: Date | string;
refCommandNo: string;
refCommandDate: Date | null;
createdFullName: string;
createdAt: Date;
note: string;
insigniaName?: string
}
export type { ResponseObject };
interface ResponseInsigniaObject {
createdAt: Date;
createdFullName: string;
createdUserId: string;
id: string;
insigniaType: ResponseInsigniaType;
insigniaTypeId: string;
isActive: boolean;
lastUpdateFullName: string;
lastUpdateUserId: string;
lastUpdatedAt: Date;
level: null;
name: string;
note: string;
shortName: string;
}
interface ResponseInsigniaType {
createdAt: Date;
createdFullName: string;
createdUserId: string;
id: string;
isActive: boolean;
lastUpdateFullName: string;
lastUpdateUserId: string;
lastUpdatedAt: Date;
name: string;
}
export type { ResponseObject, ResponseInsigniaObject, ResponseInsigniaType };

View file

@ -1 +1,13 @@
export type {};
interface ResponseObject {
id: string
name: string
shortName: string
insigniaTypeName: string
createdAt: Date
lastUpdatedAt: Date
lastUpdateFullName: string
isActive: boolean
note: string
}
export type {ResponseObject};