ต่อ api(รอต่อ บางส่วน)
This commit is contained in:
parent
18e1e0d2bd
commit
7399f967d0
15 changed files with 506 additions and 155 deletions
18
src/api/11_discipline/api.discipline.ts
Normal file
18
src/api/11_discipline/api.discipline.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import env from "../index";
|
||||||
|
const discipline = `${env.API_URI}/discipline`;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
directorList:(page:number,pageSize:number,keyword:string) => `${discipline}/director?page=${page}&pageSize=${pageSize}&keyword=${keyword}`,
|
||||||
|
director:() => `${discipline}/director`,
|
||||||
|
directorbyId:(id:string) => `${discipline}/director/${id}`,
|
||||||
|
|
||||||
|
/**ช่องทางการร้องเรียน */
|
||||||
|
complaintChannel:() => `${discipline}/complaint_Channel`,
|
||||||
|
|
||||||
|
/**ลบ ช่องทางการร้องเรียน
|
||||||
|
* @param id type
|
||||||
|
*/
|
||||||
|
complaintChannelbyId:(id:string) => `${discipline}/complaint_Channel/${id}`
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -46,6 +46,8 @@ import reports from "./api/reports/api.report";
|
||||||
/** API ระบบลงเวลา */
|
/** API ระบบลงเวลา */
|
||||||
import leave from "./api/09_leave/api.leave";
|
import leave from "./api/09_leave/api.leave";
|
||||||
|
|
||||||
|
/** API วินัย */
|
||||||
|
import discipline from './api/11_discipline/api.discipline'
|
||||||
// environment variables
|
// environment variables
|
||||||
export const compettitivePanel = import.meta.env.VITE_COMPETITIVE_EXAM_PANEL;
|
export const compettitivePanel = import.meta.env.VITE_COMPETITIVE_EXAM_PANEL;
|
||||||
export const qualifyDisableExamPanel = import.meta.env
|
export const qualifyDisableExamPanel = import.meta.env
|
||||||
|
|
@ -92,6 +94,9 @@ const API = {
|
||||||
|
|
||||||
/**leave */
|
/**leave */
|
||||||
...leave,
|
...leave,
|
||||||
|
|
||||||
|
/**discipline */
|
||||||
|
...discipline,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,17 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { useQuasar, QForm } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import { useRouter, useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
import Form from '@/modules/11_discipline/components/6_BasicInformation/Channel/Form.vue'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* รวมตัวแปร
|
* รวมตัวแปร
|
||||||
*/
|
*/
|
||||||
|
const $q = useQuasar()
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const {
|
const {
|
||||||
date2Thai,
|
date2Thai,
|
||||||
|
|
@ -21,9 +25,9 @@ const {
|
||||||
} = mixin;
|
} = mixin;
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const myForm = ref<QForm | null>(null); //form data input
|
//form data input
|
||||||
const edit = ref<boolean>(false);
|
const edit = ref<boolean>(false);
|
||||||
const channel = ref<string>("");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* เรียกข้อมูลจากรายการ
|
* เรียกข้อมูลจากรายการ
|
||||||
|
|
@ -38,19 +42,27 @@ const fetchData = async () => {};
|
||||||
const deleteData = async (id: string) => {};
|
const deleteData = async (id: string) => {};
|
||||||
|
|
||||||
/* บันทึกข้อมูล**/
|
/* บันทึกข้อมูล**/
|
||||||
const SaveData = async () => {};
|
function onSubmit(channelReturn:string){
|
||||||
const checkSave = () => {};
|
dialogConfirm($q,()=>saveData(channelReturn))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
function saveData(channelReturn:string){
|
||||||
* เพิ่มข้อมูล
|
console.log(channelReturn)
|
||||||
*/
|
showLoader()
|
||||||
const addData = async () => {};
|
http
|
||||||
|
.post(config.API.complaintChannel(),{
|
||||||
/**
|
name:channelReturn
|
||||||
* แก้ไขข้อมูล
|
})
|
||||||
* @param id ช่องทาง
|
.then((res) => {
|
||||||
*/
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
const editData = async (id: string) => {};
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
router.push(`/discipline/channel`);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ย้อนกลับหน้ารายการ
|
* ย้อนกลับหน้ารายการ
|
||||||
|
|
@ -74,33 +86,6 @@ const clickBack = () => {
|
||||||
/>
|
/>
|
||||||
{{ edit ? "ช่องทางการร้องเรียน" : "เพิ่มช่องทางการร้องเรียน" }}
|
{{ edit ? "ช่องทางการร้องเรียน" : "เพิ่มช่องทางการร้องเรียน" }}
|
||||||
</div>
|
</div>
|
||||||
<q-form ref="myForm">
|
<Form :on-submit="onSubmit" />
|
||||||
<div class="col-12">
|
|
||||||
<q-card bordered>
|
|
||||||
<div class="col-12 row q-col-gutter-md q-pa-md">
|
|
||||||
<div class="col-xs-12 col-sm-12 row">
|
|
||||||
<q-separator />
|
|
||||||
<div class="col-12 row q-pa-sm q-col-gutter-sm">
|
|
||||||
<q-input
|
|
||||||
class="col-12"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
v-model="channel"
|
|
||||||
for="channel"
|
|
||||||
hide-bottom-space
|
|
||||||
label="กรอกชื่อช่องทาง"
|
|
||||||
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อช่องทาง'}`]"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<q-separator />
|
|
||||||
<div class="row col-12 q-pa-sm">
|
|
||||||
<q-space />
|
|
||||||
<q-btn label="บันทึก" color="public" @click="checkSave"> </q-btn>
|
|
||||||
</div>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
</q-form>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted, reactive } from "vue";
|
||||||
|
import Form from "@/modules/11_discipline/components/6_BasicInformation/Channel/Form.vue";
|
||||||
|
import type { FormData } from "@/modules/11_discipline/interface/request/director";
|
||||||
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
|
import router from "@/router";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const typeId = ref<string>(route.params.id.toString());
|
||||||
|
const $q = useQuasar();
|
||||||
|
const mixin = useCounterMixin();
|
||||||
|
const { messageError, showLoader, hideLoader, dialogConfirm, success } = mixin;
|
||||||
|
|
||||||
|
/**เมื่อเริ่มโหลดหน้า
|
||||||
|
* เรียกใช้งาน fetchData เพื่อดึงข้อมูล
|
||||||
|
*/
|
||||||
|
onMounted(() => {
|
||||||
|
fetchData();
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get ข้อมูลเก่ากรณีแก้ไขข้อมูล
|
||||||
|
*/
|
||||||
|
const data = reactive<FormData>({
|
||||||
|
personalId:"",
|
||||||
|
prefix: "",
|
||||||
|
firstname: "",
|
||||||
|
lastname: "",
|
||||||
|
position: "",
|
||||||
|
phone: "",
|
||||||
|
email: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ดึงค่าจาก api
|
||||||
|
*/
|
||||||
|
const fetchData = async () => {
|
||||||
|
data.prefix = "นาง";
|
||||||
|
data.firstname = "เกสินี";
|
||||||
|
data.lastname = "เจียรสุมัย";
|
||||||
|
data.position = "ครู";
|
||||||
|
data.phone = "0800808080";
|
||||||
|
data.email = "e@email.com";
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* บันทึกข้อมูลที่เเก้ไข
|
||||||
|
* @param id ระบุ บุคคล
|
||||||
|
*/
|
||||||
|
function onSubmit(type:string) {
|
||||||
|
dialogConfirm($q, () => putData(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
function putData(type: string) {
|
||||||
|
showLoader();
|
||||||
|
http
|
||||||
|
.put(config.API.complaintChannelbyId(typeId.value), {
|
||||||
|
name:type
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
router.push(`/discipline/channel`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div class="col-xs-12 col-sm-12 col-md-11">
|
||||||
|
<div class="toptitle col-12 row items-center">
|
||||||
|
<q-btn
|
||||||
|
icon="mdi-arrow-left"
|
||||||
|
unelevated
|
||||||
|
round
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
color="primary"
|
||||||
|
class="q-mr-sm"
|
||||||
|
@click="router.push(`/discipline/channel`)"
|
||||||
|
/>
|
||||||
|
แก้ไขช่องทางการร้องเรียน
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Form :on-submit="onSubmit"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch } from "vue";
|
||||||
|
const channel = ref<string>("");
|
||||||
|
const channelRef = ref<any>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* รับ props มาจาก page หลัก
|
||||||
|
*/
|
||||||
|
const props = defineProps({
|
||||||
|
data: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
onSubmit: {
|
||||||
|
type: Function,
|
||||||
|
default: () => "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* เช็คข้อมูลจาก props
|
||||||
|
* เมื่อมีข้อมูล
|
||||||
|
* เก็บข้อมูลลง formData
|
||||||
|
*/
|
||||||
|
watch(props.data, async () => {});
|
||||||
|
|
||||||
|
/** ฟังชั่นตรวจสอบความถูกต้องก่อน บันทึก */
|
||||||
|
function save() {
|
||||||
|
channelRef.value.validate().then(async (result: boolean) => {
|
||||||
|
console.log("1");
|
||||||
|
if (result) {
|
||||||
|
if (channel.value) {
|
||||||
|
props.onSubmit(channel.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<q-form ref="channelRef">
|
||||||
|
<div class="col-12">
|
||||||
|
<q-card bordered>
|
||||||
|
<div class="col-12 row q-col-gutter-md q-pa-md">
|
||||||
|
<div class="col-xs-12 col-sm-12 row">
|
||||||
|
<q-separator />
|
||||||
|
<div class="col-12 row q-pa-sm q-col-gutter-sm">
|
||||||
|
<q-input
|
||||||
|
class="col-12"
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
v-model="channel"
|
||||||
|
for="channel"
|
||||||
|
hide-bottom-space
|
||||||
|
label="กรอกชื่อช่องทาง"
|
||||||
|
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อช่องทาง'}`]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<q-separator />
|
||||||
|
<div class="row col-12 q-pa-sm">
|
||||||
|
<q-space />
|
||||||
|
<q-btn
|
||||||
|
for="ButtonOnSubmit"
|
||||||
|
id="formSubmit"
|
||||||
|
label="บันทึก"
|
||||||
|
color="public"
|
||||||
|
@click="save"
|
||||||
|
>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</q-form>
|
||||||
|
</template>
|
||||||
|
|
@ -10,7 +10,7 @@ import http from "@/plugins/http";
|
||||||
|
|
||||||
const dataStore = useDisciplineChannelDataStore();
|
const dataStore = useDisciplineChannelDataStore();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { dialogRemove } = mixin;
|
const { dialogRemove, showLoader, messageError, hideLoader, success } = mixin;
|
||||||
const $q = useQuasar(); //ใช้ noti quasar
|
const $q = useQuasar(); //ใช้ noti quasar
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,41 +42,53 @@ const clickAdd = () => {
|
||||||
router.push(`/discipline/channel/add`);
|
router.push(`/discipline/channel/add`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** get data */
|
||||||
|
async function getComplaintChanal() {
|
||||||
|
showLoader();
|
||||||
|
await http
|
||||||
|
.get(config.API.complaintChannel())
|
||||||
|
.then((res) => {
|
||||||
|
const data = res.data.result.data;
|
||||||
|
dataStore.fetchData(data);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ลบข้อมู,
|
* ลบข้อมูล
|
||||||
* @param id ไอดีของข้อมูล
|
* @param id ไอดีของข้อมูล
|
||||||
*/
|
*/
|
||||||
const clickDelete = (id: string) => {
|
function clickDelete(id: string) {
|
||||||
dialogRemove(
|
dialogRemove($q, async () => deleteData(id), `ลบข้อมูล`);
|
||||||
$q,
|
}
|
||||||
async () => {
|
|
||||||
// await deleteData(id);
|
|
||||||
// await getData();
|
|
||||||
},
|
|
||||||
`ลบข้อมูล`
|
|
||||||
// `ลบข้อมูลของ ${name}`
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**เมื่อเริ่มโหลดหน้า
|
/**
|
||||||
* ส่งข้อมูลจำลองไปยัง store
|
* ลบข้อมูล
|
||||||
|
* @param id type
|
||||||
*/
|
*/
|
||||||
|
async function deleteData(id: string) {
|
||||||
|
showLoader();
|
||||||
|
await http
|
||||||
|
.delete(config.API.complaintChannelbyId(id))
|
||||||
|
.then((res) => {
|
||||||
|
success($q, "ลบข้อมูลสำเร็จ");
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
await getComplaintChanal();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**เมื่อเริ่มโหลดหน้า เรียกใช้ฟังชั่น*/
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// get ข้อมูลแล้วโยนใส่ store
|
getComplaintChanal();
|
||||||
dataStore.fetchData([
|
|
||||||
{
|
|
||||||
subject: " จดหมาย",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
subject: " อีเมล์",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
subject: " โทรศัพท์",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
subject: " บอกเล่า",
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -157,11 +169,18 @@ onMounted(() => {
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body="props">
|
<template v-slot:body="props">
|
||||||
<q-tr :props="props" class="cursor-pointer">
|
<q-tr :props="props" class="cursor-pointer">
|
||||||
<q-td key="no" :props="props">
|
<q-td
|
||||||
{{ props.rowIndex + 1 }}
|
v-for="col in props.cols"
|
||||||
</q-td>
|
:key="col.name"
|
||||||
<q-td key="subject" :props="props">
|
:props="props"
|
||||||
{{ props.row.subject }}
|
@click="$router.push(`/discipline/channel/${props.row.id}`)"
|
||||||
|
>
|
||||||
|
<div v-if="col.name === 'no'">
|
||||||
|
{{ props.rowIndex + 1 }}
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
{{ col.value}}
|
||||||
|
</div>
|
||||||
</q-td>
|
</q-td>
|
||||||
<q-td>
|
<q-td>
|
||||||
<q-btn
|
<q-btn
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,46 @@
|
||||||
import Form from "@/modules/11_discipline/components/6_BasicInformation/Director/Form.vue";
|
import Form from "@/modules/11_discipline/components/6_BasicInformation/Director/Form.vue";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
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";
|
||||||
|
|
||||||
|
const $q = useQuasar();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { messageError, showLoader, hideLoader, dialogConfirm, success } = mixin;
|
const { messageError, showLoader, hideLoader, dialogConfirm, success } = mixin;
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
/** บันทึกข้อมูลเเละ route กลับหน้าหลัก */
|
/**
|
||||||
const onSubmit = async () => {
|
* บันทึกข้อมูลที่เเก้ไข
|
||||||
// post
|
* @param id ระบุ บุคคล
|
||||||
router.push(`/discipline/director`);
|
*/
|
||||||
};
|
function onSubmit(formData:FormDataPost) {
|
||||||
|
dialogConfirm($q, () => addData(formData));
|
||||||
|
}
|
||||||
|
|
||||||
|
function addData(formData: FormDataPost) {
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
router.push(`/discipline/director`);
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="col-xs-12 col-sm-12 col-md-11">
|
<div class="col-xs-12 col-sm-12 col-md-11">
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,17 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, reactive } from "vue";
|
import { ref, onMounted, reactive } from "vue";
|
||||||
import Form from "@/modules/11_discipline/components/6_BasicInformation/Director/Form.vue";
|
import Form from "@/modules/11_discipline/components/6_BasicInformation/Director/Form.vue";
|
||||||
import type { FormData } from "@/modules/11_discipline/interface/request/director";
|
import type { FormData } from "@/modules/11_discipline/interface/request/director";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
|
import router from "@/router";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const personalId = ref<string>(route.params.id.toString());
|
||||||
|
const $q = useQuasar();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { messageError, showLoader, hideLoader, dialogConfirm, success } = mixin;
|
const { messageError, showLoader, hideLoader, dialogConfirm, success } = mixin;
|
||||||
|
|
||||||
|
|
@ -18,12 +26,12 @@ onMounted(() => {
|
||||||
* get ข้อมูลเก่ากรณีแก้ไขข้อมูล
|
* get ข้อมูลเก่ากรณีแก้ไขข้อมูล
|
||||||
*/
|
*/
|
||||||
const data = reactive<FormData>({
|
const data = reactive<FormData>({
|
||||||
|
personalId:"",
|
||||||
prefix: "",
|
prefix: "",
|
||||||
firstname: "",
|
firstname: "",
|
||||||
lastname: "",
|
lastname: "",
|
||||||
position: "",
|
position: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
responsibilities: "",
|
|
||||||
email: "",
|
email: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -36,7 +44,6 @@ const fetchData = async () => {
|
||||||
data.lastname = "เจียรสุมัย";
|
data.lastname = "เจียรสุมัย";
|
||||||
data.position = "ครู";
|
data.position = "ครู";
|
||||||
data.phone = "0800808080";
|
data.phone = "0800808080";
|
||||||
data.responsibilities = "ประธาน";
|
|
||||||
data.email = "e@email.com";
|
data.email = "e@email.com";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -44,9 +51,31 @@ const fetchData = async () => {
|
||||||
* บันทึกข้อมูลที่เเก้ไข
|
* บันทึกข้อมูลที่เเก้ไข
|
||||||
* @param id ระบุ บุคคล
|
* @param id ระบุ บุคคล
|
||||||
*/
|
*/
|
||||||
const onSubmit = async (id: string) => {
|
function onSubmit(formData:FormData) {
|
||||||
// put
|
dialogConfirm($q, () => putData(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,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
router.push(`/discipline/director`);
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="col-xs-12 col-sm-12 col-md-11">
|
<div class="col-xs-12 col-sm-12 col-md-11">
|
||||||
|
|
@ -59,11 +88,11 @@ const onSubmit = async (id: string) => {
|
||||||
flat
|
flat
|
||||||
color="primary"
|
color="primary"
|
||||||
class="q-mr-sm"
|
class="q-mr-sm"
|
||||||
@click="$router.push(`/discipline/director`)"
|
@click="router.push(`/discipline/director`)"
|
||||||
/>
|
/>
|
||||||
แก้ไขรายชื่อกรรมการ
|
แก้ไขรายชื่อกรรมการ
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form @onSubmit="onSubmit" :data="data" />
|
<Form :on-submit="onSubmit" :data="data"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits([
|
||||||
|
"formDataReturn"
|
||||||
|
])
|
||||||
/**
|
/**
|
||||||
* ข้อมูลรหัสบัตรประชาชน
|
* ข้อมูลรหัสบัตรประชาชน
|
||||||
*/
|
*/
|
||||||
|
|
@ -30,13 +33,13 @@ const idCardRef = ref<any>(null);
|
||||||
* ข้อมูลทั้งก้อน form
|
* ข้อมูลทั้งก้อน form
|
||||||
*/
|
*/
|
||||||
const formData = reactive<FormData>({
|
const formData = reactive<FormData>({
|
||||||
|
personalId:"",
|
||||||
prefix: "",
|
prefix: "",
|
||||||
firstname: "",
|
firstname: "",
|
||||||
lastname: "",
|
lastname: "",
|
||||||
position: "",
|
position: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
email: "",
|
email: ""
|
||||||
responsibilities: "",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -94,7 +97,7 @@ function onValidate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasError.every((result) => result === true)) {
|
if (hasError.every((result) => result === true)) {
|
||||||
props.onSubmit();
|
props.onSubmit(formData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, useAttrs, onMounted } from "vue";
|
import { ref, useAttrs, onMounted, watch } from "vue";
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
@ -11,28 +11,95 @@ import http from "@/plugins/http";
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const dataStore = useDisciplineDirectorDataStore();
|
const dataStore = useDisciplineDirectorDataStore();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { messageError, showLoader, hideLoader, dialogConfirm, dialogRemove } =
|
const {
|
||||||
mixin;
|
messageError,
|
||||||
|
showLoader,
|
||||||
|
hideLoader,
|
||||||
|
dialogConfirm,
|
||||||
|
dialogRemove,
|
||||||
|
success,
|
||||||
|
} = mixin;
|
||||||
|
|
||||||
|
const currentPage = ref<number>(1);
|
||||||
|
const maxPage = ref<number>(1);
|
||||||
|
const page = ref<number>(1);
|
||||||
|
const rowsPerPage = ref<number>(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*pagination ของตาราง
|
||||||
|
*/
|
||||||
|
const pagination = ref({
|
||||||
|
descending: false,
|
||||||
|
page: page.value,
|
||||||
|
rowsPerPage: rowsPerPage.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ลบข้อมูล
|
||||||
|
* @param id ไอดีของข้อมูล
|
||||||
|
*/
|
||||||
|
function clickDelete(id: string) {
|
||||||
|
dialogRemove($q, async () => deleteData(id), `ลบข้อมูล`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ลบข้อมูล
|
||||||
|
* @param id type
|
||||||
|
*/
|
||||||
|
async function deleteData(id: string) {
|
||||||
|
showLoader();
|
||||||
|
await http
|
||||||
|
.delete(config.API.directorbyId(id))
|
||||||
|
.then((res) => {
|
||||||
|
success($q, "ลบข้อมูลสำเร็จ");
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
await getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**เมื่อเริ่มโหลดหน้า
|
/**เมื่อเริ่มโหลดหน้า
|
||||||
* ส่งข้อมูลจำลองไปยัง store
|
* ส่งข้อมูลจำลองไปยัง store
|
||||||
*/
|
*/
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
getList();
|
||||||
// get ข้อมูลแล้วโยนใส่ store
|
// get ข้อมูลแล้วโยนใส่ store
|
||||||
dataStore.fetchData([
|
|
||||||
{
|
|
||||||
name: "นางเกสินี เจียรสุมัย",
|
|
||||||
position: "ครู",
|
|
||||||
email: "e@email.com",
|
|
||||||
phone: "0800808080",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "นายสรวิชญ์ พลสิทธิ์",
|
|
||||||
position: "ทดลองงาน",
|
|
||||||
email: "g@gmail.com",
|
|
||||||
phone: "0614565145",
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -47,36 +114,9 @@ function resetFilter() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function filterFn(){
|
||||||
*pagination ของตาราง
|
getList()
|
||||||
*/
|
console.log('enter',filterKeyword.value)
|
||||||
const pagination = ref({
|
|
||||||
// sortBy: "desc",
|
|
||||||
descending: false,
|
|
||||||
page: 1,
|
|
||||||
rowsPerPage: 25,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ลบข้อมูล
|
|
||||||
* @param id ของกรรมการแต่ละบุคคล
|
|
||||||
*/
|
|
||||||
function clickDelete(id: string) {
|
|
||||||
dialogRemove($q, async () => {
|
|
||||||
// ยืนยันการลบข้อมูล
|
|
||||||
// showLoader();
|
|
||||||
// await http
|
|
||||||
// .delete(config.API.periodExamId(id))
|
|
||||||
// .then((res) => {
|
|
||||||
// success($q, "ลบข้อมูลสำเร็จ");
|
|
||||||
// })
|
|
||||||
// .catch((e) => {
|
|
||||||
// messageError($q, e);
|
|
||||||
// })
|
|
||||||
// .finally(async () => {
|
|
||||||
// hideLoader();
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -108,6 +148,7 @@ function clickDelete(id: string) {
|
||||||
outlined
|
outlined
|
||||||
debounce="300"
|
debounce="300"
|
||||||
placeholder="ค้นหา"
|
placeholder="ค้นหา"
|
||||||
|
@keydown.enter.prevent="filterFn"
|
||||||
>
|
>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-icon v-if="filterKeyword == ''" name="search" />
|
<q-icon v-if="filterKeyword == ''" name="search" />
|
||||||
|
|
@ -150,6 +191,17 @@ function clickDelete(id: string) {
|
||||||
v-model:pagination="pagination"
|
v-model:pagination="pagination"
|
||||||
:visible-columns="dataStore.visibleColumns"
|
:visible-columns="dataStore.visibleColumns"
|
||||||
>
|
>
|
||||||
|
<template v-slot:pagination="scope">
|
||||||
|
<q-pagination
|
||||||
|
v-model="currentPage"
|
||||||
|
active-color="primary"
|
||||||
|
color="dark"
|
||||||
|
:max="Number(maxPage)"
|
||||||
|
size="sm"
|
||||||
|
boundary-links
|
||||||
|
direction-links
|
||||||
|
></q-pagination>
|
||||||
|
</template>
|
||||||
<template v-slot:header="props">
|
<template v-slot:header="props">
|
||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
|
|
@ -164,7 +216,7 @@ function clickDelete(id: string) {
|
||||||
v-for="col in props.cols"
|
v-for="col in props.cols"
|
||||||
:key="col.name"
|
:key="col.name"
|
||||||
:props="props"
|
:props="props"
|
||||||
@click="$router.push(`/discipline/director/${props.row.no}`)"
|
@click="$router.push(`/discipline/director/${props.row.id}`)"
|
||||||
>
|
>
|
||||||
<div v-if="col.name == 'no'">
|
<div v-if="col.name == 'no'">
|
||||||
{{ props.rowIndex + 1 }}
|
{{ props.rowIndex + 1 }}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,20 @@
|
||||||
interface FormData {
|
interface FormData {
|
||||||
|
personalId:string
|
||||||
|
prefix: string;
|
||||||
|
firstname: string;
|
||||||
|
lastname: string;
|
||||||
|
position: string;
|
||||||
|
phone: string;
|
||||||
|
email: string;
|
||||||
|
}
|
||||||
|
interface FormDataPost {
|
||||||
|
personalId:string
|
||||||
prefix: string;
|
prefix: string;
|
||||||
firstname: string;
|
firstname: string;
|
||||||
lastname: string;
|
lastname: string;
|
||||||
position: string;
|
position: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
email: string;
|
email: string;
|
||||||
responsibilities:string
|
|
||||||
}
|
}
|
||||||
interface FormRef {
|
interface FormRef {
|
||||||
prefix: object | null;
|
prefix: object | null;
|
||||||
|
|
@ -19,5 +28,6 @@ interface FormRef {
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
FormData,
|
FormData,
|
||||||
FormRef
|
FormRef,
|
||||||
|
FormDataPost
|
||||||
};
|
};
|
||||||
|
|
@ -1,10 +1,21 @@
|
||||||
interface DirectorRows {
|
interface DirectorRows {
|
||||||
name: string;
|
id:string
|
||||||
|
prefix:string
|
||||||
|
firstName:string
|
||||||
|
lastName:string
|
||||||
position: string;
|
position: string;
|
||||||
email: string;
|
email: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
}
|
}
|
||||||
|
interface DirectorRowsResponse {
|
||||||
|
id:string
|
||||||
|
fullName:string
|
||||||
|
position:string
|
||||||
|
email:string
|
||||||
|
phone:string
|
||||||
|
}
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
DirectorRows
|
DirectorRows,
|
||||||
|
DirectorRowsResponse
|
||||||
};
|
};
|
||||||
|
|
@ -38,6 +38,10 @@ const channelAdd = () =>
|
||||||
import(
|
import(
|
||||||
"@/modules/11_discipline/components/6_BasicInformation/Channel/AddPage.vue"
|
"@/modules/11_discipline/components/6_BasicInformation/Channel/AddPage.vue"
|
||||||
);
|
);
|
||||||
|
const channelEdit = () =>
|
||||||
|
import(
|
||||||
|
"@/modules/11_discipline/components/6_BasicInformation/Channel/EditPage.vue"
|
||||||
|
);
|
||||||
const complaintAdd = () =>
|
const complaintAdd = () =>
|
||||||
import("@/modules/11_discipline/components/1_Complaint/AddComplaintPage.vue");
|
import("@/modules/11_discipline/components/1_Complaint/AddComplaintPage.vue");
|
||||||
const complaintEdit = () =>
|
const complaintEdit = () =>
|
||||||
|
|
@ -223,6 +227,16 @@ export default [
|
||||||
Role: "coin",
|
Role: "coin",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/discipline/channel/:id",
|
||||||
|
name: "/discipline-channelEdit",
|
||||||
|
component: channelEdit,
|
||||||
|
meta: {
|
||||||
|
Auth: true,
|
||||||
|
Key: [11.2],
|
||||||
|
Role: "coin",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/discipline-order/add",
|
path: "/discipline-order/add",
|
||||||
name: "/disciplineorder-add",
|
name: "/disciplineorder-add",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export const useDisciplineChannelDataStore = defineStore(
|
||||||
//ค้นหา คอลัมน์ คอลัมน์ที่แสดง
|
//ค้นหา คอลัมน์ คอลัมน์ที่แสดง
|
||||||
const visibleColumns = ref<string[]>([
|
const visibleColumns = ref<string[]>([
|
||||||
"no",
|
"no",
|
||||||
"subject",
|
"name",
|
||||||
"interrogated",
|
"interrogated",
|
||||||
"fault",
|
"fault",
|
||||||
"status",
|
"status",
|
||||||
|
|
@ -28,11 +28,11 @@ export const useDisciplineChannelDataStore = defineStore(
|
||||||
style: "font-size: 14px",
|
style: "font-size: 14px",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "subject",
|
name: "name",
|
||||||
align: "left",
|
align: "left",
|
||||||
label: "ชื่อประเภท",
|
label: "ชื่อประเภท",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
field: "subject",
|
field: "name",
|
||||||
headerStyle: "font-size: 14px",
|
headerStyle: "font-size: 14px",
|
||||||
style: "font-size: 14px",
|
style: "font-size: 14px",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import type { DirectorRows } from "@/modules/11_discipline/interface/response/director";
|
import type { DirectorRows,DirectorRowsResponse } from "@/modules/11_discipline/interface/response/director";
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
|
|
||||||
// store ระบบวินัย >> ข้อมูลพื้นฐาน >> กรรมการ
|
// store ระบบวินัย >> ข้อมูลพื้นฐาน >> กรรมการ
|
||||||
|
|
@ -10,7 +10,7 @@ export const useDisciplineDirectorDataStore = defineStore(
|
||||||
//ค้นหา คอลัมน์ คอลัมน์ที่แสดง
|
//ค้นหา คอลัมน์ คอลัมน์ที่แสดง
|
||||||
const visibleColumns = ref<string[]>([
|
const visibleColumns = ref<string[]>([
|
||||||
"no",
|
"no",
|
||||||
"name",
|
"fullName",
|
||||||
"position",
|
"position",
|
||||||
"email",
|
"email",
|
||||||
"phone",
|
"phone",
|
||||||
|
|
@ -28,11 +28,11 @@ export const useDisciplineDirectorDataStore = defineStore(
|
||||||
style: "font-size: 14px",
|
style: "font-size: 14px",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "name",
|
name: "fullName",
|
||||||
align: "left",
|
align: "left",
|
||||||
label: "ชื่อ-นามสกุล",
|
label: "ชื่อ-นามสกุล",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
field: "name",
|
field: "fullName",
|
||||||
headerStyle: "font-size: 14px",
|
headerStyle: "font-size: 14px",
|
||||||
style: "font-size: 14px",
|
style: "font-size: 14px",
|
||||||
},
|
},
|
||||||
|
|
@ -66,9 +66,16 @@ export const useDisciplineDirectorDataStore = defineStore(
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ข้อมูลในตาราง
|
// ข้อมูลในตาราง
|
||||||
const rows = ref<DirectorRows[]>([]);
|
const rows = ref<DirectorRowsResponse[]>([]);
|
||||||
function fetchData(data: DirectorRows[]) {
|
function fetchData(data: DirectorRows[]) {
|
||||||
rows.value = data
|
const dataList:DirectorRowsResponse[] = data.map((item:DirectorRows)=>({
|
||||||
|
id:item.id,
|
||||||
|
fullName:`${item.prefix}${item.firstName} ${item.lastName}`,
|
||||||
|
position:item.position,
|
||||||
|
email:item.email,
|
||||||
|
phone:item.phone
|
||||||
|
}))
|
||||||
|
rows.value = dataList
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue