AIP == > IDP

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-10-01 10:43:52 +07:00
parent b5829ec905
commit b059e3a770
9 changed files with 333 additions and 144 deletions

View file

@ -1,18 +1,22 @@
<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useRequestEditStore } from "@/modules/04_registryPerson/stores/RequestEdit";
import config from "@/app.config";
import http from "@/plugins/http";
import type { QTableProps } from "quasar";
import type {
DataOption,
Pagination,
} from "@/modules/04_registryPerson/interface/index/Main";
import type { DataListsIDP } from "@/modules/04_registryPerson/interface/response/Main";
import DialogEditIDP from "@/modules/04_registryPerson/components/requestEdit/Dialog02_EditIDP.vue";
const $q = useQuasar();
const store = useRequestEditStore();
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
/**
@ -20,14 +24,14 @@ const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
*/
const status = ref<string>("PENDING"); //
const keyword = ref<string>(""); //
const statusOption = ref<DataOption[]>(store.optionStatus); //
const statusOption = ref<DataOption[]>(store.optionStatusIDP); //
const modalEdit = ref<boolean>(false); //
const requestId = ref<string>(""); //id
/**
* Table
*/
const rows = ref<any[]>([]); //
const rows = ref<DataListsIDP[]>([]); //
const page = ref<number>(1); //
const pageSize = ref<number>(10); //
const rowsTotal = ref<number>(0); //
@ -44,11 +48,11 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
{
name: "knowledgeSkills",
name: "name",
align: "left",
label: "ความรู้ / ทักษะ / สมรรถนะที่ต้องได้รับการพัฒนา",
sortable: true,
field: "knowledgeSkills",
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
@ -103,16 +107,16 @@ const columns = ref<QTableProps["columns"]>([
label: "สถานะคำร้อง",
sortable: true,
field: "status",
format: (v) => store.convertStatus(v),
format: (v) => store.convertStatusIDP(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "remark",
name: "reason",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "remark",
field: "reason",
format: (v) => (v ? v : "-"),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@ -120,47 +124,53 @@ const columns = ref<QTableProps["columns"]>([
]);
const visibleColumns = ref<string[]>([
"createdAt",
"knowledgeSkills",
"name",
"developmentProjects",
"developmentTarget",
"developmentResults",
"developmentReport",
"document",
"status",
"remark",
"reason",
]);
function fetchData() {
const data = [
{
id: "1",
createdAt: "2024-09-17T08:21:21.600Z",
status: "PENDING",
knowledgeSkills: "ความรู้",
developmentProjects: "การพัฒนา",
developmentTarget: "เป้าหมาย",
developmentResults: "ผล",
developmentReport: "รายงาน",
},
];
rows.value = data;
/** function fetch ข้อมูลรายการการพัฒนารายบุคคล*/
async function fetchData() {
showLoader();
await http
.get(config.API.requestDevelopmentEdit + `admin`, {
params: {
page: page.value,
pageSize: pageSize.value,
status: status.value ? status.value : "",
keyword: keyword.value,
},
})
.then(async (res) => {
const data = await res.data.result;
maxPage.value = Math.ceil(data.total / pageSize.value);
rowsTotal.value = data.total;
rows.value = data.data;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* function เลอกสถานะคำรอง
*/
/** function เลือกสถานะคำร้อง */
function updateStatusValue() {
page.value = 1;
// fetch
// function fetchData() {
fetchData();
}
/**
* function เคลยร สถานะคำรอง
*/
/** function เคลียร์ สถานะคำร้อง */
function clearStatus() {
status.value = "";
statusOption.value = store.optionStatus;
statusOption.value = store.optionStatusIDP;
}
/**
@ -171,7 +181,7 @@ function clearStatus() {
function filterOption(val: string, update: Function) {
update(() => {
status.value = val ? "" : status.value;
statusOption.value = store.optionStatus.filter(
statusOption.value = store.optionStatusIDP.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
@ -195,6 +205,70 @@ function onclickEdit(id: string) {
requestId.value = id;
}
/**
* function หาชอไฟล
* @param id รายการยนคำรองขอแกไขขอม
*/
function onDownloadFile(id: string) {
showLoader();
http
.get(
config.API.file(
"ระบบทะเบียนประวัติ",
"เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล",
id
)
)
.then(async (res) => {
if (res.data.length !== 0) {
await downloadUrl(id, res.data[0].fileName);
} else {
hideLoader();
}
})
.catch((e) => {
messageError($q, e);
hideLoader();
});
}
/**
* function โหลดไฟล
* @param id รายการยนคำรองขอแกไขขอม
* @param fileName อไฟล
*/
async function downloadUrl(id: string, fileName: string) {
await http
.get(
config.API.fileByFile(
"ระบบทะเบียนประวัติ",
"เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล",
id,
fileName
)
)
.then((res) => {
window.open(res.data.downloadUrl, "_blank");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* การเปลยนแปลงของ pageSize
* เมอมการเปลยนแปลงจำทำการ งชอมลรายการคำรองขอแกไขทะเบยนประวตามจำนวน pageSize
*/
watch(
() => pageSize.value,
() => {
fetchData();
}
);
onMounted(() => {
fetchData();
});
@ -291,12 +365,38 @@ onMounted(() => {
</q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name === 'document'">
<q-btn icon="mdi-download" round dense flat color="primary">
<div v-if="col.name == 'developmentProjects'">
<div class="column">
<q-checkbox
size="xs"
:model-value="props.row.isDevelopment70"
label="70 การลงมือปฏิบัติ (โดยผู้บังคับบัญชามอบหมาย)"
/>
<q-checkbox
size="xs"
:model-value="props.row.isDevelopment20"
label="20 การเรียนรู้จากผู้อื่น (Coach/Mentor/Consulting)"
/>
<q-checkbox
size="xs"
:model-value="props.row.isDevelopment10"
label="10 การฝึกอบรมอื่นๆ"
/>
</div>
</div>
<div v-else-if="col.name === 'document'">
<q-btn
icon="mdi-download"
round
dense
flat
color="primary"
@click.pervent="onDownloadFile(props.row.id)"
>
<q-tooltip>หลกฐานอางอ</q-tooltip>
</q-btn>
</div>
<div v-else class="table_ellipsis2">
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
@ -320,7 +420,11 @@ onMounted(() => {
</div>
</q-card>
<DialogEditIDP v-model:modal="modalEdit" v-model:request-id="requestId" />
<DialogEditIDP
v-model:modal="modalEdit"
v-model:request-id="requestId"
:fetch-data-list="fetchData"
/>
</template>
<style scoped></style>