แก้ฟิลเตอร์ระบบ บรรจุ

This commit is contained in:
setthawutttty 2024-12-11 11:49:34 +07:00
parent a15efd7b45
commit b8f336d2ba
7 changed files with 88 additions and 23 deletions

View file

@ -52,7 +52,7 @@ const mixin = useCounterMixin();
const { const {
date2Thai, date2Thai,
success, success,
onSearchDataTable,
messageError, messageError,
showLoader, showLoader,
hideLoader, hideLoader,
@ -82,6 +82,7 @@ const modalHistory = ref<boolean>(false); //modal ประวัติการ
const profileId = ref<string>(""); const profileId = ref<string>("");
const rows = ref<Certificate[]>([]); const rows = ref<Certificate[]>([]);
const rowsData = ref<Certificate[]>([]);
const filter = ref<string>(""); //search data table const filter = ref<string>(""); //search data table
const visibleColumns = ref<String[]>([]); const visibleColumns = ref<String[]>([]);
profileData.certicate.columns.length == 0 profileData.certicate.columns.length == 0
@ -333,6 +334,7 @@ const saveData = async () => {
await props.fetch("Certificate"); await props.fetch("Certificate");
await success($q, "บันทึกข้อมูลสำเร็จ"); await success($q, "บันทึกข้อมูลสำเร็จ");
rows.value = props.data; rows.value = props.data;
rowsData.value = props.data;
modal.value = false; modal.value = false;
}) })
.catch((e) => { .catch((e) => {
@ -359,6 +361,7 @@ const editData = async () => {
await props.fetch("Certificate"); await props.fetch("Certificate");
await success($q, "บันทึกข้อมูลสำเร็จ"); await success($q, "บันทึกข้อมูลสำเร็จ");
rows.value = props.data; rows.value = props.data;
rowsData.value = props.data;
modal.value = false; modal.value = false;
}) })
.catch((e) => { .catch((e) => {
@ -384,6 +387,7 @@ const clickDelete = async () => {
await props.fetch("Certificate"); await props.fetch("Certificate");
await success($q, "ลบข้อมูลสำเร็จ"); await success($q, "ลบข้อมูลสำเร็จ");
rows.value = props.data; rows.value = props.data;
rowsData.value = props.data;
modal.value = false; modal.value = false;
}) })
.catch((e) => { .catch((e) => {
@ -488,6 +492,14 @@ const getClass = (val: boolean) => {
}; };
}; };
function onSearch() {
rows.value = onSearchDataTable(
filter.value,
rowsData.value,
columns.value ? columns.value : []
);
}
watch(visibleColumns, async (count: String[], prevCount: String[]) => { watch(visibleColumns, async (count: String[], prevCount: String[]) => {
changeProfileColumns("certicate", count); changeProfileColumns("certicate", count);
}); });
@ -497,6 +509,7 @@ onMounted(() => {
profileId.value = route.params.personalId.toString(); profileId.value = route.params.personalId.toString();
} }
rows.value = props.data; rows.value = props.data;
rowsData.value = props.data;
}); });
</script> </script>
<template> <template>
@ -505,7 +518,7 @@ onMounted(() => {
<ProfileTable <ProfileTable
:rows="rows" :rows="rows"
:columns="columns" :columns="columns"
:filter="filter" :on-search="onSearch"
:visible-columns="visibleColumns" :visible-columns="visibleColumns"
v-model:inputfilter="filter" v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns" v-model:inputvisible="visibleColumns"

View file

@ -31,6 +31,7 @@ const mixin = useCounterMixin();
const { const {
success, success,
dateToISO, dateToISO,
onSearchDataTable,
date2Thai, date2Thai,
messageError, messageError,
showLoader, showLoader,
@ -95,6 +96,7 @@ const editRow = ref<boolean>(false); //เช็คมีการแก้ไ
const checkValidate = ref<boolean>(false); //validate data const checkValidate = ref<boolean>(false); //validate data
const rows = ref<Education[]>(props.data); const rows = ref<Education[]>(props.data);
const rowsData = ref<Education[]>(props.data);
const filter = ref<string>(""); //search data table const filter = ref<string>(""); //search data table
const visibleColumns = ref<String[]>([]); const visibleColumns = ref<String[]>([]);
@ -456,6 +458,7 @@ const saveData = async () => {
.then(async () => { .then(async () => {
await props.fetch("Education"); await props.fetch("Education");
rows.value = props.data; rows.value = props.data;
rowsData.value = props.data;
success($q, "บันทึกข้อมูลสำเร็จ"); success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false; modal.value = false;
}) })
@ -501,6 +504,7 @@ const editData = async () => {
await props.fetch("Education"); await props.fetch("Education");
success($q, "บันทึกข้อมูลสำเร็จ"); success($q, "บันทึกข้อมูลสำเร็จ");
rows.value = props.data; rows.value = props.data;
rowsData.value = props.data;
modal.value = false; modal.value = false;
}) })
.catch((e) => { .catch((e) => {
@ -524,6 +528,7 @@ const clickDelete = async () => {
await success($q, "ลบข้อมูลสำเร็จ"); await success($q, "ลบข้อมูลสำเร็จ");
modal.value = false; modal.value = false;
rows.value = props.data; rows.value = props.data;
rowsData.value = props.data;
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
@ -669,6 +674,14 @@ const getClass = (val: boolean) => {
}; };
}; };
function onSearch() {
rows.value = onSearchDataTable(
filter.value,
rowsData.value,
columns.value ? columns.value : []
);
}
watch(startDate, (count, prevCount) => { watch(startDate, (count, prevCount) => {
minDate.value = new Date(`${startDate.value}-01-01`); minDate.value = new Date(`${startDate.value}-01-01`);
}); });
@ -691,8 +704,8 @@ onMounted(async () => {
<q-form ref="myForm"> <q-form ref="myForm">
<ProfileTable <ProfileTable
:rows="rows" :rows="rows"
:on-search="onSearch"
:columns="columns" :columns="columns"
:filter="filter"
:visible-columns="visibleColumns" :visible-columns="visibleColumns"
v-model:inputfilter="filter" v-model:inputfilter="filter"
v-model:inputvisible="visibleColumns" v-model:inputvisible="visibleColumns"

View file

@ -11,9 +11,10 @@ const initialPagination = ref<Pagination>({
rowsPerPage: 0, rowsPerPage: 0,
}); });
const inputfilter = defineModel<string>("inputfilter", { required: true });
const props = defineProps({ const props = defineProps({
inputfilter: String,
name: String, name: String,
onSearch: Function,
icon: String, icon: String,
inputvisible: Array, inputvisible: Array,
editvisible: Boolean, editvisible: Boolean,
@ -99,22 +100,16 @@ const resetFilter = () => {
<q-input <q-input
standout standout
dense dense
:model-value="inputfilter" v-model="inputfilter"
ref="filterRef" ref="filterRef"
@update:model-value="updateInput"
outlined outlined
placeholder="ค้นหา" placeholder="ค้นหา"
style="max-width: 200px" style="max-width: 200px"
class="q-ml-sm" class="q-ml-sm"
@keydown.enter="props.onSearch?.()"
> >
<template v-slot:append> <template v-slot:append>
<q-icon v-if="inputfilter == ''" name="search" /> <q-icon name="search" />
<q-icon
v-if="inputfilter !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template> </template>
</q-input> </q-input>
<!-- แสดงคอลมนใน table --> <!-- แสดงคอลมนใน table -->

View file

@ -15,7 +15,7 @@ import { useSelectOrgStore } from "@/modules/05_placement/stores/storeSelect";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
/** use*/ /** use*/
const { date2Thai } = useCounterMixin(); const { date2Thai, onSearchDataTable } = useCounterMixin();
const store = useSelectOrgStore(); const store = useSelectOrgStore();
@ -40,6 +40,7 @@ const optionPosLevel = defineModel<FormPosLevel[]>("optionPosLevel", {
const bmaOfficer = defineModel<string>("bmaOfficer", { required: true }); const bmaOfficer = defineModel<string>("bmaOfficer", { required: true });
const positionRows = ref<DataPositionNo[]>(positionData.value); const positionRows = ref<DataPositionNo[]>(positionData.value);
const positionRowsData = ref<DataPositionNo[]>(positionData.value);
const props = defineProps({ const props = defineProps({
fetchDataTable: Function, fetchDataTable: Function,
@ -231,10 +232,19 @@ async function onClickSelectPos(id: string) {
// } // }
// } // }
function onSearch() {
positionRows.value = onSearchDataTable(
filters.value,
positionRowsData.value,
columns.value ? columns.value : []
);
}
// filter filter // filter filter
watch(positionData, (newVal, oldVal) => { watch(positionData, (newVal, oldVal) => {
if (newVal != oldVal) { if (newVal != oldVal) {
positionRows.value = positionData.value; positionRows.value = positionData.value;
positionRowsData.value = positionData.value;
} }
}); });
@ -248,6 +258,7 @@ onMounted(async () => {
}, 1000); }, 1000);
} else { } else {
positionRows.value = positionData.value; positionRows.value = positionData.value;
positionRowsData.value = positionData.value;
} }
}); });
</script> </script>
@ -349,9 +360,15 @@ onMounted(async () => {
<div class="row q-gutter-md"> <div class="row q-gutter-md">
<div> <div>
<q-input outlined dense v-model="filters" label="ค้นหา"> <q-input
outlined
dense
v-model="filters"
label="ค้นหา"
@keydown.enter="onSearch"
>
<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>
@ -377,7 +394,6 @@ onMounted(async () => {
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="positionRows" :rows="positionRows"
:filter="filters"
row-key="id" row-key="id"
flat flat
bordered bordered

View file

@ -36,7 +36,7 @@ const {
success, success,
dialogConfirm, dialogConfirm,
date2Thai, date2Thai,
onSearchDataTable onSearchDataTable,
} = mixin; } = mixin;
/** รับค่ามาจากหน้าหลัก */ /** รับค่ามาจากหน้าหลัก */
@ -67,6 +67,7 @@ const rows = ref<any[]>([]);
const rowsData = ref<any[]>([]); const rowsData = ref<any[]>([]);
const rowsAwait = ref<any[]>([]); const rowsAwait = ref<any[]>([]);
const rowsFilter = ref<any>([]); const rowsFilter = ref<any>([]);
const rowsFilterData = ref<any>([]);
const rowsOrder = ref<any[]>([]); const rowsOrder = ref<any[]>([]);
const myForm = ref<any>(); const myForm = ref<any>();
const files = ref<any>(null); const files = ref<any>(null);
@ -402,6 +403,12 @@ async function getTable() {
e.nodeName !== null && e.nodeName !== null &&
e.reportingDate !== null e.reportingDate !== null
); );
rowsFilterData.value = await rows.value.filter(
(e: any) =>
e.draft == "รอส่งตัว" &&
e.nodeName !== null &&
e.reportingDate !== null
);
DataStore.checkLoad(1); DataStore.checkLoad(1);
// insertAvatar(rows.value); // insertAvatar(rows.value);
}) })
@ -838,6 +845,14 @@ function onSearch() {
); );
} }
function onSearchAdd() {
rowsFilter.value = onSearchDataTable(
filterlistAdd.value,
rowsFilterData.value,
columns.value ? columns.value : []
);
}
onMounted(async () => { onMounted(async () => {
await getWorkFlow(); await getWorkFlow();
await getTable(); await getTable();
@ -1406,6 +1421,7 @@ onMounted(async () => {
v-model="filterlistAdd" v-model="filterlistAdd"
placeholder="ค้นหา" placeholder="ค้นหา"
style="width: 850px; max-width: auto" style="width: 850px; max-width: auto"
@keydown.enter="onSearchAdd"
> >
<template v-slot:append> <template v-slot:append>
<q-icon name="search" /> <q-icon name="search" />
@ -1422,7 +1438,6 @@ onMounted(async () => {
map-options map-options
:options="columns" :options="columns"
option-value="name" option-value="name"
style="min-width: 140px" style="min-width: 140px"
class="gt-xs q-ml-sm" class="gt-xs q-ml-sm"
/> />
@ -1436,7 +1451,6 @@ onMounted(async () => {
dense dense
:rows="rowsFilter" :rows="rowsFilter"
:columns="columns" :columns="columns"
:filter="filterlistAdd"
row-key="name" row-key="name"
class="custom-header-table" class="custom-header-table"
selection="multiple" selection="multiple"

View file

@ -14,7 +14,7 @@ import DialogCreateCommand from "@/modules/18_command/components/DialogCreateCom
const $q = useQuasar(); const $q = useQuasar();
const selected = ref<AppointMainRows[]>([]); const selected = ref<AppointMainRows[]>([]);
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { dialogConfirm } = mixin; const { dialogConfirm, onSearchDataTable } = mixin;
const dataMapToSend = computed(() => { const dataMapToSend = computed(() => {
return selected.value.map((i: any) => ({ return selected.value.map((i: any) => ({
@ -29,6 +29,7 @@ const dataMapToSend = computed(() => {
const filterKeyword = defineModel<string>("filterKeyword", { required: true }); const filterKeyword = defineModel<string>("filterKeyword", { required: true });
const rows = defineModel<AppointMainRows[]>("rows", { required: true }); const rows = defineModel<AppointMainRows[]>("rows", { required: true });
const rowsData = defineModel<AppointMainRows[]>("rowsData", { required: true });
/** props*/ /** props*/
const props = defineProps({ const props = defineProps({
modal: Boolean, modal: Boolean,
@ -130,6 +131,14 @@ function convertText(val: string) {
} }
} }
function onSearch() {
rows.value = onSearchDataTable(
filterKeyword.value,
rowsData.value,
columns.value ? columns.value : []
);
}
watchEffect(() => { watchEffect(() => {
if (props.modal === true) { if (props.modal === true) {
selected.value = []; selected.value = [];
@ -153,6 +162,7 @@ watchEffect(() => {
dense dense
placeholder="ค้นหา" placeholder="ค้นหา"
v-model="filterKeyword" v-model="filterKeyword"
@keydown.enter="onSearch"
> >
<template v-slot:append> <template v-slot:append>
<q-icon name="search" /> <q-icon name="search" />
@ -178,7 +188,6 @@ watchEffect(() => {
<d-table <d-table
:columns="columns" :columns="columns"
:rows="rows" :rows="rows"
:filter="filterKeyword.trim()"
row-key="id" row-key="id"
:visible-columns="visibleColumns" :visible-columns="visibleColumns"
selection="single" selection="single"

View file

@ -26,6 +26,7 @@ const router = useRouter();
const rows = ref<AppointMainRows[]>([]); const rows = ref<AppointMainRows[]>([]);
const rowsData = ref<AppointMainRows[]>([]); const rowsData = ref<AppointMainRows[]>([]);
const rowsOrder = ref<AppointMainRows[]>([]); const rowsOrder = ref<AppointMainRows[]>([]);
const rowsOrderData = ref<AppointMainRows[]>([]);
const filterKeyword = ref<string>(""); const filterKeyword = ref<string>("");
const filterKeywordOrder = ref<string>(""); const filterKeywordOrder = ref<string>("");
@ -153,14 +154,17 @@ function convertText(val: string) {
function onSendOrder() { function onSendOrder() {
modalOrder.value = true; modalOrder.value = true;
rowsOrder.value = rows.value.filter( const listData = rows.value.filter(
(item: AppointMainRows) => item.status == "PENDING" (item: AppointMainRows) => item.status == "PENDING"
); );
rowsOrder.value = listData;
rowsOrderData.value = listData;
} }
function closeModal() { function closeModal() {
modalOrder.value = false; modalOrder.value = false;
rowsOrder.value = []; rowsOrder.value = [];
rowsOrderData.value = [];
} }
function onSearch() { function onSearch() {
@ -313,6 +317,7 @@ onMounted(async () => {
v-model:modal="modalOrder" v-model:modal="modalOrder"
:close-modal="closeModal" :close-modal="closeModal"
v-model:rows="rowsOrder" v-model:rows="rowsOrder"
v-model:rowsData="rowsOrderData"
v-model:filter-keyword="filterKeywordOrder" v-model:filter-keyword="filterKeywordOrder"
:get-data="getData" :get-data="getData"
/> />