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

@ -175,6 +175,93 @@
</div>
</div>
</q-card>
<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
/>
</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
/></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)" />
</q-card-actions>
</q-card>
</q-dialog>
</template>
<script setup lang="ts">
@ -190,13 +277,13 @@ import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import type { resMain } from "@/modules/06_retirement/interface/response/Main";
const yearOptions = reactive<any[]>([]);
const mixin = useCounterMixin();
const { messageError, date2Thai, showLoader, hideLoader } = mixin;
const router = useRouter();
const $q = useQuasar(); // noti quasar
const modal = ref<boolean>(false);
const radio = ref<string>("");
const pagination = ref({
sortBy: "desc",
descending: false,
@ -204,6 +291,9 @@ const pagination = ref({
rowsPerPage: 10,
});
const actionOption = ref<resMain[]>([]);
const action = ref<string>("");
const type = ref<string>("officer");
const visibleColumns = ref<string[]>(["no", "Date", "retireNumber"]); //
@ -243,19 +333,21 @@ const currentYear = new Date().getFullYear();
const rows = ref<resMain[]>([]);
const tab = ref<any>("officer");
const visibleColumns2 = ref<string[]>(["no", "name", "retireNumber"]);
const getYear = () => {
yearOptions.length = 0;
yearOptions.push(currentYear + 543);
// console.log(yearOptions);
get(type.value, currentYear);
fiscalyear.value = currentYear + 543;
const yearOptions = reactive<any[]>([]);
const filteryear = () => {
console.log(yearOptions);
yearOptions.push({ id: currentYear, name: currentYear + 543 });
console.log(yearOptions[0].id);
fiscalyear.value = yearOptions[0].id;
fetchRetirement(type.value, currentYear);
};
const get = async (type: string, year: any) => {
const fetchRetirement = async (type: string, year: any) => {
radio.value = "";
showLoader();
await http
.get(config.API.retirement(type, year))
.then((res) => {
// console.log(res);
console.log(res);
rows.value = [];
let data = res.data.result;
rows.value = data.map((items: resMain) => ({
@ -264,7 +356,10 @@ const get = async (type: string, year: any) => {
year: items.year,
retireNumber: items.round,
total: items.total,
round: items.round,
}));
actionOption.value = rows.value;
console.log(actionOption.value);
})
.catch((e) => {})
.finally(() => {
@ -272,7 +367,7 @@ const get = async (type: string, year: any) => {
});
};
onMounted(() => {
getYear();
filteryear();
});
// 2
const columns2 = ref<QTableProps["columns"]>([
@ -360,34 +455,73 @@ const rows2 = ref<FormMainProbation2[]>([
// };
const clickAdd = () => {
// modal.value = true;
$q.dialog({
title: 'เพิ่มประกาศ',
message: 'เลือกประกาศที่ต้องการเพิ่มข้อมูล',
options: {
type: 'radio',
model: 'opt1',
// inline: true
items: [
{ label: 'ประกาศเพิ่มผู้เกษียณ', value: 'ADD'},
{ label: 'ประกาศแก้ไขข้อมูลผู้เกษียน', value: 'EDIT' },
{ label: 'ประกาศยกเลิกผู้เกษียณ', value: 'REMOVE' }
]
},
cancel: {
flat: true,
color: "negative",
},
persistent: true,
}).onOk(data => {
console.log("option===>", data)
router.push(`/retirement/list/${type.value}/${currentYear}`);
}).onCancel(() => {
}).onDismiss(() => {
// console.log(rows.value.length, type.value);
if (rows.value.length == 0) {
$q.dialog({
title: "ยืนยันการเพิ่มข้อมูลประกาศเกษียณ",
message: "ต้องการเพิ่มข้อมูลประกาศเกษียณใช่หรือไม่?",
cancel: {
flat: true,
color: "negative",
},
persistent: true,
})
/* $q.dialog({
title: "ยืนยันการเพิ่มข้อมูลประกาศเกษียณ",
message: "ต้องการเพิ่มข้อมูลประกาศเกษียณใช่หรือไม่?",
.onOk(async () => {
let data = { type: type.value, year: currentYear };
await cerateRetirement(data);
})
.onCancel(() => {})
.onDismiss(() => {});
}
modal.value = true;
action.value = "";
radio.value = "";
// $q.dialog({
// title: "",
// message: "",
// options: {
// type: "radio",
// model: "opt1",
// // inline: true
// items: [
// { label: "", value: "ADD" },
// { label: "", value: "EDIT" },
// { label: "", value: "REMOVE" },
// ],
// },
// cancel: {
// flat: true,
// color: "negative",
// },
// persistent: true,
// })
// .onOk((data) => {
// console.log("option===>", data);
// router.push(`/retirement/list/${type.value}/${currentYear}`);
// })
// .onCancel(() => {})
// .onDismiss(() => {});
};
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);
});
};
const clickSelect = async (action: string) => {
// console.log(action);
// console.log(radio.value);
$q.dialog({
title: "ยืนยันการแก้ไขข้อมูลประกาศเกษียณ",
message: "ต้องการแก้ไขข้อมูลประกาศเกษียณใช่หรือไม่?",
cancel: {
flat: true,
color: "negative",
@ -395,20 +529,29 @@ const clickAdd = () => {
persistent: true,
})
.onOk(async () => {
router.push(`/retirement/list/${type.value}/${currentYear}`);
let data = {
type: type.value,
year: currentYear,
retireHistoryId: action,
option: radio.value,
};
console.log(data);
await cerateRetirement(data);
})
.onCancel(() => {})
.onDismiss(() => {}); */
.onDismiss(() => {});
};
const clickClose = async () => {
modal.value = false;
};
const fiscalyear = ref<number>();
const fiscalyearOP = ref<any>([
{ id: 1, name: "ทั้งหมด" },
{ id: 2, name: "2565" },
{ id: 3, name: "2565" },
]);
// const fiscalyearOP = ref<any>([
// { id: 1, name: "" },
// { id: 2, name: "2565" },
// { id: 3, name: "2565" },
// ]);
//
const filterKeyword = ref<string>("");
@ -435,11 +578,11 @@ const paginationLabel = (start: string, end: string, total: string) => {
const nextPage = (prop: any) => {
// console.log(prop.id);
router.push(`/retirement/listretire/${prop.id}/${type.value}`);
router.push(`/retirement/${prop.id}`);
};
watch(type, () => {
get(type.value, currentYear);
fetchRetirement(type.value, currentYear);
});
</script>
@ -447,6 +590,9 @@ watch(type, () => {
.filter-card {
background-color: #f1f1f1b0;
}
.q-item-custom {
padding: 0;
}
.toggle-expired-account {
font-size: 12px;