ข้อมูลทะเบียนประวัติ => Dialog
This commit is contained in:
parent
cbf34695b8
commit
e452c6dfe0
8 changed files with 1536 additions and 626 deletions
312
src/modules/04_registryNew/components/registry/DialogAddData.vue
Normal file
312
src/modules/04_registryNew/components/registry/DialogAddData.vue
Normal file
|
|
@ -0,0 +1,312 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch, reactive } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type { DataOption } from "@/modules/04_registryNew/interface/index/Main";
|
||||
import type { DataType } from "@/modules/04_registryNew/interface/response/Main";
|
||||
import type {
|
||||
FormAddPerson,
|
||||
MyObjectRef,
|
||||
} from "@/modules/04_registryNew/interface/request/Main";
|
||||
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
/** importStore*/
|
||||
import { useRegistryNewDataStore } from "@/modules/04_registryNew/store";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
const $q = useQuasar();
|
||||
const store = useRegistryNewDataStore();
|
||||
const {
|
||||
dialogRemove,
|
||||
dialogConfirm,
|
||||
success,
|
||||
messageError,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
dialogMessageNotify,
|
||||
} = useCounterMixin();
|
||||
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
|
||||
const props = defineProps({
|
||||
fetchData: { type: Function },
|
||||
fetchType: { type: Function },
|
||||
});
|
||||
|
||||
const prefixOps = ref<DataOption[]>([]);
|
||||
const levelOps = ref<DataType[]>([]);
|
||||
|
||||
const formData = reactive<FormAddPerson>({
|
||||
prefix: "",
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
citizenId: "",
|
||||
position: "",
|
||||
posTypeId: "",
|
||||
posLevelId: "",
|
||||
});
|
||||
|
||||
const prefixRef = ref<object | null>(null);
|
||||
const firstNameRef = ref<object | null>(null);
|
||||
const lastNameRef = ref<object | null>(null);
|
||||
const citizenIdRef = ref<object | null>(null);
|
||||
const positionRef = ref<object | null>(null);
|
||||
const posTypeIdRef = ref<object | null>(null);
|
||||
const posLevelIdRef = ref<object | null>(null);
|
||||
|
||||
const objectRef: MyObjectRef = {
|
||||
prefix: prefixRef,
|
||||
firstName: firstNameRef,
|
||||
lastName: lastNameRef,
|
||||
citizenId: citizenIdRef,
|
||||
position: positionRef,
|
||||
posTypeId: posTypeIdRef,
|
||||
posLevelId: posLevelIdRef,
|
||||
};
|
||||
|
||||
function fetchPrefix() {
|
||||
http
|
||||
.get(config.API.orgPrefix)
|
||||
.then((res) => {
|
||||
prefixOps.value = res.data.result.map((v: any) => ({
|
||||
id: v.name,
|
||||
name: v.name,
|
||||
}));
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function ตรวจสอบเลขประจำตัวประชาชน
|
||||
* @param citizenId เลขประจำตัวประชาชน
|
||||
*/
|
||||
function changeCardID(citizenId: string | number | null) {
|
||||
if (citizenId != null && typeof citizenId == "string") {
|
||||
if (citizenId.length == 13 && citizenId) {
|
||||
http
|
||||
.put(config.API.profileNewCitizenId(citizenId), {
|
||||
citizenId: citizenId,
|
||||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
if (err.response.data.status === 500) {
|
||||
dialogMessageNotify($q, err.response.data.message);
|
||||
} else {
|
||||
messageError($q, err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fetchLevel(id: string) {
|
||||
const listLevel = store.posTypeMain.find((e: DataType) => e.id === id);
|
||||
levelOps.value = listLevel?.posLevels;
|
||||
|
||||
const checkLevel = levelOps.value.filter(
|
||||
(e: DataType) => e.id === formData.posLevelId
|
||||
);
|
||||
if (checkLevel.length === 0) {
|
||||
formData.posLevelId = "";
|
||||
}
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
modal.value = false;
|
||||
clearFormData();
|
||||
}
|
||||
|
||||
function clearFormData() {
|
||||
formData.prefix = "";
|
||||
formData.firstName = "";
|
||||
formData.lastName = "";
|
||||
formData.citizenId = "";
|
||||
formData.position = "";
|
||||
formData.posTypeId = "";
|
||||
formData.posLevelId = "";
|
||||
}
|
||||
|
||||
function validateForm() {
|
||||
const hasError = [];
|
||||
for (const key in objectRef) {
|
||||
if (Object.prototype.hasOwnProperty.call(objectRef, key)) {
|
||||
const property = objectRef[key];
|
||||
if (property.value && typeof property.value.validate === "function") {
|
||||
const isValid = property.value.validate();
|
||||
hasError.push(isValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError.every((result) => result === true)) {
|
||||
onSubmit();
|
||||
}
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.registryNew, formData)
|
||||
.then(() => {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
props.fetchData?.();
|
||||
closeDialog();
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
() => modal.value,
|
||||
() => {
|
||||
if (modal.value) {
|
||||
fetchPrefix();
|
||||
props.fetchType?.();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<q-dialog v-model="modal" persistent>
|
||||
<q-card style="min-width: 350px" class="bg-grey-11">
|
||||
<form @submit.prevent="validateForm">
|
||||
<q-card-section class="flex justify-between" style="padding: 0">
|
||||
<DialogHeader tittle="เพิ่มข้อมูล" :close="closeDialog" />
|
||||
</q-card-section>
|
||||
|
||||
<q-separator />
|
||||
<q-card-section class="q-pa-md q-col-gutter-md">
|
||||
<q-select
|
||||
bg-color="white"
|
||||
ref="prefixRef"
|
||||
v-model="formData.prefix"
|
||||
label="คำนำหน้าชื่อ"
|
||||
outlined
|
||||
dense
|
||||
:options="prefixOps"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
map-options
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || 'กรุณาเลือกคำนำหน้าชื่อ']"
|
||||
emit-value
|
||||
/>
|
||||
<q-input
|
||||
bg-color="white"
|
||||
ref="firstNameRef"
|
||||
outlined
|
||||
v-model="formData.firstName"
|
||||
label="ชื่อ"
|
||||
dense
|
||||
lazy-rules
|
||||
borderless
|
||||
:rules="[(val) => val.length > 0 || 'กรุณากรอกชื่อ']"
|
||||
hide-bottom-space
|
||||
/>
|
||||
<q-input
|
||||
bg-color="white"
|
||||
ref="lastNameRef"
|
||||
outlined
|
||||
v-model="formData.lastName"
|
||||
label="นามสกุล"
|
||||
dense
|
||||
lazy-rules
|
||||
borderless
|
||||
:rules="[(val) => val.length > 0 || 'กรุณากรอกนามสกุล']"
|
||||
hide-bottom-space
|
||||
/>
|
||||
<q-input
|
||||
bg-color="white"
|
||||
ref="citizenIdRef"
|
||||
outlined
|
||||
v-model="formData.citizenId"
|
||||
label="เลขประจำตัวประชาชน"
|
||||
dense
|
||||
lazy-rules
|
||||
borderless
|
||||
:rules="[
|
||||
(val: string) => !!val || `${'กรุณากรอกเลขประจำตัวประชาชน'}`,
|
||||
(val: string) =>
|
||||
val.length >= 13 ||
|
||||
`${'กรุณากรอกเลขประจำตัวประชาชนให้ครบ'}`,
|
||||
]"
|
||||
maxlength="13"
|
||||
hide-bottom-space
|
||||
mask="#############"
|
||||
@update:model-value="changeCardID"
|
||||
/>
|
||||
<q-input
|
||||
bg-color="white"
|
||||
ref="positionRef"
|
||||
outlined
|
||||
v-model="formData.position"
|
||||
label="ตำแหน่ง"
|
||||
dense
|
||||
lazy-rules
|
||||
borderless
|
||||
:rules="[(val) => val.length > 0 || 'กรุณากรอกตำแหน่ง']"
|
||||
hide-bottom-space
|
||||
/>
|
||||
<q-select
|
||||
bg-color="white"
|
||||
ref="posTypeIdRef"
|
||||
v-model="formData.posTypeId"
|
||||
label="ประเภทตำแหน่ง"
|
||||
outlined
|
||||
:options="store.posTypeOps"
|
||||
dense
|
||||
options-cover
|
||||
map-options
|
||||
emit-value
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || 'กรุณาเลือกประเภทตำแหน่ง']"
|
||||
@update:model-value="fetchLevel"
|
||||
/>
|
||||
<q-select
|
||||
bg-color="white"
|
||||
ref="posLevelIdRef"
|
||||
v-model="formData.posLevelId"
|
||||
label="ระดับตำแหน่ง"
|
||||
:options="levelOps"
|
||||
outlined
|
||||
dense
|
||||
map-options
|
||||
emit-value
|
||||
option-label="posLevelName"
|
||||
option-value="id"
|
||||
options-cover
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || 'กรุณาเลือกระดับตำแหน่ง']"
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
<q-separator />
|
||||
<q-card-actions align="right">
|
||||
<q-btn
|
||||
id="onSubmit"
|
||||
type="submit"
|
||||
dense
|
||||
unelevated
|
||||
label="บันทึก"
|
||||
color="public"
|
||||
class="q-px-md"
|
||||
>
|
||||
<q-tooltip>บันทึกข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-card-actions>
|
||||
</form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
431
src/modules/04_registryNew/components/registry/DialogHistory.vue
Normal file
431
src/modules/04_registryNew/components/registry/DialogHistory.vue
Normal file
|
|
@ -0,0 +1,431 @@
|
|||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRouter } from "vue-router";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
/** importType*/
|
||||
import type { DataOption } from "@/modules/04_registryNew/interface/index/Main";
|
||||
import type { QForm } from "quasar";
|
||||
|
||||
/** importStore*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/** use*/
|
||||
const myForm = ref<QForm>();
|
||||
const router = useRouter();
|
||||
const $q = useQuasar();
|
||||
const { showLoader, hideLoader, messageError, date2Thai, dialogMessageNotify } =
|
||||
useCounterMixin();
|
||||
|
||||
/**props*/
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
|
||||
const employeeClass = ref<string>("");
|
||||
const typeKeyword = ref<string>("");
|
||||
const Keyword = ref<string>("");
|
||||
const positionKeyword = ref<string>("");
|
||||
const employeeClassOps = ref<DataOption[]>([
|
||||
{ id: "officer", name: "ข้าราชการ กทม.สามัญ" },
|
||||
{ id: "perm", name: "ลูกจ้างประจำ" },
|
||||
]);
|
||||
const typeKeywordOps = ref<DataOption[]>([
|
||||
{ id: "no", name: "เลขที่ตำแหน่ง" },
|
||||
{ id: "position", name: "ตำแหน่ง" },
|
||||
]);
|
||||
const positionOps = ref<DataOption[]>([]);
|
||||
const columns = ref<any["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
label: "ลำดับ",
|
||||
field: "no",
|
||||
align: "left",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "citizenId",
|
||||
align: "left",
|
||||
label: "เลขประจำตัวประชาชน",
|
||||
field: "citizenId",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
align: "left",
|
||||
label: "ชื่อ - นามสกุล",
|
||||
field: "name",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posNo",
|
||||
align: "left",
|
||||
label: "เลขที่ตำแหน่ง",
|
||||
field: "posNo",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "position",
|
||||
align: "left",
|
||||
label: "ตำแหน่ง",
|
||||
field: "position",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "date",
|
||||
align: "left",
|
||||
label: "วันที่ถือครอง",
|
||||
field: "date",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
const rows = ref<any>([]);
|
||||
|
||||
function fecthPositionOfficer() {
|
||||
http
|
||||
.get(config.API.listPositionPathHistory)
|
||||
.then((res) => {
|
||||
let data = res.data.result.items;
|
||||
positionOps.value = data.map((e: any) => ({ id: e.id, name: e.name }));
|
||||
options.value = positionOps.value;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
});
|
||||
}
|
||||
function fetchPositionPerm() {
|
||||
http
|
||||
.get(config.API.listPositionEmployeePositionHistory)
|
||||
.then((res) => {
|
||||
let data = res.data.result.items;
|
||||
positionOps.value = data.map((e: any) => ({ id: e.id, name: e.name }));
|
||||
options.value = positionOps.value;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
});
|
||||
}
|
||||
|
||||
function changeEmployeeClass() {
|
||||
typeKeyword.value = "";
|
||||
Keyword.value = "";
|
||||
positionKeyword.value = "";
|
||||
rows.value = [];
|
||||
}
|
||||
function selectTypeKeyword(typeKeyword: string) {
|
||||
positionOps.value = [];
|
||||
positionKeyword.value = "";
|
||||
Keyword.value = "";
|
||||
|
||||
if (typeKeyword == "position" && employeeClass.value === "officer") {
|
||||
fecthPositionOfficer();
|
||||
} else if (typeKeyword == "position" && employeeClass.value === "perm") {
|
||||
fetchPositionPerm();
|
||||
}
|
||||
}
|
||||
|
||||
function clickSearch(type: string) {
|
||||
myForm.value!.validate().then((result: boolean) => {
|
||||
if (result) {
|
||||
showLoader();
|
||||
let body = {};
|
||||
if (typeKeyword.value === "no") {
|
||||
Object.assign(body, {
|
||||
posNo: Keyword.value,
|
||||
});
|
||||
} else if (typeKeyword.value === "position") {
|
||||
Object.assign(body, {
|
||||
positionId: positionKeyword.value,
|
||||
});
|
||||
}
|
||||
http
|
||||
.post(config.API.profileHistory(type), body)
|
||||
.then((res) => {
|
||||
let data = res.data.result;
|
||||
if (data.length !== 0) {
|
||||
rows.value = data.map((e: any) => ({
|
||||
id: e.id,
|
||||
citizenId: e.citizenId,
|
||||
name: e.firstName + " " + e.lastName,
|
||||
posNo: e.posNo,
|
||||
position: e.position,
|
||||
date: date2Thai(e.date),
|
||||
}));
|
||||
} else {
|
||||
dialogMessageNotify($q, "ไม่มีข้อมูลที่ต้องการค้นหา");
|
||||
rows.value = [];
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
rows.value = [];
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
const options = ref<any>([]);
|
||||
function filterFn(val: string, update: any) {
|
||||
if (val === "") {
|
||||
update(() => {
|
||||
options.value = positionOps.value;
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
update(() => {
|
||||
options.value = positionOps.value.filter(
|
||||
(e) => e.name.search(val) !== -1
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
function clickRedirect(id: string) {
|
||||
router.push(`/registry/${id}`);
|
||||
}
|
||||
|
||||
const paging = ref<boolean>(true);
|
||||
const pagination = ref({
|
||||
sortBy: "order",
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
const paginationLabel = (start: number, end: number, total: number) => {
|
||||
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
|
||||
else return start + "-" + end + " ใน " + total;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-dialog v-model="modal">
|
||||
<q-card style="width: 850px; max-width: 80vw">
|
||||
<q-card-section>
|
||||
<div class="my-content">
|
||||
<div
|
||||
class="row q-pa-xs items-center bg-blue-1"
|
||||
style="border-radius: 4px 4px 0px 0px"
|
||||
>
|
||||
<q-icon
|
||||
size="20px"
|
||||
color="blue-9"
|
||||
name="mdi-filter-variant"
|
||||
class="q-mx-sm"
|
||||
/>
|
||||
<div class="text-blue-9 text-subtitle2 text-weight-medium">
|
||||
<span>ประวัติถือครองตำแหน่ง</span>
|
||||
</div>
|
||||
<q-space />
|
||||
<q-btn
|
||||
color="blue-9"
|
||||
icon="mdi-close"
|
||||
size="12px"
|
||||
flat
|
||||
round
|
||||
dense
|
||||
v-close-popup
|
||||
/>
|
||||
</div>
|
||||
<q-separator color="blue-1" />
|
||||
<div class="dialog-card-contain">
|
||||
<q-card-section class="q-pa-sm">
|
||||
<q-form ref="myForm">
|
||||
<div class="row col-12 q-col-gutter-xs">
|
||||
<q-select
|
||||
class="col-4"
|
||||
hide-bottom-space
|
||||
:rules="[(val:string) => !!val || `${'กรุณาเลือก ประเภท'}`]"
|
||||
outlined
|
||||
dense
|
||||
lazy-rules
|
||||
v-model="employeeClass"
|
||||
emit-value
|
||||
map-options
|
||||
:options="employeeClassOps"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:label="`${'ประเภท'}`"
|
||||
use-input
|
||||
input-debounce="0"
|
||||
@update:model-value="changeEmployeeClass"
|
||||
/>
|
||||
<q-select
|
||||
class="col-4"
|
||||
hide-bottom-space
|
||||
:rules="[(val:string) => !!val || `${'กรุณาเลือก ฟิลด์ที่จะค้น'}`]"
|
||||
outlined
|
||||
dense
|
||||
lazy-rules
|
||||
v-model="typeKeyword"
|
||||
emit-value
|
||||
map-options
|
||||
:options="typeKeywordOps"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:label="`${' เลือกฟิลด์ที่จะค้น'}`"
|
||||
use-input
|
||||
input-debounce="0"
|
||||
@update:model-value="selectTypeKeyword(typeKeyword)"
|
||||
/>
|
||||
<q-input
|
||||
v-if="typeKeyword === 'no'"
|
||||
class="col-4"
|
||||
borderless
|
||||
outlined
|
||||
dense
|
||||
debounce="300"
|
||||
v-model="Keyword"
|
||||
placeholder="เลขที่ตำแหน่ง"
|
||||
:rules="[(val:string) => !!val || `${'กรุณากรอก เลขที่ตำแหน่ง'}`]"
|
||||
/>
|
||||
<q-select
|
||||
v-if="typeKeyword === 'position'"
|
||||
class="col-4"
|
||||
hide-bottom-space
|
||||
:rules="[(val:string) => !!val || `${'กรุณาเลือก ตำแหน่ง'}`]"
|
||||
outlined
|
||||
dense
|
||||
v-model="positionKeyword"
|
||||
emit-value
|
||||
map-options
|
||||
:options="options"
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
:label="`${' เลือกตำแหน่ง'}`"
|
||||
use-input
|
||||
input-debounce="0"
|
||||
@filter="filterFn"
|
||||
behavior="menu"
|
||||
>
|
||||
<template v-slot:no-option>
|
||||
<q-item>
|
||||
<q-item-section class="text-grey">
|
||||
ไม่มีข้อมูล
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template></q-select
|
||||
>
|
||||
<q-space />
|
||||
<div>
|
||||
<q-btn
|
||||
dense
|
||||
color="primary"
|
||||
icon="mdi-magnify"
|
||||
label="ค้นหา"
|
||||
class="q-px-md"
|
||||
@click="clickSearch(employeeClass)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section class="q-pt-none">
|
||||
<q-table
|
||||
flat
|
||||
dense
|
||||
bordered
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
row-key="order"
|
||||
class="custom-header-table"
|
||||
no-data-label="ไม่มีข้อมูล"
|
||||
:pagination-label="paginationLabel"
|
||||
v-model:pagination="pagination"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<div class="text-grey-7 text-weight-medium">
|
||||
<span class="row">{{ col.label }}</span>
|
||||
</div>
|
||||
</q-th>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td key="no" :props="props"> {{ props.rowIndex + 1 }}</q-td>
|
||||
<q-td key="order" :props="props">{{ props.row.order }} </q-td>
|
||||
<q-td
|
||||
key="citizenId"
|
||||
class="text-primary"
|
||||
@click="clickRedirect(props.row.id)"
|
||||
:props="props"
|
||||
>{{ props.row.citizenId }}</q-td
|
||||
>
|
||||
<q-td
|
||||
key="name"
|
||||
class="text-primary"
|
||||
@click="clickRedirect(props.row.id)"
|
||||
:props="props"
|
||||
>{{ props.row.name }}</q-td
|
||||
>
|
||||
|
||||
<q-td key="posNo" :props="props">{{ props.row.posNo }}</q-td>
|
||||
<q-td key="position" :props="props">{{
|
||||
props.row.position
|
||||
}}</q-td>
|
||||
<q-td key="date" :props="props">{{ props.row.date }}</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:pagination="scope">
|
||||
<q-pagination
|
||||
v-model="pagination.page"
|
||||
color="primary"
|
||||
:max="scope.pagesNumber"
|
||||
:max-pages="5"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
></q-pagination>
|
||||
</template>
|
||||
</q-table>
|
||||
</q-card-section>
|
||||
|
||||
<!-- <q-card-actions align="right">
|
||||
<q-btn flat label="OK" color="primary" v-close-popup />
|
||||
</q-card-actions> -->
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.custom-header-table {
|
||||
max-height: 64vh;
|
||||
|
||||
.q-table tr:nth-child(odd) td {
|
||||
background: white;
|
||||
}
|
||||
|
||||
.q-table tr:nth-child(even) td {
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.q-table thead tr {
|
||||
background: #ecebeb;
|
||||
}
|
||||
|
||||
.q-table thead tr th {
|
||||
position: sticky;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.q-table thead tr:last-child th {
|
||||
top: 48px;
|
||||
}
|
||||
|
||||
.q-table thead tr:first-child th {
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,112 +1,272 @@
|
|||
<script setup lang="ts">
|
||||
import type { QTableColumn } from "quasar";
|
||||
import { ref, watch, computed, onMounted } from "vue";
|
||||
|
||||
const visibleColumns = defineModel<string[]>("visibleColumns");
|
||||
/** importType*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type { FormFilter } from "@/modules/04_registryNew/interface/request/Main";
|
||||
|
||||
const mode = defineModel<string>("mode");
|
||||
/** importComponent*/
|
||||
import DialogAddData from "@/modules/04_registryNew/components/registry/DialogAddData.vue";
|
||||
import DialogHistory from "@/modules/04_registryNew/components/registry/DialogHistory.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
columns: QTableColumn[];
|
||||
}>();
|
||||
/** importStore*/
|
||||
import { useRegistryNewDataStore } from "@/modules/04_registryNew/store";
|
||||
|
||||
const rows = [
|
||||
const store = useRegistryNewDataStore();
|
||||
|
||||
const formFilter = defineModel<FormFilter>("formFilter", { required: true });
|
||||
const maxPage = defineModel<Number>("maxPage", { required: true });
|
||||
const props = defineProps({
|
||||
rows: { type: Array },
|
||||
fetchData: { type: Function },
|
||||
fetchType: { type: Function },
|
||||
});
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
no: 1,
|
||||
fullName: "นางสาวกัณฐิมา กานสิน",
|
||||
citizenId: "1231231231234",
|
||||
posNo: "สกก.1",
|
||||
position: "นักบริหาร",
|
||||
posPath: "บริหาร",
|
||||
posType: "บริหาร",
|
||||
posLevel: "ชำนาญการพิเศษ",
|
||||
posOc: "ฝ่ายบริหารงานทั่วไป",
|
||||
year: 2566,
|
||||
salary: "40,000",
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
sortable: true,
|
||||
field: "no",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
no: 2,
|
||||
fullName: "นายธามไทย คนคูเมือง",
|
||||
citizenId: "5555555555555",
|
||||
posNo: "สกก.5",
|
||||
position: "นักจัดการงานทั่วไป",
|
||||
posPath: "จัดการงานทั่วไป",
|
||||
posType: "วิชาการ",
|
||||
posLevel: "ปฏิบัติการ",
|
||||
posOc: "ฝ่ายบริหารงานทั่วไป",
|
||||
year: 2566,
|
||||
salary: "25,000",
|
||||
name: "fullName",
|
||||
align: "left",
|
||||
label: "ชื่อ - นามสกุล",
|
||||
sortable: true,
|
||||
field: "fullName",
|
||||
headerStyle: "font-size: 14px; min-width: 200px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
no: 2,
|
||||
fullName: "นายธามไทย คนคูเมือง",
|
||||
citizenId: "5555555555555",
|
||||
posNo: "สกก.5",
|
||||
position: "นักจัดการงานทั่วไป",
|
||||
posPath: "จัดการงานทั่วไป",
|
||||
posType: "วิชาการ",
|
||||
posLevel: "ปฏิบัติการ",
|
||||
posOc: "ฝ่ายบริหารงานทั่วไป",
|
||||
year: 2566,
|
||||
salary: "25,000",
|
||||
name: "posNo",
|
||||
align: "left",
|
||||
label: "ตำแหน่งเลขที่",
|
||||
sortable: true,
|
||||
field: "posNo",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
no: 2,
|
||||
fullName: "นายธามไทย คนคูเมือง",
|
||||
citizenId: "5555555555555",
|
||||
posNo: "สกก.5",
|
||||
position: "นักจัดการงานทั่วไป",
|
||||
posPath: "จัดการงานทั่วไป",
|
||||
posType: "วิชาการ",
|
||||
posLevel: "ปฏิบัติการ",
|
||||
posOc: "ฝ่ายบริหารงานทั่วไป",
|
||||
year: 2566,
|
||||
salary: "25,000",
|
||||
name: "position",
|
||||
align: "left",
|
||||
label: "ตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "position",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
no: 2,
|
||||
fullName: "นายธามไทย คนคูเมือง",
|
||||
citizenId: "5555555555555",
|
||||
posNo: "สกก.5",
|
||||
position: "นักจัดการงานทั่วไป",
|
||||
posPath: "จัดการงานทั่วไป",
|
||||
posType: "วิชาการ",
|
||||
posLevel: "ปฏิบัติการ",
|
||||
posOc: "ฝ่ายบริหารงานทั่วไป",
|
||||
year: 2566,
|
||||
salary: "25,000",
|
||||
name: "posPath",
|
||||
align: "left",
|
||||
label: "สายงาน",
|
||||
sortable: true,
|
||||
field: "posPath",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
no: 2,
|
||||
fullName: "นายธามไทย คนคูเมือง",
|
||||
citizenId: "5555555555555",
|
||||
posNo: "สกก.5",
|
||||
position: "นักจัดการงานทั่วไป",
|
||||
posPath: "จัดการงานทั่วไป",
|
||||
posType: "วิชาการ",
|
||||
posLevel: "ปฏิบัติการ",
|
||||
posOc: "ฝ่ายบริหารงานทั่วไป",
|
||||
year: 2566,
|
||||
salary: "25,000",
|
||||
name: "posType",
|
||||
align: "left",
|
||||
label: "สายงาน",
|
||||
sortable: true,
|
||||
field: "posPath",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
];
|
||||
{
|
||||
name: "posLevel",
|
||||
align: "left",
|
||||
label: "ระดับชั้นงาน",
|
||||
sortable: true,
|
||||
field: "posLevel",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "posOc",
|
||||
align: "left",
|
||||
label: "สังกัด",
|
||||
sortable: true,
|
||||
field: "posOc",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "year",
|
||||
align: "left",
|
||||
label: "ปีงบประมาณ",
|
||||
sortable: true,
|
||||
field: "year",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "salary",
|
||||
align: "left",
|
||||
label: "ค่าจ้าง",
|
||||
sortable: true,
|
||||
field: "salary",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
]);
|
||||
|
||||
const visibleColumns = ref<string[]>([
|
||||
"no",
|
||||
"fullName",
|
||||
"posNo",
|
||||
"position",
|
||||
"posPath",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"posOc",
|
||||
"year",
|
||||
"salary",
|
||||
]);
|
||||
|
||||
function updatePagePagination() {
|
||||
props.fetchData?.();
|
||||
}
|
||||
|
||||
function updatePageSizePagination(newPagination: any) {
|
||||
formFilter.value.page = 1;
|
||||
formFilter.value.pageSize = newPagination.rowsPerPage;
|
||||
}
|
||||
|
||||
const pagination = ref({
|
||||
page: formFilter.value.page,
|
||||
rowsPerPage: formFilter.value.pageSize,
|
||||
});
|
||||
|
||||
const modalDialogAdd = ref<boolean>(false);
|
||||
const modalHistory = ref<boolean>(false);
|
||||
|
||||
function onClickAddData() {
|
||||
modalDialogAdd.value = !modalDialogAdd.value;
|
||||
}
|
||||
|
||||
function onClickHistory() {
|
||||
modalHistory.value = !modalHistory.value;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formFilter.value.pageSize,
|
||||
() => {
|
||||
props.fetchData?.();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<!-- :filter="filterKeyword"
|
||||
:visible-columns="visibleColumns" -->
|
||||
|
||||
<template>
|
||||
<q-toolbar style="padding: 0px">
|
||||
<q-btn
|
||||
round
|
||||
flat
|
||||
color="primary"
|
||||
icon="add"
|
||||
size="16px"
|
||||
@click="onClickAddData"
|
||||
>
|
||||
<q-tooltip>เพิ่มข้อมูล</q-tooltip></q-btn
|
||||
>
|
||||
<q-btn
|
||||
round
|
||||
flat
|
||||
color="blue"
|
||||
icon="mdi-history"
|
||||
size="16px"
|
||||
@click="onClickHistory"
|
||||
>
|
||||
<q-tooltip>ประวัติถือครองตำแหน่ง</q-tooltip></q-btn
|
||||
>
|
||||
<q-space />
|
||||
<q-select
|
||||
v-if="store.mode === 'table'"
|
||||
v-model="visibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
:display-value="$q.lang.table.columns"
|
||||
emit-value
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
options-cover
|
||||
style="min-width: 150px"
|
||||
class="q-mr-sm"
|
||||
/>
|
||||
|
||||
<q-btn-toggle
|
||||
v-model="store.mode"
|
||||
dense
|
||||
class="no-shadow"
|
||||
toggle-color="grey-4"
|
||||
:options="[
|
||||
{ value: 'table', slot: 'table' },
|
||||
{ value: 'card', slot: 'card' },
|
||||
]"
|
||||
>
|
||||
<template v-slot:table>
|
||||
<q-icon
|
||||
name="format_list_bulleted"
|
||||
size="24px"
|
||||
:style="{
|
||||
color: store.mode === 'table' ? '#787B7C' : '#C9D3DB',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template v-slot:card>
|
||||
<q-icon
|
||||
name="mdi-view-grid-outline"
|
||||
size="24px"
|
||||
:style="{
|
||||
color: store.mode === 'card' ? '#787B7C' : '#C9D3DB',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
</q-btn-toggle>
|
||||
</q-toolbar>
|
||||
<d-table
|
||||
ref="table"
|
||||
:card-container-class="mode === 'card' ? 'q-col-gutter-md' : ''"
|
||||
:columns="props.columns"
|
||||
:rows="rows"
|
||||
row-key="name"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:grid="mode === 'card'"
|
||||
:paging="true"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
:card-container-class="store.mode === 'card' ? 'q-col-gutter-md' : ''"
|
||||
:columns="columns"
|
||||
:rows="props.rows"
|
||||
:grid="store.mode === 'card'"
|
||||
:paging="true"
|
||||
v-model:pagination="pagination"
|
||||
:rows-per-page-options="[20, 50, 100]"
|
||||
:visible-columns="visibleColumns"
|
||||
@update:pagination="updatePageSizePagination"
|
||||
>
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
|
|
@ -116,27 +276,44 @@ const rows = [
|
|||
</q-th>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:body="props" v-if="mode === 'table'">
|
||||
<q-tr :props="props" class="cursor-pointer" v-if="mode === 'table'">
|
||||
<template v-slot:body="props" v-if="store.mode === 'table'">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td v-for="col in props.cols" :key="col.id">
|
||||
<template v-if="col.name == 'fullName'">
|
||||
<q-item v-ripple>
|
||||
<q-item-section avatar>
|
||||
<img
|
||||
src="@/assets/avatar_user.jpg"
|
||||
class="col-4 img-info"
|
||||
style="width: 35px; height: 40px; border-radius: 50%"
|
||||
/>
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section>
|
||||
<div class="text-weight-medium">{{ props.row.fullName }}</div>
|
||||
<div class="text-weight-light">{{ props.row.citizenId }}</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<div v-if="col.name === 'no'">
|
||||
{{
|
||||
(formFilter.page - 1) * formFilter.pageSize + props.rowIndex + 1
|
||||
}}
|
||||
</div>
|
||||
<template v-else-if="col.name == 'fullName'">
|
||||
<div class="row col-12 wrap items-center">
|
||||
<q-item>
|
||||
<q-item-section avatar>
|
||||
<q-avatar>
|
||||
<img
|
||||
v-if="props.row.avatar == null"
|
||||
src="@/assets/avatar_user.jpg"
|
||||
class="col-4 img-info"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
:src="props.row.avatar"
|
||||
class="col-4 img-info"
|
||||
/>
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<div class="text-weight-medium">
|
||||
{{
|
||||
`${props.row.prefix}${props.row.firstName} ${props.row.lastName}`
|
||||
}}
|
||||
</div>
|
||||
<div class="text-weight-light">{{ props.row.citizenId }}</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ col.value }}
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</template>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
|
|
@ -152,7 +329,9 @@ const rows = [
|
|||
style="width: 120px; height: 120px; border-radius: 50%"
|
||||
/>
|
||||
<div class="text-weight-medium q-mt-md">
|
||||
{{ props.row.fullName }}
|
||||
{{
|
||||
`${props.row.prefix}${props.row.firstName} ${props.row.lastName}`
|
||||
}}
|
||||
</div>
|
||||
<div class="text-weight-light full-width text-center">
|
||||
{{ props.row.citizenId }}
|
||||
|
|
@ -198,7 +377,48 @@ const rows = [
|
|||
</q-card>
|
||||
</div>
|
||||
</template>
|
||||
<template v-slot:pagination="scope">
|
||||
<q-pagination
|
||||
v-model="formFilter.page"
|
||||
active-color="primary"
|
||||
color="dark"
|
||||
:max="Number(maxPage)"
|
||||
:max-pages="5"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
@update:model-value="updatePagePagination()"
|
||||
></q-pagination>
|
||||
</template>
|
||||
<template v-slot:no-data="{ icon, message, filter }">
|
||||
<div class="full-width row flex-center text-accent q-gutter-sm">
|
||||
<span
|
||||
><div
|
||||
style="
|
||||
height: 50vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
"
|
||||
class="text-grey-5"
|
||||
>
|
||||
<q-icon name="search" size="4rem" />
|
||||
|
||||
<span>ไม่พบข้อมูล</span>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</d-table>
|
||||
|
||||
<DialogAddData
|
||||
v-model:modal="modalDialogAdd"
|
||||
:fetchData="props.fetchData"
|
||||
:fetchType="props.fetchType"
|
||||
/>
|
||||
|
||||
<DialogHistory v-model:modal="modalHistory" />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
|
@ -206,4 +426,8 @@ const rows = [
|
|||
background-color: #089cfc;
|
||||
color: white;
|
||||
}
|
||||
.my-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue