ปรับ code และ ปุม delete รายการรอบการปฏิบัติงาน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-11-14 09:20:30 +07:00
parent bcb46fa272
commit 01cbfe6245
17 changed files with 1452 additions and 996 deletions

View file

@ -1,18 +1,22 @@
<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { useResultDataStore } from "@/modules/07_insignia/storeResult";
import { useQuasar } from "quasar";
/** import Type*/
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
import type { QTableProps, QInput } from "quasar";
/** import Components*/
import Dialogbody from "@/modules/07_insignia/components/3_result/Dialogbody.vue";
import DialogForm from "@/modules/07_insignia/components/3_result/DialogForm.vue";
import fileUploadview from "../components/3_result/fileUpload.vue";
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
import type { QTableProps, QInput } from "quasar";
import { useQuasar } from "quasar";
/** import Stores */
import { useResultDataStore } from "@/modules/07_insignia/storeResult";
import { useCounterMixin } from "@/stores/mixin";
/** useStore*/
const DataStore = useResultDataStore();
const mixin = useCounterMixin();
const {
@ -23,9 +27,10 @@ const {
messageError,
success,
} = mixin;
const $q = useQuasar();
const tab = ref<string>("");
const $q = useQuasar();
const tab = ref<string>("");
const selectRound = ref<string>("");
const selectRoundOption = ref<OptionData[]>([]);
const modal = ref<boolean>(false);
@ -44,81 +49,9 @@ const filterEmployee = ref<any>(DataStore.employeeClassOps);
const ModalDialog = ref<boolean>(false);
const dateCheckReceive = ref<any>();
const dateCheckReturn = ref<any>();
const dataModal = ref<any>([])
onMounted(async () => {
await fecthRound();
});
//
const fecthRound = async () => {
showLoader();
await http
.get(config.API.noteround())
.then(async (res) => {
let data = res.data.result;
if (data.length !== 0) {
selectRoundOption.value = data.map((e: any) => ({
name: "รอบการเสนอขอพระราชทานเครื่องราชฯ ปี" + " " + (e.year + 543),
id: e.id,
}));
selectRound.value = data[0].id;
await fecthInsignia();
await fecthInsigniaType();
}
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
};
//
const fecthInsignia = async () => {
await http
.get(config.API.insignia)
.then((res) => {
let data = res.data.result;
DataStore.fetchDatainsignia(data);
})
.catch((err) => {
messageError($q, err);
});
};
//
const fecthInsigniaType = async () => {
await http(config.API.insigniaType)
.then((res) => {
let data = res.data.result;
DataStore.fetchDatainsigniaType(data);
tab.value = DataStore.insigniaType[0].name;
loadView.value = true;
})
.catch((err) => {
messageError($q, err);
});
};
const visibleColumns = ref<String[]>([
"no",
"status",
"citizenId",
"name",
"type",
"dateReceive",
"date",
"employeeType",
"volumeNo",
"section",
"page",
"number",
"vatnumber",
"datepay",
"typepay",
"address",
"action",
]);
const dataModal = ref<any>([]);
/** ข้อมูล Tabla*/
const columns = ref<QTableProps["columns"]>([
{
name: "no",
@ -270,9 +203,101 @@ const columns = ref<QTableProps["columns"]>([
field: "",
},
]);
const visibleColumns = ref<String[]>([
"no",
"status",
"citizenId",
"name",
"type",
"dateReceive",
"date",
"employeeType",
"volumeNo",
"section",
"page",
"number",
"vatnumber",
"datepay",
"typepay",
"address",
"action",
]);
const filterRef = ref<QInput>();
const filter = ref<string>("");
/** function เรียกรอบการเสนอขอพระราชทานเครื่องราช*/
async function fecthRound() {
showLoader();
await http
.get(config.API.noteround())
.then(async (res) => {
let data = res.data.result;
if (data.length !== 0) {
selectRoundOption.value = data.map((e: any) => ({
name: "รอบการเสนอขอพระราชทานเครื่องราชฯ ปี" + " " + (e.year + 543),
id: e.id,
}));
selectRound.value = data[0].id;
await fecthInsignia();
await fecthInsigniaType();
}
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** function เรียกประเภทเครื่องราช*/
async function fecthInsignia() {
await http
.get(config.API.insignia)
.then((res) => {
let data = res.data.result;
DataStore.fetchDatainsignia(data);
})
.catch((err) => {
messageError($q, err);
});
}
/** function เรียกระดับเครื่องราช*/
async function fecthInsigniaType() {
await http(config.API.insigniaType)
.then((res) => {
let data = res.data.result;
DataStore.fetchDatainsigniaType(data);
tab.value = DataStore.insigniaType[0].name;
loadView.value = true;
})
.catch((err) => {
messageError($q, err);
});
}
/** function เลือกประเภทเครื่องราช*/
function selectorInsignia() {
fecthlistInsignia();
}
/**
* function เลอกรอบการเสนอขอ
* @param round รอบการเสนอขอ
*/
function selectorRound(round: string) {
if (round) {
selectRound.value = round;
}
fecthlistInsignia();
}
/** callback function จำทำงานเมื่อ tab มีการเปลี่ยนแปลง*/
watch(tab, () => {
if (tab.value !== "doc") {
DataStore.insignia = ''
DataStore.insignia = "";
fecthlistInsignia();
insigniaTypeOption.value = DataStore.insigniaOp.filter(
(e: any) => e.insigniaType == tab.value || e.name == "ทั้งหมด"
@ -280,27 +305,16 @@ watch(tab, () => {
insigniaTypeFilter.value = insigniaTypeOption.value;
}
});
/** callback function จำทำงานเมื่อ modal มีการเปลี่ยนแปลง*/
watch(modal, () => {
if (modal.value == false) {
fecthlistInsignia();
}
});
//
const selectorInsignia = () => {
fecthlistInsignia();
};
//
const selectorRound = (round: string) => {
if (round) {
selectRound.value = round;
}
fecthlistInsignia();
};
// /
const fecthlistInsignia = async () => {
/** function เรียกราชชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยาภรณ์/การจ่ายใบกำกับ */
async function fecthlistInsignia() {
showLoader();
let data = {
insigniaTypeId: tab.value,
@ -319,9 +333,14 @@ const fecthlistInsignia = async () => {
.finally(() => {
hideLoader();
});
};
}
const uploadFile = async (event: any, action: string) => {
/**
* function uploadFile
* @param event file
* @param action typepreview
*/
async function uploadFile(event: any, action: string) {
if (selectRound.value !== undefined) {
let id = selectRound.value;
dialogConfirm($q, async () => {
@ -349,38 +368,44 @@ const uploadFile = async (event: any, action: string) => {
"ยืนยันการบันทึกรายการข้อมูล",
"ต้องการยืนยันรายการข้อมูลนี้หรื้อไม่ ?";
}
};
}
const filterRef = ref<QInput>();
const filter = ref<string>("");
const close = () => {
/** function closePopup*/
function close() {
modal.value = false;
ModalDialog.value = false;
};
}
const addData = () => {
/** function openPopup add*/
function addData() {
modal.value = true;
action.value = "addData";
};
const editData = (data: any) => {
}
/** function openPopup edit*/
function editData(data: any) {
personId.value = data.id;
profileType.value = data.profileType;
action.value = "editData";
modal.value = true;
};
}
const save = () => {
console.log("save function");
};
/** ข้อมูล ไฟล์*/
const modelPerview = ref<boolean>(false);
const rowspreview = ref<any>([]);
const typepreview = ref<string>("");
const fileInsignia = ref<any>(null);
// fileupload
const perviewfile = async (event: any, actionType: string) => {
/**
* function แสดง fileupload
* @param event ไฟล
* @param actionType ประเภทไฟล receice,invoice
*/
async function perviewfile(event: any, actionType: string) {
showLoader();
typepreview.value = actionType;
fileInsignia.value = event;
@ -419,7 +444,7 @@ const perviewfile = async (event: any, actionType: string) => {
hideLoader();
});
}
};
}
const resetFilter = () => {
// reset X
@ -437,55 +462,65 @@ const paginationLabel = (start: number, end: number, total: number) => {
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
else return start + "-" + end + " ใน " + total;
};
const OpenModal = (data: any) => {
dataModal.value = data
/** function openPopup */
function OpenModal(data: any) {
dataModal.value = data;
ModalDialog.value = true;
dateCheckReceive.value = data.dateReceiveInsignia;
dateCheckReturn.value = data.dateReturnInsignia;
personId.value = data.id;
};
const filterSelector = (val: any, update: Function, name: any) => {
}
/**
* function นหาขอม option
* @param val คำคนหา
* @param update function
* @param name selec
*/
function filterSelector(val: any, update: Function, name: any) {
update(() => {
const needle = val.toLowerCase();
if (name === 'insigniaTypeFilter') {
DataStore.insignia = null as any
insigniaTypeFilter.value = insigniaTypeOption.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
if (name === "insigniaTypeFilter") {
DataStore.insignia = null as any;
insigniaTypeFilter.value = insigniaTypeOption.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "filterInvoice") {
DataStore.invoiceType = "";
filterInvoice.value = DataStore.invoiceTypeop.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "filterEmployee") {
DataStore.employeeClass = "";
filterEmployee.value = DataStore.employeeClassOps.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
}
else if(name === 'filterInvoice'){
DataStore.invoiceType =''
filterInvoice.value = DataStore.invoiceTypeop.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
}
else if(name === 'filterEmployee'){
DataStore.employeeClass = ''
filterEmployee.value = DataStore.employeeClassOps.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
}
}
)
});
}
const clearInsigniaFilters = (name: string) => {
if (name ==='insigniaTypeFilter' ) {
DataStore.insignia = "";
insigniaTypeFilter.value = insigniaTypeOption.value
}
else if(name === 'filterInvoice'){
/**
* function clearfilter เครองราช
* @param name selec
*/
function clearInsigniaFilters(name: string) {
if (name === "insigniaTypeFilter") {
DataStore.insignia = "";
insigniaTypeFilter.value = insigniaTypeOption.value;
} else if (name === "filterInvoice") {
DataStore.invoiceType = "all";
filterInvoice.value = DataStore.invoiceTypeop
}
else if(name === 'filterEmployee'){
filterInvoice.value = DataStore.invoiceTypeop;
} else if (name === "filterEmployee") {
DataStore.employeeClass = "all";
filterEmployee.value = DataStore.employeeClassOps
filterEmployee.value = DataStore.employeeClassOps;
}
}
/** hook*/
onMounted(async () => {
await fecthRound();
});
</script>
<template>
@ -555,7 +590,7 @@ const clearInsigniaFilters = (name: string) => {
v-model="fileResult"
label="บันทึกผลการได้รับพระราชทานเครื่องราชอิสริยาภรณ์"
accept=".xlsx"
class=" full-width"
class="full-width"
>
<template v-slot:prepend>
<q-icon name="attach_file" color="primary" />
@ -587,10 +622,10 @@ const clearInsigniaFilters = (name: string) => {
v-model="fileinvoice"
label="บันทึกผลการจ่ายใบกำกับ"
accept=".xlsx"
class=" full-width"
class="full-width"
>
<template v-slot:prepend>
<q-icon name="attach_file" color="primary"/>
<q-icon name="attach_file" color="primary" />
</template>
<q-tooltip>พโหลดไฟลนทกผลการจายใบกำก</q-tooltip>
</q-file>
@ -610,7 +645,7 @@ const clearInsigniaFilters = (name: string) => {
</div>
</q-card>
<div class="row col-12 q-pb-sm q-col-gutter-xs">
<q-select
<q-select
v-model="DataStore.insignia"
dense
outlined
@ -636,7 +671,8 @@ const clearInsigniaFilters = (name: string) => {
name="cancel"
@click.stop.prevent="
clearInsigniaFilters('insigniaTypeFilter'),
selectorInsignia()"
selectorInsignia()
"
class="cursor-pointer"
/>
</template>
@ -647,7 +683,7 @@ const clearInsigniaFilters = (name: string) => {
</q-item-section>
</q-item>
</template>
</q-select>
</q-select>
<q-space />
<div class="items-center" style="display: flex">
<!-- นหาขอความใน table -->
@ -688,7 +724,6 @@ const clearInsigniaFilters = (name: string) => {
class="gt-xs q-ml-sm"
/>
</div>
</div>
<div class="row col-12 q-mb-sm q-col-gutter-xs">
<q-select
@ -764,10 +799,7 @@ const clearInsigniaFilters = (name: string) => {
doneFn:Function) => filterSelector(inputValue, doneFn,'filterEmployee'
) "
>
<template
v-if="DataStore.employeeClass !== 'all'"
v-slot:append
>
<template v-if="DataStore.employeeClass !== 'all'" v-slot:append>
<q-icon
name="cancel"
@click.stop.prevent="
@ -781,12 +813,12 @@ const clearInsigniaFilters = (name: string) => {
/>
</template>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
<div>
<q-btn