ปรับ code เครื่องราช ==> จัดการคำขอ
This commit is contained in:
parent
01430c06a1
commit
7bc71cf93f
5 changed files with 222 additions and 98 deletions
|
|
@ -3,7 +3,6 @@ import { onMounted, ref, computed, reactive, watch } from "vue";
|
|||
import { useQuasar, QForm } from "quasar";
|
||||
|
||||
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
|
||||
import { useroleUserDataStore } from "@/stores/roleUser";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
import http from "@/plugins/http";
|
||||
|
|
@ -11,8 +10,17 @@ import config from "@/app.config";
|
|||
|
||||
/** import Type*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
|
||||
import type {
|
||||
OptionData,
|
||||
Pagination,
|
||||
DataProfileOtherSystem,
|
||||
DataManageList,
|
||||
} from "@/modules/07_insignia/interface/index/Main";
|
||||
import type { CheckboxData } from "@/modules/07_insignia/interface/request/Main";
|
||||
import type {
|
||||
ResponseProfile,
|
||||
ResponseInsigniaType,
|
||||
} from "@/modules/07_insignia/interface/response/Main";
|
||||
|
||||
/** import components*/
|
||||
import DialogPopupReason from "@/components/Dialogs/PopupReason.vue";
|
||||
|
|
@ -25,7 +33,6 @@ import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
|||
const myForm = ref<QForm>();
|
||||
const $q = useQuasar();
|
||||
const DataStore = useInsigniaDataStore();
|
||||
const roleDataStore = useroleUserDataStore();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
dialogConfirm,
|
||||
|
|
@ -249,8 +256,8 @@ const columns2 = ref<QTableProps["columns"]>([
|
|||
},
|
||||
]);
|
||||
|
||||
const rows2 = ref<any[]>([]); //รายชื่อข้าราชการตามหน่วยงานที่จะเพิ่ม
|
||||
const person = ref<any>([]);
|
||||
const rows2 = ref<DataProfileOtherSystem[]>([]); //รายชื่อข้าราชการตามหน่วยงานที่จะเพิ่ม
|
||||
const person = ref<DataManageList>();
|
||||
|
||||
/** เช็คสถานนะแสดงปุ่มเพิ่ม*/
|
||||
const checkStatus = computed(() => {
|
||||
|
|
@ -277,11 +284,9 @@ function changtypeOc() {
|
|||
|
||||
/** function เพิ่มรายชื่อ*/
|
||||
async function clickmodalAdd() {
|
||||
await clearForm();
|
||||
let ocId = DataStore.typeOc ? DataStore.typeOc : DataStore.agency;
|
||||
// showLoader();
|
||||
clearForm();
|
||||
await fecthInsignia();
|
||||
await fecthlistperson(ocId);
|
||||
await fecthlistperson();
|
||||
}
|
||||
|
||||
function onCloseModalAdd() {
|
||||
|
|
@ -296,7 +301,7 @@ const formFilter = reactive({
|
|||
searchField: "citizenId",
|
||||
searchKeyword: "",
|
||||
});
|
||||
const filterOption = ref<any[]>([
|
||||
const filterOption = ref<OptionData[]>([
|
||||
{
|
||||
id: "citizenId",
|
||||
name: "เลขประจำตัวประชาชน",
|
||||
|
|
@ -311,14 +316,14 @@ const filterOption = ref<any[]>([
|
|||
* function เรียกรายชื่อข้าราชการตามหน่วยงานที่จะเพิ่ม
|
||||
* @param id หน่วยงาน
|
||||
*/
|
||||
async function fecthlistperson(id: string = "") {
|
||||
async function fecthlistperson() {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.registryNewOtherSystem(""), { params: formFilter })
|
||||
.then((res) => {
|
||||
maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize);
|
||||
total.value = res.data.result.total;
|
||||
let data = res.data.result.data.map((e: any) => ({
|
||||
let data = res.data.result.data.map((e: ResponseProfile) => ({
|
||||
id: e.id,
|
||||
rootId: e.rootId,
|
||||
citizenId: e.citizenId,
|
||||
|
|
@ -340,19 +345,11 @@ async function fecthlistperson(id: string = "") {
|
|||
}
|
||||
|
||||
/** update ค่า เเถวข้อมูล */
|
||||
function updatePageSize(newPagination: any) {
|
||||
function updatePageSize(newPagination: Pagination) {
|
||||
formFilter.page = 1;
|
||||
formFilter.pageSize = newPagination.rowsPerPage;
|
||||
}
|
||||
|
||||
/** เช็คเเถวข้อมูลว่ามีการเปลี่ยนแปลงไหม */
|
||||
watch(
|
||||
() => formFilter.pageSize,
|
||||
() => {
|
||||
fecthlistperson();
|
||||
}
|
||||
);
|
||||
|
||||
/** function ยืนยันการเพิ่มรายชื่อ*/
|
||||
async function clickAdd() {
|
||||
dataPerson.id
|
||||
|
|
@ -408,7 +405,7 @@ async function addlistperson(id: string) {
|
|||
* function openPopup แก้ไขเครื่องราชฯ
|
||||
* @param props รายละเอียด
|
||||
*/
|
||||
async function clickmodalEdit(props: any) {
|
||||
async function clickmodalEdit(props: DataManageList) {
|
||||
insignia.value = props.insigniaSend;
|
||||
person.value = props;
|
||||
modalEdit.value = true;
|
||||
|
|
@ -433,7 +430,7 @@ async function downloadFile(response: any, filename: string) {
|
|||
/** function เรียก file รายชื่อข้าราชการสามัญฯ*/
|
||||
async function downloadFileexcel() {
|
||||
const findInsigniaId = DataStore.dataInsigniaType.find(
|
||||
(e: any) => e.name == DataStore.typeinsignia
|
||||
(e: ResponseInsigniaType) => e.name == DataStore.typeinsignia
|
||||
);
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -442,7 +439,12 @@ async function downloadFileexcel() {
|
|||
{
|
||||
profileType:
|
||||
DataStore.employeeClass == "all" ? null : DataStore.employeeClass,
|
||||
InsigniaId: DataStore.typeinsignia == "all" ? null : findInsigniaId.id,
|
||||
InsigniaId:
|
||||
DataStore.typeinsignia == "all"
|
||||
? null
|
||||
: findInsigniaId
|
||||
? findInsigniaId.id
|
||||
: "",
|
||||
},
|
||||
{ responseType: "blob" }
|
||||
)
|
||||
|
|
@ -460,47 +462,39 @@ async function downloadFileexcel() {
|
|||
});
|
||||
}
|
||||
|
||||
/*** function ยืนยันการแก้ไขเครื่องราช*/
|
||||
/** function ยืนยันการแก้ไขเครื่องราช แก้ไขเครื่องราช API*/
|
||||
async function clickSave() {
|
||||
dialogConfirm(
|
||||
$q,
|
||||
async () => {
|
||||
await listEdit(person.value.id);
|
||||
showLoader();
|
||||
let data = {
|
||||
insigniaId: insignia.value,
|
||||
};
|
||||
await http
|
||||
.put(config.API.insigniaEdit(person.value ? person.value.id : ""), data)
|
||||
.then(async () => {
|
||||
await props?.fecthInsigniaByOc?.(
|
||||
props.roundId,
|
||||
organization.value,
|
||||
"officer",
|
||||
props.tab
|
||||
);
|
||||
success($q, "แก้ไขเครื่องราชฯ ที่ยื่นขอสำเร็จ");
|
||||
modalEdit.value = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
},
|
||||
"ยืนยันการแก้ไขเครื่องราชฯ ที่ยื่นขอ",
|
||||
"ต้องการยืนยันการแก้ไขเครื่องราชฯ ที่ยื่นขอนี้หรือไม่ ?"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* function แก้ไขเครื่องราช API
|
||||
* @param profileId
|
||||
*/
|
||||
async function listEdit(profileId: string) {
|
||||
showLoader();
|
||||
let data: any = {
|
||||
insigniaId: insignia.value,
|
||||
};
|
||||
await http
|
||||
.put(config.API.insigniaEdit(profileId), data)
|
||||
.then(async () => {
|
||||
await props?.fecthInsigniaByOc?.(
|
||||
props.roundId,
|
||||
organization.value,
|
||||
"officer",
|
||||
props.tab
|
||||
);
|
||||
success($q, "แก้ไขเครื่องราชฯ ที่ยื่นขอสำเร็จ");
|
||||
modalEdit.value = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function openPopup ไม่ยืนขอ
|
||||
* @param id profileId
|
||||
|
|
@ -650,7 +644,7 @@ async function fecthInsignia() {
|
|||
await http
|
||||
.get(config.API.insigniaOrg)
|
||||
.then((res) => {
|
||||
const listtype = res.data.result.map((e: any) => ({
|
||||
const listtype = res.data.result.map((e: ResponseInsigniaType) => ({
|
||||
id: e.id,
|
||||
name: e.name + `(${e.shortName})`,
|
||||
}));
|
||||
|
|
@ -787,6 +781,22 @@ function clearInsigniaFilters(name: string) {
|
|||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => DataStore.typeOc,
|
||||
async () => {
|
||||
filterOrganizationOP.value = await DataStore.optionsTypeOc;
|
||||
organization.value = await DataStore.typeOc;
|
||||
}
|
||||
);
|
||||
|
||||
/** เช็คเเถวข้อมูลว่ามีการเปลี่ยนแปลงไหม */
|
||||
watch(
|
||||
() => formFilter.pageSize,
|
||||
() => {
|
||||
fecthlistperson();
|
||||
}
|
||||
);
|
||||
|
||||
/** Hook*/
|
||||
onMounted(async () => {
|
||||
filterOrganizationOP.value = await DataStore.optionsTypeOc;
|
||||
|
|
@ -804,14 +814,6 @@ onMounted(async () => {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => DataStore.typeOc,
|
||||
async () => {
|
||||
filterOrganizationOP.value = await DataStore.optionsTypeOc;
|
||||
organization.value = await DataStore.typeOc;
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue