api retirement

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-08-07 11:06:04 +07:00
parent dccc335463
commit b3bfe6a4b9
4 changed files with 409 additions and 158 deletions

View file

@ -4,18 +4,18 @@ import AddList from "../ListRetirement/AddList.vue";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import { useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useRouter } from "vue-router";
const router = useRouter();
const route = useRoute();
const router = useRouter();
const $q = useQuasar();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, success } = mixin;
const type_params = route.params.type;
const year_params = route.params.year;
const retireld_params = route.params.id;
// const type_params = route.params.type;
// const year_params = route.params.year;
const retireld_params = route.params.retirementId;
const modalNote = ref<boolean>(false);
const note = ref<string>("");
@ -159,22 +159,25 @@ const visibleColumns = ref<string[]>([
"bureau",
]);
const action = ref<string>("");
onMounted(() => {
// console.log(route.params);
if (retireld_params === undefined) {
fecthlistprofile(type_params, year_params);
} else {
fecthlist(retireld_params);
}
retireld.value = retireld_params.toString();
console.log(retireld_params);
fecthlistprofile(retireld.value);
});
const round = ref<number>();
const typeReport = ref<string>("");
// fecthlist
const fecthlistprofile = async (type: any, year: any) => {
const fecthlistprofile = async (id: string) => {
showLoader();
await http
.get(config.API.profile(type, year))
.then((res: any) => {
// console.log(res);
retireld.value = res.data.result.id;
.get(config.API.listRetire(id))
.then((res) => {
console.log(res);
round.value = res.data.result.round;
typeReport.value = res.data.result.typeReport;
rows.value = res.data.result.profile.map((e: any) => ({
id: e.id,
profileId: e.profileId,
@ -187,37 +190,11 @@ const fecthlistprofile = async (type: any, year: any) => {
positionNumber: e.posNoEmployee,
positionLavel: e.positionEmployeeLevel,
bureau: e.oc,
reason: e.reason,
remove: e.remove,
}));
})
.catch((e: any) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
const fecthlist = async (retireld: any) => {
showLoader();
await http
.get(config.API.listRetire(retireld))
.then((res: any) => {
// retireld.value = res.data.result.id;
rows.value = res.data.result.map((e: any) => ({
id: e.id,
profileId: e.profileId,
order: e.order,
fixname: e.prefix,
name: e.fullName,
organizationOrganization: e.organizationOrganization,
positionType: e.positionType,
position: e.position,
positionNumber: e.posNoEmployee,
positionLavel: e.positionEmployeeLevel,
bureau: e.oc,
}));
// console.log(rows.value);
})
.catch((e: any) => {
.catch((e) => {
messageError($q, e);
})
.finally(() => {
@ -225,10 +202,7 @@ const fecthlist = async (retireld: any) => {
});
};
// DelProfile
const clickDelete = (prop: any) => {
console.log(prop);
let retireProfileId = prop.profileId;
const clickDelete = () => {
$q.dialog({
title: "ยืนยันการลบข้อมูล",
message: "ต้องการลบข้อมูลนี้ใช่หรือไม่?",
@ -240,7 +214,10 @@ const clickDelete = (prop: any) => {
})
.onOk(async () => {
await http
.delete(config.API.profileRetire(retireProfileId))
.post(config.API.removeProfile(), {
retireProfileId: retireProfileId.value,
reason: note.value,
})
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
})
@ -248,29 +225,30 @@ const clickDelete = (prop: any) => {
messageError($q, e);
})
.finally(async () => {
if (retireld_params === undefined) {
await fecthlistprofile(type_params, year_params);
} else await fecthlist(retireld_params);
retireld.value = retireld_params.toString();
await fecthlistprofile(retireld.value);
modalNote.value = false;
});
})
.onCancel(() => { })
.onDismiss(() => { });
.onCancel(() => {})
.onDismiss(() => {});
};
// note
const fetchReason = async (prop: string) => {
await http
.get(config.API.reasonId(prop))
.then((res: any) => {
console.log(res.data.result);
note.value = res.data.result.reason;
retireProfileId.value = res.data.result.id;
})
.catch((e: any) => {
messageError($q, e);
});
};
// const fetchReason = async (prop: string) => {
// await http
// .get(config.API.reasonId(prop))
// .then((res: any) => {
// console.log(res.data.result);
// note.value = res.data.result.reason;
// retireProfileId.value = res.data.result.id;
// })
// .catch((e: any) => {
// messageError($q, e);
// });
// };
const saveNote = () => {
console.log(retireProfileId.value, note.value);
$q.dialog({
title: "ยืนยันการบันทึกข้อมูลข้อมูล",
message: "ต้องการบันทึกข้อมูลนี้ใช่หรือไม่?",
@ -281,7 +259,6 @@ const saveNote = () => {
persistent: true,
})
.onOk(async () => {
// console.log("");
await http
.post(config.API.createnote(), {
retireProfileId: retireProfileId.value,
@ -294,17 +271,18 @@ const saveNote = () => {
messageError($q, e);
})
.finally(async () => {
await fecthlist(retireld_params);
retireld.value = retireld_params.toString();
fecthlistprofile(retireld.value);
modalNote.value = false;
});
})
.onCancel(() => { })
.onDismiss(() => { });
.onCancel(() => {})
.onDismiss(() => {});
};
const UpdateListId = (retireld: string, pId: string) => {
profileId.value = pId;
fecthlist(retireld);
fecthlistprofile(retireld);
console.log("profileId", profileId.value);
};
const backHistory = () => {
@ -362,13 +340,29 @@ const paginationLabel = (start: number, end: number, total: number) => {
<template>
<div class="toptitle text-dark col-12 row items-center">
<q-btn icon="mdi-arrow-left" unelevated round dense flat color="primary" class="q-mr-sm" @click="backHistory" />
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="backHistory"
/>
รายชอผเกษยณอายราชการ
</div>
<div>
<q-card class="col-12 q-pa-md">
<div class="row col-12 q-pb-sm">
<AddList :retireld="retireld" :profile-id="profileId" :UpdateListId="UpdateListId" />
<AddList
:retireld="retireld"
:profile-id="profileId"
:UpdateListId="UpdateListId"
v-if="
typeReport == null || typeReport == 'ADD' || typeReport == 'ADD'
"
/>
<!-- <q-btn flat round style="color: #016987;" icon="save" @click="saveList">
<q-tooltip>นทกขอม</q-tooltip>
</q-btn> -->
@ -397,15 +391,35 @@ const paginationLabel = (start: number, end: number, total: number) => {
<q-space />
<q-tabs shrink>
<q-input borderless outlined dense debounce="300" v-model="filter" placeholder="ค้นหา" style="max-width: 200px"
class="q-ml-sm">
<q-input
borderless
outlined
dense
debounce="300"
v-model="filter"
placeholder="ค้นหา"
style="max-width: 200px"
class="q-ml-sm"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</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 style="min-width: 150px"
class="gt-xs q-ml-sm">
<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
style="min-width: 150px"
class="gt-xs q-ml-sm"
>
<!-- <template v-slot:option="{ opt }">
<div>{{ opt.label }}</div>
<div class="sublabel">{{ opt.sublabel }}</div>
@ -415,9 +429,20 @@ const paginationLabel = (start: number, end: number, total: number) => {
</div>
<div>
<q-table flat dense bordered :rows="rows" :columns="columns" row-key="order" class="custom-header-table"
:filter="filter" :visible-columns="visibleColumns" no-data-label="ไม่มีข้อมูล"
:pagination-label="paginationLabel" v-model:pagination="pagination">
<q-table
flat
dense
bordered
:rows="rows"
:columns="columns"
row-key="order"
class="custom-header-table"
:filter="filter"
:visible-columns="visibleColumns"
no-data-label="ไม่มีข้อมูล"
:pagination-label="paginationLabel"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
@ -429,20 +454,27 @@ const paginationLabel = (start: number, end: number, total: number) => {
</div>
</q-th>
<q-th auto-width />
<q-th auto-width />
<q-th auto-width v-if="typeReport === 'EDIT' || round === 1" />
<q-th auto-width v-if="typeReport === 'REMOVE' || round === 1" />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer" :style="props.row.profileId === profileId && 'color: #26a69a;'"
@click="
fetchReason(props.row.id), (modalNote = true), (note = '')
">
<q-tr
:props="props"
class="cursor-pointer"
:style="props.row.profileId === profileId && 'color: #26a69a;'"
>
<q-td key="order" :props="props">{{ props.row.order }} </q-td>
<!-- <q-td key="fixname" :props="props">{{ props.row.fixname }}</q-td> -->
<q-td key="name" :props="props">{{ props.row.fixname + props.row.name }}</q-td>
<q-td class="table_ellipsis" key="organizationOrganization" :props="props">{{
props.row.organizationOrganization
<q-td key="name" :props="props">{{
props.row.fixname + props.row.name
}}</q-td>
<q-td
class="table_ellipsis"
key="organizationOrganization"
:props="props"
>{{ props.row.organizationOrganization }}</q-td
>
<q-td key="positionType" :props="props">{{
props.row.positionType
}}</q-td>
@ -461,7 +493,9 @@ const paginationLabel = (start: number, end: number, total: number) => {
<q-td key="govOffice" :props="props">{{
props.row.govOffice
}}</q-td>
<q-td class="table_ellipsis" key="bureau" :props="props">{{ props.row.bureau }}</q-td>
<q-td class="table_ellipsis" key="bureau" :props="props">{{
props.row.bureau
}}</q-td>
<q-td>
<!-- <q-btn
:props="props"
@ -477,20 +511,62 @@ const paginationLabel = (start: number, end: number, total: number) => {
>
<q-tooltip>โน</q-tooltip></q-btn
> -->
<q-btn flat round color="blue" dense icon="mdi-file-account"
@click="router.push(`/registry/${props.row.profileId}`)">
<q-btn
flat
round
color="blue"
dense
icon="mdi-file-account"
@click.stop="router.push(`/registry/${props.row.profileId}`)"
>
<q-tooltip>อมลทะเบยนประว</q-tooltip>
</q-btn>
</q-td>
<q-td auto-width>
<q-btn flat round class="text-red-14" icon="mdi-delete" dense
@click="clickDelete(props.row)"><q-tooltip>ลบขอม</q-tooltip></q-btn>
<q-td auto-width v-if="typeReport === 'EDIT' || round === 1">
<q-btn
flat
round
color="primary"
icon="mdi-pencil"
dense
@click.stop="
(modalNote = true),
(note = props.row.reason),
(action = 'edit'),
(retireProfileId = props.row.profileId)
"
>
<q-tooltip>กรอกเหตผล</q-tooltip>
</q-btn>
</q-td>
<q-td auto-width v-if="typeReport === 'REMOVE' || round === 1">
<q-btn
flat
round
class="text-red-14"
icon="mdi-delete"
dense
@click.stop="
(modalNote = true),
(action = 'delete'),
(note = props.row.remove),
(retireProfileId = props.row.profileId)
"
><q-tooltip>ลบขอม</q-tooltip></q-btn
>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
<q-pagination v-model="pagination.page" color="primary" :max="scope.pagesNumber" :max-pages="5" size="sm"
boundary-links direction-links></q-pagination>
<q-pagination
v-model="pagination.page"
color="primary"
:max="scope.pagesNumber"
:max-pages="5"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
</q-table>
</div>
@ -502,19 +578,46 @@ const paginationLabel = (start: number, end: number, total: number) => {
<q-card style="width: 700px; max-width: 80vw">
<q-card-section class="q-pt-none">
<q-toolbar class="q-py-md">
<q-toolbar-title class="header-text text-weight-bolder">กรอกเหตผล
<q-toolbar-title class="header-text text-weight-bolder"
>กรอกเหตผล
</q-toolbar-title>
<q-btn icon="close" unelevated round dense @click="modalNote = false"
style="color: #ff8080; background-color: #ffdede" />
<q-btn
icon="close"
unelevated
round
dense
@click="modalNote = false"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
</q-card-section>
<q-card-section class="q-pt-none">
<q-input outlined dense lazy-rules v-model="note" :rules="[(val) => !!val || 'กรุณากรอกเหตุผล']"
:label="`${'กรอกเหตุผล'}`" type="textarea" />
<q-input
outlined
dense
lazy-rules
v-model="note"
:rules="[(val) => !!val || 'กรุณากรอกเหตุผล']"
:label="`${'กรอกเหตุผล'}`"
type="textarea"
/>
</q-card-section>
<q-card-actions align="right">
<q-btn label="บักทึก" color="secondary" @click="saveNote" :disable="visibleNote" />
<q-btn
v-if="action === 'delete'"
label="บันทึก"
color="secondary"
:disable="visibleNote"
@click="clickDelete"
/>
<q-btn
v-else
label="บักทึก"
color="secondary"
@click="saveNote"
:disable="visibleNote"
/>
</q-card-actions>
</q-card>
</q-dialog>