Refactoring code module 03_recruiting
This commit is contained in:
parent
b223c2433e
commit
87e2e3b080
36 changed files with 6139 additions and 6335 deletions
|
|
@ -1,7 +1,12 @@
|
|||
<script setup lang="ts">
|
||||
import type { QTableProps } from "quasar";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
import { ref, onMounted, nextTick } from "vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import type {
|
||||
WebType,
|
||||
AddressWeb,
|
||||
|
|
@ -10,12 +15,9 @@ import type {
|
|||
EnableType,
|
||||
CmsTable,
|
||||
} from "@/modules/03_recruiting/interface/index/Main";
|
||||
import type { Columns } from "@/modules/03_recruiting/interface/request/Career";
|
||||
import type { DataLink } from "@/modules/03_recruiting/interface/request/Editor";
|
||||
import type { QForm } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import HeaderTop from "@/modules/03_recruiting/components/top1.vue";
|
||||
import ProfileTable from "@/modules/03_recruiting/components/Table1.vue";
|
||||
|
||||
|
|
@ -29,10 +31,10 @@ const {
|
|||
messageError,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
dialogMessageNotify,
|
||||
dialogConfirm,
|
||||
dialogRemove,
|
||||
} = mixin;
|
||||
|
||||
const previous = ref<boolean>(false);
|
||||
const next = ref<boolean>(false);
|
||||
const addDialog = ref<boolean>(false);
|
||||
|
|
@ -53,7 +55,6 @@ const inputName = ref<string | null>("");
|
|||
const inputNameBack = ref<string | null>("");
|
||||
const editvisible = ref<boolean>(false);
|
||||
const dialog = ref<boolean>(false);
|
||||
const edit = ref<boolean>(false);
|
||||
const qeditor = ref<string>("");
|
||||
const title = ref<string>("");
|
||||
const filter = ref<string>(""); //search data table
|
||||
|
|
@ -69,6 +70,7 @@ const web = ref<WebType>({
|
|||
eng: "",
|
||||
descripstion: "",
|
||||
});
|
||||
|
||||
const address = ref<AddressWeb>({
|
||||
address: null,
|
||||
provinceId: null,
|
||||
|
|
@ -82,18 +84,21 @@ const enable = ref<EnableType>({
|
|||
web: false,
|
||||
about: false,
|
||||
});
|
||||
|
||||
const visibleColumns = ref<String[]>([
|
||||
"name",
|
||||
"link",
|
||||
"createdAt",
|
||||
"lastUpdatedAt",
|
||||
]);
|
||||
|
||||
const visibleColumnsAgency = ref<String[]>([
|
||||
"name",
|
||||
"link",
|
||||
"createdAt",
|
||||
"lastUpdatedAt",
|
||||
]);
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "name",
|
||||
|
|
@ -141,14 +146,11 @@ const columns = ref<QTableProps["columns"]>([
|
|||
},
|
||||
]);
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchData();
|
||||
await fetchProvince();
|
||||
await fetchDistrict(address.value.provinceId);
|
||||
await fetchSubDistrict(address.value.districtId);
|
||||
});
|
||||
|
||||
const clickPreviousNext = (page: string) => {
|
||||
/**
|
||||
* ฟังชั่น หน้าถัดไป ย้อนกลับหน้า page
|
||||
* @param page next/previous
|
||||
*/
|
||||
function clickPreviousNext(page: string) {
|
||||
const index: number =
|
||||
page == "next" ? indexRow.value - 1 : indexRow.value + 1;
|
||||
let length: number;
|
||||
|
|
@ -168,9 +170,14 @@ const clickPreviousNext = (page: string) => {
|
|||
previous.value = index == 0 ? false : true;
|
||||
next.value = index == length - 1 ? false : true;
|
||||
indexRow.value = index;
|
||||
};
|
||||
}
|
||||
|
||||
const selectData = (id: string, agency: boolean) => {
|
||||
/**
|
||||
* ฟังชั่น เปิดรายละเอียด
|
||||
* @param id
|
||||
* @param agency
|
||||
*/
|
||||
function selectData(id: string, agency: boolean) {
|
||||
dialog.value = !dialog.value;
|
||||
addDialog.value = false;
|
||||
editvisible.value = false;
|
||||
|
|
@ -197,20 +204,25 @@ const selectData = (id: string, agency: boolean) => {
|
|||
indexRow.value = index;
|
||||
previous.value = index == 0 ? false : true;
|
||||
next.value = index == length - 1 ? false : true;
|
||||
};
|
||||
}
|
||||
|
||||
const editDialog = () => {
|
||||
/** แก้ไขข้อมูล ส่วนราชการ/หน่วยงาน */
|
||||
function editDialog() {
|
||||
inputName.value = inputNameBack.value;
|
||||
|
||||
editvisible.value = !editvisible.value;
|
||||
};
|
||||
}
|
||||
|
||||
const clickClose = () => {
|
||||
/** ปิด dialog ส่วนราชการ/หน่วยงาน */
|
||||
function clickClose() {
|
||||
dialog.value = !dialog.value;
|
||||
addDialog.value = false;
|
||||
};
|
||||
|
||||
const clickAdd = (agency: boolean) => {
|
||||
}
|
||||
/**
|
||||
* เปิด dialog ส่วนราชการ/หน่วยงาน
|
||||
* @param agency true/false
|
||||
*/
|
||||
function clickAdd(agency: boolean) {
|
||||
dialog.value = !dialog.value;
|
||||
title.value = agency ? "เพิ่มหน่วยงาน" : "เพิ่มส่วนราชการ";
|
||||
agencyRow.value = agency;
|
||||
|
|
@ -218,17 +230,19 @@ const clickAdd = (agency: boolean) => {
|
|||
editvisible.value = true;
|
||||
inputLink.value = "";
|
||||
inputName.value = "";
|
||||
};
|
||||
}
|
||||
|
||||
const statusHeader = () => {
|
||||
/** เช็คสถานะ เปิด/ปิด เพิ่มข้อมูล */
|
||||
function statusHeader() {
|
||||
return Object.values(enable.value).includes(true);
|
||||
};
|
||||
}
|
||||
|
||||
const cancelBlog = async () => {
|
||||
/** ปิด dialog ข้อมูลเกี่ยวกับเรา */
|
||||
async function cancelBlog() {
|
||||
await fetchData();
|
||||
};
|
||||
|
||||
const saveAdd = async () => {
|
||||
}
|
||||
/** save ข้อมูล */
|
||||
async function saveAdd() {
|
||||
dialogform.value?.validate().then(async (result: boolean) => {
|
||||
if (result) {
|
||||
if (agencyRow.value) {
|
||||
|
|
@ -262,9 +276,10 @@ const saveAdd = async () => {
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const saveDelete = async (del: string) => {
|
||||
/** ลบข้อมูล */
|
||||
async function saveDelete(del: string) {
|
||||
if (agencyRow.value) {
|
||||
const filt = cmsAgency.value.filter((r: any) => r.id != idRow.value);
|
||||
let arrData: DataLink[] = [];
|
||||
|
|
@ -288,9 +303,10 @@ const saveDelete = async (del: string) => {
|
|||
await saveDataGoverment(arrData, del);
|
||||
dialog.value = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const saveEdit = async () => {
|
||||
/** edit */
|
||||
async function saveEdit() {
|
||||
if (agencyRow.value) {
|
||||
let arrData: DataLink[] = [];
|
||||
cmsAgency.value.map((r: any) => {
|
||||
|
|
@ -325,14 +341,12 @@ const saveEdit = async () => {
|
|||
});
|
||||
await saveDataGoverment(arrData, "");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const saveDataAgency = async (data: DataLink[], del: string) => {
|
||||
/** save หน่วยงาน */
|
||||
async function saveDataAgency(data: DataLink[], del: string) {
|
||||
dialogform.value?.validate().then(async (result: boolean) => {
|
||||
if (result) {
|
||||
// if (data.length === 0) {
|
||||
// dialogMessageNotify($q, "ลบข้อมูลต้องมี 2 ลิ้งอย่างน้อย 2 ลิ้ง");
|
||||
// } else
|
||||
if (del) {
|
||||
dialogRemove($q, () => dataPostAgency(data));
|
||||
} else {
|
||||
|
|
@ -340,9 +354,10 @@ const saveDataAgency = async (data: DataLink[], del: string) => {
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const saveDataGoverment = async (data: DataLink[], del: string) => {
|
||||
/** save ราชการ */
|
||||
async function saveDataGoverment(data: DataLink[], del: string) {
|
||||
dialogform.value?.validate().then(async (result: boolean) => {
|
||||
if (result) {
|
||||
// if (data.length === 0) {
|
||||
|
|
@ -355,8 +370,13 @@ const saveDataGoverment = async (data: DataLink[], del: string) => {
|
|||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const dataPostAgency = async (data: DataLink[]) => {
|
||||
}
|
||||
|
||||
/**
|
||||
* เพิ่มข้อมูล
|
||||
* @param data ข้อมูลหน่วยงาน
|
||||
*/
|
||||
async function dataPostAgency(data: DataLink[]) {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.cmsAgency, data)
|
||||
|
|
@ -368,8 +388,13 @@ const dataPostAgency = async (data: DataLink[]) => {
|
|||
dialog.value = false;
|
||||
await fetchData();
|
||||
});
|
||||
};
|
||||
const dataPost = async (data: DataLink[]) => {
|
||||
}
|
||||
|
||||
/**
|
||||
* เพิ่มข้อมูล
|
||||
* @param data ข้อมูลราชการ
|
||||
*/
|
||||
async function dataPost(data: DataLink[]) {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.cmsGoverment, data)
|
||||
|
|
@ -381,8 +406,10 @@ const dataPost = async (data: DataLink[]) => {
|
|||
dialog.value = false;
|
||||
await fetchData();
|
||||
});
|
||||
};
|
||||
const fetchData = async () => {
|
||||
}
|
||||
|
||||
/** ดึงข้อมูลรายละเอียด */
|
||||
async function fetchData() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.cms)
|
||||
|
|
@ -443,9 +470,10 @@ const fetchData = async () => {
|
|||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const takeLogo = async () => {
|
||||
/** เพิ่มโลโก้ */
|
||||
async function takeLogo() {
|
||||
showLoader();
|
||||
const formData = new FormData();
|
||||
formData.append("FileData", imageFileLogo.value);
|
||||
|
|
@ -460,9 +488,10 @@ const takeLogo = async () => {
|
|||
imageUrlLogo.value = null;
|
||||
await fetchData();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const takeBanner = async () => {
|
||||
/** เพิ่ม banner */
|
||||
async function takeBanner() {
|
||||
showLoader();
|
||||
const formData = new FormData();
|
||||
formData.append("FileData", imageFile.value);
|
||||
|
|
@ -477,9 +506,10 @@ const takeBanner = async () => {
|
|||
imageUrl.value = null;
|
||||
await fetchData();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const sendDataDetail = async () => {
|
||||
/** body รายละเอียด */
|
||||
async function sendDataDetail() {
|
||||
webform.value?.validate().then(async (result: boolean) => {
|
||||
if (result) {
|
||||
const data = {
|
||||
|
|
@ -501,9 +531,10 @@ const sendDataDetail = async () => {
|
|||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const sendDataAbout = async () => {
|
||||
/** body ข้อมูลเกี่ยวกับเรา */
|
||||
async function sendDataAbout() {
|
||||
myform.value?.validate().then(async (result: boolean) => {
|
||||
if (result) {
|
||||
const data = {
|
||||
|
|
@ -528,9 +559,10 @@ const sendDataAbout = async () => {
|
|||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const fetchProvince = async () => {
|
||||
/** ดึงข้อมูลก่อนหน้า dialog */
|
||||
async function fetchProvince() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.province)
|
||||
|
|
@ -548,9 +580,13 @@ const fetchProvince = async () => {
|
|||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const fetchDistrict = async (id: string | null) => {
|
||||
/**
|
||||
* ดึงข้อมูล อำเภอ
|
||||
* @param id id อำเภอ
|
||||
*/
|
||||
async function fetchDistrict(id: string | null) {
|
||||
if (id !== null && id != "") {
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -570,9 +606,13 @@ const fetchDistrict = async (id: string | null) => {
|
|||
hideLoader();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const fetchSubDistrict = async (id: string | null) => {
|
||||
/**
|
||||
* ดึงข้อมูล ตำบล
|
||||
* @param id id จังหวัด
|
||||
*/
|
||||
async function fetchSubDistrict(id: string | null) {
|
||||
if (id !== null && id != "") {
|
||||
showLoader();
|
||||
await http
|
||||
|
|
@ -596,67 +636,77 @@ const fetchSubDistrict = async (id: string | null) => {
|
|||
hideLoader();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const selectProvince = (e: string) => {
|
||||
/**
|
||||
* ฟังชั่นเลือกจังหวัด
|
||||
* @param e id จังหวัด
|
||||
*/
|
||||
function selectProvince(e: string) {
|
||||
address.value.districtId = "";
|
||||
address.value.subdistrictId = "";
|
||||
address.value.code = "";
|
||||
myform.value?.resetValidation();
|
||||
fetchDistrict(e);
|
||||
};
|
||||
}
|
||||
|
||||
const selectDistrict = (e: string) => {
|
||||
/** เลือกอำเภอ */
|
||||
function selectDistrict(e: string) {
|
||||
address.value.subdistrictId = "";
|
||||
address.value.code = "";
|
||||
|
||||
myform.value?.resetValidation();
|
||||
fetchSubDistrict(e);
|
||||
};
|
||||
}
|
||||
|
||||
const selectSubDistrict = (e: string) => {
|
||||
/** เลือกตำบล */
|
||||
function selectSubDistrict(e: string) {
|
||||
const findcode = subdistrictOptions.value.filter((r: any) => r.id == e);
|
||||
const namecode = findcode.length > 0 ? findcode[0].zipCode : "";
|
||||
address.value.code = namecode;
|
||||
};
|
||||
}
|
||||
|
||||
const clickImageLogo = () => {
|
||||
function clickImageLogo() {
|
||||
if (imageFileLogo.value !== null) {
|
||||
takeLogo();
|
||||
} else {
|
||||
inputImageLogo.value.click();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const clickImage = () => {
|
||||
/** อัปโหลดแบนเนอร์/โลโก้ */
|
||||
function clickImage() {
|
||||
if (imageFile.value !== null) {
|
||||
takeBanner();
|
||||
} else {
|
||||
inputImage.value.click();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const checkLogoExits = ref<boolean>(false);
|
||||
const checkFileLogo = async () => {
|
||||
/** เช็คโลโก้ */
|
||||
async function checkFileLogo() {
|
||||
try {
|
||||
const response = await fetch(imageUrlLogo.value, { method: "GET" });
|
||||
checkLogoExits.value = response.ok;
|
||||
} catch (error) {
|
||||
checkLogoExits.value = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const checkBannerExits = ref<boolean>(false);
|
||||
const checkFileBanner = async () => {
|
||||
/** เช็คแบนเนอร์ */
|
||||
async function checkFileBanner() {
|
||||
try {
|
||||
const response = await fetch(imageUrl.value, { method: "GET" });
|
||||
checkBannerExits.value = response.ok;
|
||||
} catch (error) {
|
||||
checkBannerExits.value = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const uploadImageLogo = (e: any) => {
|
||||
/** อัปโหลดโลโก้ */
|
||||
function uploadImageLogo(e: any) {
|
||||
let input = e.target.files;
|
||||
if (input.length > 0) {
|
||||
const formData = new FormData();
|
||||
|
|
@ -667,9 +717,10 @@ const uploadImageLogo = (e: any) => {
|
|||
return;
|
||||
}
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
const uploadImage = (e: any) => {
|
||||
/** อัปโหลดแบนเนอร์*/
|
||||
function uploadImage(e: any) {
|
||||
let input = e.target.files;
|
||||
if (input.length > 0) {
|
||||
const formData = new FormData();
|
||||
|
|
@ -680,14 +731,21 @@ const uploadImage = (e: any) => {
|
|||
return;
|
||||
}
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
const getClass = (val: boolean) => {
|
||||
function getClass(val: boolean) {
|
||||
return {
|
||||
"full-width inputgreen cursor-pointer": val,
|
||||
"full-width cursor-pointer": !val,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchData();
|
||||
await fetchProvince();
|
||||
await fetchDistrict(address.value.provinceId);
|
||||
await fetchSubDistrict(address.value.districtId);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue