รายละเอียดรับโอน

This commit is contained in:
Thanit Konmek 2023-08-16 12:55:07 +07:00
parent b4ac343685
commit 1a7b4bf418
11 changed files with 1283 additions and 142 deletions

View file

@ -1,39 +1,40 @@
<script setup lang="ts">
import { ref, computed, onMounted } from "vue";
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { useRouter } from "vue-router";
import DialogFooter from "@/modules/05_placement/components/Receive/DialogFooter.vue";
import DialogHeader from "@/modules/05_placement/components/Receive/DialogHeader.vue";
import DialogOrgTree from "@/modules/05_placement/components/Receive/receiveModal.vue";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
const mixin = useCounterMixin(); //
const { showLoader, hideLoader, dateText, success, messageError, date2Thai } =
mixin;
const selected = ref([]);
const checkSelected = computed(() => {
if (selected.value.length === 0) {
return true;
}
});
const add = () => {
router.push(`/receive/add`);
};
const clickClose = () => {
modal.value = false;
};
import type { QTableProps } from "quasar";
import type {
ResponseData,
ResponseRow,
} from "@/modules/05_placement/interface/response/Receive";
const $q = useQuasar();
const router = useRouter();
const mixin = useCounterMixin(); //
const {
showLoader,
hideLoader,
dialogMessage,
success,
messageError,
date2Thai,
} = mixin;
const selected = ref<ResponseRow[]>([]);
const modal = ref<boolean>(false);
const popup = () => {
modal.value = true;
};
const router = useRouter();
const modalTree = ref<boolean>(false);
const personal = ref<any[]>([]);
@ -56,57 +57,10 @@ const visibleColumns2 = ref<string[]>([
const filterKeyword = ref<string>("");
const filterKeyword2 = ref<string>("");
const filterRef = ref<any>(null);
const resetFilter = () => {
filterKeyword.value = "";
filterKeyword2.value = "";
filterRef.value.focus();
};
onMounted(() => {
fecthlistRecevice();
});
const listRecevice = ref<any>([]);
const fecthlistRecevice = async () => {
showLoader();
await http
.get(config.API.receiveData())
.then((res) => {
let response = res.data.result;
listRecevice.value = response;
// console.log(response);
rows.value = response.map((e: any) => ({
personalId: e.id,
citizenId: e.citizenId,
fullname: e.firstname + " " + e.lastname,
organizationName:
e.organizationName +
" " +
e.organizationShortName +
" " +
e.positionNumber +
" " +
e.positionPath,
orgName: e.organizationName,
organizationShortName: e.organizationShortName,
positionNumber: e.positionNumber,
positionPath: e.positionPath,
birthday: date2Thai(e.dateOfBirth),
}));
// console.log(rows.value);
rows2.value = rows.value.filter((e: any) => e.orgName !== null);
})
.catch((e) => {
console.log(typeof e);
})
.finally(() => {
hideLoader();
});
};
// const nextPage = (id:string) => {
// router.push("/retirement/resign/"+id);
// };
const rows = ref<any>([
const listRecevice = ref<any[]>([]);
const filters = ref<ResponseRow[]>([]);
const rows = ref<ResponseRow[]>([
// {
// personalId: "08db721d-add6-47b0-8a13-5f45d106e8d1",
// citizenId: "1234444332222",
@ -119,18 +73,18 @@ const rows = ref<any>([
// birthday: dateText(new Date("1989-09-03")),
// },
]);
const rows2 = ref<any>([
{
personalId: "08db721d-add6-47b0-8a13-5f45d106e8d1",
citizenId: "1234444332222",
fullname: "นางสาวอย พชช",
organizationName: "นักจัดการงานทั่วไป",
orgName: "กลุ่มงานช่วยนักบริหาร",
organizationShortName: "สกจ.",
positionNumber: "กก. 1",
positionPath: "นักจัดการงานทั่วไป",
birthday: dateText(new Date("1989-09-03")),
},
const rows2 = ref<ResponseRow[]>([
// {
// personalId: "08db721d-add6-47b0-8a13-5f45d106e8d1",
// citizenId: "1234444332222",
// fullname: " ",
// organizationName: "",
// orgName: "",
// organizationShortName: ".",
// positionNumber: ". 1",
// positionPath: "",
// birthday: dateText(new Date("1989-09-03")),
// },
]);
const columns = ref<QTableProps["columns"]>([
{
@ -231,6 +185,77 @@ const columns2 = ref<QTableProps["columns"]>([
},
]);
onMounted(() => {
fecthlistRecevice();
});
const fecthlistRecevice = async () => {
showLoader();
await http
.get(config.API.receiveData())
.then((res: any) => {
const response = res.data.result;
listRecevice.value = response;
// console.log(response);
let list: ResponseRow[] = [];
response.map((e: ResponseData) => {
list.push({
personalId: e.id ?? "",
citizenId: e.citizenId ?? "-",
fullname: e.firstname + " " + e.lastname,
organizationName:
e.organizationName +
" " +
e.organizationShortName +
" " +
e.positionNumber +
" " +
e.positionPath,
orgName: e.organizationName,
organizationShortName: e.organizationShortName,
positionNumber: e.positionNumber,
positionPath: e.positionPath,
birthday: e.dateOfBirth == null ? "-" : date2Thai(e.dateOfBirth),
status: e.status,
});
});
rows.value = list;
filters.value = list;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
const resetFilter = () => {
filterKeyword.value = "";
filterKeyword2.value = "";
filterRef.value.focus();
};
const checkSelected = computed(() => {
if (selected.value.length === 0) {
return true;
}
});
const row = filters.value.filter(
(r: ResponseRow) =>
r.status == "WAITTING" || r.status == "PENDING" || r.status == "APPROVE"
);
rows2.value = row;
const add = () => {
router.push(`/receive/add`);
};
const clickClose = () => {
modal.value = false;
};
const openModalTree = (id: string) => {
personalId.value = id;
console.log(personalId.value);
@ -240,31 +265,33 @@ const openModalTree = (id: string) => {
};
const openDelete = (id: string) => {
console.log(id);
dialogMessage(
$q,
"ลบข้อมูล",
"ต้องการทำการลบข้อมูลนี้ใช่หรือไม่",
"delete",
undefined,
"red",
async () => await fetchDataDelete(id),
undefined,
false
);
};
$q.dialog({
title: `ลบข้อมูล`,
message: `ต้องการทำการลบข้อมูลนี้ใช่หรือไม่?`,
cancel: "ยกเลิก",
ok: "ยืนยัน",
persistent: true,
})
.onOk(async () => {
showLoader();
await http
.delete(config.API.receiveDataId(id))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
fecthlistRecevice();
hideLoader();
});
const fetchDataDelete = async (id: string) => {
showLoader();
await http
.delete(config.API.receiveDataId(id))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
})
.onCancel(() => {});
.catch((e) => {
messageError($q, e);
})
.finally(() => {
fecthlistRecevice();
hideLoader();
});
};
const closeModalTree = async () => {
@ -277,6 +304,30 @@ const nextPage = (row: any) => {
path: `/receive/${row.personalId}`,
});
};
const saveOrder = async () => {
const id = selected.value.map((r: any) => r.personalId);
const body = {
id,
};
showLoader();
await http
.post(config.API.receiveReport, body)
.then((res: any) => {
// const data = res.data.result;
// console.log(data);
success($q, "ส่งไปออกคำสั่งรับโอนสำเร็จ");
clickClose();
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fecthlistRecevice();
hideLoader();
});
};
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">รายการรบโอน</div>
@ -626,7 +677,7 @@ const nextPage = (row: any) => {
<q-card-actions align="right" class="bg-white text-teal">
<q-btn
label="ส่งไปออกคำสั่ง"
@click=""
@click="saveOrder"
:disable="checkSelected"
color="public"
/>