ประกาศเกษียณอายุราชการ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-09-19 16:45:07 +07:00
parent 1530da36cf
commit f592008bbe
6 changed files with 438 additions and 580 deletions

View file

@ -8,10 +8,9 @@ import { useRoute } from "vue-router";
const $q = useQuasar(); // noti quasar
const mixin = useCounterMixin();
const { messageError, success, showLoader, hideLoader } = mixin;
const { messageError, success, showLoader, hideLoader, dialogConfirm } = mixin;
const route = useRoute();
const type_params = route.params.type;
const retireld_params = route.params.id;
const props = defineProps({
retireld: String,
@ -65,57 +64,16 @@ const columns = ref<any["columns"]>([
align: "left",
},
]);
const rows = ref<any>([
// {
// fullname: " ",
// position: "",
// level: "",
// affiliation: " ",
// },
// {
// fullname: " ",
// position: "",
// level: "",
// affiliation: " ",
// },
// {
// fullname: " ",
// position: "",
// level: "",
// affiliation: " ",
// },
// {
// fullname: " ",
// position: "",
// level: "",
// affiliation: " ",
// },
// {
// fullname: " ",
// position: "",
// level: "",
// affiliation: " ",
// },
// {
// fullname: " ",
// position: "",
// level: "",
// affiliation: " ",
// },
// {
// fullname: " ",
// position: "",
// level: "",
// affiliation: " ",
// },
]);
const rows = ref<any>([]);
watch(modal, () => {
if (modal.value === true) {
retireld.value = props.retireld;
if (props.dataProfile.type === "OFFICER") {
type.value = "officer";
} else type.value = "all";
if (props.dataProfile) {
if (props.dataProfile.type === "OFFICER") {
type.value = "officer";
} else type.value = "all";
}
fecthlistRetire();
}
@ -146,14 +104,11 @@ const findlist = async (id: string) => {
{ criteriaType: "employee_class", criteriaValue: "perm" },
];
}
// console.log(data);
await http
.post(config.API.profileSearchNewOcIdType(id, type.value), {
criterias: data,
})
.then((res) => {
// console.log(res.data.result);
rows.value = res.data.result.map((e: any) => ({
id: e.id,
fullname: e.fullname,
@ -172,25 +127,13 @@ const findlist = async (id: string) => {
// putlist
const clickAdd = (props: any) => {
// console.log("props===>",props.row.id)
if (retireld.value == undefined) {
retireld.value = retireld_params;
}
let data: any = props.row.id;
// console.log("retireld & profileId", retireld.value, data);
$q.dialog({
title: "ยืนยันการเพิ่มข้อมูล",
message: "ต้องการเพิ่มข้อมูลนี้ใช่หรือไม่?",
cancel: {
flat: true,
color: "negative",
},
persistent: true,
})
.onOk(async () => {
// console.log("");
dialogConfirm(
$q,
async () => {
await http
.put(config.API.profileRetire(retireld.value), { profileId: data })
.then(() => {
@ -201,12 +144,12 @@ const clickAdd = (props: any) => {
messageError($q, e);
})
.finally(() => {
// fecthlistRetire();
modal.value = false;
});
})
.onCancel(() => {})
.onDismiss(() => {});
},
"ยืนยันการเพิ่มข้อมูล",
"ต้องการเพิ่มข้อมูลนี้ใช่หรือไม่ ?"
);
};
// update retireld
const updateListData = (retireld: string, pId: string) => {
@ -294,9 +237,6 @@ const paginationLabel = (start: number, end: number, total: number) => {
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td>{{ props.rowIndex + 1 }}</q-td>
<!-- <q-td key="order" :props="props">
{{ props.row.order }}
</q-td> -->
<q-td key="fullname" :props="props">
{{ props.row.fullname }}
</q-td>

View file

@ -14,7 +14,14 @@ const route = useRoute();
const router = useRouter();
const $q = useQuasar();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, success, dialogConfirm } = mixin;
const {
showLoader,
hideLoader,
messageError,
success,
dialogConfirm,
dialogRemove,
} = mixin;
const retireld_params = route.params.retirementId;
const modalNote = ref<boolean>(false);
@ -26,7 +33,6 @@ const filter = ref<string>("");
const statusUpload = ref<boolean>();
const modalEdit = ref<boolean>(false);
const textReport = ref<string>("");
const columns = ref<any["columns"]>([
{
name: "order",
@ -161,7 +167,6 @@ const fecthlistprofile = async (id: string) => {
await http
.get(config.API.listRetire(id))
.then((res) => {
console.log(res);
dataProfile.value = res.data.result;
round.value = res.data.result.round;
statusReport.value = res.data.result.json;
@ -182,7 +187,6 @@ const fecthlistprofile = async (id: string) => {
reason: e.reason,
remove: e.remove,
}));
console.log(statusReport.value);
if (statusReport.value == false) {
fecthCheck(retireld.value);
} else statusUpload.value = true;
@ -194,6 +198,7 @@ const fecthlistprofile = async (id: string) => {
hideLoader();
});
};
//
const fecthCheck = async (id: string) => {
await http
.get(config.API.checkfileupload(id))
@ -201,21 +206,14 @@ const fecthCheck = async (id: string) => {
statusUpload.value = res.data.result;
})
.catch((err) => {
console.log(err);
messageError($q, err);
});
};
// DelProfile
const clickDelete = () => {
$q.dialog({
title: "ยืนยันการลบข้อมูล",
message: "ต้องการลบข้อมูลนี้ใช่หรือไม่?",
cancel: {
flat: true,
color: "negative",
},
persistent: true,
})
.onOk(async () => {
dialogRemove(
$q,
async () => {
await http
.post(config.API.removeProfile(), {
retireProfileId: retireProfileId.value,
@ -232,36 +230,16 @@ const clickDelete = () => {
await fecthlistprofile(retireld.value);
modalNote.value = false;
});
})
.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 saveNote = () => {
console.log(retireProfileId.value, note.value);
$q.dialog({
title: "ยืนยันการบันทึกข้อมูลข้อมูล",
message: "ต้องการบันทึกข้อมูลนี้ใช่หรือไม่?",
cancel: {
flat: true,
color: "negative",
},
persistent: true,
})
.onOk(async () => {
"ยืนยันการลบข้อมูล",
"ต้องการลบข้อมูลนี้ใช่หรือไม่ ?"
);
};
//
const saveNote = () => {
dialogConfirm(
$q,
async () => {
await http
.post(config.API.createnote(), {
retireProfileId: retireProfileId.value,
@ -278,15 +256,15 @@ const saveNote = () => {
fecthlistprofile(retireld.value);
modalNote.value = false;
});
})
.onCancel(() => {})
.onDismiss(() => {});
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการบันทึกข้อมูลนี้ใช่หรือไม่ ?"
);
};
const UpdateListId = (retireld: string, pId: string) => {
profileId.value = pId;
fecthlistprofile(retireld);
console.log("profileId", profileId.value);
};
const backHistory = () => {
window.history.back();
@ -299,13 +277,11 @@ const visibleNote = computed(() => {
const uploadFile = async (event: any) => {
showLoader();
const selectedFile = event;
console.log(selectedFile);
const formdata = new FormData();
formdata.append("file", selectedFile);
await http
.put(config.API.fileRetirement(retireld.value.toString()), formdata)
.then((res) => {
.then(() => {
success($q, "เพิ่มไฟล์สำเร็จ");
})
.catch((err) => {
@ -326,9 +302,6 @@ const downloadAttachment = async (type: string, id: string) => {
responseType: "blob",
})
.then(async (res) => {
const data = res.data.result;
console.log(data);
let list: any[] = [];
downloadFile(res, `${"รายชื่อผู้เกษียณอายุราชการ"}.${type}`);
})
.catch((e) => {
@ -562,6 +535,7 @@ const paginationLabel = (start: number, end: number, total: number) => {
statusUpload !== true
"
/>
<q-th auto-width v-else></q-th>
<q-th
auto-width
v-if="
@ -572,6 +546,7 @@ const paginationLabel = (start: number, end: number, total: number) => {
statusUpload !== true
"
/>
<q-th auto-width v-else></q-th>
</q-tr>
</template>
<template v-slot:body="props">
@ -639,6 +614,7 @@ const paginationLabel = (start: number, end: number, total: number) => {
<q-tooltip>กรอกเหตผล</q-tooltip>
</q-btn>
</q-td>
<q-td auto-width v-else></q-td>
<q-td
auto-width
v-if="
@ -664,6 +640,7 @@ const paginationLabel = (start: number, end: number, total: number) => {
><q-tooltip>ลบขอม</q-tooltip></q-btn
>
</q-td>
<q-td auto-width v-else></q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">

View file

@ -0,0 +1,200 @@
<script setup lang="ts">
import { ref } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
const $q = useQuasar();
const mixin = useCounterMixin();
const { dialogConfirm, messageError } = mixin;
const router = useRouter();
const props = defineProps({
type: {
type: String,
},
year: {
type: Number,
},
rows: {
type: Object,
},
actionOptio: {
type: Object,
},
checkjson: {
type: Boolean,
},
});
const modal = ref<boolean>(false);
const radio = ref<string>("");
const actionOption = ref<any>([]);
const action = ref<string>("");
//
const clickAdd = () => {
if (props.rows) {
//
if (props.rows.length == 0) {
dialogConfirm(
$q,
async () => {
let data = { type: props.type, year: props.year };
await cerateRetirement(data);
},
"ยืนยันการเพิ่มข้อมูลประกาศเกษียณ",
"ต้องการเพิ่มข้อมูลประกาศเกษียณใช่หรือไม่ ?"
);
} else {
modal.value = true;
action.value = "";
radio.value = "";
if (props.actionOptio) {
actionOption.value = props.actionOptio;
}
}
}
};
//
const clickSelect = async (action: string) => {
dialogConfirm(
$q,
async () => {
let data = {
type: props.type,
year: props.year,
retireHistoryId: action,
option: radio.value,
};
await cerateRetirement(data);
},
"ยืนยันการแก้ไขข้อมูลประกาศเกษียณ",
"ต้องการแก้ไขข้อมูลประกาศเกษียณใช่หรือไม่ ?"
);
};
// API
const cerateRetirement = async (data: object) => {
await http
.post(config.API.createProfile(), data)
.then((res) => {
let response = res.data.result;
let retirementId = response.id;
router.push(`/retirement/${retirementId}`);
})
.catch((e) => {
messageError($q, e);
});
};
</script>
<template>
<q-btn
size="12px"
flat
round
color="add"
icon="mdi-plus"
@click="clickAdd"
:disable="checkjson"
>
<q-tooltip>เพ</q-tooltip>
</q-btn>
<q-dialog v-model="modal">
<q-card style="width: 450px; max-width: 80vw">
<q-card-section>
<div class="text-h6">เพมประกาศ</div>
</q-card-section>
<q-card-section class="q-pt-none">
เลอกประกาศทองการเพมขอม
</q-card-section>
<q-separator />
<div class="q-pa-md">
<q-list>
<q-item class="q-item-custom">
<q-item-section avatar class="q-item-custom">
<q-radio
v-model="radio"
val="ADD"
color="teal"
@click="action = ''"
/>
</q-item-section>
<q-item-section>
<q-item-label>ประกาศเพมผเกษยณ</q-item-label>
</q-item-section>
</q-item>
<q-item class="q-item-custom">
<q-item-section avatar class="q-item-custom">
<q-radio
v-model="radio"
val="EDIT"
color="teal"
@click="action = ''"
/>
</q-item-section>
<q-item-section>
<q-item-label>ประกาศแกไขขอมลผเกษยณ</q-item-label>
<q-item-label v-if="radio === 'EDIT'">
<q-select
dense
v-model="action"
:options="actionOption"
label="เลือกรอบ"
option-label="round"
option-value="id"
emit-value
map-options
:rules="[(val) => !!val || 'กรุณาเลือกรอบ']"
/>
</q-item-label>
</q-item-section>
</q-item>
<q-item class="q-item-custom">
<q-item-section avatar class="q-item-custom">
<q-radio
v-model="radio"
val="REMOVE"
color="teal"
@click="action = ''"
/>
</q-item-section>
<q-item-section>
<q-item-label>ประกาศยกเลกผเกษยณ</q-item-label>
<q-item-label v-if="radio === 'REMOVE'">
<q-select
dense
v-model="action"
:options="actionOption"
label="เลือกรอบ"
option-label="round"
option-value="id"
emit-value
map-options
:rules="[(val) => !!val || 'กรุณาเลือกรอบ']"
/></q-item-label>
</q-item-section>
</q-item>
</q-list>
</div>
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn flat label="ยกเลิก" color="red" v-close-popup />
<q-btn
flat
label="ตกลง"
@click="clickSelect(action)"
:disable="radio === '' || (action === '' && radio !== 'ADD')"
/>
</q-card-actions>
</q-card>
</q-dialog>
</template>
<style scoped></style>