This commit is contained in:
Warunee Tamkoo 2024-08-01 12:12:28 +07:00
parent 46533bbd62
commit 15d3ac574d
128 changed files with 347 additions and 322 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,583 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/** importType*/
import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main";
import type {
DataPerson,
DataType,
} from "@/modules/04_registryPerson/interface/response/Main";
import type { FormFilter } from "@/modules/04_registryPerson/interface/request/Main";
/** importComponents*/
import TableView from "@/modules/04_registryPerson/components/TableView.vue";
import avatar from "@/assets/avatar_user.jpg";
/** importStore*/
import { useRegistryNewDataStore } from "@/modules/04_registryPerson/store";
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
const store = useRegistryNewDataStore();
const { showLoader, hideLoader, messageError } = useCounterMixin();
const mode = ref<"table" | "card">("table");
const isShowFilter = ref<boolean>(false);
const isShowBtnFilter = ref<boolean>(true);
const empType = ref<string>("officer"); // .//
const labelOption = reactive({
type: "ข้าราชการ กทม.สามัญ",
posType: "ทั้งหมด",
posLevel: "ทั้งหมด",
retireYear: "",
});
const searchType = ref<string>("fullName");
const formFilter = reactive<FormFilter>({
page: 1,
pageSize: 12,
keyword: "",
type: "",
posType: "",
posLevel: "",
retireYear: "",
rangeYear: { min: 0, max: 60 },
isShowRetire: false,
isProbation: false,
});
const maxPage = ref<number>(1);
const total = ref<number>(0);
const dataPersonMain = ref<DataPerson[]>([]);
const conditionTotal = computed(() => {
let num: string = "";
if (formFilter.isProbation && formFilter.isShowRetire) {
num = "(2)";
} else if (formFilter.isProbation || formFilter.isShowRetire) {
num = "(1)";
} else "";
return num;
});
/**
* function เรยกขอมลตำแหนงประเภท
*/
function fetchType() {
http
.get(config.API.orgPosType)
.then((res) => {
store.fetchType(res.data.result);
})
.catch((err) => {
messageError($q, err);
});
}
/**
* function เรยกขอมลกลมงาน
*/
function fetchOptionGroup() {
http
.get(config.API.orgEmployeeType)
.then((res) => {
store.fetchType(res.data.result);
})
.catch((err) => {
messageError($q, err);
});
}
function fetchYearOption() {
if (store.yearOps.length === 0) {
const options = [];
const year = new Date().getFullYear();
for (let i = year - 40; i <= year + 60; i++) {
options.push({ id: i.toString(), name: (i + 543).toString() });
}
if (options) {
store.yearOps.push(...options);
}
}
}
/**
* function fetch รายชอขอมลทะเบยนประว
*/
function fetchDataPerson() {
showLoader();
let queryParams: any = {
page: formFilter.page,
pageSize: formFilter.pageSize,
};
if (formFilter.keyword) {
queryParams = Object.assign({}, queryParams, {
searchField: searchType.value,
searchKeyword: formFilter.keyword,
});
}
if (labelOption.posLevel != "ทั้งหมด") {
queryParams = Object.assign({}, queryParams, {
posLevel: labelOption.posLevel,
});
}
if (labelOption.posType != "ทั้งหมด") {
queryParams = Object.assign({}, queryParams, {
posType: labelOption.posType,
});
}
if (formFilter.isProbation != null) {
queryParams.isProbation = formFilter.isProbation;
}
if (formFilter.isShowRetire != null) {
queryParams.isRetire = formFilter.isShowRetire;
}
if (empType.value !== "officer") {
queryParams.type = empType.value;
}
http
.get(
config.API.registryNew(empType.value !== "officer" ? "-employee" : ""),
{ params: queryParams }
)
.then((res) => {
maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize);
dataPersonMain.value = res.data.result.data;
total.value = res.data.result.total;
insertAvatar(res.data.result.data);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* function fetch ปโปรไฟล
* @param items อมลคน
*/
function insertAvatar(items: DataPerson[]) {
items.map((x: any, index: number) => {
if (x.avatarName != null) {
http
.get(
config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", x.id, x.avatarName)
)
.then((img) => {
dataPersonMain.value[index] = {
...x,
avatar: img.data.downloadUrl,
};
})
.catch(() => {
dataPersonMain.value[index] = {
...x,
avatar: avatar,
};
});
} else {
dataPersonMain.value[index] = {
...x,
avatar: avatar,
};
}
});
}
/**
* funciotn แสดงตวเลอกเพมเต
*/
function onClickShowFilter() {
isShowFilter.value = !isShowFilter.value;
isShowBtnFilter.value = false;
if (isShowFilter.value) {
fetchType();
// fetchLevel();
fetchYearOption();
}
}
/**
* funciotn นหาขอม
*/
function onclickSearch() {
isShowFilter.value = true;
isShowBtnFilter.value = false;
formFilter.page = 1;
if (isShowFilter.value) {
fetchType();
// fetchLevel();
fetchYearOption();
}
formFilter.keyword = formFilter.keyword === null ? "" : formFilter.keyword;
fetchDataPerson();
}
/**
* function เลอกประเภทขาราชการ
* @param item ประเภทขาราชการ
*/
function selectType(item: DataOption) {
labelOption.type = item.name;
empType.value = item.id;
formFilter.page = 1;
labelOption.posType = "ทั้งหมด";
labelOption.posLevel = "ทั้งหมด";
if (item.id !== "officer") {
formFilter.isShowRetire = null;
formFilter.isProbation = null;
fetchOptionGroup();
} else {
fetchType();
}
fetchDataPerson();
}
/**
* function เลอกประเภทตำแหน
* @param item ประเภทตำแหน
*/
function selectPosType(item: DataOption) {
const dataType = store.posTypeMain.find((e: DataType) => e.id === item.id);
store.fetchLevel(dataType?.posLevels);
labelOption.posType = item.name;
labelOption.posLevel = "ทั้งหมด";
formFilter.page = 1;
fetchDataPerson();
}
/**
* function เลอกประเภทตำแหน
* @param item ประเภทระด
*/
function selectPosLevel(item: DataOption) {
labelOption.posLevel = item.name;
formFilter.page = 1;
fetchDataPerson();
}
/**
* function เคลวเลอก
* @param t ประเภทตวเลอก
*/
function clearSelect(t: string) {
if (t === "posType") {
labelOption.posType = "ทั้งหมด";
labelOption.posLevel = "ทั้งหมด";
} else if (t === "posLevel") {
labelOption.posLevel = "ทั้งหมด";
} else if (t === "retireYear") {
labelOption.retireYear = "";
} else if (t === "rangeYear") {
formFilter.rangeYear.min = 0;
formFilter.rangeYear.max = 60;
}
formFilter.page = 1;
fetchDataPerson();
}
onMounted(async () => {
fetchDataPerson();
});
</script>
<template>
<q-card class="q-mt-md">
<q-card-section class="card-img q-pb-lg">
<div class="text-h5 text-center q-py-md text-weight-medium">
นหาขอมลทะเบยนประว
</div>
<div class="row justify-center">
<div
class="col-xs-12 col-sm-12 col-md-11 q-pa-md bg-Search rounded-borders"
>
<q-form @submit="onclickSearch">
<div class="bg-white row col-12 q-pa-none rounded-borders">
<div class="row col-11">
<div class="col-3 row wrap">
<q-select
borderless
bg-color="white"
v-model="searchType"
:options="store.searchTypeOption"
emit-value
dense
emit-option
option-label="name"
option-value="id"
map-options
class="selectS col-11 q-px-md"
color="deep-orange"
dropdown-icon="mdi-chevron-down"
/>
<q-separator vertical />
</div>
<q-input
borderless
dense
bg-color="white"
v-model="formFilter.keyword"
clearable
placeholder="ค้นหา"
class="col-9 q-pr-md"
@clear="fetchDataPerson"
>
<template v-slot:before>
<q-icon name="search" color="deep-orange" />
</template>
</q-input>
</div>
<div class="row col-1">
<q-btn
class="fit btnSearch"
unelevated
color="deep-orange"
label="ค้นหา"
type="submit"
/>
</div>
</div>
</q-form>
<div v-if="isShowBtnFilter" class="col-12 row q-mt-sm">
<q-space />
<q-btn
flat
label="ตัวเลือกเพิ่มเติม"
icon-right="mdi-tune"
@click="onClickShowFilter"
dense
class="q-px-sm"
></q-btn>
</div>
<div
class="row q-mt-sm q-gutter-sm justify-center"
v-if="isShowFilter"
>
<q-btn-dropdown
flat
rounded
dense
label-color="white"
dropdown-icon="mdi-chevron-down"
class="q-px-sm"
>
<template v-slot:label>
{{ `${labelOption.type}` }}
</template>
<q-list>
<q-item
v-for="(item, index) in store.employeeClassOps"
:key="index"
clickable
v-close-popup
@click="selectType(item)"
>
<q-item-section>
<q-item-label>{{ item.name }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
<q-separator inset vertical class="lineFil" />
<q-btn-dropdown
rounded
flat
dense
label-color="white"
dropdown-icon="mdi-chevron-down"
class="q-px-sm"
>
<template v-slot:label>
{{
labelOption.posType !== "ทั้งหมด"
? labelOption.posType
: empType === "officer"
? `ตำแหน่งประเภท${labelOption.posType}`
: `กลุ่มงาน${labelOption.posType}`
}}
<q-btn
size="10px"
flat
round
color="white"
icon="close"
v-if="labelOption.posType !== 'ทั้งหมด'"
@click.stop.prevent="clearSelect('posType')"
/>
</template>
<q-list>
<q-item
v-for="(item, index) in store.posTypeOps"
:key="index"
clickable
v-close-popup
@click="selectPosType(item)"
>
<q-item-section>
<q-item-label>{{ item.name }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
<q-separator inset vertical class="lineFil" />
<q-btn-dropdown
flat
dense
rounded
label-color="white"
dropdown-icon="mdi-chevron-down"
class="q-px-sm"
:disable="labelOption.posType === 'ทั้งหมด' ? true : false"
>
<template v-slot:label>
{{
labelOption.posLevel !== "ทั้งหมด"
? labelOption.posLevel
: empType === "officer"
? `ระดับ${labelOption.posLevel}`
: `ระดับชั้นงาน${labelOption.posLevel}`
}}
<q-btn
size="10px"
flat
round
color="white"
icon="close"
v-if="labelOption.posLevel !== 'ทั้งหมด'"
@click.stop.prevent="clearSelect('posLevel')"
/>
</template>
<q-list
:style="store.posLevelOps.length > 9 ? 'height: 450px' : ''"
>
<q-item
v-for="(item, index) in store.posLevelOps"
:key="index"
clickable
v-close-popup
@click="selectPosLevel(item)"
>
<q-item-section>
<q-item-label>{{ item.name }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
<q-separator
inset
vertical
class="lineFil"
v-if="empType === 'officer'"
/>
<q-btn-dropdown
v-if="empType === 'officer'"
flat
dense
rounded
label-color="white"
dropdown-icon="mdi-chevron-down"
:label="`เงื่อนไขอื่นๆ ${conditionTotal}`"
class="q-px-sm"
>
<q-list>
<q-item clickable v-close-popup>
<q-item-section>
<q-toggle
v-model="formFilter.isProbation"
color="primary"
label="ทดลองปฏิบัติหน้าที่ราชการ"
@update:model-value="fetchDataPerson"
/>
</q-item-section>
</q-item>
<q-item clickable v-close-popup>
<q-item-section>
<q-toggle
v-model="formFilter.isShowRetire"
color="primary"
label="แสดงข้อมูลผู้พ้นจากราชการ"
@update:model-value="fetchDataPerson"
/>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</div>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-section>
<TableView
v-model:mode="mode"
:rows="dataPersonMain"
v-model:formFilter="formFilter"
v-model:maxPage="maxPage"
:fetchData="fetchDataPerson"
:fetchType="fetchType"
:total="total"
:empType="empType"
/>
</q-card-section>
</q-card>
</template>
<style scoped>
.card-img {
background: url("@/assets/registry-banner.png");
background-size: cover;
color: white;
}
:deep(.custom-select.q-field--outlined .q-field__control) {
color: white;
background-color: #36969f;
}
:deep(.custom-select.q-field--outlined .q-field__control::before) {
border: 1px solid #fff;
}
:deep(.custom-btn.q-btn--outline::before) {
background-color: #36969f;
}
.btnSearch {
border-radius: 0px 4px 4px 0px;
}
.bg-Search {
background: #00000015;
}
.lineFil {
transform: rotate(30deg);
height: 20px;
margin-top: 15px;
background: #ffffff7b !important;
}
.selectS .q-field__control .q-field__append .q-icon {
color: #ff5722 !important;
}
</style>

View file

@ -0,0 +1,405 @@
<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 } = 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: "no",
align: "left",
label: "ลำดับ",
sortable: false,
field: (row) => rows.value.indexOf(row) + 1,
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[]>([
"no",
"fullname",
"topic",
"detail",
"document",
"status",
"remark",
]);
/**
* วแปร
*/
const status = ref<string>("");
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 v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<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"
size="12px"
@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-td>
<q-btn
icon="edit"
round
dense
flat
color="edit"
size="12px"
@click.pervent="onclickEdit(props.row.id)"
>
<q-tooltip>แกไขสถานะคำรอง</q-tooltip>
</q-btn>
</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>