ui วินัย > ข้อมูลพื้นฐาน > รายชื่อกรรมการ
This commit is contained in:
parent
7c0284a87a
commit
7db2ff2260
9 changed files with 535 additions and 65 deletions
|
|
@ -0,0 +1,34 @@
|
|||
<script setup lang="ts">
|
||||
import Form from "@/modules/11_discipline/components/6_BasicInformation/Director/Form.vue"
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
messageError,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
dialogConfirm,
|
||||
success,
|
||||
} = mixin;
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
// บันทึกข้อมูล
|
||||
const onSubmit = async () => {
|
||||
// post
|
||||
router.push(`/discipline/director`)
|
||||
};
|
||||
</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/director`)" />
|
||||
เพิ่มรายชื่อกรรมการ
|
||||
</div>
|
||||
|
||||
<Form :on-submit="onSubmit" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, reactive } from "vue";
|
||||
import Form from "@/modules/11_discipline/components/6_BasicInformation/Director/Form.vue"
|
||||
import type { FormData } from "@/modules/11_discipline/interface/request/director";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
messageError,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
dialogConfirm,
|
||||
success,
|
||||
} = mixin;
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
});
|
||||
|
||||
// get ข้อมูลเก่ากรณีแก้ไขข้อมูล
|
||||
const data = reactive<FormData>({
|
||||
prefix: "",
|
||||
firstname: "",
|
||||
lastname: "",
|
||||
position: "",
|
||||
phone: "",
|
||||
responsibilities: "",
|
||||
email: "",
|
||||
})
|
||||
const fetchData = async () => {
|
||||
// ดึงค่าจาก api
|
||||
data.prefix = "นาง"
|
||||
data.firstname = "เกสินี"
|
||||
data.lastname = "เจียรสุมัย"
|
||||
data.position = "ครู"
|
||||
data.phone = "0800808080"
|
||||
data.responsibilities = "ประธาน"
|
||||
data.email = "e@email.com"
|
||||
};
|
||||
|
||||
// แก้ไขข้อมูล
|
||||
const onSubmit = async (id: string) => {
|
||||
// put
|
||||
};
|
||||
</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/director`)" />
|
||||
แก้ไขรายชื่อกรรมการ
|
||||
</div>
|
||||
|
||||
<Form @onSubmit="onSubmit" :data="data" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, watch } from "vue";
|
||||
import type { FormData, FormRef } from "@/modules/11_discipline/interface/request/director";
|
||||
|
||||
// รับ props มาจาก page หลัก
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
onSubmit: {
|
||||
type: Function,
|
||||
default: () => "",
|
||||
},
|
||||
});
|
||||
|
||||
// ข้อมูลรหัสบัตรประชาชน
|
||||
const idCard = ref<string>("");
|
||||
const idCardRef = ref<any>(null)
|
||||
|
||||
// ข้อมูลทั้งก้อน form
|
||||
const formData = reactive<FormData>({
|
||||
prefix: "",
|
||||
firstname: "",
|
||||
lastname: "",
|
||||
position: "",
|
||||
phone: "",
|
||||
responsibilities: "",
|
||||
email: "",
|
||||
});
|
||||
|
||||
watch(props.data, async () => {
|
||||
console.log("data==>", props.data)
|
||||
formData.prefix = props.data.prefix
|
||||
formData.firstname = props.data.firstname
|
||||
formData.lastname = props.data.lastname
|
||||
formData.position = props.data.position
|
||||
formData.phone = props.data.phone
|
||||
formData.responsibilities = props.data.responsibilities
|
||||
formData.email = props.data.email
|
||||
});
|
||||
|
||||
// เพิ่มบุคลากร
|
||||
function addEmployee() {
|
||||
if (idCardRef.value.validate()) {
|
||||
console.log("idCard===>", idCard.value)
|
||||
}
|
||||
}
|
||||
|
||||
// ตรวจสอบข้อมูลก่อนส่งไปยัง api
|
||||
const prefixRef = ref<object | null>(null)
|
||||
const firstnameRef = ref<object | null>(null)
|
||||
const lastnameRef = ref<object | null>(null)
|
||||
const positionRef = ref<object | null>(null)
|
||||
const phoneRef = ref<object | null>(null)
|
||||
const responsibilitiesRef = ref<object | null>(null)
|
||||
const emailRef = ref<object | null>(null)
|
||||
const formRef: FormRef = {
|
||||
prefix: prefixRef,
|
||||
firstname: firstnameRef,
|
||||
lastname: lastnameRef,
|
||||
position: positionRef,
|
||||
phone: phoneRef,
|
||||
responsibilities: responsibilitiesRef,
|
||||
email: emailRef
|
||||
};
|
||||
|
||||
function onValidate() {
|
||||
const hasError = [];
|
||||
for (const key in formRef) {
|
||||
if (Object.prototype.hasOwnProperty.call(formRef, key)) {
|
||||
const property = formRef[key];
|
||||
if (property.value && typeof property.value.validate === "function") {
|
||||
const isValid = property.value.validate();
|
||||
hasError.push(isValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError.every((result) => result === true)) {
|
||||
props.onSubmit()
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<form @submit.prevent.stop="onValidate" class="q-gutter-md">
|
||||
<div class="col-12">
|
||||
|
||||
<q-card bordered>
|
||||
|
||||
<div class="row q-pa-md q-col-gutter-sm">
|
||||
<div class="col-md-3 row q-pa-md text-bold">
|
||||
<label>ค้นหาบุคคลากรที่อยู่ในระบบ</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<q-input dense outlined v-model="idCard" label="รหัสบัตรประชาชน" ref="idCardRef"
|
||||
:rules="[(val: string) => !!val || `${'กรุณากรอกรหัสบัตรประชาชน'}`]" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<q-btn unelevated dense color="primary" class="q-px-md q-py-sm" @click="addEmployee" label="เพิ่มบุคลากร" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row q-px-md q-col-gutter-sm">
|
||||
<div class="col-md-3">
|
||||
<q-input dense outlined v-model="formData.prefix" label="คำนำหน้า" ref="prefixRef"
|
||||
:rules="[(val: string) => val !== null && val !== '' || `${'กรุณากรอกคำนำหน้า'}`]" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<q-input dense outlined v-model="formData.firstname" label="ชื่อ" ref="firstnameRef"
|
||||
:rules="[(val: string) => val !== null && val !== '' || `${'กรุณากรอกชื่อ'}`]" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<q-input dense outlined v-model="formData.lastname" label="นามสกุล" ref="lastnameRef"
|
||||
:rules="[(val: string) => !!val || `${'กรุณากรอกนามสกุล'}`]" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<q-input dense outlined v-model="formData.position" label="ตำแหน่ง" ref="positionRef"
|
||||
:rules="[(val: string) => !!val || `${'กรุณากรอกตำแหน่ง'}`]" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<q-input dense outlined v-model="formData.phone" label="เบอร์โทร" ref="phoneRef"
|
||||
:rules="[(val: string) => !!val || `${'กรุณากรอกเบอร์โทร'}`]" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<q-input dense outlined v-model="formData.responsibilities" label="หน้าที่" ref="responsibilitiesRef"
|
||||
:rules="[(val: string) => !!val || `${'กรุณากรอกหน้าที่'}`]" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<q-input dense outlined v-model="formData.email" label="อีเมล" ref="emailRef"
|
||||
:rules="[(val: string) => !!val || `${'กรุณากรอกอีเมล'}`]" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<q-separator />
|
||||
<div class="row col-12 q-pa-sm">
|
||||
<q-space />
|
||||
<q-btn type="submit" flat round color="public" icon="mdi-content-save-outline">
|
||||
<q-tooltip>บันทึกข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
|
||||
</q-card>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
|
@ -1,9 +1,146 @@
|
|||
<script setup lang="ts"></script>
|
||||
<script setup lang="ts">
|
||||
import { ref, useAttrs, onMounted } from "vue";
|
||||
import type { QTableProps } from "quasar";
|
||||
import router from "@/router";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useDisciplineDirectorDataStore } from '@/modules/11_discipline/stroes/DirectorStore'
|
||||
|
||||
import config from "@/app.config";
|
||||
import http from "@/plugins/http";
|
||||
|
||||
const $q = useQuasar();
|
||||
const dataStore = useDisciplineDirectorDataStore()
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
date2Thai,
|
||||
success,
|
||||
messageError,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
dialogConfirm,
|
||||
dialogRemove,
|
||||
} = mixin;
|
||||
|
||||
onMounted(() => {
|
||||
// get ข้อมูลแล้วโยนใส่ store
|
||||
dataStore.fetchData([
|
||||
{
|
||||
no: 1,
|
||||
name: "นางเกสินี เจียรสุมัย",
|
||||
position: "ครู",
|
||||
responsibilities: "ประธาน",
|
||||
email: "e@email.com",
|
||||
phone: "0800808080",
|
||||
},
|
||||
{
|
||||
no: 2,
|
||||
name: "นายสรวิชญ์ พลสิทธิ์",
|
||||
position: "ทดลองงาน",
|
||||
responsibilities: "เลขานุการ",
|
||||
email: "g@gmail.com",
|
||||
phone: "0614565145",
|
||||
},
|
||||
])
|
||||
});
|
||||
|
||||
// ค้นหาในตาราง
|
||||
const filterKeyword = ref<string>("");
|
||||
const filterRef = ref<HTMLInputElement | null>(null);
|
||||
function resetFilter() {
|
||||
filterKeyword.value = "";
|
||||
if (filterRef.value) {
|
||||
filterRef.value.focus();
|
||||
}
|
||||
};
|
||||
|
||||
// กำหนด pagination
|
||||
const pagination = ref({
|
||||
// sortBy: "desc",
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 25,
|
||||
});
|
||||
|
||||
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>
|
||||
<template>
|
||||
<div>
|
||||
<h1>กรรมการ</h1>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
รายการชื่อกรรมการ
|
||||
</div>
|
||||
</template>
|
||||
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
|
||||
<div class="row q-col-gutter-sm">
|
||||
<div class="row col-12 q-col-gutter-sm">
|
||||
<div>
|
||||
<q-btn @click="$router.push(`/discipline/director/add`)" size="12px" flat round color="add" icon="mdi-plus">
|
||||
<q-tooltip>เพิ่มรายชื่อกรรมการ</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
<q-space />
|
||||
|
||||
<style scoped></style>
|
||||
<q-input class="col-xs-12 col-sm-3 col-md-2" standout dense v-model="filterKeyword" ref="filterRef" outlined
|
||||
debounce="300" placeholder="ค้นหา">
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="filterKeyword == ''" name="search" />
|
||||
<q-icon v-if="filterKeyword !== ''" name="clear" class="cursor-pointer" @click="resetFilter" />
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-select v-model="dataStore.visibleColumns" multiple outlined dense options-dense
|
||||
:display-value="$q.lang.table.columns" emit-value map-options :options="dataStore.columns" option-value="name"
|
||||
options-cover style="min-width: 150px" class="col-xs-12 col-sm-3 col-md-2" />
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<d-table :columns="dataStore.columns" :rows="dataStore.rows" :filter="filterKeyword" row-key="tb-list" flat
|
||||
bordered :paging="true" dense v-model:pagination="pagination" :visible-columns="dataStore.visibleColumns">
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<span class="text-weight-medium">{{ col.label }}</span>
|
||||
</q-th>
|
||||
<q-th auto-width />
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td v-for="col in props.cols" :key="col.name" :props="props" @click="$router.push(`/discipline/director/${props.row.no}`)">
|
||||
<!-- <div v-if="col.name == 'phone'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div> -->
|
||||
<div>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
<q-td auto-width>
|
||||
<q-btn dense size="12px" flat round color="red" @click="clickDelete(props.row.id)" icon="mdi-delete">
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue