UI => IDP

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-26 13:46:04 +07:00
parent 311ff2d15c
commit d9ff26ac4a
7 changed files with 1198 additions and 396 deletions

View file

@ -0,0 +1,326 @@
<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import { useRequestEditStore } from "@/modules/04_registryPerson/stores/RequestEdit";
import type { QTableProps } from "quasar";
import type {
DataOption,
Pagination,
} from "@/modules/04_registryPerson/interface/index/Main";
import DialogEditIDP from "@/modules/04_registryPerson/components/requestEdit/Dialog02_EditIDP.vue";
const store = useRequestEditStore();
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
/**
* วแปร
*/
const status = ref<string>("PENDING"); //
const keyword = ref<string>(""); //
const statusOption = ref<DataOption[]>(store.optionStatus); //
const modalEdit = ref<boolean>(false); //
const requestId = ref<string>(""); //id
/**
* Table
*/
const rows = ref<any[]>([]); //
const page = ref<number>(1); //
const pageSize = ref<number>(10); //
const rowsTotal = ref<number>(0); //
const maxPage = ref<number>(0); //
const columns = ref<QTableProps["columns"]>([
{
name: "createdAt",
align: "left",
label: "วันที่ยื่นขอ",
sortable: true,
field: "createdAt",
format: (v) => (v ? date2Thai(v, false, true) : "-"),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "knowledgeSkills",
align: "left",
label: "ความรู้ / ทักษะ / สมรรถนะที่ต้องได้รับการพัฒนา",
sortable: true,
field: "knowledgeSkills",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "developmentProjects",
align: "left",
label: "วิธีการพัฒนา",
sortable: true,
field: "developmentProjects",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "developmentTarget",
align: "left",
label: "เป้าหมายการพัฒนา",
sortable: true,
field: "developmentTarget",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "developmentResults",
align: "left",
label: "วิธีการวัดผลการพัฒนา",
sortable: true,
field: "developmentResults",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "developmentReport",
align: "left",
label: "รายงานผลการพัฒนา",
sortable: true,
field: "developmentReport",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "document",
align: "left",
label: "หลักฐานอ้างอิง",
sortable: true,
field: "document",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "status",
align: "left",
label: "สถานะคำร้อง",
sortable: true,
field: "status",
format: (v) => store.convertStatus(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "remark",
align: "left",
label: "หมายเหตุ",
sortable: true,
field: "remark",
format: (v) => (v ? v : "-"),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const visibleColumns = ref<string[]>([
"createdAt",
"knowledgeSkills",
"developmentProjects",
"developmentTarget",
"developmentResults",
"developmentReport",
"document",
"status",
"remark",
]);
function fetchData() {
const data = [
{
id: "1",
createdAt: "2024-09-17T08:21:21.600Z",
status: "PENDING",
knowledgeSkills: "ความรู้",
developmentProjects: "การพัฒนา",
developmentTarget: "เป้าหมาย",
developmentResults: "ผล",
developmentReport: "รายงาน",
},
];
rows.value = data;
}
/**
* function เลอกสถานะคำรอง
*/
function updateStatusValue() {
page.value = 1;
// fetch
// function fetchData() {
}
/**
* function เคลยร สถานะคำรอง
*/
function clearStatus() {
status.value = "";
statusOption.value = store.optionStatus;
}
/**
* function นหาคำใน select สถานะคำรอง
* @param val คำค
* @param update Function
*/
function filterOption(val: string, update: Function) {
update(() => {
status.value = val ? "" : status.value;
statusOption.value = store.optionStatus.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
}
/**
* function เลอกแถวตอหน
* @param newPagination
*/
function updatePageSizePagination(newPagination: Pagination) {
page.value = 1;
pageSize.value = newPagination.rowsPerPage;
}
/**
* funciton แกไขคำรอง
* @param id รายการคำรอง
*/
function onclickEdit(id: string) {
modalEdit.value = true;
requestId.value = id;
}
onMounted(() => {
fetchData();
});
</script>
<template>
<q-card class="q-pa-md">
<div class="row q-mb-sm q-col-gutter-sm">
<div class="col-xs-10 col-md-3">
<q-select
style="max-width: 250px"
v-model="status"
label="สถานะคำร้อง"
dense
outlined
emit-value
map-options
option-label="name"
option-value="id"
:options="statusOption"
@update:model-value="updateStatusValue"
:clearable="status !== ''"
@clear="clearStatus"
use-input
@filter="(inputValue:string,
doneFn:Function) => filterOption(inputValue, doneFn
) "
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template>
</q-select>
</div>
<q-space />
<q-input
v-model="keyword"
outlined
clearable
dense
label="ค้นหา"
style="width: 250px"
@keydown.enter="updateStatusValue()"
>
</q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
class="col-xs-12 col-sm-3 col-md-2"
/>
</div>
<div class="col-12">
<d-table
:columns="columns"
:rows="rows"
row-key="id"
:rows-per-page-options="[10, 25, 50, 100]"
:paging="true"
:visible-columns="visibleColumns"
@update:pagination="updatePageSizePagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width />
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props">
<q-td auto-width>
<q-btn
icon="edit"
round
dense
flat
color="edit"
@click.pervent="onclickEdit(props.row.id)"
>
<q-tooltip>แกไขสถานะคำรอง</q-tooltip>
</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">
<q-tooltip>หลกฐานอางอ</q-tooltip>
</q-btn>
</div>
<div v-else class="table_ellipsis2">
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ rowsTotal }} รายการ
<q-pagination
v-model="page"
active-color="primary"
color="dark"
:max="Number(maxPage)"
:max-pages="5"
size="sm"
boundary-links
direction-links
@update:model-value="fetchData"
></q-pagination>
</template>
</d-table>
</div>
</q-card>
<DialogEditIDP v-model:modal="modalEdit" v-model:request-id="requestId" />
</template>
<style scoped></style>