Merge branch 'develop' of https://github.com/Frappet/bma-ehr-frontend into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-03-22 09:33:00 +07:00
commit 25303bc6ca
3 changed files with 201 additions and 217 deletions

View file

@ -91,4 +91,13 @@ profileNewFamilyByFamilyId: (familyId: string) =>
`${registryNew}family/${familyId}`, `${registryNew}family/${familyId}`,
profileNewFamilyeHisByFamilyId: (familyId: string) => profileNewFamilyeHisByFamilyId: (familyId: string) =>
`${registryNew}family/history/${familyId}`, `${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}`,
};

View file

@ -30,8 +30,17 @@ const {
messageError, messageError,
success, success,
dateToISO, dateToISO,
dialogRemove,
} = mixin; } = mixin;
const disciplineData = reactive<any>({
date: new Date(),
level: "",
detail: "",
unStigma: "",
refCommandNo: "",
profileId: profileId.value,
refCommandDate: null,
});
const rows = ref<RequestItemsObject[]>([]); const rows = ref<RequestItemsObject[]>([]);
const mode = ref<string>("table"); const mode = ref<string>("table");
const filterKeyword = ref<string>(""); const filterKeyword = ref<string>("");
@ -66,6 +75,7 @@ const columns = ref<QTableProps["columns"]>([
label: "วัน เดือน ปี", label: "วัน เดือน ปี",
sortable: true, sortable: true,
field: "date", field: "date",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) => sort: (a: string, b: string) =>
@ -121,6 +131,7 @@ const columns = ref<QTableProps["columns"]>([
label: "เอกสารอ้างอิง (ลงวันที่)", label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true, sortable: true,
field: "refCommandDate", field: "refCommandDate",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) => sort: (a: string, b: string) =>
@ -218,18 +229,82 @@ function filterSelector(val: string, update: Function, refData: string) {
function closeDialog() { function closeDialog() {
modal.value = false; modal.value = false;
edit.value = false; edit.value = false;
disciplineData.date = null;
date.value = null; disciplineData.detail = "";
detail.value = ""; disciplineData.level = "";
level.value = ""; disciplineData.unStigma = "";
unStigma.value = ""; disciplineData.refCommandNo = "";
refCommandNo.value = ""; disciplineData.refCommandDate = null;
refCommandDate.value = null;
} }
function openDialogAdd() { function openDialogAdd() {
modal.value = true; modal.value = true;
} }
async function fetchData(id: string) {
showLoader();
await http
.get(config.API.profileNewDisciplineByProfileId(id))
.then(async (res) => {
console.log(res.data.result);
rows.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function addData() {
await http
.post(config.API.profileNewDiscipline, disciplineData)
.then(() => {
fetchData(profileId.value);
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function editData(idData: string) {
await http
.patch(config.API.profileNewDisciplineByDisciplineId(idData), {
...disciplineData,
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.profileNewDisciplineByDisciplineId(idData))
.then(() => {
fetchData(profileId.value);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
})
);
}
/** /**
* กดเลอกขอมลทจะแกไข * กดเลอกขอมลทจะแกไข
* @param props props ใน row เลอก * @param props props ใน row เลอก
@ -240,184 +315,80 @@ function openDialogEdit(props: RequestItemsObject) {
console.log(props); console.log(props);
id.value = props.id; id.value = props.id;
date.value = props.date; disciplineData.date = props.date;
detail.value = props.detail; disciplineData.detail = props.detail;
level.value = props.level; disciplineData.level = props.level;
unStigma.value = props.unStigma; disciplineData.unStigma = props.unStigma;
refCommandNo.value = props.refCommandNo; disciplineData.refCommandNo = props.refCommandNo;
refCommandDate.value = props.refCommandDate; disciplineData.refCommandDate = props.refCommandDate;
} }
/** 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.profileDisId(profileId.value), {
// id: id.value,
// level: level.value,
// detail: detail.value,
// unStigma: unStigma.value,
// refCommandNo: refCommandNo.value,
// refCommandDate:
// refCommandDate.value == null
// ? null
// : dateToISO(refCommandDate.value as Date),
// date: dateToISO(date.value),
// })
// .then((res) => {
// success($q, "");
// closeDialog()
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
}
/**
* นทกแกไขขอม
*/
const editData = async () => {
// showLoader();
// await http
// .put(config.API.profileDisId(id.value), {
// id: id.value,
// level: level.value,
// detail: detail.value,
// unStigma: unStigma.value,
// refCommandNo: refCommandNo.value,
// refCommandDate:
// refCommandDate.value == null
// ? null
// : dateToISO(refCommandDate.value as Date),
// date: dateToISO(date.value as Date),
// })
// .then((res) => {
// success($q, "");
// modal.value = false;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
};
/**
* งชนดอมลประวแกไขขอมลทเลอก
* @param row อม row ประวการแกไข
*/
function openDialogHistory(idOrder: string) { function openDialogHistory(idOrder: string) {
modalHistory.value = true; modalHistory.value = true;
id.value = idOrder; id.value = idOrder;
} }
function getData() { async function onSubmit() {
// showLoader(); dialogConfirm(
// http $q,
// .get(config.API.profileDisId(profileId.value)) async () => {
// .then((res) => { edit.value ? editData(id.value) : addData();
// let data = res.data.result; closeDialog();
// console.log(data);
// rows.value = [];
// data.map((e: RequestItemsObject) => {
// rows.value.push({
// id: e.id,
// level: e.level,
// detail: e.detail,
// unStigma: e.unStigma,
// refCommandNo: e.refCommandNo,
// refCommandDate: e.refCommandDate ? new Date(e.refCommandDate) : null,
// date: e.date,
// createdFullName: e.createdFullName,
// createdAt: e.createdAt,
// });
// });
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {});
const data: RequestItemsObject[] = [
{
level: "ภาคทัณฑ์",
detail: "1",
refCommandNo: "1",
refCommandDate: null,
date: new Date("2024-03-19T00:00:00"),
unStigma: "1",
id: "08dc2e0f-5631-4a7c-8ac4-0f7c99156c2e",
createdAt: new Date("2024-02-15T17:17:38.524861"),
createdFullName: "สาวิตรี ศรีสมัย",
}, },
{ "ยืนยันการบันทึกข้อมูล",
level: "ภาคทัณฑ์", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
detail: "11", );
refCommandNo: "11",
refCommandDate: new Date("2024-03-11T00:00:00"),
date: new Date("2024-02-20T00:00:00"),
unStigma: "",
id: "08dc2e11-3588-44ea-8c1a-99109a4c4fe0",
createdAt: new Date("2024-02-20T12:59:47.193103"),
createdFullName: "สาวิตรี ศรีสมัย",
},
{
level: "ตัดเงินเดือน",
detail: "115",
refCommandNo: "1",
refCommandDate: new Date("2024-03-11T00:00:00"),
date: new Date("2024-02-20T00:00:00"),
unStigma: "11",
id: "08dc2e11-8054-416c-8299-81005d739a25",
createdAt: new Date("2024-02-20T12:59:47.193103"),
createdFullName: "สาวิตรี ศรีสมัย",
},
{
level: "",
detail: "test",
refCommandNo: "12",
refCommandDate: new Date("2024-03-11T00:00:00"),
date: new Date("2024-02-20T00:00:00"),
unStigma: "",
id: "08dc31d9-24a0-4870-896c-4c4ea8f7b104",
createdAt: new Date("2024-02-20T12:59:47.193103"),
createdFullName: "สาวิตรี ศรีสมัย",
},
];
rows.value = data;
} }
// const data: RequestItemsObject[] = [
// {
// level: "",
// detail: "1",
// refCommandNo: "1",
// refCommandDate: null,
// date: new Date("2024-03-19T00:00:00"),
// unStigma: "1",
// id: "08dc2e0f-5631-4a7c-8ac4-0f7c99156c2e",
// createdAt: new Date("2024-02-15T17:17:38.524861"),
// createdFullName: " ",
// },
// {
// level: "",
// detail: "11",
// refCommandNo: "11",
// refCommandDate: new Date("2024-03-11T00:00:00"),
// date: new Date("2024-02-20T00:00:00"),
// unStigma: "",
// id: "08dc2e11-3588-44ea-8c1a-99109a4c4fe0",
// createdAt: new Date("2024-02-20T12:59:47.193103"),
// createdFullName: " ",
// },
// {
// level: "",
// detail: "115",
// refCommandNo: "1",
// refCommandDate: new Date("2024-03-11T00:00:00"),
// date: new Date("2024-02-20T00:00:00"),
// unStigma: "11",
// id: "08dc2e11-8054-416c-8299-81005d739a25",
// createdAt: new Date("2024-02-20T12:59:47.193103"),
// createdFullName: " ",
// },
// {
// level: "",
// detail: "test",
// refCommandNo: "12",
// refCommandDate: new Date("2024-03-11T00:00:00"),
// date: new Date("2024-02-20T00:00:00"),
// unStigma: "",
// id: "08dc31d9-24a0-4870-896c-4c4ea8f7b104",
// createdAt: new Date("2024-02-20T12:59:47.193103"),
// createdFullName: " ",
// },
// ];
// rows.value = data;
onMounted(() => { onMounted(async () => {
getData(); await fetchData(profileId.value);
}); });
</script> </script>
<template> <template>
@ -523,27 +494,30 @@ onMounted(() => {
</template> </template>
<template v-slot:body="props" v-if="mode === 'table'"> <template v-slot:body="props" v-if="mode === 'table'">
<q-tr :props="props" class="cursor-pointer"> <q-tr :props="props" class="cursor-pointer">
<q-td <q-td v-for="col in props.cols" :key="col.id">
v-for="col in props.cols"
:key="col.id"
@click="openDialogEdit(props.row)"
>
<div v-if="col.name === 'no'"> <div v-if="col.name === 'no'">
{{ {{
(formFilter.page - 1) * formFilter.pageSize + props.rowIndex + 1 (formFilter.page - 1) * formFilter.pageSize + props.rowIndex + 1
}} }}
</div> </div>
<div
v-else-if="col.name == 'refCommandDate' || col.name == 'date'"
class="table_ellipsis"
>
{{ col.value == null ? null : date2Thai(col.value) }}
</div>
<div v-else> <div v-else>
{{ col.value ? col.value : "-" }} {{ col.value ? col.value : "-" }}
</div> </div>
</q-td> </q-td>
<q-td auto-width> <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 <q-btn
color="info" color="info"
flat flat
@ -555,6 +529,19 @@ onMounted(() => {
> >
<q-tooltip>ประวแกไขว</q-tooltip> <q-tooltip>ประวแกไขว</q-tooltip>
</q-btn> </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-td>
</q-tr> </q-tr>
</template> </template>
@ -673,7 +660,7 @@ onMounted(() => {
<!-- dialog add edit --> <!-- dialog add edit -->
<q-dialog v-model="modal" persistent> <q-dialog v-model="modal" persistent>
<q-card style="min-width: 600px"> <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"> <q-card-section class="flex justify-between" style="padding: 0">
<DialogHeader tittle="วินัย" :close="closeDialog" /> <DialogHeader tittle="วินัย" :close="closeDialog" />
</q-card-section> </q-card-section>
@ -684,7 +671,7 @@ onMounted(() => {
<div class="col-xs-6 col-sm-6 col-md-6"> <div class="col-xs-6 col-sm-6 col-md-6">
<datepicker <datepicker
menu-class-name="modalfix" menu-class-name="modalfix"
v-model="date" v-model="disciplineData.date"
:locale="'th'" :locale="'th'"
autoApply autoApply
:enableTimePicker="false" :enableTimePicker="false"
@ -700,7 +687,7 @@ onMounted(() => {
class="full-width inputgreen cursor-pointer" class="full-width inputgreen cursor-pointer"
outlined outlined
dense dense
:model-value="date2Thai(date)" :model-value="date2Thai(disciplineData.date)"
:rules="[(val:string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี'}`]" :rules="[(val:string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี'}`]"
hide-bottom-space hide-bottom-space
:label="`${'วัน/เดือน/ปี'}`" :label="`${'วัน/เดือน/ปี'}`"
@ -728,7 +715,7 @@ onMounted(() => {
outlined outlined
dense dense
lazy-rules lazy-rules
v-model="detail" v-model="disciplineData.detail"
:rules="[(val:string) => !!val || `${'กรุณากรอกรายละเอียด'}`]" :rules="[(val:string) => !!val || `${'กรุณากรอกรายละเอียด'}`]"
hide-bottom-space hide-bottom-space
:label="`${'รายละเอียด'}`" :label="`${'รายละเอียด'}`"
@ -740,7 +727,7 @@ onMounted(() => {
outlined outlined
dense dense
lazy-rules lazy-rules
v-model="level" v-model="disciplineData.level"
:label="`${'ระดับการลงโทษทางวินัย'}`" :label="`${'ระดับการลงโทษทางวินัย'}`"
emit-value emit-value
map-options map-options
@ -759,7 +746,7 @@ onMounted(() => {
class="full-width inputgreen cursor-pointer" class="full-width inputgreen cursor-pointer"
outlined outlined
dense dense
v-model="unStigma" v-model="disciplineData.unStigma"
hide-bottom-space hide-bottom-space
:label="`${'ล้างมลทิน'}`" :label="`${'ล้างมลทิน'}`"
/> />
@ -771,7 +758,7 @@ onMounted(() => {
outlined outlined
dense dense
lazy-rules lazy-rules
v-model="refCommandNo" v-model="disciplineData.refCommandNo"
hide-bottom-space hide-bottom-space
:label="`${'เลขที่คำสั่ง'}`" :label="`${'เลขที่คำสั่ง'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกเลขที่คำสั่ง'}`]" :rules="[(val:string) => !!val || `${'กรุณากรอกเลขที่คำสั่ง'}`]"
@ -784,7 +771,7 @@ onMounted(() => {
<div class="col-xs-6 col-sm-6 col-md-6"> <div class="col-xs-6 col-sm-6 col-md-6">
<datepicker <datepicker
menu-class-name="modalfix" menu-class-name="modalfix"
v-model="refCommandDate" v-model="disciplineData.refCommandDate"
:locale="'th'" :locale="'th'"
autoApply autoApply
:enableTimePicker="false" :enableTimePicker="false"
@ -796,12 +783,12 @@ onMounted(() => {
}}</template> }}</template>
<template #trigger> <template #trigger>
<q-input <q-input
ref="dateRef"
class="full-width inputgreen cursor-pointer" class="full-width inputgreen cursor-pointer"
outlined outlined
dense dense
:model-value=" :model-value="date2Thai(disciplineData.refCommandDate)"
(refCommandDate && date2Thai(refCommandDate as Date)) || null hide-bottom-space
"
:label="`${'เอกสารอ้างอิง (ลงวันที่)'}`" :label="`${'เอกสารอ้างอิง (ลงวันที่)'}`"
> >
<template v-slot:prepend> <template v-slot:prepend>
@ -816,13 +803,6 @@ onMounted(() => {
> >
</q-icon> </q-icon>
</template> </template>
<template v-if="refCommandDate && edit" v-slot:append>
<q-icon
name="cancel"
@click.stop.prevent="refCommandDate = null"
class="cursor-pointer"
/>
</template>
</q-input> </q-input>
</template> </template>
</datepicker> </datepicker>
@ -844,7 +824,7 @@ onMounted(() => {
<q-tooltip>นทกขอม</q-tooltip> <q-tooltip>นทกขอม</q-tooltip>
</q-btn> </q-btn>
</q-card-actions> </q-card-actions>
</form> </q-form>
</q-card> </q-card>
</q-dialog> </q-dialog>

View file

@ -55,6 +55,7 @@ const columns = ref<QTableProps["columns"]>([
field: "date", field: "date",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
format: (v) => date2Thai(v),
sort: (a: string, b: string) => sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
@ -107,6 +108,7 @@ const columns = ref<QTableProps["columns"]>([
align: "left", align: "left",
label: "เอกสารอ้างอิง (ลงวันที่)", label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true, sortable: true,
format: (v) => date2Thai(v),
field: "refCommandDate", field: "refCommandDate",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
@ -130,6 +132,7 @@ const columns = ref<QTableProps["columns"]>([
label: "วันที่แก้ไข", label: "วันที่แก้ไข",
sortable: true, sortable: true,
field: "createdAt", field: "createdAt",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
sort: (a: string, b: string) => sort: (a: string, b: string) =>
@ -139,8 +142,9 @@ const columns = ref<QTableProps["columns"]>([
function getHistory() { function getHistory() {
showLoader(); showLoader();
http http
.get(config.API.profileDisHisId(id.value)) .get(config.API.profileNewDisciplineHisByDisciplineId(id.value))
.then((res) => { .then((res) => {
console.log(res.data.result);
let data = res.data.result; let data = res.data.result;
rows.value = []; rows.value = [];
data.map((e: RequestItemsObject) => { data.map((e: RequestItemsObject) => {
@ -259,15 +263,6 @@ watch(modal, (status) => {
1 1
}} }}
</div> </div>
<div
v-else-if="
col.name == 'refCommandDate' ||
col.name == 'date' ||
col.name == 'createdAt'
"
>
{{ col.value == null ? null : date2Thai(col.value) }}
</div>
<div v-else> <div v-else>
{{ col.value ? col.value : "-" }} {{ col.value ? col.value : "-" }}
</div> </div>