Merge branch 'oat_dev' into develop

This commit is contained in:
oat_dev 2024-03-22 09:31:52 +07:00
commit f1a16e3acc
3 changed files with 201 additions and 217 deletions

View file

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

View file

@ -30,8 +30,17 @@ const {
messageError,
success,
dateToISO,
dialogRemove,
} = mixin;
const disciplineData = reactive<any>({
date: new Date(),
level: "",
detail: "",
unStigma: "",
refCommandNo: "",
profileId: profileId.value,
refCommandDate: null,
});
const rows = ref<RequestItemsObject[]>([]);
const mode = ref<string>("table");
const filterKeyword = ref<string>("");
@ -66,6 +75,7 @@ const columns = ref<QTableProps["columns"]>([
label: "วัน เดือน ปี",
sortable: true,
field: "date",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -121,6 +131,7 @@ const columns = ref<QTableProps["columns"]>([
label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true,
field: "refCommandDate",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -218,18 +229,82 @@ function filterSelector(val: string, update: Function, refData: string) {
function closeDialog() {
modal.value = false;
edit.value = false;
date.value = null;
detail.value = "";
level.value = "";
unStigma.value = "";
refCommandNo.value = "";
refCommandDate.value = null;
disciplineData.date = null;
disciplineData.detail = "";
disciplineData.level = "";
disciplineData.unStigma = "";
disciplineData.refCommandNo = "";
disciplineData.refCommandDate = null;
}
function openDialogAdd() {
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 เลอก
@ -240,184 +315,80 @@ function openDialogEdit(props: RequestItemsObject) {
console.log(props);
id.value = props.id;
date.value = props.date;
detail.value = props.detail;
level.value = props.level;
unStigma.value = props.unStigma;
refCommandNo.value = props.refCommandNo;
refCommandDate.value = props.refCommandDate;
disciplineData.date = props.date;
disciplineData.detail = props.detail;
disciplineData.level = props.level;
disciplineData.unStigma = props.unStigma;
disciplineData.refCommandNo = props.refCommandNo;
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) {
modalHistory.value = true;
id.value = idOrder;
}
function getData() {
// showLoader();
// http
// .get(config.API.profileDisId(profileId.value))
// .then((res) => {
// let data = res.data.result;
// 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: "สาวิตรี ศรีสมัย",
async function onSubmit() {
dialogConfirm(
$q,
async () => {
edit.value ? editData(id.value) : addData();
closeDialog();
},
{
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(() => {
getData();
onMounted(async () => {
await fetchData(profileId.value);
});
</script>
<template>
@ -523,27 +494,30 @@ 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 == 'refCommandDate' || col.name == 'date'"
class="table_ellipsis"
>
{{ col.value == null ? null : 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
@ -555,6 +529,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>
@ -673,7 +660,7 @@ onMounted(() => {
<!-- dialog add edit -->
<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>
@ -684,7 +671,7 @@ onMounted(() => {
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
menu-class-name="modalfix"
v-model="date"
v-model="disciplineData.date"
:locale="'th'"
autoApply
:enableTimePicker="false"
@ -700,7 +687,7 @@ onMounted(() => {
class="full-width inputgreen cursor-pointer"
outlined
dense
:model-value="date2Thai(date)"
:model-value="date2Thai(disciplineData.date)"
:rules="[(val:string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี'}`]"
hide-bottom-space
:label="`${'วัน/เดือน/ปี'}`"
@ -728,7 +715,7 @@ onMounted(() => {
outlined
dense
lazy-rules
v-model="detail"
v-model="disciplineData.detail"
:rules="[(val:string) => !!val || `${'กรุณากรอกรายละเอียด'}`]"
hide-bottom-space
:label="`${'รายละเอียด'}`"
@ -740,7 +727,7 @@ onMounted(() => {
outlined
dense
lazy-rules
v-model="level"
v-model="disciplineData.level"
:label="`${'ระดับการลงโทษทางวินัย'}`"
emit-value
map-options
@ -759,7 +746,7 @@ onMounted(() => {
class="full-width inputgreen cursor-pointer"
outlined
dense
v-model="unStigma"
v-model="disciplineData.unStigma"
hide-bottom-space
:label="`${'ล้างมลทิน'}`"
/>
@ -771,7 +758,7 @@ onMounted(() => {
outlined
dense
lazy-rules
v-model="refCommandNo"
v-model="disciplineData.refCommandNo"
hide-bottom-space
:label="`${'เลขที่คำสั่ง'}`"
:rules="[(val:string) => !!val || `${'กรุณากรอกเลขที่คำสั่ง'}`]"
@ -784,7 +771,7 @@ onMounted(() => {
<div class="col-xs-6 col-sm-6 col-md-6">
<datepicker
menu-class-name="modalfix"
v-model="refCommandDate"
v-model="disciplineData.refCommandDate"
:locale="'th'"
autoApply
:enableTimePicker="false"
@ -796,12 +783,12 @@ onMounted(() => {
}}</template>
<template #trigger>
<q-input
ref="dateRef"
class="full-width inputgreen cursor-pointer"
outlined
dense
:model-value="
(refCommandDate && date2Thai(refCommandDate as Date)) || null
"
:model-value="date2Thai(disciplineData.refCommandDate)"
hide-bottom-space
:label="`${'เอกสารอ้างอิง (ลงวันที่)'}`"
>
<template v-slot:prepend>
@ -816,13 +803,6 @@ onMounted(() => {
>
</q-icon>
</template>
<template v-if="refCommandDate && edit" v-slot:append>
<q-icon
name="cancel"
@click.stop.prevent="refCommandDate = null"
class="cursor-pointer"
/>
</template>
</q-input>
</template>
</datepicker>
@ -844,7 +824,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: "date",
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" }),
},
@ -107,6 +108,7 @@ const columns = ref<QTableProps["columns"]>([
align: "left",
label: "เอกสารอ้างอิง (ลงวันที่)",
sortable: true,
format: (v) => date2Thai(v),
field: "refCommandDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@ -130,6 +132,7 @@ const columns = ref<QTableProps["columns"]>([
label: "วันที่แก้ไข",
sortable: true,
field: "createdAt",
format: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -139,8 +142,9 @@ const columns = ref<QTableProps["columns"]>([
function getHistory() {
showLoader();
http
.get(config.API.profileDisHisId(id.value))
.get(config.API.profileNewDisciplineHisByDisciplineId(id.value))
.then((res) => {
console.log(res.data.result);
let data = res.data.result;
rows.value = [];
data.map((e: RequestItemsObject) => {
@ -259,15 +263,6 @@ watch(modal, (status) => {
1
}}
</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>
{{ col.value ? col.value : "-" }}
</div>