filter ==> จัดการ web services
This commit is contained in:
parent
cc6c038218
commit
c4bcb0b755
4 changed files with 118 additions and 100 deletions
|
|
@ -305,6 +305,8 @@ onMounted(async () => {
|
|||
use-input
|
||||
hide-selected
|
||||
fill-input
|
||||
:clearable="apiNameId !==''"
|
||||
@clear="(apiNameId = ''), (options = dataApiName)"
|
||||
@update:modelValue="onSelectType"
|
||||
@filter="(inputValue: string,doneFn: Function) => filterSelector(inputValue, doneFn )"
|
||||
>
|
||||
|
|
@ -24,10 +24,12 @@ const {
|
|||
messageError,
|
||||
success,
|
||||
date2Thai,
|
||||
onSearchDataTable,
|
||||
} = useCounterMixin();
|
||||
|
||||
/** Table*/
|
||||
const rows = ref<ListWebServices[]>([]); //รายการ webservices
|
||||
const rowsMain = ref<ListWebServices[]>([]); //รายการ webservices
|
||||
const keyword = ref<string>(""); //คำค้นหา รายการ webservices
|
||||
const visibleColumns = ref<string[]>([
|
||||
"name",
|
||||
|
|
@ -107,6 +109,7 @@ async function fetchListWebServices() {
|
|||
.then(async (res) => {
|
||||
const data = await res.data.result;
|
||||
rows.value = data;
|
||||
rowsMain.value = data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -140,6 +143,14 @@ function onDeleteData(id: string) {
|
|||
});
|
||||
}
|
||||
|
||||
function serchDataTable() {
|
||||
rows.value = onSearchDataTable(
|
||||
keyword.value,
|
||||
rowsMain.value,
|
||||
columns.value ? columns.value : []
|
||||
);
|
||||
}
|
||||
|
||||
/** hook เมื่อเรียก Components จะเรียกฟังก์ชัน 'fetchListWebServices' เรียกข้อมูลรายการ webservices*/
|
||||
onMounted(() => {
|
||||
fetchListWebServices();
|
||||
|
|
@ -148,9 +159,6 @@ onMounted(() => {
|
|||
|
||||
<template>
|
||||
<div class="row items-center">
|
||||
<!-- <div class="toptitle text-dark row items-center q-py-xs">
|
||||
รายการ web services
|
||||
</div> -->
|
||||
<q-space />
|
||||
<q-btn
|
||||
flat
|
||||
|
|
@ -160,105 +168,91 @@ onMounted(() => {
|
|||
/>
|
||||
</div>
|
||||
|
||||
<!-- <q-card flast bordered class="q-pa-md"> -->
|
||||
<!-- toolbar -->
|
||||
<div class="items-center col-12 row q-col-gutter-sm">
|
||||
<q-btn
|
||||
class="q-ml-sm"
|
||||
flat
|
||||
round
|
||||
dense
|
||||
color="primary"
|
||||
icon="add"
|
||||
@click.pervent="modalApiKey = true"
|
||||
>
|
||||
<q-tooltip>สร้าง API Key </q-tooltip>
|
||||
</q-btn>
|
||||
<q-space />
|
||||
<q-input
|
||||
borderless
|
||||
dense
|
||||
outlined
|
||||
clearable
|
||||
v-model="keyword"
|
||||
placeholder="ค้นหา"
|
||||
@clear="keyword = ''"
|
||||
>
|
||||
<template v-slot:append v-if="keyword === ''">
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
:display-value="$q.lang.table.columns"
|
||||
emit-value
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
style="min-width: 140px"
|
||||
/>
|
||||
</div>
|
||||
<div class="items-center col-12 row q-col-gutter-sm">
|
||||
<q-btn
|
||||
class="q-ml-sm"
|
||||
flat
|
||||
round
|
||||
dense
|
||||
color="primary"
|
||||
icon="add"
|
||||
@click.pervent="modalApiKey = true"
|
||||
>
|
||||
<q-tooltip>สร้าง API Key </q-tooltip>
|
||||
</q-btn>
|
||||
<q-space />
|
||||
<q-input
|
||||
borderless
|
||||
dense
|
||||
outlined
|
||||
v-model="keyword"
|
||||
placeholder="ค้นหา"
|
||||
@keydown.enter.pervent="serchDataTable"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
:display-value="$q.lang.table.columns"
|
||||
emit-value
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
style="min-width: 140px"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="col-12 q-pt-sm">
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
row-key="id"
|
||||
:filter="keyword"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
:visible-columns="visibleColumns"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<q-th auto-width />
|
||||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<span class="text-weight-medium">{{ col.label }}</span>
|
||||
</q-th>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props">
|
||||
<q-td auto-width>
|
||||
<q-btn
|
||||
dense
|
||||
flat
|
||||
round
|
||||
color="red"
|
||||
@click="onDeleteData(props.row.id)"
|
||||
icon="delete"
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn></q-td
|
||||
<!-- Table -->
|
||||
<div class="col-12 q-pt-sm">
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
:visible-columns="visibleColumns"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<q-th auto-width />
|
||||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<span class="text-weight-medium">{{ col.label }}</span>
|
||||
</q-th>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props">
|
||||
<q-td auto-width>
|
||||
<q-btn
|
||||
dense
|
||||
flat
|
||||
round
|
||||
color="red"
|
||||
@click="onDeleteData(props.row.id)"
|
||||
icon="delete"
|
||||
>
|
||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<!-- <div v-if="col.name === 'apiNames'">
|
||||
<q-list dense>
|
||||
<q-item v-for="(item, key) in col.value">
|
||||
<q-item-section>- {{ item.name }}</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</div> -->
|
||||
<div v-html="col.value ? col.value : '-'"></div>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn></q-td
|
||||
>
|
||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<div v-html="col.value ? col.value : '-'"></div>
|
||||
|
||||
<div>
|
||||
<!-- {{ col.value ? col.value : "-" }} -->
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
<!-- </q-card> -->
|
||||
<div></div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
|
||||
<!-- สร้าง API Key -->
|
||||
<DialogApiKey
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { ref } from "vue";
|
|||
|
||||
/** importComponents*/
|
||||
import ListView from "@/modules/06_webservices/view/listView.vue";
|
||||
import LogView from "@/modules/06_webservices/view/logView.vue";
|
||||
import LogView from "@/modules/06_webservices/view/historyView.vue";
|
||||
|
||||
const tabs = ref<string>("list");
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1058,6 +1058,26 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
}
|
||||
}
|
||||
|
||||
function onSearchDataTable(keyword: string, data: any[], columns: any[]) {
|
||||
const searchText = keyword.trim().toLowerCase();
|
||||
|
||||
if (!searchText) {
|
||||
return data; // คืนค่าทั้งหมดถ้าไม่มีข้อความค้นหา
|
||||
}
|
||||
|
||||
// คืนค่าข้อมูลที่กรองแล้ว
|
||||
return data.filter((row: any) => {
|
||||
return columns.some((col: any) => {
|
||||
const rawValue = row[col.field];
|
||||
const formattedValue = col.format
|
||||
? col.format(rawValue, row) // ใช้ `format` ถ้ามี
|
||||
: rawValue;
|
||||
|
||||
return String(formattedValue).toLowerCase().includes(searchText);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
calAge,
|
||||
date2Thai,
|
||||
|
|
@ -1099,5 +1119,7 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
findOrgNameOld,
|
||||
findPosMasterNo,
|
||||
findPosMasterNoOld,
|
||||
|
||||
onSearchDataTable,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue