filter ==> จัดการผู้ใช้งาน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-12-11 15:12:22 +07:00
parent 8c7bd47d37
commit 404a47e78b
7 changed files with 66 additions and 85 deletions

View file

@ -23,6 +23,7 @@ const {
messageError, messageError,
success, success,
dialogMessageNotify, dialogMessageNotify,
onSearchDataTable,
} = useCounterMixin(); } = useCounterMixin();
/** props*/ /** props*/
@ -41,6 +42,8 @@ const props = defineProps({
}); });
const rows = ref<Roles[]>([]); const rows = ref<Roles[]>([]);
const rowsMain = ref<Roles[]>([]);
const keyword = ref<string>("");
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
name: "roleName", name: "roleName",
@ -63,12 +66,12 @@ const columns = ref<QTableProps["columns"]>([
]); ]);
const visibleColumns = ref<string[]>(["roleName", "roleDescription"]); const visibleColumns = ref<string[]>(["roleName", "roleDescription"]);
const keyword = ref<string>("");
const selected = ref<Roles[]>([]); const selected = ref<Roles[]>([]);
function closeDialog() { function closeDialog() {
modal.value = false; modal.value = false;
selected.value = []; selected.value = [];
keyword.value = "";
} }
function fetchListRoles() { function fetchListRoles() {
@ -78,6 +81,7 @@ function fetchListRoles() {
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
rows.value = data; rows.value = data;
rowsMain.value = data;
const findRole = data.find( const findRole = data.find(
(e: Roles) => e.id === props.dataPosMaster.authRoleId (e: Roles) => e.id === props.dataPosMaster.authRoleId
); );
@ -124,6 +128,14 @@ function onSubmit() {
} }
} }
function serchDataTable() {
rows.value = onSearchDataTable(
keyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
watch( watch(
() => modal.value, () => modal.value,
() => { () => {
@ -140,9 +152,15 @@ watch(
<q-card-section> <q-card-section>
<div class="row q-col-gutter-sm"> <div class="row q-col-gutter-sm">
<div class="col-12"> <div class="col-12">
<q-input outlined dense v-model="keyword" label="ค้นหา"> <q-input
outlined
dense
v-model="keyword"
label="ค้นหา"
@keydown.enter.pervent="serchDataTable"
>
<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>
@ -151,7 +169,6 @@ watch(
ref="table" ref="table"
:columns="columns" :columns="columns"
:rows="rows" :rows="rows"
:filter="keyword"
row-key="id" row-key="id"
flat flat
bordered bordered
@ -162,15 +179,6 @@ watch(
selection="single" selection="single"
v-model:selected="selected" v-model:selected="selected"
> >
<!-- <template v-slot:header-selection="scope">
<q-checkbox
keep-color
color="primary"
dense
v-model="scope.selected"
/>
</template> -->
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer"> <q-tr :props="props" class="cursor-pointer">
<q-td> <q-td>

View file

@ -208,15 +208,18 @@ watch(
dense dense
v-model="qurey.searchKeyword" v-model="qurey.searchKeyword"
label="คำค้น" label="คำค้น"
clearable
> >
<template v-slot:append v-if="!qurey.searchKeyword"> <!-- <template v-slot:append>
<q-icon name="search" color="grey-5" /> <q-icon name="search" />
</template> </template> -->
</q-input> </q-input>
</q-toolbar-title> </q-toolbar-title>
<q-btn <q-btn
outline
icon="search"
class="full-height"
label="ค้นหา" label="ค้นหา"
color="primary" color="primary"
@click="onSearchListPerson(true)" @click="onSearchListPerson(true)"

View file

@ -220,7 +220,6 @@ function onClickAction(type: string, data: Users) {
/** /**
* งกนเป popup สำหรบเพมขอมลผใชงาน * งกนเป popup สำหรบเพมขอมลผใชงาน
*
* กำหนดสถานะการแกไขเป false และ id ใชงานทองการแกไขเปนคาวาง * กำหนดสถานะการแกไขเป false และ id ใชงานทองการแกไขเปนคาวาง
*/ */
function openDialog() { function openDialog() {
@ -232,7 +231,6 @@ function openDialog() {
/** /**
* function นยนการลบขอมลรายการผใชงาน * function นยนการลบขอมลรายการผใชงาน
* @param id รายการผใชงาน * @param id รายการผใชงาน
*
* ลบขอมลรายชอเสรจแลวทำการดงขอมลรายชอผใชงานใหม * ลบขอมลรายชอเสรจแลวทำการดงขอมลรายชอผใชงานใหม
*/ */
function onDeleteUser(id: string) { function onDeleteUser(id: string) {
@ -257,7 +255,6 @@ function onDeleteUser(id: string) {
* งกนระงบการใชงานผใชงาน * งกนระงบการใชงานผใชงาน
* @param id ใชงาน * @param id ใชงาน
* @param type เปดใชงาน,ระงบการใชงาน * @param type เปดใชงาน,ระงบการใชงาน
*
* เสรจแลวทำการดงขอมลรายชอผใชงานใหม * เสรจแลวทำการดงขอมลรายชอผใชงานใหม
*/ */
function onLockUser(id: string, type: boolean) { function onLockUser(id: string, type: boolean) {
@ -286,7 +283,6 @@ function onLockUser(id: string, type: boolean) {
/** /**
* function ปเดท paging * function ปเดท paging
* @param initialPagination อม pagination * @param initialPagination อม pagination
*
* กำหนดหนาไปยงหนาแรก * กำหนดหนาไปยงหนาแรก
*/ */
function updatePagination(initialPagination: Pagination) { function updatePagination(initialPagination: Pagination) {
@ -314,7 +310,6 @@ function filterFnOptions(val: string, update: Function, type: string) {
/** /**
* การเปลยนแปลงของจำนวนขอมลตอหน * การเปลยนแปลงของจำนวนขอมลตอหน
*
* งขอมลรายชอผใชงานตามจำนวนขอมลตอหน * งขอมลรายชอผใชงานตามจำนวนขอมลตอหน
*/ */
watch( watch(
@ -326,7 +321,6 @@ watch(
/** /**
* hook ทำงานเมอมการเรยกใชงาน Components * hook ทำงานเมอมการเรยกใชงาน Components
*
* งขอมลรายชอผใชงาน * งขอมลรายชอผใชงาน
*/ */
onMounted(async () => { onMounted(async () => {
@ -385,12 +379,10 @@ onMounted(async () => {
dense dense
outlined outlined
v-model="keyword" v-model="keyword"
clearable
@clear="keyword = ''"
placeholder="ค้นหา" placeholder="ค้นหา"
@keydown.enter.prevent="(currentPage = 1), fetchListUsers()" @keydown.enter.prevent="(currentPage = 1), fetchListUsers()"
> >
<template v-slot:append v-if="keyword === ''"> <template v-slot:append>
<q-icon name="search" /> <q-icon name="search" />
</template> </template>
</q-input> </q-input>

View file

@ -18,11 +18,18 @@ import DialogAddRole from "@/modules/02_users/components/Roles/DialogAddRole.vue
/** use*/ /** use*/
const $q = useQuasar(); const $q = useQuasar();
const router = useRouter(); const router = useRouter();
const { dialogRemove, messageError, showLoader, hideLoader, success } = const {
useCounterMixin(); dialogRemove,
messageError,
showLoader,
hideLoader,
success,
onSearchDataTable,
} = useCounterMixin();
/** Table*/ /** Table*/
const rows = ref<Roles[]>([]); // const rows = ref<Roles[]>([]); //
const rowsMain = ref<Roles[]>([]); //
const keyword = ref<string>(""); // const keyword = ref<string>(""); //
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
@ -75,7 +82,6 @@ const itemMenu = ref<ItemsMenu[]>([
/** /**
* function fetch รายการบทบาท * function fetch รายการบทบาท
*
* และบนทกใน rows * และบนทกใน rows
*/ */
async function fetchListRole() { async function fetchListRole() {
@ -85,6 +91,7 @@ async function fetchListRole() {
.then(async (res) => { .then(async (res) => {
const data = await res.data.result; const data = await res.data.result;
rows.value = data; rows.value = data;
rowsMain.value = data;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -110,9 +117,7 @@ function onClickAction(type: string, data: Roles) {
} }
} }
/** /** เปิด popup เพิ่มบทบาท*/
* เป popup เพมบทบาท
*/
function openDialog() { function openDialog() {
modalDialogAdd.value = true; modalDialogAdd.value = true;
} }
@ -139,9 +144,16 @@ function onDeleteRole(id: string) {
}); });
} }
function serchDataTable() {
rows.value = onSearchDataTable(
keyword.value,
rowsMain.value,
columns.value ? columns.value : []
);
}
/** /**
* hook ทำงานเมอมการเรยกใชงาน Components * hook ทำงานเมอมการเรยกใชงาน Components
*
* งขอมลบทบาท * งขอมลบทบาท
*/ */
onMounted(() => { onMounted(() => {
@ -166,14 +178,12 @@ onMounted(() => {
<q-input <q-input
borderless borderless
dense dense
debounce="300"
outlined outlined
v-model="keyword" v-model="keyword"
placeholder="ค้นหา" placeholder="ค้นหา"
clearable @keydown.enter.pervent="serchDataTable"
@clear="keyword = ''"
> >
<template v-slot:append v-if="keyword===''"> <template v-slot:append>
<q-icon name="search" /> <q-icon name="search" />
</template> </template>
</q-input> </q-input>
@ -198,7 +208,6 @@ onMounted(() => {
:columns="columns" :columns="columns"
:rows="rows" :rows="rows"
row-key="id" row-key="id"
:filter="keyword"
flat flat
bordered bordered
:paging="true" :paging="true"

View file

@ -22,9 +22,7 @@ import type {
import DialogAdd from "@/modules/02_users/components/Permissions/DialogAdd.vue"; import DialogAdd from "@/modules/02_users/components/Permissions/DialogAdd.vue";
import PopupPersonal from "@/modules/02_users/components/RoleOrganization/DialogPersonal.vue"; import PopupPersonal from "@/modules/02_users/components/RoleOrganization/DialogPersonal.vue";
/** /** use*/
* use
*/
const $q = useQuasar(); const $q = useQuasar();
const store = usePermissionsStore(); const store = usePermissionsStore();
const { showLoader, hideLoader, messageError, success, dialogRemove } = const { showLoader, hideLoader, messageError, success, dialogRemove } =
@ -254,9 +252,7 @@ const pagination = ref<Pagination>({
const modalDialogAdd = ref<boolean>(false); // popup const modalDialogAdd = ref<boolean>(false); // popup
/** /** function เรียกข้อมูลโครงสร้าง แบบปัจุบันและ แบบร่าง */
* function เรยกขอมลโครงสราง แบบปนและ แบบราง
*/
async function fetchOrganizationActive() { async function fetchOrganizationActive() {
showLoader(); showLoader();
await http await http
@ -545,13 +541,7 @@ onMounted(() => {
<div class="col-12"> <div class="col-12">
<q-input dense outlined v-model="filter" label="ค้นหา"> <q-input dense outlined v-model="filter" label="ค้นหา">
<template v-slot:append> <template v-slot:append>
<q-icon <q-icon name="search" />
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
<q-icon name="search" color="grey-5" v-else />
</template> </template>
</q-input> </q-input>
</div> </div>
@ -659,8 +649,6 @@ onMounted(() => {
dense dense
v-model="reqMaster.keyword" v-model="reqMaster.keyword"
label="ค้นหา" label="ค้นหา"
clearable
@clear="reqMaster.keyword = ''"
@keydown.enter.prevent=" @keydown.enter.prevent="
(reqMaster.page = 1), (reqMaster.page = 1),
fetchDataTable( fetchDataTable(
@ -670,8 +658,8 @@ onMounted(() => {
) )
" "
> >
<template v-slot:append v-if="reqMaster.keyword === ''"> <template v-slot:append>
<q-icon name="search" color="grey-5" /> <q-icon name="search" />
</template> </template>
</q-input> </q-input>
</div> </div>

View file

@ -241,13 +241,7 @@ onMounted(async () => {
<div> <div>
<q-input dense outlined v-model="filter" label="ค้นหา"> <q-input dense outlined v-model="filter" label="ค้นหา">
<template v-slot:append> <template v-slot:append>
<q-icon <q-icon name="search" />
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
<q-icon v-else name="search" color="grey-5" />
</template> </template>
</q-input> </q-input>
</div> </div>
@ -258,7 +252,7 @@ onMounted(async () => {
:nodes="nodeTree" :nodes="nodeTree"
node-key="orgRootName" node-key="orgRootName"
label-key="labelName" label-key="labelName"
:filter="filter" :filter="filter?.trim()"
no-results-label="ไม่พบข้อมูลที่ค้นหา" no-results-label="ไม่พบข้อมูลที่ค้นหา"
no-nodes-label="ไม่มีข้อมูล" no-nodes-label="ไม่มีข้อมูล"
v-model:expanded="expanded" v-model:expanded="expanded"
@ -349,22 +343,15 @@ onMounted(async () => {
label="คำค้น" label="คำค้น"
hide-bottom-space hide-bottom-space
> >
<template v-slot:append>
<q-icon
v-if="qureyBody.searchKeyword"
name="cancel"
@click="qureyBody.searchKeyword = ''"
class="cursor-pointer"
></q-icon>
</template>
</q-input> </q-input>
</div> </div>
<div> <div>
<q-btn <q-btn
outline
color="primary" color="primary"
icon="search" icon="search"
label="ค้นหา" label="ค้นหา"
class="full-width" class="full-width full-height"
@click="fetchListPerson(true)" @click="fetchListPerson(true)"
/> />
</div> </div>

View file

@ -441,13 +441,7 @@ onMounted(() => {
<div class="col-12"> <div class="col-12">
<q-input dense outlined v-model="filter" label="ค้นหา"> <q-input dense outlined v-model="filter" label="ค้นหา">
<template v-slot:append> <template v-slot:append>
<q-icon <q-icon name="search" />
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
<q-icon v-else name="search" color="grey-5" />
</template> </template>
</q-input> </q-input>
</div> </div>
@ -460,7 +454,7 @@ onMounted(() => {
:nodes="lazy" :nodes="lazy"
node-key="orgTreeId" node-key="orgTreeId"
label-key="labelName" label-key="labelName"
:filter="filter" :filter="filter?.trim()"
no-results-label="ไม่พบข้อมูลที่ค้นหา" no-results-label="ไม่พบข้อมูลที่ค้นหา"
no-nodes-label="ไม่มีข้อมูล" no-nodes-label="ไม่มีข้อมูล"
v-model:expanded="expanded" v-model:expanded="expanded"
@ -555,8 +549,6 @@ onMounted(() => {
dense dense
v-model="reqMaster.keyword" v-model="reqMaster.keyword"
label="ค้นหา" label="ค้นหา"
clearable
@clear="reqMaster.keyword = ''"
@keydown.enter.prevent=" @keydown.enter.prevent="
(reqMaster.page = 1), (reqMaster.page = 1),
fetchDataTable( fetchDataTable(
@ -566,8 +558,8 @@ onMounted(() => {
) )
" "
> >
<template v-slot:append v-if="reqMaster.keyword === ''"> <template v-slot:append>
<q-icon name="search" color="grey-5" /> <q-icon name="search" />
</template> </template>
</q-input> </q-input>
</div> </div>
@ -709,7 +701,9 @@ onMounted(() => {
<q-item-section avatar> <q-item-section avatar>
<q-icon color="red" name="delete" /> <q-icon color="red" name="delete" />
</q-item-section> </q-item-section>
<q-item-section> ลบหนาทความรบผดชอบทงหมด</q-item-section> <q-item-section>
ลบหนาทความรบผดชอบทงหมด</q-item-section
>
</q-item> </q-item>
</q-list> </q-list>
</q-menu> </q-menu>