Merge branch 'phatt_dev' into develop

This commit is contained in:
puriphatt 2024-03-20 17:30:41 +07:00
commit 63b1c0d32e
4 changed files with 166 additions and 132 deletions

View file

@ -63,4 +63,12 @@ profileNewCertificateByCertificateId: (certificateId: string) =>
`${registryNew}certificate/${certificateId}`,
profileNewCertificateHisByCertificateId: (certificateId: string) =>
`${registryNew}certificate/history/${certificateId}`,
// ข้อมูลอื่นๆ
profileNewOther: `${registryNew}other`,
profileNewOtherByProfileId: (profileId: string) =>
`${registryNew}other/${profileId}`,
profileNewOtherById: (dataId: string) => `${registryNew}other/${dataId}`,
profileNewOtherHisById: (dataId: string) =>
`${registryNew}other/history/${dataId}`,
};

View file

@ -7,6 +7,8 @@ import type {
MyObjectRef,
} from "@/modules/04_registryNew/interface/index/other";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import DialogHeader from "@/components/DialogHeader.vue";
import { useRoute } from "vue-router";
@ -14,7 +16,15 @@ import DialogHistory from "@/modules/04_registryNew/components/detail/Other/01_O
const route = useRoute();
const $q = useQuasar();
const mixin = useCounterMixin();
const { date2Thai, showLoader, hideLoader, success, messageError } = mixin;
const {
date2Thai,
showLoader,
hideLoader,
success,
messageError,
dialogRemove,
dialogConfirm,
} = mixin;
const id = ref<string>("");
@ -45,6 +55,7 @@ const modal = ref<boolean>(false);
const edit = ref<boolean>(false);
const modalHistory = ref<boolean>(false);
const isActive = ref<boolean>(true);
const date = ref<Date | null>(null);
const detail = ref<string>();
@ -65,6 +76,7 @@ const columns = ref<QTableProps["columns"]>([
field: "date",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width: 50px;",
format: (v) => date2Thai(v),
},
{
name: "detail",
@ -91,6 +103,7 @@ function openDialogEdit(props: RowList) {
modal.value = true;
edit.value = true;
id.value = props.id;
date.value = props.date;
detail.value = props.detail;
}
@ -112,107 +125,118 @@ function closeDialog() {
/** 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);
dialogConfirm(
$q,
async () => {
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();
}
}
if (hasError.every((result) => result === true)) {
if (edit.value) {
editData();
} else {
saveData();
}
}
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
/**
* นทกเพมขอม
*/
function saveData() {
// showLoader();
// await http
// .post(config.API.profileOtherId(profileId.value), {
// id: id.value,
// date: date.value,
// detail: detail.value,
// })
// .then((res) => {
// success($q, "");
// modal.value = false;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
async function saveData() {
showLoader();
await http
.post(config.API.profileNewOther, {
profileId: profileId.value,
isActive: isActive.value,
date: date.value,
detail: detail.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
getData();
closeDialog();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* นทกแกไขขอม
*/
const editData = async () => {
// showLoader();
// await http
// .put(config.API.profileOtherId(id.value), {
// id: id.value,
// date: date.value,
// detail: detail.value,
// })
// .then((res) => {
// success($q, "");
// modal.value = false;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await fetchData();
// });
closeDialog();
};
async function editData() {
showLoader();
await http
.patch(config.API.profileNewOtherById(id.value), {
isActive: isActive.value,
date: date.value,
detail: detail.value,
})
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
getData();
closeDialog();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
function getData() {
const data: RowList[] = [
{
id: "08dc3c0e-b6ef-4e6c-8c84-787447416450",
date: null,
detail: "ทดสอบ 1",
createdFullName: "สาวิตรี ศรีสมัย",
createdAt: new Date("2024-03-04T05:48:27.615Z"),
},
{
id: "08dc3c0e-bd30-48e8-8d14-31bcaf92b3a2",
date: null,
detail: "ทดสอบ 2",
createdFullName: "สาวิตรี ศรีสมัย",
createdAt: new Date("2024-03-04T05:48:38.105Z"),
},
{
id: "08dc3c0e-c874-41fe-8b55-7c992ebf99b2",
date: new Date("2024-03-03T17:00:00.000Z"),
detail: "ข้อมูลอื่นๆ",
createdFullName: "สาวิตรี ศรีสมัย",
createdAt: new Date("2024-03-04T05:48:57.002Z"),
},
];
async function getData() {
showLoader();
await http
.get(config.API.profileNewOtherByProfileId(profileId.value))
.then((res) => {
rows.value = res.data.result;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
rows.value = data;
async function deleteData(id: string) {
showLoader();
await http
.delete(config.API.profileNewOtherById(id))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
getData();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
const infoRows = [
{ title: 'รายละเอียด', value: '' },
{ title: 'ล้างมลทิน', value: '' },
{ title: 'เลขที่คำสั่ง', value: '' },
{ title: 'เอกสารอ้างอิง (ลงวันที่)', value: '' }
]
{ title: "รายละเอียด", value: "" },
{ title: "ล้างมลทิน", value: "" },
{ title: "เลขที่คำสั่ง", value: "" },
{ title: "เอกสารอ้างอิง (ลงวันที่)", value: "" },
];
onMounted(() => {
getData();
});
@ -318,24 +342,24 @@ 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)"
>
<div v-if="col.name === 'no'">
{{
(formFilter.page - 1) * formFilter.pageSize + props.rowIndex + 1
}}
</div>
<div v-else-if="col.name == 'date'" class="table_ellipsis">
{{ col.value ? date2Thai(col.value) : "-" }}
</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
flat
dense
round
class="q-mr-xs"
size="14px"
color="primary"
icon="mdi-pencil-outline"
@click="openDialogEdit(props.row)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
color="info"
flat
@ -347,6 +371,19 @@ onMounted(() => {
>
<q-tooltip>ประวแกไขอนๆ</q-tooltip>
</q-btn>
<!-- <q-btn
flat
dense
round
size="14px"
color="red"
icon="mdi-delete"
@click="
dialogRemove($q, async () => await deleteData(props.row.id))
"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn> -->
</q-td>
</q-tr>
</template>
@ -376,36 +413,23 @@ onMounted(() => {
</div>
<q-separator />
<q-card-section class="q-pa-none">
<div class="row q-pa-sm">
<div class="col text-grey-6 text-weight-medium">รายละเอยด</div>
<div class="col">
{{ props.row.detail !== "" ? props.row.detail : "-" }}
</div>
<div class="col text-grey-6 text-weight-medium">างมลท</div>
<div class="col">
{{ props.row.unStigma ? props.row.unStigma : "-" }}
</div>
</div>
<q-separator />
<div class="row bg-grey-2 q-pa-sm">
<div class="col text-grey-6 text-weight-medium">เลขทคำส</div>
<div class="col">
{{
props.row.refCommandNo ? props.row.refCommandNo : "-"
}}
</div>
<div class="col text-grey-6 text-weight-medium">
เอกสารอางอ (ลงวนท)
</div>
<div class="col">
{{
props.row.refCommandDate
? date2Thai(props.row.refCommandDate)
: "-"
}}
</div>
</div>
<q-item
v-for="(col, index) in props.cols.filter(
(col) => col.name !== 'desc'
)"
:key="col.name"
:class="index % 2 !== 0 ? 'bg-grey-1' : ''"
>
<q-item-section class="text-grey-6">
<q-item-label>{{ col.label }}</q-item-label>
</q-item-section>
<q-item-section class="text-dark">
<q-item-label>
{{ col.value ? col.value : "-" }}
</q-item-label>
</q-item-section>
</q-item>
</q-card-section>
</q-card>
</div>

View file

@ -91,8 +91,7 @@ const columns = ref<QTableProps["columns"]>([
]);
function getHistory() {
showLoader();
http
.get(config.API.profileOtherHisId(id.value))
http.get(config.API.profileNewOtherHisById(id.value))
.then((res) => {
let data = res.data.result;
rows.value = [];

View file

@ -26,6 +26,7 @@ const profileId = ref<string>(
);
async function getData() {
showLoader()
await http
.get(
config.API.file("ระบบทะเบียนประวัติ", "เอกสารหลักฐาน", profileId.value)
@ -36,7 +37,9 @@ async function getData() {
.catch((e) => {
messageError($q, e);
})
.finally(() => {});
.finally(() => {
hideLoader()
});
}
/**