405 lines
10 KiB
Vue
405 lines
10 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted, watch } from "vue";
|
|
import { useRouter } from "vue-router";
|
|
import { useQuasar } from "quasar";
|
|
import config from "@/app.config";
|
|
import http from "@/plugins/http";
|
|
|
|
/**
|
|
* importType
|
|
*/
|
|
import type { QTableProps } from "quasar";
|
|
import type {
|
|
DataOption,
|
|
Pagination,
|
|
} from "@/modules/04_registryPerson/interface/index/Main";
|
|
|
|
/**
|
|
* importComponents
|
|
*/
|
|
import DialogStatus from "@/modules/04_registryPerson/components/requestEdit/DialogStatus.vue";
|
|
|
|
/**
|
|
* importStore
|
|
*/
|
|
import { useRequestEditStore } from "@/modules/04_registryPerson/stores/RequestEdit";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
/**
|
|
* use
|
|
*/
|
|
const $q = useQuasar();
|
|
const router = useRouter();
|
|
const store = useRequestEditStore();
|
|
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
|
|
|
|
/**
|
|
* 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: "lastUpdatedAt",
|
|
align: "left",
|
|
label: "วันที่ยื่นขอ",
|
|
sortable: true,
|
|
field: "lastUpdatedAt",
|
|
format: (v) => (v ? date2Thai(v, false, true) : "-"),
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "fullname",
|
|
align: "left",
|
|
label: "ชื่อ-นามสกุล",
|
|
sortable: false,
|
|
field: "fullname",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "topic",
|
|
align: "left",
|
|
label: "ชื่อเรื่อง",
|
|
sortable: true,
|
|
field: "topic",
|
|
format: (v) => (v ? v : "-"),
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "detail",
|
|
align: "left",
|
|
label: "รายละเอียด",
|
|
sortable: true,
|
|
field: "detail",
|
|
format: (v) => (v ? v : "-"),
|
|
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[]>([
|
|
"lastUpdatedAt",
|
|
|
|
"fullname",
|
|
"topic",
|
|
"detail",
|
|
"document",
|
|
"status",
|
|
"remark",
|
|
]);
|
|
|
|
/**
|
|
* ตัวแปร
|
|
*/
|
|
const status = ref<string>("PENDING");
|
|
const keyword = ref<string>("");
|
|
const statusOption = ref<DataOption[]>(store.optionStatus);
|
|
const modalStatus = ref<boolean>(false);
|
|
const requestId = ref<string>("");
|
|
|
|
function fetchListRequset() {
|
|
showLoader();
|
|
http
|
|
.get(config.API.requestEdit + `admin`, {
|
|
params: {
|
|
page: page.value,
|
|
pageSize: pageSize.value,
|
|
status: status.value,
|
|
keyword: keyword.value,
|
|
},
|
|
})
|
|
.then((res) => {
|
|
const data = 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 updateStatusValue() {
|
|
page.value = 1;
|
|
fetchListRequset();
|
|
}
|
|
|
|
function clearStatus() {
|
|
status.value = "";
|
|
statusOption.value = store.optionStatus;
|
|
}
|
|
|
|
function filterOption(val: string, update: Function) {
|
|
update(() => {
|
|
status.value = val ? "" : status.value;
|
|
statusOption.value = store.optionStatus.filter(
|
|
(v: any) => v.name.indexOf(val) > -1
|
|
);
|
|
});
|
|
}
|
|
|
|
function onclickEdit(id: string) {
|
|
modalStatus.value = true;
|
|
requestId.value = id;
|
|
}
|
|
|
|
function updatePageSizePagination(newPagination: Pagination) {
|
|
page.value = 1;
|
|
pageSize.value = newPagination.rowsPerPage;
|
|
}
|
|
|
|
/**
|
|
* function หาชื่อไฟล์
|
|
* @param id รายการยื่นคำร้องขอแก้ไขข้อมูล
|
|
*/
|
|
function onDownloadFile(id: string) {
|
|
showLoader();
|
|
http
|
|
.get(
|
|
config.API.file(
|
|
"ระบบทะเบียนประวัติ",
|
|
"เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล",
|
|
id
|
|
)
|
|
)
|
|
.then((res) => {
|
|
if (res.data.length !== 0) {
|
|
downloadUrl(id, res.data[0].fileName);
|
|
} else {
|
|
hideLoader();
|
|
}
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* function โหลดไฟล์
|
|
* @param id รายการยื่นคำร้องขอแก้ไขข้อมูล
|
|
* @param fileName ชื่อไฟล์
|
|
*/
|
|
function downloadUrl(id: string, fileName: string) {
|
|
http
|
|
.get(
|
|
config.API.fileByFile(
|
|
"ระบบทะเบียนประวัติ",
|
|
"เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล",
|
|
id,
|
|
fileName
|
|
)
|
|
)
|
|
.then((res) => {
|
|
window.open(res.data.downloadUrl, "_blank");
|
|
})
|
|
.catch((e) => {
|
|
messageError($q, e);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
watch(
|
|
() => pageSize.value,
|
|
() => {
|
|
fetchListRequset();
|
|
}
|
|
);
|
|
|
|
onMounted(() => {
|
|
fetchListRequset();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="row items-center">
|
|
<div class="toptitle text-dark row items-center q-py-xs">
|
|
<q-btn
|
|
icon="mdi-arrow-left"
|
|
unelevated
|
|
round
|
|
dense
|
|
flat
|
|
color="primary"
|
|
class="q-mr-sm"
|
|
@click="router.go(-1)"
|
|
/>
|
|
รายการคำร้องขอแก้ไขทะเบียนประวัติ
|
|
</div>
|
|
</div>
|
|
<q-card flat bordered 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 == 'no'">
|
|
{{ props.rowIndex + 1 }}
|
|
</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">
|
|
{{ 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="fetchListRequset()"
|
|
></q-pagination>
|
|
</template>
|
|
</d-table>
|
|
</div>
|
|
</q-card>
|
|
|
|
<DialogStatus
|
|
v-model:modal="modalStatus"
|
|
:fetchData="fetchListRequset"
|
|
:requestId="requestId"
|
|
/>
|
|
</template>
|
|
|
|
<style scoped></style>
|