แก้เครื่องราชฯ>>จัดการคำขอ (แสดงเลข 000)
This commit is contained in:
parent
48f10f992d
commit
206acc18c3
5 changed files with 142 additions and 136 deletions
|
|
@ -2,10 +2,12 @@
|
|||
import { ref, onMounted } from "vue";
|
||||
import { useQuasar, QForm } from "quasar";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
/** import Store*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
/** useStore*/
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
date2Thai,
|
||||
|
|
@ -17,9 +19,12 @@ const {
|
|||
success,
|
||||
dialogMessageNotify,
|
||||
} = mixin;
|
||||
|
||||
/** use */
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const $q = useQuasar();
|
||||
|
||||
const id = ref<string>(route.params.id as string);
|
||||
const myForm = ref<QForm | null>(null); //form data input
|
||||
const edit = ref<boolean>(false);
|
||||
|
|
@ -35,14 +40,8 @@ const options = ref([
|
|||
{ label: "รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ 2", value: 2 },
|
||||
]);
|
||||
|
||||
onMounted(async () => {
|
||||
if (route.params.id) {
|
||||
// มี params id ให้ เรียกข้อมูลของรอบการเสนอขอ
|
||||
await fetchData();
|
||||
}
|
||||
});
|
||||
// เรียกข้อมูลของรอบการเสนอขอ
|
||||
const fetchData = async () => {
|
||||
/** Function เรียกข้อมูลของรอบการเสนอขอ */
|
||||
async function fetchData() {
|
||||
edit.value = true;
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -59,7 +58,7 @@ const fetchData = async () => {
|
|||
datelast.value = data.period_amount;
|
||||
dateStart.value = new Date(data.period_start);
|
||||
dateEnd.value = new Date(data.period_end);
|
||||
files.value = data.period_doc;
|
||||
// files.value = data.period_doc;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
|
|
@ -67,22 +66,29 @@ const fetchData = async () => {
|
|||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const fileUploadDoc = async (files: any) => {
|
||||
/**
|
||||
* Function อัพโหลดไฟล์
|
||||
* @param files ไฟล์
|
||||
*/
|
||||
function fileUploadDoc(files: any) {
|
||||
files.forEach((file: any) => {
|
||||
fileDocDataUpload.value.push(file);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const updateYear = async (e: number) => {
|
||||
yearly.value = e;
|
||||
/**
|
||||
* Function อัพเดทปี
|
||||
* @param year รับค่าปี คศ
|
||||
*/
|
||||
async function updateYear(year: number) {
|
||||
yearly.value = year;
|
||||
await updateDateRange();
|
||||
};
|
||||
// แก้ไขข้อมูล
|
||||
}
|
||||
|
||||
// คลิกบันทึก
|
||||
const checkSave = () => {
|
||||
/** Function ตรวจสอบค่าว่างของ Input */
|
||||
function checkSave() {
|
||||
if (myForm.value !== null) {
|
||||
myForm.value.validate().then(async (success) => {
|
||||
if (success) {
|
||||
|
|
@ -92,18 +98,20 @@ const checkSave = () => {
|
|||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
// บันทึกข้อมูล
|
||||
const SaveData = async () => {
|
||||
}
|
||||
|
||||
/** Function บันทึกข้อมูล */
|
||||
async function SaveData() {
|
||||
if (edit.value) {
|
||||
await editData(id.value);
|
||||
} else {
|
||||
await addData();
|
||||
clickBack();
|
||||
}
|
||||
};
|
||||
// อัพเดทวันที่เริ่มต้น และ สิ้นสุด
|
||||
const updateDateRange = () => {
|
||||
}
|
||||
|
||||
/** Function อัพเดทวันที่เริ่มต้น และ สิ้นสุด */
|
||||
function updateDateRange() {
|
||||
if (roundInsig.value.value == 1) {
|
||||
dateStart.value = new Date(yearly.value, 9, 1);
|
||||
dateEnd.value = new Date(yearly.value + 1, 3, 29);
|
||||
|
|
@ -111,9 +119,10 @@ const updateDateRange = () => {
|
|||
dateStart.value = new Date(yearly.value + 1, 3, 29);
|
||||
dateEnd.value = new Date(yearly.value + 1, 4, 29);
|
||||
}
|
||||
};
|
||||
// เพิ่มข้อมูลรอบการเสนอขอพระราชทานเครื่องราชฯ
|
||||
const addData = async () => {
|
||||
}
|
||||
|
||||
/** Function เพิ่มข้อมูลรอบการเสนอขอพระราชทานเครื่องราชฯ */
|
||||
async function addData() {
|
||||
const formData = new FormData();
|
||||
const name = `รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ ${
|
||||
roundInsig.value.value
|
||||
|
|
@ -141,9 +150,10 @@ const addData = async () => {
|
|||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
// แก้ไขข้อมูล
|
||||
const editData = async (id: string) => {
|
||||
}
|
||||
|
||||
/** Function แก้ไขข้อมูลรอบการเสนอขอพระราชทานเครื่องราชฯ */
|
||||
async function editData(id: string) {
|
||||
const formData = new FormData();
|
||||
const name = `รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ ${
|
||||
roundInsig.value.value
|
||||
|
|
@ -172,11 +182,18 @@ const editData = async (id: string) => {
|
|||
hideLoader();
|
||||
clickBack();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const clickBack = () => {
|
||||
/** Function ย้อนกลับหน้า รอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์ */
|
||||
function clickBack() {
|
||||
router.push({ name: "insigniaProposals" });
|
||||
};
|
||||
}
|
||||
|
||||
/** Hook */
|
||||
onMounted(async () => {
|
||||
// มี params id ให้ เรียกข้อมูลของรอบการเสนอขอ
|
||||
(await route.params?.id) && fetchData();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="col-xs-12 col-sm-12 col-md-11">
|
||||
|
|
|
|||
|
|
@ -1,14 +1,22 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, useAttrs, onMounted } from "vue";
|
||||
import type { QTableProps } from "quasar";
|
||||
import router from "@/router";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import type { FormProprsalsRound2 } from "@/modules/07_insignia/interface/request/Main";
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
|
||||
|
||||
/** import Type*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type {
|
||||
FormProprsalsRound2,
|
||||
ColId,
|
||||
} from "@/modules/07_insignia/interface/request/Main";
|
||||
|
||||
/** import Store*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
|
||||
/** useStroe */
|
||||
const storeInsignia = useInsigniaDataStore();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
date2Thai,
|
||||
|
|
@ -19,18 +27,19 @@ const {
|
|||
dialogConfirm,
|
||||
dialogRemove,
|
||||
} = mixin;
|
||||
const $q = useQuasar(); //ใช้ noti quasar
|
||||
const storeInsignia = useInsigniaDataStore();
|
||||
|
||||
/** use */
|
||||
const $q = useQuasar(); //ใช้ noti quasar
|
||||
|
||||
/** คอลัมน์ที่แสดง */
|
||||
const visibleColumns = ref<string[]>([
|
||||
"period_name",
|
||||
"period_year",
|
||||
"period_start",
|
||||
"period_end",
|
||||
"statusRoyal",
|
||||
]); //ค้นหา คอลัมน์ คอลัมน์ที่แสดง
|
||||
|
||||
// หัวตาราง
|
||||
]);
|
||||
/** คอลัมน์ */
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "period_name",
|
||||
|
|
@ -76,7 +85,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
},
|
||||
{
|
||||
name: "statusRoyal",
|
||||
align: "center",
|
||||
align: "left",
|
||||
label: "สถานะ",
|
||||
sortable: false,
|
||||
field: "statusRoyal",
|
||||
|
|
@ -84,15 +93,11 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
// ข้อมูลตาราง (จำลอง)
|
||||
/** ข้อมูลตาราง (จำลอง)*/
|
||||
const rows = ref<FormProprsalsRound2[]>([]);
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchData();
|
||||
});
|
||||
|
||||
//เรียกจาก API รายการรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์
|
||||
const fetchData = async () => {
|
||||
/** Function เรียกรายการรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์ */
|
||||
async function fetchData() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.listRoundInsignia())
|
||||
|
|
@ -119,16 +124,18 @@ const fetchData = async () => {
|
|||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
// redirect หน้าข้อมูลรอบการเสนอข้อ
|
||||
interface Col {
|
||||
period_id: string;
|
||||
}
|
||||
const clickEdit = (col: Col) => {
|
||||
|
||||
/** Function redirect หน้าข้อมูลรอบการเสนอข้อ */
|
||||
function clickEdit(col: ColId) {
|
||||
router.push(`/insignia/round-add/${col.period_id}`);
|
||||
};
|
||||
// ยืนยันการลบรอบการเสนอขอ
|
||||
const clickDelete = (id: string) => {
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ยืนยันการลบรอบการเสนอขอ
|
||||
* @param id รอบการเสนขอ
|
||||
*/
|
||||
function clickDelete(id: string) {
|
||||
dialogRemove($q, async () => {
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -144,13 +151,15 @@ const clickDelete = (id: string) => {
|
|||
hideLoader();
|
||||
});
|
||||
});
|
||||
};
|
||||
// เพิ่มรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์
|
||||
const clickAdd = () => {
|
||||
}
|
||||
|
||||
/** Fnction เพิ่มรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์ */
|
||||
function clickAdd() {
|
||||
router.push({ name: "roundAdd" });
|
||||
};
|
||||
// คำนวณราชชื่อผู้ได้รับเครื่องราช
|
||||
const clickListInsignia = async (propsId: string) => {
|
||||
}
|
||||
|
||||
/** Fnction คำนวณราชชื่อผู้ได้รับเครื่องราช */
|
||||
async function clickListInsignia(propsId: string) {
|
||||
dialogConfirm(
|
||||
$q,
|
||||
async () => {
|
||||
|
|
@ -159,9 +168,10 @@ const clickListInsignia = async (propsId: string) => {
|
|||
"ยืนยันการคำนวณราชชื่อผู้ได้รับเครื่องราชฯ",
|
||||
"ต้องการยืนยันการคำนวณราชชื่อผู้ได้รับเครื่องราชฯนี้หรือไม่ ?"
|
||||
);
|
||||
};
|
||||
// เรียกจาก API ข้อมูลผู้ได้รับเครื่องราชฯ
|
||||
const getRequest = async (id: string) => {
|
||||
}
|
||||
|
||||
/** Fnction เรียกจาก API ข้อมูลผู้ได้รับเครื่องราชฯ */
|
||||
async function getRequest(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.requestInsignia(id))
|
||||
|
|
@ -174,9 +184,9 @@ const getRequest = async (id: string) => {
|
|||
.finally(async () => {
|
||||
await fetchData();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// ค้นหาในตาราง
|
||||
/** ค้นหาในตาราง */
|
||||
const filterKeyword = ref<string>("");
|
||||
const filterRef = ref<HTMLInputElement | null>(null);
|
||||
const resetFilter = () => {
|
||||
|
|
@ -187,17 +197,16 @@ const resetFilter = () => {
|
|||
};
|
||||
|
||||
const attrs = ref<any>(useAttrs());
|
||||
const paging = ref<boolean>(true);
|
||||
const pagination = ref({
|
||||
// sortBy: "desc",
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
const paginationLabel = (start: string, end: string, total: string) => {
|
||||
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
|
||||
else return start + "-" + end + " ใน " + total;
|
||||
};
|
||||
|
||||
/** Hook */
|
||||
onMounted(async () => {
|
||||
await fetchData();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
|
|
@ -258,7 +267,7 @@ const paginationLabel = (start: string, end: string, total: string) => {
|
|||
/>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<q-table
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
|
|
@ -271,7 +280,6 @@ const paginationLabel = (start: string, end: string, total: string) => {
|
|||
class="custom-header-table"
|
||||
v-bind="attrs"
|
||||
:visible-columns="visibleColumns"
|
||||
:pagination-label="paginationLabel"
|
||||
v-model:pagination="pagination"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
|
|
@ -287,39 +295,13 @@ const paginationLabel = (start: string, end: string, total: string) => {
|
|||
<template v-slot:body="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td
|
||||
key="period_name"
|
||||
:props="props"
|
||||
v-for="col in props.cols"
|
||||
:key="col.id"
|
||||
@click="clickEdit(props.row)"
|
||||
>
|
||||
{{ props.row.period_name }}
|
||||
</q-td>
|
||||
<q-td
|
||||
key="period_year"
|
||||
:props="props"
|
||||
@click="clickEdit(props.row)"
|
||||
>
|
||||
{{ props.row.period_year }}
|
||||
</q-td>
|
||||
<q-td
|
||||
key="period_start"
|
||||
:props="props"
|
||||
@click="clickEdit(props.row)"
|
||||
>
|
||||
{{ props.row.period_start }}
|
||||
</q-td>
|
||||
<q-td
|
||||
key="period_end"
|
||||
:props="props"
|
||||
@click="clickEdit(props.row)"
|
||||
>
|
||||
{{ props.row.period_end }}
|
||||
</q-td>
|
||||
<q-td
|
||||
key="statusRoyal"
|
||||
:props="props"
|
||||
@click="clickEdit(props.row)"
|
||||
>
|
||||
{{ props.row.statusRoyal }}
|
||||
<div>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
<q-td
|
||||
key="period_isActive"
|
||||
|
|
@ -385,19 +367,7 @@ const paginationLabel = (start: string, end: string, total: string) => {
|
|||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:pagination="scope">
|
||||
<q-pagination
|
||||
v-model="pagination.page"
|
||||
active-color="primary"
|
||||
color="dark"
|
||||
:max="scope.pagesNumber"
|
||||
:max-pages="5"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
></q-pagination>
|
||||
</template>
|
||||
</q-table>
|
||||
</d-table>
|
||||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ const fecthAgency = async () => {
|
|||
.then(async (res) => {
|
||||
loadview.value = true;
|
||||
DataStore.agency = res.data.result;
|
||||
DataStore.typeOc = DataStore.agency
|
||||
DataStore.typeOc = DataStore.agency;
|
||||
if (roleDataStore.adminRole) {
|
||||
await fecthType(); // ถ้าไม่มีหนวยงานจะเรียกหน่วยงานทั้งหมด
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -15,10 +15,14 @@ interface FormProprsalsRound2 {
|
|||
period_end: any;
|
||||
period_isActive: boolean;
|
||||
period_doc: any;
|
||||
period_status:any
|
||||
period_status: any;
|
||||
}
|
||||
interface ItemType {
|
||||
name: string;
|
||||
shortName: string;
|
||||
}
|
||||
export type { FormProprsalsRound, FormProprsalsRound2,ItemType };
|
||||
|
||||
interface ColId {
|
||||
period_id: string;
|
||||
}
|
||||
export type { FormProprsalsRound, FormProprsalsRound2, ItemType ,ColId};
|
||||
|
|
|
|||
|
|
@ -53,9 +53,21 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
|
|||
level: e.rank,
|
||||
salary: e.salary,
|
||||
salary2: Number(e.salary).toLocaleString(),
|
||||
insigniaType: e.lastInsignia ? `${e.lastInsignia} (${dataInsigniaType.value.find((item: any) => item.name === e.lastInsignia)?.shortName || ''})` : '',
|
||||
insigniaType: e.lastInsignia
|
||||
? `${e.lastInsignia} (${
|
||||
dataInsigniaType.value.find(
|
||||
(item: any) => item.name === e.lastInsignia
|
||||
)?.shortName || ""
|
||||
})`
|
||||
: "",
|
||||
insigniaCheck: e.requestInsignia,
|
||||
insigniaSend: e.requestInsignia ? `${e.requestInsignia} (${dataInsigniaType.value.find((item: any) => item.name === e.requestInsignia)?.shortName || ''})` : '',
|
||||
insigniaSend: e.requestInsignia
|
||||
? `${e.requestInsignia} (${
|
||||
dataInsigniaType.value.find(
|
||||
(item: any) => item.name === e.requestInsignia
|
||||
)?.shortName || ""
|
||||
})`
|
||||
: "",
|
||||
insigniaLevel: e.level,
|
||||
dateSend: date2Thai(e.requestDate),
|
||||
requestNote: e.requestNote,
|
||||
|
|
@ -67,15 +79,17 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
|
|||
isApprove: e.isApprove,
|
||||
statusMark:
|
||||
e.markDiscipline === true ||
|
||||
e.markLeave === true ||
|
||||
e.markRate === true
|
||||
e.markLeave === true ||
|
||||
e.markRate === true
|
||||
? true
|
||||
: false,
|
||||
}));
|
||||
const item = datalist
|
||||
const item = datalist;
|
||||
for (let j = 0; j < item.length; j++) {
|
||||
const data = item[j];
|
||||
const filteredData = dataInsigniaType.value.find((item: any) => item.name === data.insigniaType);
|
||||
const filteredData = dataInsigniaType.value.find(
|
||||
(item: any) => item.name === data.insigniaType
|
||||
);
|
||||
if (filteredData) {
|
||||
data.insigniaType = `${data.insigniaType} (${filteredData.shortName})`;
|
||||
} else {
|
||||
|
|
@ -97,10 +111,11 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
|
|||
};
|
||||
// เรียก Option หน่วยงานทั้งหมด
|
||||
const fetchOption = (op: any) => {
|
||||
if (agency.value !== null) {
|
||||
const aId = agency.value ?? "00000000-0000-0000-0000-000000000000";
|
||||
|
||||
if (aId !== "00000000-0000-0000-0000-000000000000") {
|
||||
typeOc.value = agency.value;
|
||||
optionsTypeOc.value = op;
|
||||
// .filter((e: any) => e.id == agency.value);
|
||||
} else {
|
||||
(optionsTypeOc.value = op), (typeOc.value = op[0].id);
|
||||
}
|
||||
|
|
@ -117,14 +132,14 @@ export const useInsigniaDataStore = defineStore("insignia", () => {
|
|||
typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }];
|
||||
for (let i = 1; i <= double_name.length; i++) {
|
||||
const type = double_name[i - 1];
|
||||
const filterShortName = dataInsigniaType.value.find((item: any) => item.name === type)
|
||||
const filterShortName = dataInsigniaType.value.find(
|
||||
(item: any) => item.name === type
|
||||
);
|
||||
const listtype = {
|
||||
id: type,
|
||||
name: `${type} (${filterShortName.shortName})`,
|
||||
|
||||
};
|
||||
typeinsigniaOptions.value.push(listtype);
|
||||
|
||||
}
|
||||
} else typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }];
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue