fix bug โครงสร้าง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-12-03 16:27:30 +07:00
parent daecd9524a
commit 62e7284d5d
6 changed files with 118 additions and 90 deletions

View file

@ -67,6 +67,7 @@ const props = defineProps({
type: Object, type: Object,
required: true, required: true,
}, },
fetchDataTable: Function,
}); });
const title = ref<string>("ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน"); //title Dialog const title = ref<string>("ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน"); //title Dialog
@ -93,14 +94,6 @@ const isDisable = computed(() => {
} else return false; } else return false;
}); });
/**
* function เช filter
*/
function resetFilter() {
filterTree.value = "";
filterRef.value.focus();
}
/** /**
* function เลอกขอมลหนวยงาน * function เลอกขอมลหนวยงาน
*/ */
@ -157,6 +150,12 @@ function updatePagination(newPagination: NewPagination) {
reqMaster.value.page = 1; reqMaster.value.page = 1;
} }
function onSearchData() {
reqMaster.value.page = 1;
reqMaster.value.keyword = filterTable.value;
props.fetchDataTable?.(store.treeId, store.level, false);
}
/** /**
* การเปลยนแปลง modal เมอเป true * การเปลยนแปลง modal เมอเป true
*/ */
@ -165,6 +164,7 @@ watch(
() => { () => {
reqMaster.value.page = 1; reqMaster.value.page = 1;
filterTree.value = ""; filterTree.value = "";
filterTable.value = "";
pagination.value.rowsPerPage = reqMaster.value.pageSize; pagination.value.rowsPerPage = reqMaster.value.pageSize;
title.value = `ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน ${props.mainTree.orgName}`; title.value = `ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน ${props.mainTree.orgName}`;
@ -190,7 +190,10 @@ watch(
> >
<q-header> <q-header>
<q-toolbar> <q-toolbar>
<HeaderDialog :tittle="title" :close="() => (modal = false)" /> <HeaderDialog
:tittle="title"
:close="() => ((modal = false), (reqMaster.keyword = ''))"
/>
</q-toolbar> </q-toolbar>
<q-separator color="grey-4" /> <q-separator color="grey-4" />
</q-header> </q-header>
@ -206,7 +209,13 @@ watch(
<q-space /> <q-space />
<div> <div>
<q-input outlined dense v-model="filterTable" label="ค้นหา"> <q-input
outlined
dense
v-model="filterTable"
label="ค้นหา"
@keydown.enter="onSearchData"
>
<template v-slot:append> <template v-slot:append>
<q-icon name="search" /> <q-icon name="search" />
</template> </template>
@ -214,71 +223,72 @@ watch(
</div> </div>
</q-toolbar> </q-toolbar>
<d-table <div class="col-12">
flat <d-table
bordered flat
:rows="rows" bordered
:columns="columns" :rows="rows"
row-key="id" :columns="columns"
:filter="filterTable.trim()" row-key="id"
no-data-label="ไม่มีข้อมูล" no-data-label="ไม่มีข้อมูล"
selection="multiple" selection="multiple"
v-model:selected="selectedFilter" v-model:selected="selectedFilter"
:rows-per-page-options="[10, 25, 50, 100]" :rows-per-page-options="[10, 25, 50, 100]"
v-model:pagination="pagination" v-model:pagination="pagination"
@update:pagination="updatePagination" @update:pagination="updatePagination"
> >
<template v-slot:header-selection="scope"> <template v-slot:header-selection="scope">
<q-checkbox <q-checkbox
keep-color keep-color
color="primary" color="primary"
dense dense
v-model="scope.selected" v-model="scope.selected"
/> />
</template> </template>
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr :props="props"> <q-tr :props="props">
<q-td> <q-td>
<q-checkbox <q-checkbox
keep-color keep-color
color="primary" color="primary"
dense dense
v-model="props.selected" v-model="props.selected"
/> />
</q-td> </q-td>
<q-td <q-td
v-for="col in props.cols" v-for="col in props.cols"
:key="col.name" :key="col.name"
:props="props" :props="props"
> >
<div v-if="col.name == 'no'"> <div v-if="col.name == 'no'">
{{ {{
(reqMaster.page - 1) * Number(reqMaster.pageSize) + (reqMaster.page - 1) * Number(reqMaster.pageSize) +
props.rowIndex + props.rowIndex +
1 1
}} }}
</div> </div>
<div v-else> <div v-else>
{{ col.value }} {{ col.value }}
</div> </div>
</q-td> </q-td>
</q-tr> </q-tr>
</template> </template>
<template v-slot:pagination="scope"> <template v-slot:pagination="scope">
<q-pagination <q-pagination
v-model="reqMaster.page" v-model="reqMaster.page"
active-color="primary" active-color="primary"
color="dark" color="dark"
:max="totalPage" :max="totalPage"
:max-pages="5" :max-pages="5"
size="sm" size="sm"
boundary-links boundary-links
direction-links direction-links
></q-pagination> ></q-pagination>
</template> </template>
</d-table> </d-table>
</div>
</q-card> </q-card>
<q-card <q-card

View file

@ -106,6 +106,7 @@ async function fetchDataTable(id: string, level: number, action: boolean) {
: store.historyId; : store.historyId;
isLoad.value = true; isLoad.value = true;
} }
posMaster.value = [];
await http await http
.post(config.API.orgPosMasterList, { .post(config.API.orgPosMasterList, {
@ -113,7 +114,6 @@ async function fetchDataTable(id: string, level: number, action: boolean) {
keyword: reqMaster.keyword.trim(), keyword: reqMaster.keyword.trim(),
}) })
.then(async (res) => { .then(async (res) => {
posMaster.value = [];
const dataMain: PosMaster[] = []; const dataMain: PosMaster[] = [];
totalPage.value = Math.ceil(res.data.result.total / reqMaster.pageSize); totalPage.value = Math.ceil(res.data.result.total / reqMaster.pageSize);
res.data.result.data.forEach((e: PosMaster) => { res.data.result.data.forEach((e: PosMaster) => {

View file

@ -528,6 +528,10 @@ watch(
if (!modalDialogMMove.value) { if (!modalDialogMMove.value) {
pagination.value.page = 1; pagination.value.page = 1;
pagination.value.rowsPerPage = reqMaster.value.pageSize; pagination.value.rowsPerPage = reqMaster.value.pageSize;
if (posMaster.value.length === 0) {
props.fetchDataTable?.(reqMaster.value.id, reqMaster.value.type, false);
}
} }
} }
); );
@ -616,7 +620,7 @@ watch(
@keydown.enter.prevent="props.filterKeyword(reqMaster.keyword)" @keydown.enter.prevent="props.filterKeyword(reqMaster.keyword)"
> >
<template v-slot:append> <template v-slot:append>
<q-icon name="search" color="grey-5" /> <q-icon name="search" />
</template> </template>
</q-input> </q-input>
</div> </div>
@ -936,6 +940,7 @@ watch(
:type="typeMove" :type="typeMove"
:rowId="rowId" :rowId="rowId"
:mainTree="props.mainTree ? props.mainTree : []" :mainTree="props.mainTree ? props.mainTree : []"
:fetchDataTable="props.fetchDataTable"
/> />
<!-- ประวตำแหน --> <!-- ประวตำแหน -->

View file

@ -41,7 +41,6 @@ const {
messageError, messageError,
dialogMessageNotify, dialogMessageNotify,
success, success,
onSearchDataTable,
} = useCounterMixin(); } = useCounterMixin();
/** /**
@ -70,6 +69,7 @@ const props = defineProps({
type: Object, type: Object,
required: true, required: true,
}, },
fetchDataTable: Function,
}); });
const title = ref<string>("ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน"); const title = ref<string>("ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน");
@ -80,7 +80,14 @@ const levelTree = ref<number>(0);
const filterTable = ref<string>(""); const filterTable = ref<string>("");
const selectedFilter = ref<PosMaster2[]>([]); const selectedFilter = ref<PosMaster2[]>([]);
const dataMain = ref<PosMaster2[]>([...rows.value]);
/**
* function เช filter
*/
function resetFilter() {
filterTree.value = "";
filterRef.value.focus();
}
/** /**
* function เลอกขอมลหนวยงาน * function เลอกขอมลหนวยงาน
@ -149,12 +156,10 @@ const pagination = ref({
rowsPerPage: reqMaster.value.pageSize, rowsPerPage: reqMaster.value.pageSize,
}); });
function onSearchTable() { function onSearchData() {
rows.value = onSearchDataTable( reqMaster.value.page = 1;
filterTable.value, reqMaster.value.keyword = filterTable.value;
dataMain.value, props.fetchDataTable?.(store.treeId, store.level, false);
columns.value ? columns.value : []
);
} }
watch( watch(
@ -162,9 +167,8 @@ watch(
() => { () => {
reqMaster.value.page = 1; reqMaster.value.page = 1;
filterTree.value = ""; filterTree.value = "";
pagination.value.rowsPerPage = reqMaster.value.pageSize;
dataMain.value = rows.value;
filterTable.value = ""; filterTable.value = "";
pagination.value.rowsPerPage = reqMaster.value.pageSize;
title.value = `ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน ${props.mainTree.orgName}`; title.value = `ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน ${props.mainTree.orgName}`;
if (modal.value && props.type === "SINGER") { if (modal.value && props.type === "SINGER") {
@ -188,7 +192,10 @@ watch(
> >
<q-header> <q-header>
<q-toolbar> <q-toolbar>
<HeaderDialog :tittle="title" :close="() => (modal = false)" /> <HeaderDialog
:tittle="title"
:close="() => ((modal = false), (reqMaster.keyword = ''))"
/>
</q-toolbar> </q-toolbar>
<q-separator color="grey-4" /> <q-separator color="grey-4" />
</q-header> </q-header>
@ -209,7 +216,7 @@ watch(
dense dense
v-model="filterTable" v-model="filterTable"
label="ค้นหา" label="ค้นหา"
@keydown.enter="onSearchTable" @keydown.enter="onSearchData"
> >
<template v-slot:append> <template v-slot:append>
<q-icon name="search" /> <q-icon name="search" />
@ -217,6 +224,7 @@ watch(
</q-input> </q-input>
</div> </div>
</q-toolbar> </q-toolbar>
<div class="col-12"> <div class="col-12">
<d-table <d-table
flat flat
@ -227,7 +235,7 @@ watch(
no-data-label="ไม่มีข้อมูล" no-data-label="ไม่มีข้อมูล"
selection="multiple" selection="multiple"
v-model:selected="selectedFilter" v-model:selected="selectedFilter"
:rows-per-page-options="[10, 25, 50, 100]" :rows-per-page-options="[1, 10, 25, 50, 100]"
v-model:pagination="pagination" v-model:pagination="pagination"
@update:pagination="updatePagination" @update:pagination="updatePagination"
> >

View file

@ -366,6 +366,10 @@ watch(
if (!modalDialogMMove.value) { if (!modalDialogMMove.value) {
pagination.value.page = 1; pagination.value.page = 1;
pagination.value.rowsPerPage = reqMaster.value.pageSize; pagination.value.rowsPerPage = reqMaster.value.pageSize;
if (posMaster.value.length === 0) {
props.fetchDataTable?.(reqMaster.value.id, reqMaster.value.type, false);
}
} }
} }
); );
@ -475,7 +479,7 @@ watch(
bordered bordered
:paging="true" :paging="true"
dense dense
:rows-per-page-options="[10, 25, 50, 100]" :rows-per-page-options="[1, 10, 25, 50, 100]"
@update:pagination="updatePagination" @update:pagination="updatePagination"
class="tableTb" class="tableTb"
v-model:pagination="pagination" v-model:pagination="pagination"
@ -682,6 +686,7 @@ watch(
:type="typeMove" :type="typeMove"
:rowId="rowId" :rowId="rowId"
:mainTree="props.mainTree ? props.mainTree : []" :mainTree="props.mainTree ? props.mainTree : []"
:fetchDataTable="props.fetchDataTable"
/> />
<!-- ประวตำแหน --> <!-- ประวตำแหน -->

View file

@ -94,10 +94,10 @@ function fetchDataTable(id: string, level: number, action: boolean) {
if (action === true) { if (action === true) {
isLoad.value = true; isLoad.value = true;
} }
posMaster.value = [];
http http
.post(config.API.orgPosMasterListEmp, reqMaster) .post(config.API.orgPosMasterListEmp, reqMaster)
.then(async (res) => { .then(async (res) => {
posMaster.value = [];
const dataMain: PosMaster[] = []; const dataMain: PosMaster[] = [];
totalPage.value = Math.ceil(res.data.result.total / reqMaster.pageSize); totalPage.value = Math.ceil(res.data.result.total / reqMaster.pageSize);
res.data.result.data.forEach((e: PosMaster) => { res.data.result.data.forEach((e: PosMaster) => {