ปรับเเก้
This commit is contained in:
parent
d2c6837a86
commit
46f82b78fc
18 changed files with 446 additions and 190 deletions
|
|
@ -1,12 +1,12 @@
|
|||
<script setup lang="ts">
|
||||
import Form from "@/modules/11_discipline/components/6_BasicInformation/Director/Form.vue";
|
||||
import Form from "@/modules/12_evaluatePersonal/components/Director/Form.vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useQuasar } from "quasar";
|
||||
import type { FormDataPost } from "@/modules/11_discipline/interface/request/director";
|
||||
|
||||
// import type { FormDataPost } from "@/modules/11_discipline/interface/request/director";
|
||||
import type { DataForm } from "@/modules/12_evaluatePersonal/interface/index/director";
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const { messageError, showLoader, hideLoader, dialogConfirm, success } = mixin;
|
||||
|
|
@ -16,21 +16,22 @@ const router = useRouter();
|
|||
* บันทึกข้อมูลที่เเก้ไข
|
||||
* @param id ระบุ บุคคล
|
||||
*/
|
||||
function onSubmit(formData:FormDataPost) {
|
||||
function onSubmit(formData:DataForm) {
|
||||
dialogConfirm($q, () => addData(formData));
|
||||
}
|
||||
|
||||
function addData(formData: FormDataPost) {
|
||||
function addData(formData: DataForm) {
|
||||
console.log(formData)
|
||||
showLoader();
|
||||
http
|
||||
.post(config.API.director(), {
|
||||
personalId:formData.personalId ?? '',
|
||||
prefix: formData.prefix,
|
||||
firstName: formData.firstname,
|
||||
lastName: formData.lastname,
|
||||
position: formData.position,
|
||||
email: formData.email,
|
||||
phone: formData.phone,
|
||||
.post(config.API.evaluateDirectorMain(), {
|
||||
// personalId:formData.personalId ?? '',
|
||||
Prefix: formData.prefix,
|
||||
FirstName: formData.firstname,
|
||||
LastName: formData.lastname,
|
||||
Position: formData.position,
|
||||
Email: formData.email,
|
||||
Phone: formData.phone,
|
||||
})
|
||||
.then((res) => {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
|
|
@ -39,7 +40,7 @@ function addData(formData: FormDataPost) {
|
|||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
router.push(`/discipline/director`);
|
||||
router.push(`/evaluate/director`);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, reactive } from "vue";
|
||||
import Form from "@/modules/11_discipline/components/6_BasicInformation/Director/Form.vue";
|
||||
import Form from "@/modules/12_evaluatePersonal/components/Director/Form.vue";
|
||||
import type { FormData } from "@/modules/11_discipline/interface/request/director";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
|
|
@ -41,16 +41,17 @@ const data = reactive<FormData>({
|
|||
const fetchData = async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.directorbyId(personalId.value))
|
||||
// .get(config.API.evaluateDirectorById(personalId.value))
|
||||
.get(config.API.evaluateDirectorById('0a185476-c764-42d7-a6f9-2c3824a401ed'))
|
||||
.then((res) => {
|
||||
const dataApi = res.data.result;
|
||||
personalId.value = dataApi.id;
|
||||
data.prefix = dataApi.prefix;
|
||||
data.firstname = dataApi.firstName;
|
||||
data.lastname = dataApi.lastName;
|
||||
data.position = dataApi.position;
|
||||
data.phone = dataApi.phone;
|
||||
data.email = dataApi.email;
|
||||
personalId.value = dataApi.Id;
|
||||
data.prefix = dataApi.Prefix;
|
||||
data.firstname = dataApi.FirstName;
|
||||
data.lastname = dataApi.LastName;
|
||||
data.position = dataApi.Position;
|
||||
data.phone = dataApi.Phone;
|
||||
data.email = dataApi.Email;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
|
|
@ -71,13 +72,14 @@ function onSubmit(formData: FormData) {
|
|||
function putData(formData: FormData) {
|
||||
showLoader();
|
||||
http
|
||||
.put(config.API.directorbyId(personalId.value), {
|
||||
prefix: formData.prefix,
|
||||
firstName: formData.firstname,
|
||||
lastName: formData.lastname,
|
||||
position: formData.position,
|
||||
email: formData.email,
|
||||
phone: formData.phone,
|
||||
// .put(config.API.evaluateDirectorById(personalId.value), {
|
||||
.put(config.API.evaluateDirectorById('0a185476-c764-42d7-a6f9-2c3824a401ed'), {
|
||||
Prefix: formData.prefix,
|
||||
FirstName: formData.firstname,
|
||||
LastName: formData.lastname,
|
||||
Position: formData.position,
|
||||
Email: formData.email,
|
||||
Phone: formData.phone,
|
||||
})
|
||||
.then((res) => {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
|
|
@ -86,7 +88,7 @@ function putData(formData: FormData) {
|
|||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
router.push(`/discipline/director`);
|
||||
router.push(`/evaluate/director`);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -83,9 +83,11 @@ function addEmployee() {
|
|||
keyword: idCard.value,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
const dataApi = res.data.result;
|
||||
if (dataApi.length > 0) {
|
||||
const dataList = dataApi[0];
|
||||
formData.personalId = dataList.personId;
|
||||
formData.prefix = dataList.prefix;
|
||||
formData.firstname = dataList.firstName;
|
||||
formData.lastname = dataList.lastName;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ import type { QTableProps } from "quasar";
|
|||
import router from "@/router";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useDisciplineDirectorDataStore } from "@/modules/11_discipline/store/DirectorStore";
|
||||
import { useEvaluateDirectorDataStore } from "@/modules/12_evaluatePersonal/store/DirectorStore";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
const $q = useQuasar();
|
||||
const dataStore = useDisciplineDirectorDataStore();
|
||||
const dataStore = useEvaluateDirectorDataStore();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
messageError,
|
||||
|
|
@ -34,37 +34,126 @@ const pagination = ref({
|
|||
rowsPerPage: rowsPerPage.value,
|
||||
});
|
||||
|
||||
watch(() => currentPage.value,() => {
|
||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
||||
getList();
|
||||
});
|
||||
watch(
|
||||
() => currentPage.value,
|
||||
() => {
|
||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
watch(()=>pagination.value.rowsPerPage,()=>{
|
||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
||||
currentPage.value = 1
|
||||
getList();
|
||||
})
|
||||
async function getList() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.directorList(
|
||||
currentPage.value,
|
||||
rowsPerPage.value,
|
||||
filterKeyword.value
|
||||
)
|
||||
)
|
||||
.then((res) => {
|
||||
maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value);
|
||||
const data = res.data.result.data
|
||||
dataStore.fetchData(data);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
watch(
|
||||
() => pagination.value.rowsPerPage,
|
||||
() => {
|
||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
||||
currentPage.value = 1;
|
||||
getList();
|
||||
}
|
||||
);
|
||||
|
||||
function getList() {
|
||||
// showLoader();
|
||||
// http
|
||||
// .get(
|
||||
// config.API.evaluateDirectorMain(
|
||||
// currentPage.value,
|
||||
// rowsPerPage.value,
|
||||
// filterKeyword.value
|
||||
// )
|
||||
// )
|
||||
// .then((res) => {
|
||||
|
||||
// maxPage.value = Math.ceil(res.data.result.total / rowsPerPage.value);
|
||||
// const data = res.data.result.data
|
||||
// dataStore.fetchData(data);
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
|
||||
// {
|
||||
// "Id": "0a185476-c764-42d7-a6f9-2c3824a401ed",
|
||||
// "CreatedAt": "2023-12-19T02:40:59.898Z",
|
||||
// "CreatedUserId": "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
// "LastUpdatedAt": "2023-12-19T02:40:59.898Z",
|
||||
// "LastUpdateUserId": "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
// "CreatedFullName": "สาวิตรี ศรีสมัย",
|
||||
// "LastUpdateFullName": "สาวิตรี ศรีสมัย",
|
||||
// "Prefix": "นาย",
|
||||
// "FirstName": "เทสดี",
|
||||
// "LastName": "ลองแอด",
|
||||
// "Phone": "0999998767",
|
||||
// "Email": "email@gmail.com",
|
||||
// "Position": "frontEnd"
|
||||
// }
|
||||
|
||||
const data = [
|
||||
{
|
||||
Id: "xx1",
|
||||
CreatedAt: "2023-12-19T02:40:59.898Z",
|
||||
CreatedUserId: "cc1",
|
||||
LastUpdatedAt: "2023-12-19T02:40:59.898Z",
|
||||
LastUpdateUserId: "ll1",
|
||||
CreatedFullName: "สาวิตรี ศรีสมัย",
|
||||
LastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
Prefix: "นาย",
|
||||
FirstName: "เทสดี",
|
||||
LastName: "ลองแอด",
|
||||
Phone: "0999998767",
|
||||
Email: "email@gmail.com",
|
||||
Position: "frontEnd",
|
||||
},
|
||||
{
|
||||
Id: "xx2",
|
||||
CreatedAt: "2023-12-19T02:40:59.898Z",
|
||||
CreatedUserId: "cc2",
|
||||
LastUpdatedAt: "2023-12-19T02:40:59.898Z",
|
||||
LastUpdateUserId: "ll2",
|
||||
CreatedFullName: "สาวิตรี ศรีสมัย",
|
||||
LastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
Prefix: "นาย",
|
||||
FirstName: "เทสดี",
|
||||
LastName: "ลองแอด",
|
||||
Phone: "0999998767",
|
||||
Email: "email@gmail.com",
|
||||
Position: "frontEnd",
|
||||
},
|
||||
{
|
||||
Id: "xx3",
|
||||
CreatedAt: "2023-12-19T02:40:59.898Z",
|
||||
CreatedUserId: "cc3",
|
||||
LastUpdatedAt: "2023-12-19T02:40:59.898Z",
|
||||
LastUpdateUserId: "ll3",
|
||||
CreatedFullName: "สาวิตรี ศรีสมัย",
|
||||
LastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
Prefix: "นาย",
|
||||
FirstName: "เทสดี",
|
||||
LastName: "ลองแอด",
|
||||
Phone: "0999998767",
|
||||
Email: "email@gmail.com",
|
||||
Position: "frontEnd",
|
||||
},
|
||||
{
|
||||
Id: "xx4",
|
||||
CreatedAt: "2023-12-19T02:40:59.898Z",
|
||||
CreatedUserId: "cc5",
|
||||
LastUpdatedAt: "2023-12-19T02:40:59.898Z",
|
||||
LastUpdateUserId: "ll5",
|
||||
CreatedFullName: "สาวิตรี ศรีสมัย",
|
||||
LastUpdateFullName: "สาวิตรี ศรีสมัย",
|
||||
Prefix: "นาย",
|
||||
FirstName: "เทสดี",
|
||||
LastName: "ลองแอด",
|
||||
Phone: "0999998767",
|
||||
Email: "email@gmail.com",
|
||||
Position: "frontEnd",
|
||||
},
|
||||
|
||||
];
|
||||
dataStore.fetchData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -82,7 +171,7 @@ function clickDelete(id: string) {
|
|||
async function deleteData(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.directorbyId(id))
|
||||
.delete(config.API.evaluateDirectorById(id))
|
||||
.then((res) => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
|
|
@ -94,19 +183,12 @@ async function deleteData(id: string) {
|
|||
});
|
||||
}
|
||||
|
||||
/**เมื่อเริ่มโหลดหน้า
|
||||
* ส่งข้อมูลจำลองไปยัง store
|
||||
*/
|
||||
onMounted(() => {
|
||||
getList();
|
||||
// get ข้อมูลแล้วโยนใส่ store
|
||||
});
|
||||
|
||||
/**
|
||||
* ค้นหาในตาราง
|
||||
*/
|
||||
const filterKeyword = ref<string>("");
|
||||
const filterRef = ref<HTMLInputElement | null>(null);
|
||||
|
||||
function resetFilter() {
|
||||
filterKeyword.value = "";
|
||||
if (filterRef.value) {
|
||||
|
|
@ -114,10 +196,14 @@ function resetFilter() {
|
|||
}
|
||||
}
|
||||
|
||||
function filterFn(){
|
||||
getList()
|
||||
console.log('enter',filterKeyword.value)
|
||||
function filterFn() {
|
||||
getList();
|
||||
console.log("enter", filterKeyword.value);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue