เพิ่ม store tab

This commit is contained in:
setthawutttty 2023-09-15 17:36:07 +07:00
parent d9bc13bf45
commit 30d1eac0ba
2 changed files with 25 additions and 18 deletions

View file

@ -0,0 +1,14 @@
import { defineStore } from "pinia";
import { ref } from 'vue'
export const useDataStoreRetirement = defineStore("retirementDatastore", () => {
const tab = ref<any>("officer");
const type = ref<string>("officer");
const clickTab = (role:string) => {
type.value = role
}
return {
tab,
type,
clickTab
};
});

View file

@ -13,12 +13,9 @@
indicator-color="primary"
align="left"
>
<q-tab name="officer" label="ขรก.กทม.สามัญ" @click="type = 'officer'" />
<q-tab
name="employee"
label="ลูกจ้างประจำ"
@click="type = 'employee'"
/>
<q-tab name="officer" label="ขรก.กทม.สามัญ" @click="clickTab('officer')" />
<q-tab name="employee" label="ลูกจ้างประจำ" @click="clickTab('employee')" />
</q-tabs>
</div>
<q-separator />
@ -287,8 +284,12 @@ import { useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useDataStoreRetirement } from '@/modules/06_retirement/storeRetirement'
import type { resMain } from "@/modules/06_retirement/interface/response/Main";
import { storeToRefs } from "pinia";
const useStoreRetire = useDataStoreRetirement()
const { clickTab} = useStoreRetire
const { tab , type} = storeToRefs(useDataStoreRetirement())
const mixin = useCounterMixin();
const { messageError, date2Thai, showLoader, hideLoader, dialogConfirm } =
mixin;
@ -306,7 +307,7 @@ const pagination = ref({
const actionOption = ref<resMain[]>([]);
const action = ref<string>("");
const type = ref<string>("officer");
const visibleColumns = ref<string[]>([
"no",
"Date",
@ -353,13 +354,10 @@ const columns = ref<QTableProps["columns"]>([
// ()
const currentYear = new Date().getFullYear();
const rows = ref<resMain[]>([]);
const tab = ref<any>("officer");
const visibleColumns2 = ref<string[]>(["no", "name", "retireNumber"]);
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);
};
@ -369,7 +367,6 @@ const fetchRetirement = async (type: string, year: any) => {
await http
.get(config.API.retirement(type, year))
.then((res) => {
// console.log(res);
rows.value = [];
let data = res.data.result;
rows.value = data.map((items: any) => ({
@ -483,12 +480,11 @@ const rows2 = ref<FormMainProbation2[]>([
// };
const clickAdd = () => {
console.log(rows.value.length, type.value);
if (rows.value.length == 0) {
dialogConfirm(
$q,
async () => {
let data = { type: type.value, year: currentYear };
let data = { type: type, year: currentYear };
await cerateRetirement(data);
},
"ยืนยันการเพิ่มข้อมูลประกาศเกษียณ",
@ -517,7 +513,7 @@ const clickSelect = async (action: string) => {
$q,
async () => {
let data = {
type: type.value,
type: type,
year: currentYear,
retireHistoryId: action,
option: radio.value,
@ -534,7 +530,6 @@ const checkjson = ref<boolean>();
const checkststus = (data: any) => {
let jsonfasle = data.find((e: any) => e.document == false);
// console.log(jsonfasle)
if (jsonfasle) {
checkjson.value = true;
@ -570,7 +565,6 @@ const paginationLabel = (start: string, end: string, total: string) => {
else return start + "-" + end + " ใน " + total;
};
const nextPage = (prop: any) => {
// console.log(prop.id);
router.push(`/retirement/${prop.id}`);
};
@ -579,7 +573,6 @@ watch(type, () => {
fetchRetirement(type.value, currentYear);
});
const typeReportChangeName = (val: string) => {
// console.log(val);
switch (val) {
case "EDIT":
return "ประกาศแก้ไขเกษียณ";