เครื่ิองราช => fix bug

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-06-30 21:12:26 +07:00
parent 2475f86608
commit 08455521f2
6 changed files with 262 additions and 133 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { onMounted, ref, computed, reactive } from "vue";
import { onMounted, ref, computed, reactive, watch } from "vue";
import { useQuasar, QForm } from "quasar";
import http from "@/plugins/http";
@ -275,52 +275,111 @@ function changtypeOc() {
/** function เพิ่มรายชื่อ*/
async function clickmodalAdd() {
let ocId = DataStore.typeOc ? DataStore.typeOc : DataStore.agency;
showLoader();
// showLoader();
await fecthInsignia();
await fecthlistperson(ocId);
clearForm();
}
const maxPage = ref<number>(0);
const total = ref<number>(0);
const formFilter = reactive({
page: 1,
pageSize: 10,
searchField: "citizenId",
searchKeyword: "",
});
const filterOption = ref<any[]>([
{
id: "citizenId",
name: "เลขประจำตัวประชาชน",
},
{
id: "fullName",
name: "ชื่อ - นามสกุล",
},
]);
/**
* function เรยกรายชอขาราชการตามหนวยงานทจะเพ
* @param id หนวยงาน
*/
async function fecthlistperson(id: string) {
let data = [{}];
data = [
{
criteriaType: "is_retire",
criteriaValue: "false",
},
{
criteriaType: "is_probation",
criteriaValue: "false",
},
];
await http
.post(config.API.profileSearchNewOcIdType(id, "officer"), {
criterias: data,
})
async function fecthlistperson(id: string = "") {
showLoader();
http
.get(config.API.registryNew(""), { params: formFilter })
.then((res) => {
let data = res.data.result.map((e: any) => ({
maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize);
total.value = res.data.result.total;
let data = res.data.result.data.map((e: any) => ({
id: e.id,
rootId: e.rootId,
citizenId: e.citizenId,
fullname: e.fullname == null ? "-" : e.fullname,
position: e.position == null ? "-" : e.position,
level: e.positionEmployeeLevel == null ? "-" : e.positionEmployeeLevel,
organizationOrganization: e.oc == null ? "-" : e.oc,
fullname: `${e.prefix}${e.firstName} ${e.lastName}`,
position: e.position,
level: e.posLevel,
organizationOrganization: e.root,
}));
modalAdd.value = true;
rows2.value = data;
})
.catch((e) => {
messageError($q, e);
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
// let data = [{}];
// data = [
// {
// criteriaType: "is_retire",
// criteriaValue: "false",
// },
// {
// criteriaType: "is_probation",
// criteriaValue: "false",
// },
// ];
// await http
// .post(config.API.profileSearchNewOcIdType(id, "officer"), {
// criterias: data,
// })
// .then((res) => {
// let data = res.data.result.map((e: any) => ({
// id: e.id,
// citizenId: e.citizenId,
// fullname: e.fullname == null ? "-" : e.fullname,
// position: e.position == null ? "-" : e.position,
// level: e.positionEmployeeLevel == null ? "-" : e.positionEmployeeLevel,
// organizationOrganization: e.oc == null ? "-" : e.oc,
// }));
// modalAdd.value = true;
// rows2.value = data;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
}
/** update ค่า เเถวข้อมูล */
function updatePageSize(newPagination: any) {
formFilter.page = 1;
formFilter.pageSize = newPagination.rowsPerPage;
}
/** เช็คเเถวข้อมูลว่ามีการเปลี่ยนแปลงไหม */
watch(
() => formFilter.pageSize,
() => {
fecthlistperson();
}
);
/** function ยืนยันการเพิ่มรายชื่อ*/
async function clickAdd() {
dataPerson.id
@ -350,17 +409,11 @@ async function addlistperson(id: string) {
insigniaId: insigniaType.value,
insigniaPeriodId: props.roundId,
reason: reason.value,
ocId: dataPerson.rootId,
};
await http
.post(config.API.insigniaCreate(), data)
.then(() => {
success($q, "เพิ่มรายชื่อสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
modalAdd.value = false;
if (props.fecthInsigniaByOc) {
props.fecthInsigniaByOc(
props.roundId,
@ -369,6 +422,11 @@ async function addlistperson(id: string) {
props.tab
);
}
modalAdd.value = false;
success($q, "เพิ่มรายชื่อสำเร็จ");
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
@ -579,6 +637,7 @@ const dataPerson = reactive({
position: "",
organizationOrganization: "",
level: "",
rootId: "",
});
const reason = ref<string>("");
@ -591,6 +650,7 @@ function selectPerson(person: any) {
dataPerson.position = person.position;
dataPerson.organizationOrganization = person.organizationOrganization;
dataPerson.level = person.level;
dataPerson.rootId = person.rootId;
}
/** function clearFormData*/
@ -605,15 +665,20 @@ function clearForm() {
}
const insignia = ref<string>("");
const insigniaOptions = ref<any>([]);
const insigniaOptions = ref<any[]>([]);
const insigniaType = ref<string>("");
/** function เรียกประเภทเครื่องราช*/
async function fecthInsignia() {
await http
.get(config.API.insignia)
.get(config.API.insigniaOrg)
.then((res) => {
insigniaOptions.value = res.data.result;
const listtype = res.data.result.map((e: any) => ({
id: e.id,
name: e.name + `(${e.shortName})`,
}));
insigniaOptions.value = listtype;
})
.catch((e) => {
messageError($q, e);
@ -625,7 +690,7 @@ async function fecthInsignia() {
* @param id profileId
*/
function nextPage(id: string) {
router.push(`/registry/${id}`);
router.push(`/registry-new/${id}`);
}
/** ค้นหาข้อมุล table*/
@ -922,7 +987,10 @@ onMounted(async () => {
<q-space />
<div>
<q-btn
:disable="DataStore.employeeClass === 'all'|| DataStore.typeinsignia === 'all'"
:disable="
DataStore.employeeClass === 'all' ||
DataStore.typeinsignia === 'all'
"
size="md"
icon="mdi-download"
flat
@ -1158,7 +1226,7 @@ onMounted(async () => {
</div>
<!-- add -->
<q-dialog v-model="modalAdd">
<q-card style="width: 800px; max-width: 80vw">
<q-card style="width: 900px; max-width: 80vw">
<q-toolbar class="q-py-md">
<q-toolbar-title class="text-h6">เพมรายช </q-toolbar-title>
@ -1167,7 +1235,13 @@ onMounted(async () => {
unelevated
round
dense
@click="modalAdd = false"
@click="
(modalAdd = false),
(formFilter.page = 1),
(formFilter.pageSize = 10),
(formFilter.searchField = 'citizenId'),
(formFilter.searchKeyword = '')
"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
@ -1178,18 +1252,33 @@ onMounted(async () => {
<q-card flat bordered class="fit q-pa-sm">
<q-toolbar style="padding: 0">
<q-space />
<q-input
borderless
outlined
dense
debounce="300"
placeholder="ค้นหา"
v-model="filterKeyword2"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
<div class="row q-col-gutter-sm">
<q-select
dense
outlined
label="ค้นหาจาก"
v-model="formFilter.searchField"
option-label="name"
option-value="id"
:options="filterOption"
map-options
emit-value
@update:model-value="formFilter.searchKeyword = ''"
/>
<q-input
borderless
outlined
dense
debounce="300"
placeholder="ค้นหา"
v-model="formFilter.searchKeyword"
@keydown.enter="(formFilter.page = 1), fecthlistperson()"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
</div>
</q-toolbar>
<d-table
flat
@ -1197,10 +1286,11 @@ onMounted(async () => {
dense
:rows="rows2"
:columns="columns2"
:filter="filterKeyword2"
row-key="fullname"
class="custom-header-table"
v-model:pagination="pagination2"
:rows-per-page-options="[20, 25, 50, 100]"
@update:pagination="updatePageSize"
>
<template v-slot:header="props">
<q-tr :props="props">
@ -1220,7 +1310,13 @@ onMounted(async () => {
:class="{ 'text-primary': props.row.id === dataPerson.id }"
@click="selectPerson(props.row)"
>
<q-td style="width: 75px">{{ props.rowIndex + 1 }}</q-td>
<q-td style="width: 75px">
{{
(formFilter.page - 1) * formFilter.pageSize +
props.rowIndex +
1
}}</q-td
>
<q-td style="width: 250px" key="citizenId" :props="props">
{{ props.row.citizenId }}
</q-td>
@ -1229,6 +1325,20 @@ onMounted(async () => {
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="formFilter.page"
active-color="primary"
color="dark"
:max="Number(maxPage)"
:max-pages="5"
size="sm"
boundary-links
direction-links
@update:model-value="fecthlistperson()"
></q-pagination>
</template>
</d-table>
</q-card>
</div>