โครงสร้าง => refactor code
This commit is contained in:
parent
007df38109
commit
1412ea630b
13 changed files with 369 additions and 408 deletions
|
|
@ -4,7 +4,9 @@ import { useQuasar } from "quasar";
|
|||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
/** importType*/
|
||||
/**
|
||||
* importType
|
||||
*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type {
|
||||
Position,
|
||||
|
|
@ -22,14 +24,20 @@ import type {
|
|||
TypePos,
|
||||
} from "@/modules/02_organizationalNew/interface/response/organizational";
|
||||
|
||||
/** importCompoonents*/
|
||||
/**
|
||||
* importCompoonents
|
||||
*/
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
/** import*Store*/
|
||||
/**
|
||||
* import*Store
|
||||
*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
|
||||
|
||||
/** use*/
|
||||
/**
|
||||
* use
|
||||
*/
|
||||
const $q = useQuasar();
|
||||
const store = useOrganizational();
|
||||
const {
|
||||
|
|
@ -41,7 +49,9 @@ const {
|
|||
dialogMessageNotify,
|
||||
} = useCounterMixin();
|
||||
|
||||
/** props*/
|
||||
/**
|
||||
* props
|
||||
*/
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const props = defineProps({
|
||||
fetchActive: {
|
||||
|
|
@ -60,7 +70,6 @@ const props = defineProps({
|
|||
});
|
||||
|
||||
const isReadonly = ref<boolean>(false); // อ่านได้อย่างเดียว
|
||||
const isDisValidate = ref<boolean>(false);
|
||||
const typeOpsMain = ref<DataOption[]>([]);
|
||||
const levelOpsMain = ref<DataOption[]>([]);
|
||||
const typeOps = ref<DataOption[]>([]);
|
||||
|
|
@ -78,7 +87,11 @@ const formData = reactive<FormPositionFilter>({
|
|||
status: "",
|
||||
});
|
||||
|
||||
/** Table*/
|
||||
/**
|
||||
* ข้อมูลธฟิสำ Table
|
||||
*/
|
||||
const row = ref<Position[]>([]);
|
||||
const rowResult = ref<SeaechResult[]>([]);
|
||||
const visibleColumnsResult = ref<String[]>([
|
||||
"no",
|
||||
"citizenId",
|
||||
|
|
@ -216,18 +229,20 @@ const columnsResult = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
const row = ref<Position[]>([]);
|
||||
const rowResult = ref<SeaechResult[]>([]);
|
||||
|
||||
/** function closePopup*/
|
||||
/**
|
||||
* function closePopup
|
||||
*/
|
||||
function close() {
|
||||
modal.value = false;
|
||||
}
|
||||
|
||||
/** function เรียกข้อมูลประเภทตำแหน่ง*/
|
||||
async function fetchType() {
|
||||
/**
|
||||
* function เรียกข้อมูลประเภทตำแหน่ง
|
||||
*/
|
||||
function fetchType() {
|
||||
showLoader();
|
||||
await http
|
||||
http
|
||||
.get(config.API.orgPosType)
|
||||
.then((res) => {
|
||||
dataLevel.value = res.data.result;
|
||||
|
|
@ -256,7 +271,9 @@ function inputEdit(val: boolean) {
|
|||
};
|
||||
}
|
||||
|
||||
/** function เรียกข้แมูลระดับตำแหน่ง*/
|
||||
/**
|
||||
* function เรียกข้แมูลระดับตำแหน่ง
|
||||
*/
|
||||
function updateSelectType(val: string) {
|
||||
const listLevel: any = dataLevel.value.find((e: TypePos) => e.id === val);
|
||||
levelOpsMain.value = listLevel?.posLevels.map((e: OptionLevel) => ({
|
||||
|
|
@ -267,7 +284,9 @@ function updateSelectType(val: string) {
|
|||
formData.positionLevel = "";
|
||||
}
|
||||
|
||||
/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */
|
||||
/**
|
||||
* ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม
|
||||
*/
|
||||
function validateForm() {
|
||||
if (selected.value.length === 0) {
|
||||
dialogMessageNotify($q, "กรุณาเลือกรายการตำแหน่ง");
|
||||
|
|
@ -278,7 +297,9 @@ function validateForm() {
|
|||
}
|
||||
}
|
||||
|
||||
/** function ยืนยันการบันทึกข้อมูล */
|
||||
/**
|
||||
* function ยืนยันการบันทึกข้อมูล
|
||||
*/
|
||||
function onSubmit() {
|
||||
dialogConfirm(
|
||||
$q,
|
||||
|
|
@ -292,17 +313,16 @@ function onSubmit() {
|
|||
showLoader();
|
||||
http
|
||||
.post(config.API.orgProfile, body)
|
||||
.then(() => {
|
||||
props.fetchDataTable?.(store.treeId, store.level, false);
|
||||
props.getSummary();
|
||||
.then(async () => {
|
||||
await props.fetchDataTable?.(store.treeId, store.level, false);
|
||||
await props.getSummary();
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
modal.value = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(async () => {
|
||||
modal.value = await false;
|
||||
close();
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
},
|
||||
|
|
@ -315,8 +335,11 @@ const page = ref<number>(1);
|
|||
const pageSize = ref<number>(10);
|
||||
const totalPage = ref<number>(0);
|
||||
const selectedProfile = ref<SeaechResult[]>([]);
|
||||
/** functiuon ค้นหาคนครอง */
|
||||
async function searchData() {
|
||||
|
||||
/**
|
||||
* functiuon ค้นหาคนครอง
|
||||
*/
|
||||
function searchData() {
|
||||
showLoader();
|
||||
const reqBody = {
|
||||
posTypeId: formData.positionType, // id ประเภทตำแหน่ง
|
||||
|
|
@ -326,7 +349,7 @@ async function searchData() {
|
|||
pageSize: pageSize.value, //*จำนวนแถวต่อหน้า
|
||||
keyword: formData.personal, //นามสกุล ชื่อ สกุล เลขบัตร
|
||||
};
|
||||
await http
|
||||
http
|
||||
.post(config.API.orgSearchProfile, reqBody)
|
||||
.then((res) => {
|
||||
totalPage.value = Math.ceil(res.data.result.total / pageSize.value);
|
||||
|
|
@ -349,13 +372,17 @@ async function searchData() {
|
|||
});
|
||||
}
|
||||
|
||||
/** function update PageSize*/
|
||||
/**
|
||||
* function update PageSize
|
||||
*/
|
||||
function updatePagination(newPagination: NewPagination) {
|
||||
pageSize.value = newPagination.rowsPerPage;
|
||||
page.value = 1;
|
||||
}
|
||||
|
||||
/** function เคลียร์Form*/
|
||||
/**
|
||||
* function เคลียร์Form
|
||||
*/
|
||||
function clearForm() {
|
||||
formData.positionType = "";
|
||||
formData.positionLevel = "";
|
||||
|
|
@ -368,7 +395,9 @@ function clearForm() {
|
|||
isSit.value = false;
|
||||
}
|
||||
|
||||
/** function เคลียร์ตำแหน่ง*/
|
||||
/**
|
||||
* function เคลียร์ตำแหน่ง
|
||||
*/
|
||||
function clearPosition() {
|
||||
formData.positionType = "";
|
||||
formData.positionLevel = "";
|
||||
|
|
@ -625,11 +654,11 @@ watch([() => page.value, () => pageSize.value], () => {
|
|||
/>
|
||||
<div class="col-12">
|
||||
<d-table
|
||||
ref="table"
|
||||
flat
|
||||
:columns="columnsResult"
|
||||
:rows="rowResult"
|
||||
row-key="id"
|
||||
ref="table"
|
||||
flat
|
||||
:columns="columnsResult"
|
||||
:rows="rowResult"
|
||||
row-key="id"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
:paging="true"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue