Merge branch 'oat_dev' into develop
This commit is contained in:
commit
d7953fc64e
3 changed files with 143 additions and 207 deletions
|
|
@ -105,7 +105,7 @@ const historyRows = ref<ResponseObject[]>([]);
|
|||
|
||||
const pagination = ref({
|
||||
page: 1,
|
||||
rowsPerPage: 2,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
|
||||
const visibleColumns = ref<string[]>([
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, watch, onMounted } from "vue";
|
||||
import { ref, reactive, onMounted } from "vue";
|
||||
import dialogHeader from "@/components/DialogHeader.vue";
|
||||
import type { QTableProps } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
|
@ -148,8 +148,10 @@ const isDate = ref<string>("false");
|
|||
const dialogStatus = ref<string>("create");
|
||||
const historyDialog = ref<boolean>(false);
|
||||
const editId = ref<string>("");
|
||||
|
||||
const keyword = ref<string>("");
|
||||
const historyKeyword = ref<string>("");
|
||||
const trainData = reactive<RequestItemsObject>({
|
||||
profileId: id.value,
|
||||
name: "",
|
||||
topic: "",
|
||||
yearly: new Date().getFullYear(),
|
||||
|
|
@ -162,28 +164,12 @@ const trainData = reactive<RequestItemsObject>({
|
|||
endDate: new Date(),
|
||||
startYear: new Date().getFullYear(),
|
||||
finishYear: new Date().getFullYear(),
|
||||
});
|
||||
|
||||
const formFilter = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
keyword: "",
|
||||
isDate: isDate.value === "false" ? false : true,
|
||||
});
|
||||
|
||||
const pagination = ref({
|
||||
page: formFilter.page,
|
||||
rowsPerPage: formFilter.pageSize,
|
||||
});
|
||||
|
||||
const historyFormFilter = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
keyword: "",
|
||||
});
|
||||
|
||||
const historyPagination = ref({
|
||||
page: historyFormFilter.page,
|
||||
rowsPerPage: historyFormFilter.pageSize,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
|
||||
const rows = ref<ResponseObject[]>([]);
|
||||
|
|
@ -215,10 +201,6 @@ const historyVisibleColumns = ref<string[]>([
|
|||
"endDate", // วันสิ้นสุด
|
||||
]);
|
||||
|
||||
function validateForm() {
|
||||
onSubmit();
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
dialogConfirm(
|
||||
$q,
|
||||
|
|
@ -267,19 +249,9 @@ function editForm(row: any) {
|
|||
async function addData() {
|
||||
await http
|
||||
.post(config.API.profileNewTraining, {
|
||||
profileId: id.value,
|
||||
name: trainData.name,
|
||||
topic: trainData.topic ? trainData.topic : "",
|
||||
yearly: trainData.yearly,
|
||||
place: trainData.place ? trainData.place : "",
|
||||
duration: trainData.duration ? trainData.duration : "",
|
||||
department: trainData.department ? trainData.department : "",
|
||||
numberOrder: trainData.numberOrder ? trainData.numberOrder : "",
|
||||
dateOrder: trainData.dateOrder,
|
||||
startDate: trainData.startDate,
|
||||
endDate: trainData.endDate,
|
||||
isDate: isDate.value === "true" ? true : false,
|
||||
isActive: true,
|
||||
...trainData,
|
||||
startYear: undefined,
|
||||
endYear: undefined,
|
||||
})
|
||||
.then(() => {
|
||||
fetchData(id.value);
|
||||
|
|
@ -296,18 +268,10 @@ async function addData() {
|
|||
async function editData(idData: string) {
|
||||
await http
|
||||
.patch(config.API.profileNewTrainingByTrainingId(idData), {
|
||||
name: trainData.name,
|
||||
topic: trainData.topic ? trainData.topic : "",
|
||||
yearly: trainData.yearly,
|
||||
place: trainData.place ? trainData.place : "",
|
||||
duration: trainData.duration ? trainData.duration : "",
|
||||
department: trainData.department ? trainData.department : "",
|
||||
numberOrder: trainData.numberOrder ? trainData.numberOrder : "",
|
||||
dateOrder: trainData.dateOrder,
|
||||
startDate: trainData.startDate,
|
||||
endDate: trainData.endDate,
|
||||
isDate: isDate.value === "true" ? true : false,
|
||||
isActive: true,
|
||||
...trainData,
|
||||
profileId: undefined,
|
||||
startYear: undefined,
|
||||
finishYear: undefined,
|
||||
})
|
||||
.then(() => {
|
||||
fetchData(id.value);
|
||||
|
|
@ -321,18 +285,21 @@ async function editData(idData: string) {
|
|||
});
|
||||
}
|
||||
|
||||
async function deleteData(idData: string) {
|
||||
await http
|
||||
.delete(config.API.profileNewTrainingByTrainingId(idData))
|
||||
.then(() => {
|
||||
fetchData(id.value);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
function deleteData(idData: string) {
|
||||
dialogRemove($q, () =>
|
||||
http
|
||||
.delete(config.API.profileNewTrainingByTrainingId(idData))
|
||||
.then(() => {
|
||||
fetchData(id.value);
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
|
|
@ -343,62 +310,13 @@ function closeHistoryDialog() {
|
|||
historyDialog.value = false;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => isDate.value,
|
||||
() => {
|
||||
if (isDate.value === "false") {
|
||||
console.log(trainData.startDate);
|
||||
trainData.startYear = +trainData.startDate.toString().slice(11, 15);
|
||||
trainData.finishYear = +trainData.endDate.toString().slice(11, 15);
|
||||
trainData.startDate = new Date(trainData.startYear + "-01-01");
|
||||
trainData.endDate = new Date(trainData.finishYear + "-01-01");
|
||||
} else {
|
||||
trainData.startDate = new Date(trainData.startYear + "-01-01");
|
||||
trainData.endDate = new Date(trainData.finishYear + "-01-01");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => trainData.startYear,
|
||||
() => {
|
||||
if (isDate.value === "false") {
|
||||
trainData.startDate = new Date(trainData.startYear + "-01-01");
|
||||
}
|
||||
}
|
||||
);
|
||||
watch(
|
||||
() => trainData.finishYear,
|
||||
() => {
|
||||
if (isDate.value === "false") {
|
||||
trainData.endDate = new Date(trainData.finishYear + "-01-01");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => trainData.startDate,
|
||||
() => {
|
||||
if (isDate.value === "true") {
|
||||
trainData.startYear = +trainData.startDate.toString().slice(11, 15);
|
||||
}
|
||||
}
|
||||
);
|
||||
watch(
|
||||
() => trainData.endDate,
|
||||
() => {
|
||||
if (isDate.value === "true") {
|
||||
trainData.finishYear = +trainData.endDate.toString().slice(11, 15);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
async function fetchData(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.profileNewTrainingByProfileId(id))
|
||||
.then(async (res) => {
|
||||
rows.value = res.data.result;
|
||||
console.log(res.data.result);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -449,13 +367,7 @@ onMounted(async () => {
|
|||
>
|
||||
|
||||
<q-space />
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model="formFilter.keyword"
|
||||
label="ค้นหา"
|
||||
class="q-mr-sm"
|
||||
>
|
||||
<q-input dense outlined v-model="keyword" label="ค้นหา" class="q-mr-sm">
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
|
|
@ -519,7 +431,7 @@ onMounted(async () => {
|
|||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
:filter="formFilter.keyword"
|
||||
:filter="keyword"
|
||||
:rows-per-page-options="[20, 50, 100]"
|
||||
v-model:pagination="pagination"
|
||||
class="custom-header-table"
|
||||
|
|
@ -579,9 +491,7 @@ onMounted(async () => {
|
|||
size="14px"
|
||||
icon="mdi-delete"
|
||||
clickable
|
||||
@click.stop="
|
||||
dialogRemove($q, async () => await deleteData(props.row.id))
|
||||
"
|
||||
@click.stop="deleteData(props.row.id)"
|
||||
v-close-popup
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
|
|
@ -642,7 +552,7 @@ onMounted(async () => {
|
|||
|
||||
<q-dialog v-model="dialog" class="dialog" persistent>
|
||||
<q-card style="min-width: 40%" class="bg-white">
|
||||
<q-form @submit.prevent greedy @validation-success="validateForm">
|
||||
<q-form @submit.prevent greedy @validation-success="onSubmit()">
|
||||
<q-card-section class="flex justify-between" style="padding: 0">
|
||||
<dialog-header
|
||||
:tittle="dialogStatus == 'edit' ? 'แก้ไขข้อมูล' : 'เพิ่มข้อมูล'"
|
||||
|
|
@ -651,7 +561,7 @@ onMounted(async () => {
|
|||
</q-card-section>
|
||||
<q-separator color="grey-4" />
|
||||
<div class="col">
|
||||
<q-card-section class="row q-gutter-sm">
|
||||
<div class="row q-px-md q-mt-sm q-mb-sm q-gutter-sm">
|
||||
<div class="col">
|
||||
<q-input
|
||||
outlined
|
||||
|
|
@ -679,8 +589,12 @@ onMounted(async () => {
|
|||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card flat bordered class="q-px-sm q-mx-md q-mb q-pb-sm borderCard">
|
||||
</div>
|
||||
<q-card
|
||||
flat
|
||||
bordered
|
||||
class="q-px-sm q-mx-md q-my-md q-pb-sm borderCard"
|
||||
>
|
||||
<div class="row col-12 q-gutter-md q-py-sm text-grey-7">
|
||||
<q-radio
|
||||
v-model="isDate"
|
||||
|
|
@ -708,7 +622,12 @@ onMounted(async () => {
|
|||
autoApply
|
||||
year-picker
|
||||
:enableTimePicker="false"
|
||||
@update:modelValue="trainData.startYear"
|
||||
@update:modelValue="
|
||||
(v:number) =>
|
||||
(trainData.startDate = new Date(
|
||||
`${v}-01-01T00:00:02.010+07:00`
|
||||
))
|
||||
"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
|
|
@ -748,7 +667,12 @@ onMounted(async () => {
|
|||
autoApply
|
||||
year-picker
|
||||
:enableTimePicker="false"
|
||||
@update:modelValue="trainData.finishYear"
|
||||
@update:modelValue="
|
||||
(v:number) =>
|
||||
(trainData.endDate = new Date(
|
||||
`${v}-01-01T00:00:02.010+07:00`
|
||||
))
|
||||
"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
|
|
@ -789,6 +713,12 @@ onMounted(async () => {
|
|||
autoApply
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
@update:modelValue="
|
||||
(v: Date) =>
|
||||
(trainData.startYear = parseInt(
|
||||
v.toString().slice(11, 15)
|
||||
))
|
||||
"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
|
|
@ -828,6 +758,12 @@ onMounted(async () => {
|
|||
autoApply
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
@update:modelValue="
|
||||
(v: Date) =>
|
||||
(trainData.finishYear = parseInt(
|
||||
v.toString().slice(11, 15)
|
||||
))
|
||||
"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
|
|
@ -860,7 +796,7 @@ onMounted(async () => {
|
|||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
<q-card-section class="row q-gutter-sm q-pt-sm q-py-none">
|
||||
<div class="row q-px-md q-mb-sm q-gutter-sm">
|
||||
<div class="col">
|
||||
<datepicker
|
||||
menu-class-name="modalfix"
|
||||
|
|
@ -909,8 +845,8 @@ onMounted(async () => {
|
|||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row q-gutter-sm q-pt-sm q-pb-none">
|
||||
</div>
|
||||
<div class="row q-px-md q-mb-sm q-gutter-sm">
|
||||
<div class="col">
|
||||
<q-input
|
||||
outlined
|
||||
|
|
@ -929,8 +865,8 @@ onMounted(async () => {
|
|||
dense
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row q-gutter-sm q-pt-sm q-pb-none">
|
||||
</div>
|
||||
<div class="row q-px-md q-mb-sm q-gutter-sm">
|
||||
<div class="col">
|
||||
<q-input
|
||||
outlined
|
||||
|
|
@ -974,7 +910,7 @@ onMounted(async () => {
|
|||
</template>
|
||||
</datepicker>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</div>
|
||||
</div>
|
||||
<q-card-actions align="right">
|
||||
<q-btn
|
||||
|
|
@ -995,81 +931,79 @@ onMounted(async () => {
|
|||
|
||||
<q-dialog v-model="historyDialog" class="dialog" persistent>
|
||||
<q-card style="min-width: 70%" class="bg-white">
|
||||
<q-form @submit.prevent greedy @validation-success="validateForm">
|
||||
<q-card-section class="flex justify-between" style="padding: 0">
|
||||
<dialog-header
|
||||
tittle="ประวัติแก้ไขการฝึกอบรม/ดูงาน"
|
||||
:close="closeHistoryDialog"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-separator color="grey-4" />
|
||||
<q-card-section>
|
||||
<q-toolbar style="padding: 0px" class="text-primary q-mb-sm">
|
||||
<q-space />
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
bg-color="white"
|
||||
v-model="historyFormFilter.keyword"
|
||||
label="ค้นหา"
|
||||
class="q-mr-sm"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-select
|
||||
v-model="historyVisibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
bg-color="white"
|
||||
options-dense
|
||||
:display-value="$q.lang.table.columns"
|
||||
emit-value
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
options-cover
|
||||
style="min-width: 150px"
|
||||
/>
|
||||
</q-toolbar>
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="historyRows"
|
||||
row-key="name"
|
||||
flat
|
||||
:filter="historyFormFilter.keyword"
|
||||
v-model:pagination="historyPagination"
|
||||
bordered
|
||||
:paging="true"
|
||||
<q-card-section class="flex justify-between" style="padding: 0">
|
||||
<dialog-header
|
||||
tittle="ประวัติแก้ไขการฝึกอบรม/ดูงาน"
|
||||
:close="closeHistoryDialog"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-separator color="grey-4" />
|
||||
<q-card-section>
|
||||
<q-toolbar style="padding: 0px" class="text-primary q-mb-sm">
|
||||
<q-space />
|
||||
<q-input
|
||||
dense
|
||||
:rows-per-page-options="[20, 50, 100]"
|
||||
class="custom-header-table"
|
||||
:visible-columns="historyVisibleColumns"
|
||||
outlined
|
||||
bg-color="white"
|
||||
v-model="historyKeyword"
|
||||
label="ค้นหา"
|
||||
class="q-mr-sm"
|
||||
>
|
||||
<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 v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td v-for="col in props.cols" :key="col.id">
|
||||
<div>
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</q-card-section>
|
||||
</q-form>
|
||||
</q-input>
|
||||
|
||||
<q-select
|
||||
v-model="historyVisibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
bg-color="white"
|
||||
options-dense
|
||||
:display-value="$q.lang.table.columns"
|
||||
emit-value
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
options-cover
|
||||
style="min-width: 150px"
|
||||
/>
|
||||
</q-toolbar>
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="historyRows"
|
||||
row-key="name"
|
||||
flat
|
||||
:filter="historyKeyword"
|
||||
v-model:pagination="pagination"
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
:rows-per-page-options="[20, 50, 100]"
|
||||
class="custom-header-table"
|
||||
:visible-columns="historyVisibleColumns"
|
||||
>
|
||||
<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.id">
|
||||
<div>
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ interface RequestItemsObject {
|
|||
endDate: Date,
|
||||
startYear: number,
|
||||
finishYear: number,
|
||||
profileId: string,
|
||||
isDate: boolean,
|
||||
}
|
||||
|
||||
export type { RequestItemsObject };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue