Merge branch 'develop' into nice_dev

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-03-22 11:02:43 +07:00
commit 8354737642
10 changed files with 308 additions and 371 deletions

View file

@ -92,12 +92,21 @@ profileNewFamilyByFamilyId: (familyId: string) =>
profileNewFamilyeHisByFamilyId: (familyId: string) =>
`${registryNew}family/history/${familyId}`,
// ข้อมูลครอบครัว
profileNewDiscipline: `${registryNew}discipline`,
profileNewDisciplineByProfileId: (profileId: string) =>
`${registryNew}discipline/${profileId}`,
profileNewDisciplineByDisciplineId: (disciplineId: string) =>
`${registryNew}discipline/${disciplineId}`,
profileNewDisciplineHisByDisciplineId: (disciplineId: string) =>
`${registryNew}discipline/history/${disciplineId}`,
// วินัย
profileNewDiscipline: `${registryNew}discipline`,
profileNewDisciplineByProfileId: (profileId: string) =>
`${registryNew}discipline/${profileId}`,
profileNewDisciplineByDisciplineId: (disciplineId: string) =>
`${registryNew}discipline/${disciplineId}`,
profileNewDisciplineHisByDisciplineId: (disciplineId: string) =>
`${registryNew}discipline/history/${disciplineId}`,
// ปฏิบัติราชการพิเศษ
profileNewDuty: `${registryNew}duty`,
profileNewDutyByProfileId: (profileId: string) =>
`${registryNew}duty/${profileId}`,
profileNewDutyByDutyId: (dutyId: string) =>
`${registryNew}duty/${dutyId}`,
profileNewDutyHisByDutyId: (dutyId: string) =>
`${registryNew}duty/history/${dutyId}`,
};

View file

@ -15,16 +15,13 @@ import type {
DataOptionInsignia,
InsigniaOps,
} from "@/modules/04_registryNew/interface/index/Main";
import type {
RequestItemsObject,
FormData,
} from "@/modules/04_registryNew/interface/request/Insignia";
import type { RequestItemsObject } from "@/modules/04_registryNew/interface/request/Insignia";
import type { ResponseObject } 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();
const store = useInsigniaDataStore();
const { mapInsigniaOption } = store;
const mixin = useCounterMixin();
const {
date2Thai,
@ -39,27 +36,24 @@ const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const insigniaData = reactive<FormData>({
id: "",
isActive: true,
const id = ref<string>("");
const insigniaType = ref<string>("");
const insigniaForm = reactive<RequestItemsObject>({
year: 0,
receiveDate: null,
insigniaId: "",
insigniaType: "",
no: "",
issue: "",
volumeNo: "",
volume: "",
section: "",
page: "",
receiveDate: null,
insigniaId: "",
dateAnnounce: null,
refCommandNo: "",
issue: "",
volumeNo: "",
refCommandDate: null,
refCommandNo: "",
note: "",
});
const editRow = ref<boolean>(false);
const myForm = ref<QForm>();
const isEdit = ref<boolean>(false);
const modal = ref<boolean>(false);
const modeView = ref<string>("table");
@ -117,10 +111,9 @@ const columns = ref<QTableProps["columns"]>([
align: "left",
label: "ลำดับชั้น",
sortable: true,
field: "insignia",
field: (v) => v.insignia.insigniaType.name,
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" }),
},
@ -277,10 +270,9 @@ const columnsHistory = ref<QTableProps["columns"]>([
align: "left",
label: "ลำดับชั้น",
sortable: true,
field: "insignia",
field: (v) => v.insignia.insigniaType.name,
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" }),
},
@ -464,16 +456,8 @@ async function fetchInsignia() {
showLoader();
try {
const res = await http.get(config.API.insigniaOrg);
const data = res.data.result;
store.insigniaOption = [];
data.map((r: Insignia) => {
store.insigniaOption.push({
id: r.id.toString(),
name: r.name.toString() + ` (${r.shortName})`,
typeName: r.insigniaTypeName.toString(),
});
});
mapInsigniaOption(data);
} catch (error) {
messageError($q, error);
} finally {
@ -485,27 +469,13 @@ async function addEditData(editStatus: boolean = false) {
if (!profileId.value) return;
const url = editStatus
? config.API.profileNewInsignById(insigniaData.id)
? config.API.profileNewInsignById(id.value)
: config.API.profileNewInsign;
const method = editStatus ? "patch" : "post";
const reqBody: RequestItemsObject = {
...insigniaForm,
profileId: editStatus ? undefined : 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, "บันทึกข้อมูลสำเร็จ");
@ -517,62 +487,47 @@ async function addEditData(editStatus: boolean = false) {
}
}
async function clickDelete(dataId: string) {
try {
await http.delete(config.API.profileNewInsignById(dataId));
success($q, "ลบข้อมูลสำเร็จ");
await fetchData();
modal.value = false;
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}
// async function clickDelete(dataId: string) {
// 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, row?: ResponseObject) {
modal.value = true;
editRow.value = false;
isEdit.value = editStatus;
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;
id.value = row.id;
insigniaType.value = row.insignia.insigniaType.name;
insigniaForm.year = row.year;
insigniaForm.no = row.no;
insigniaForm.volume = row.volume;
insigniaForm.section = row.section;
insigniaForm.page = row.page;
insigniaForm.receiveDate = row.receiveDate;
insigniaForm.insigniaId = row.insigniaId;
insigniaForm.dateAnnounce = row.dateAnnounce;
insigniaForm.issue = row.issue;
insigniaForm.volumeNo = row.volumeNo;
insigniaForm.refCommandDate = row.refCommandDate;
insigniaForm.refCommandNo = row.refCommandNo;
insigniaForm.note = row.note;
} else {
insigniaData.id = "";
insigniaData.year = 0;
insigniaData.receiveDate = null;
insigniaData.insigniaId = "";
insigniaData.insigniaType = "";
insigniaData.no = "";
insigniaData.issue = "";
insigniaData.volumeNo = "";
insigniaData.volume = "";
insigniaData.section = "";
insigniaData.page = "";
insigniaData.dateAnnounce = null;
insigniaData.refCommandNo = "";
insigniaData.refCommandDate = null;
insigniaData.note = "";
clearData();
}
}
async function clickClose() {
if (editRow.value == true) {
dialogConfirm(
$q,
async () => {
modal.value = false;
editRow.value = false;
},
"ข้อมูลมีการแก้ไข",
"ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?"
);
} else {
modal.value = false;
}
clearData();
modal.value = false;
}
async function clickHistory(row: ResponseObject) {
@ -594,12 +549,8 @@ function onSubmit() {
dialogConfirm(
$q,
async () => {
myForm.value?.validate().then(async (result: boolean) => {
if (result) {
addEditData(isEdit.value);
modal.value = false;
}
});
addEditData(isEdit.value);
modal.value = false;
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
@ -620,17 +571,31 @@ function filterSelector(val: string, update: Function, refData: string) {
}
}
watch(
() => insigniaData.insigniaId,
() => {
const insigniaTypeFilter = Ops.value.insigniaOptions.filter(
(r: DataOptionInsignia) => r.id === insigniaData.insigniaId
);
if (insigniaTypeFilter.length > 0) {
insigniaData.insigniaType = insigniaTypeFilter[0].typeName;
}
function insigniaTypeSelection() {
const insigniaTypeFilter = Ops.value.insigniaOptions.filter(
(r: DataOptionInsignia) => r.id === insigniaForm.insigniaId
);
if (insigniaTypeFilter.length > 0) {
insigniaType.value = insigniaTypeFilter[0].typeName;
}
);
}
function clearData() {
id.value = "";
(insigniaType.value = ""), (insigniaForm.year = 0);
insigniaForm.receiveDate = null;
insigniaForm.insigniaId = "";
insigniaForm.no = "";
insigniaForm.issue = "";
insigniaForm.volumeNo = "";
insigniaForm.volume = "";
insigniaForm.section = "";
insigniaForm.page = "";
insigniaForm.dateAnnounce = null;
insigniaForm.refCommandNo = "";
insigniaForm.refCommandDate = null;
insigniaForm.note = "";
}
onMounted(async () => {
await fetchData();
@ -834,7 +799,7 @@ onMounted(async () => {
<q-dialog v-model="modal" persistent>
<q-card style="width: 600px">
<q-form greedy ref="myForm" @submit="onSubmit">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<DialogHeader tittle="เครื่องราชอิสริยาภรณ์" :close="clickClose" />
<q-separator />
<q-card-section class="q-p-sm">
@ -843,7 +808,7 @@ onMounted(async () => {
<datepicker
autoApply
year-picker
v-model="insigniaData.year"
v-model="insigniaForm.year"
week-start="0"
menu-class-name="modalfix"
:locale="'th'"
@ -857,17 +822,15 @@ onMounted(async () => {
<q-input
dense
outlined
lazy-rules
hide-bottom-space
class="inputgreen"
:model-value="insigniaData.year !== 0 ? (insigniaData.year as number) + 543 : null"
:model-value="insigniaForm.year !== 0 ? (insigniaForm.year as number) + 543 : null"
:rules="[
(val:string) =>
!!val ||
`${'กรุณาเลือกปีที่ยื่นขอพระราชทานเครื่องราชฯ'}`,
]"
:label="`${'ปีที่ยื่นขอพระราชทานเครื่องราชฯ'}`"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
<q-icon
@ -886,7 +849,7 @@ onMounted(async () => {
borderless
week-start="0"
menu-class-name="modalfix"
v-model="insigniaData.receiveDate"
v-model="insigniaForm.receiveDate"
:locale="'th'"
:enableTimePicker="false"
>
@ -905,13 +868,12 @@ onMounted(async () => {
for="inputDatereceive"
ref="dateReceivedRef"
:model-value="
insigniaData.receiveDate != null
? date2Thai(insigniaData.receiveDate as Date)
insigniaForm.receiveDate != null
? date2Thai(insigniaForm.receiveDate as Date)
: null
"
:label="`${'วันที่ได้รับ'}`"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่ได้รับ'}`]"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
<q-icon
@ -936,7 +898,7 @@ onMounted(async () => {
option-value="id"
input-debounce="0"
option-label="name"
v-model="insigniaData.insigniaId"
v-model="insigniaForm.insigniaId"
class="inputgreen"
:label="`${'ชื่อเครื่องราชฯ'}`"
:options="Ops.insigniaOptions"
@ -944,7 +906,7 @@ onMounted(async () => {
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'insigniaOptions'
) "
@update:modelValue="() => (editRow = true)"
@update:modelValue="insigniaTypeSelection"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
@ -954,9 +916,8 @@ onMounted(async () => {
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.insigniaType"
v-model="insigniaType"
:label="`${'ลำดับชั้น'}`"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
@ -965,11 +926,10 @@ onMounted(async () => {
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.no"
v-model="insigniaForm.no"
class="inputgreen"
:label="`${'ลำดับที่'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกลำดับที่'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
@ -978,11 +938,10 @@ onMounted(async () => {
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.issue"
v-model="insigniaForm.issue"
class="inputgreen"
:label="`${'ราชกิจจาฯ ฉบับที่'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกราชกิจจาฯ ฉบับที่'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
@ -991,11 +950,10 @@ onMounted(async () => {
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.volumeNo"
v-model="insigniaForm.volumeNo"
class="inputgreen"
:label="`${'เล่มที่'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกเล่มที่'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
@ -1004,11 +962,10 @@ onMounted(async () => {
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.volume"
v-model="insigniaForm.volume"
class="inputgreen"
:label="`${'เล่ม'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกเล่ม'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
@ -1017,11 +974,10 @@ onMounted(async () => {
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.section"
v-model="insigniaForm.section"
class="inputgreen"
:label="`${'ตอน'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกตอน'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
@ -1030,18 +986,17 @@ onMounted(async () => {
lazy-rules
outlined
hide-bottom-space
v-model="insigniaData.page"
v-model="insigniaForm.page"
class="inputgreen"
:label="`${'หน้า'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกหน้า'}`]"
@update:modelValue="() => (editRow = true)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
autoApply
week-start="0"
v-model="insigniaData.dateAnnounce"
v-model="insigniaForm.dateAnnounce"
menu-class-name="modalfix"
:locale="'th'"
:enableTimePicker="false"
@ -1054,16 +1009,14 @@ onMounted(async () => {
<q-input
dense
outlined
lazy-rules
hide-bottom-space
class="inputgreen"
:model-value="date2Thai(insigniaData.dateAnnounce as Date)"
:model-value="date2Thai(insigniaForm.dateAnnounce as Date)"
:label="`${'วันที่ประกาศในราชกิจจาฯ'}`"
:rules="[
(val:string) =>
!!val || `${'กรุณาเลือกวันที่ประกาศในราชกิจจาฯ'}`,
]"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:prepend>
<q-icon
@ -1082,10 +1035,9 @@ onMounted(async () => {
outlined
lazy-rules
hide-bottom-space
v-model="insigniaData.refCommandNo"
v-model="insigniaForm.refCommandNo"
class="inputgreen"
:label="`${'เลขที่คำสั่ง'}`"
@update:modelValue="() => (editRow = true)"
>
<template v-slot:append>
<q-icon name="mdi-file" class="cursor-pointer" />
@ -1096,7 +1048,7 @@ onMounted(async () => {
<datepicker
autoApply
week-start="0"
v-model="insigniaData.refCommandDate"
v-model="insigniaForm.refCommandDate"
menu-class-name="modalfix"
:locale="'th'"
:enableTimePicker="false"
@ -1110,15 +1062,13 @@ onMounted(async () => {
dense
outlined
clearable
lazy-rules
hide-bottom-space
class="inputgreen"
:label="`${'เอกสารอ้างอิง (ลง วัน/เดือน/ปี)'}`"
:model-value="
date2Thai(insigniaData.refCommandDate as Date)
date2Thai(insigniaForm.refCommandDate as Date)
"
@clear="insigniaData.refCommandDate = null"
@update:modelValue="() => (editRow = true)"
@clear="insigniaForm.refCommandDate = null"
>
<template v-slot:prepend>
<q-icon
@ -1136,10 +1086,9 @@ onMounted(async () => {
dense
outlined
hide-bottom-space
v-model="insigniaData.note"
v-model="insigniaForm.note"
class="inputgreen"
label="หมายเหตุ"
@update:modelValue="() => (editRow = true)"
/>
</div>
</div>
@ -1173,7 +1122,7 @@ onMounted(async () => {
v-model:tittle="tittleHistory"
>
<template #columns="props">
<q-tr :props="props">
<q-tr class="cursor-pointer" :props="props">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div class="table_ellipsis">
{{ col.value ? col.value : "-" }}

View file

@ -31,7 +31,7 @@ const {
dialogRemove,
} = mixin;
const disciplineData = reactive<any>({
const disciplineData = reactive<RequestItemsObject>({
date: new Date(),
level: "",
detail: "",
@ -299,7 +299,7 @@ function deleteData(idData: string) {
function openDialogEdit(props: RequestItemsObject) {
modal.value = true;
edit.value = true;
id.value = props.id;
id.value = props.id ? props.id : "";
disciplineData.date = props.date;
disciplineData.detail = props.detail;
disciplineData.level = props.level;

View file

@ -4,7 +4,6 @@ import { useQuasar, type QTableProps } from "quasar";
import type {
FormFilter,
RequestItemsObject,
MyObjectRef,
} from "@/modules/04_registryNew/interface/index/performSpecialWork";
import http from "@/plugins/http";
@ -29,6 +28,7 @@ const {
showLoader,
hideLoader,
success,
dialogRemove,
} = mixin;
const modal = ref<boolean>(false);
@ -36,24 +36,21 @@ const edit = ref<boolean>(false);
const modalHistory = ref<boolean>(false);
const id = ref<string>("");
const dateStart = ref<Date | null>(null);
const dateEnd = ref<Date | null>(null);
const detail = ref<string>();
const reference = ref<string>();
const refCommandNo = ref<string>();
const refCommandDate = ref<Date | null>(null);
const dateStartRef = ref<object | null>(null);
const dateEndRef = ref<object | null>(null);
const detailRef = ref<object | null>(null);
const referenceRef = ref<object | null>(null);
const objectRef: MyObjectRef = {
dateStart: dateStartRef,
dateEnd: dateEndRef,
detail: detailRef,
reference: referenceRef,
};
const dutyData = reactive<RequestItemsObject>({
profileId: profileId.value,
dateStart: new Date(),
dateEnd: null,
detail: "",
reference: "",
refCommandNo: "",
refCommandDate: null,
});
const rows = ref<RequestItemsObject[]>([]);
const filterKeyword = ref<string>("");
@ -92,6 +89,7 @@ const columns = ref<QTableProps["columns"]>([
field: "dateStart",
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" }),
},
@ -103,6 +101,7 @@ const columns = ref<QTableProps["columns"]>([
field: "dateEnd",
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" }),
},
@ -147,6 +146,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" }),
},
@ -157,15 +157,17 @@ function openDialogAdd() {
modal.value = true;
}
/** กดแก้ไข */
function openDialogEdit(props: RequestItemsObject) {
modal.value = true;
id.value = props.id;
dateStart.value = props.dateStart;
dateEnd.value = props.dateEnd;
detail.value = props.detail;
reference.value = props.reference;
refCommandNo.value = props.refCommandNo;
refCommandDate.value = props.refCommandDate;
edit.value = true;
id.value = props.id ? props.id : "";
dutyData.dateStart = props.dateStart;
dutyData.dateEnd = props.dateEnd;
dutyData.detail = props.detail;
dutyData.reference = props.reference;
dutyData.refCommandNo = props.refCommandNo;
dutyData.refCommandDate = props.refCommandDate;
}
/**
@ -182,126 +184,102 @@ function closeDialog() {
modal.value = false;
edit.value = false;
dateStart.value = null;
dateEnd.value = null;
detail.value = "";
reference.value = "";
refCommandNo.value = "";
refCommandDate.value = null;
dutyData.dateStart = new Date();
dutyData.dateEnd = null;
dutyData.detail = "";
dutyData.reference = "";
dutyData.refCommandNo = "";
dutyData.refCommandDate = null;
}
function getData() {
// showLoader()
// http
// .get(config.API.??)
// .then((res)=>{
/** fetch ข้อมูล */
async function fetchData(id: string) {
showLoader();
await http
.get(config.API.profileNewDutyByProfileId(id))
.then(async (res) => {
rows.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
// })
// .catch((e)=>{
// messageError($q,e)
// }).finally(()=>{
/** เพิ่มข้อมูล */
// })
const data: RequestItemsObject[] = [
{
dateStart: new Date("2024-02-15T00:00:00"),
dateEnd: new Date("2024-02-15T00:00:00"),
detail: "111",
reference: "111",
refCommandNo: "",
refCommandDate: null,
id: "08dc2e13-1c3f-4261-8168-30018e5d953c",
async function addData() {
await http
.post(config.API.profileNewDuty, dutyData)
.then(() => {
fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** แก้ไขข้อมูล */
async function editData(idData: string) {
await http
.patch(config.API.profileNewDutyByDutyId(idData), {
...dutyData,
profileId: undefined,
})
.then(() => {
fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** ลบข้อมูล */
function deleteData(idData: string) {
dialogRemove($q, () =>
http
.delete(config.API.profileNewDutyByDutyId(idData))
.then(() => {
fetchData(profileId.value);
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
})
);
}
/** กด Submit */
async function onSubmit() {
dialogConfirm(
$q,
async () => {
edit.value ? editData(id.value) : addData();
closeDialog();
},
];
rows.value = data;
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
/** validate check*/
function validateForm() {
const hasError = [];
for (const key in objectRef) {
if (Object.prototype.hasOwnProperty.call(objectRef, key)) {
const property = objectRef[key];
if (property.value && typeof property.value.validate === "function") {
const isValid = property.value.validate();
hasError.push(isValid);
}
}
}
if (hasError.every((result) => result === true)) {
if ((edit.value = false)) {
saveData();
} else {
editData();
}
}
}
/**
* นทกเพมขอม
*/
function saveData() {
// showLoader();
// await http
// .post(config.API.profileDutyId(profileId.value), {
// id: id.value,
// dateStart: dateToISO(dateStart.value),
// dateEnd: dateToISO(dateEnd.value),
// detail: detail.value,
// reference: reference.value,
// refCommandNo: refCommandNo.value,
// refCommandDate:
// refCommandDate.value == null
// ? null
// : dateToISO(refCommandDate.value as Date),
// })
// .then((res) => {
// success($q, "");
// modal.value = false;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
}
/**
* นทกแกไขขอม
*/
const editData = async () => {
// showLoader();
// await http
// .put(config.API.profileDutyId(id.value), {
// id: id.value,
// dateStart: dateToISO(dateStart.value),
// dateEnd: dateToISO(dateEnd.value),
// detail: detail.value,
// reference: reference.value,
// refCommandNo: refCommandNo.value,
// refCommandDate:
// refCommandDate.value == null
// ? null
// : dateToISO(refCommandDate.value as Date),
// })
// .then((res) => {
// success($q, "");
// modal.value = false;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
};
onMounted(() => {
getData();
onMounted(async () => {
await fetchData(profileId.value);
});
</script>
<template>
@ -407,30 +385,31 @@ onMounted(() => {
</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="openDialogEdit(props.row)"
>
<q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name === 'no'">
{{
(formFilter.page - 1) * formFilter.pageSize + props.rowIndex + 1
}}
</div>
<div
v-else-if="
col.name == 'dateStart' ||
col.name == 'dateEnd' ||
col.name == 'refCommandDate'
"
>
{{ col.value ? date2Thai(col.value) : "-" }}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="primary"
flat
dense
round
class="q-mr-xs"
size="14px"
icon="mdi-pencil-outline"
clickable
@click="openDialogEdit(props.row)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
color="info"
flat
@ -442,6 +421,19 @@ onMounted(() => {
>
<q-tooltip>ประวแกไขปฏราชการพเศษ</q-tooltip>
</q-btn>
<q-btn
color="red"
flat
dense
round
size="14px"
icon="mdi-delete"
clickable
@click.stop="deleteData(props.row.id)"
v-close-popup
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
@ -553,7 +545,7 @@ onMounted(() => {
<q-dialog v-model="modal" persistent>
<q-card style="min-width: 600px">
<form @submit.prevent="validateForm">
<q-form @submit.prevent greedy @validation-success="onSubmit()">
<q-card-section class="flex justify-between" style="padding: 0">
<DialogHeader tittle="ปฏิบัติราชการพิเศษ" :close="closeDialog" />
</q-card-section>
@ -564,7 +556,7 @@ onMounted(() => {
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
menu-class-name="modalfix"
v-model="dateStart"
v-model="dutyData.dateStart"
:locale="'th'"
autoApply
:enableTimePicker="false"
@ -580,7 +572,7 @@ onMounted(() => {
class="full-width inputgreen cursor-pointer"
outlined
dense
:model-value="date2Thai(dateStart)"
:model-value="date2Thai(dutyData.dateStart)"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่เริ่มต้น'}`]"
hide-bottom-space
:label="`${'วันที่เริ่มต้น'}`"
@ -604,12 +596,12 @@ onMounted(() => {
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
menu-class-name="modalfix"
v-model="dateEnd"
v-model="dutyData.dateEnd"
:locale="'th'"
autoApply
:enableTimePicker="false"
:min-date="dateStart"
:readonly="!dateStart"
:min-date="dutyData.dateStart"
:readonly="!dutyData.dateStart"
week-start="0"
>
<template #year="{ year }">{{ year + 543 }}</template>
@ -619,11 +611,11 @@ onMounted(() => {
<template #trigger>
<q-input
ref="dateEndRef"
:readonly="!dateStart"
:readonly="!dutyData.dateStart"
class="full-width inputgreen cursor-pointer"
dense
outlined
:model-value="date2Thai(dateEnd)"
:model-value="date2Thai(dutyData.dateEnd)"
:rules="[(val) => !!val || `${'กรุณาเลือกวันที่สิ้นสุด'}`]"
hide-bottom-space
:label="`${'วันที่สิ้นสุด'}`"
@ -652,7 +644,7 @@ onMounted(() => {
dense
lazy-rules
autogrow
v-model="reference"
v-model="dutyData.reference"
:rules="[(val) => !!val || `${'กรุณากรอกเอกสารอ้างอิง'}`]"
hide-bottom-space
:label="`${'เอกสารอ้างอิง'}`"
@ -666,7 +658,7 @@ onMounted(() => {
dense
lazy-rules
autogrow
v-model="detail"
v-model="dutyData.detail"
:rules="[(val) => !!val || `${'กรุณากรอกรายละเอียด'}`]"
hide-bottom-space
:label="`${'รายละเอียด'}`"
@ -677,7 +669,7 @@ onMounted(() => {
class="full-width inputgreen cursor-pointer"
outlined
dense
v-model="refCommandNo"
v-model="dutyData.refCommandNo"
:label="`${'เลขที่คำสั่ง'}`"
>
<template v-slot:append>
@ -688,7 +680,7 @@ onMounted(() => {
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
menu-class-name="modalfix"
v-model="refCommandDate"
v-model="dutyData.refCommandDate"
:locale="'th'"
autoApply
:enableTimePicker="false"
@ -706,7 +698,7 @@ onMounted(() => {
lazy-rules
:borderless="!edit"
:model-value="
refCommandDate == null ? null : date2Thai(refCommandDate as Date)
dutyData.refCommandDate == null ? null : date2Thai(dutyData.refCommandDate as Date)
"
hide-bottom-space
:label="`${'เอกสารอ้างอิง (ลงวันที่)'}`"
@ -723,10 +715,13 @@ onMounted(() => {
>
</q-icon>
</template>
<template v-if="refCommandDate && edit" v-slot:append>
<template
v-if="dutyData.refCommandDate && edit"
v-slot:append
>
<q-icon
name="cancel"
@click.stop.prevent="refCommandDate = null"
@click.stop.prevent="dutyData.refCommandDate = null"
class="cursor-pointer"
/>
</template>
@ -751,7 +746,7 @@ onMounted(() => {
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</q-card-actions>
</form>
</q-form>
</q-card>
</q-dialog>

View file

@ -55,6 +55,7 @@ const columns = ref<QTableProps["columns"]>([
field: "dateStart",
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" }),
},
@ -66,6 +67,7 @@ const columns = ref<QTableProps["columns"]>([
field: "dateEnd",
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" }),
},
@ -110,6 +112,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" }),
},
@ -132,6 +135,7 @@ const columns = 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" }),
},
@ -139,7 +143,7 @@ const columns = ref<QTableProps["columns"]>([
function getHistory() {
showLoader();
http
.get(config.API.profileDutyHisId(id.value))
.get(config.API.profileNewDutyHisByDutyId(id.value))
.then((res) => {
let data = res.data.result;
rows.value = [];
@ -259,17 +263,6 @@ watch(modal, (status) => {
1
}}
</div>
<div
v-else-if="
col.name == 'dateStart' ||
col.name == 'dateEnd' ||
col.name == 'createdAt' ||
col.name == 'refCommandDate'
"
class="table_ellipsis"
>
{{ col.value ? date2Thai(col.value) : "-" }}
</div>
<div v-else class="table_ellipsis">
{{ col.value ? col.value : "-" }}
</div>

View file

@ -1,13 +1,13 @@
interface RequestItemsObject {
id: string;
profileId: string,
id?: string;
level: string;
detail: string;
unStigma: string;
refCommandNo: string;
refCommandDate: Date | null;
date: Date;
createdFullName: string;
createdAt: Date;
date: Date | null;
}
interface FormFilter {

View file

@ -13,13 +13,14 @@ interface FormFilter {
//ข้อมูล
interface RequestItemsObject {
id: string;
dateStart: Date;
dateEnd: Date;
detail: string;
reference: string;
refCommandNo: string;
refCommandDate: Date | null;
profileId: string,
id?: string,
dateStart: Date | null,
dateEnd: Date | null,
detail: string,
reference: string,
refCommandNo: string,
refCommandDate: Date | null,
}
interface MyObjectRef {

View file

@ -1,6 +1,5 @@
interface RequestItemsObject {
profileId?: string;
isActive: boolean;
year: number;
no: string;
volume: string;
@ -16,23 +15,4 @@ interface RequestItemsObject {
note: string;
}
interface FormData {
id: string;
isActive: boolean;
year: number;
receiveDate: Date | null;
insigniaId: string;
insigniaType: string;
no: string;
issue: string;
volumeNo: string;
volume: string;
section: string;
page: string;
dateAnnounce: Date | null;
refCommandNo: string;
refCommandDate: Date | null;
note: string;
}
export type { RequestItemsObject, FormData };
export type { RequestItemsObject };

View file

@ -1,29 +1,26 @@
interface ResponseObject {
id: string;
createdAt: string;
createdUserId: Date | string;
lastUpdatedAt: Date | string;
createdUserId: Date | null;
lastUpdatedAt: Date | null;
lastUpdateUserId: string;
createdFullName: string;
lastUpdateFullName: string;
profileId: string;
isActive: boolean;
year: number;
no: string;
volume: string;
section: string;
page: string;
receiveDate: Date | string;
receiveDate: Date | null;
insigniaId: string;
insignia: ResponseInsigniaObject;
dateAnnounce: Date | string;
dateAnnounce: Date | null;
issue: string;
volumeNo: string;
refCommandDate: Date | string;
refCommandDate: Date | null;
refCommandNo: string;
note: string;
insigniaName?: string
}
interface ResponseInsigniaObject {

View file

@ -1,8 +1,21 @@
import { ref, computed } from "vue";
import { defineStore } from "pinia";
import type { DataOptionInsignia } from "@/modules/04_registryNew/interface/index/Main";
import type { ResponseObject as Insignia } from "@/modules/07_insignia/interface/response/Main";
export const useInsigniaDataStore = defineStore("insigniaDataStore", () => {
const insigniaOption = ref<DataOptionInsignia[]>([]);
return { insigniaOption };
function mapInsigniaOption(resData: any) {
insigniaOption.value = [];
resData.map((r: Insignia) => {
insigniaOption.value.push({
id: r.id.toString(),
name: r.name.toString() + ` (${r.shortName})`,
typeName: r.insigniaTypeName.toString(),
});
});
}
return { insigniaOption, mapInsigniaOption };
});