ปรับเส้น API list ผู้บังคับบัญชาและผู้มีอำนาจของ workflow

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-11-14 14:01:35 +07:00
parent 32b83298cd
commit 340294e76e
3 changed files with 108 additions and 4 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from "vue"; import { reactive, ref, watch } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
@ -7,6 +7,8 @@ import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import type { Pagination } from "@/components/Workflow/interface/index/Main";
import type { DataQuery } from "@/components/Workflow/interface/request/Main";
import type { DataCommander } from "@/components/Workflow/interface/response/Main"; import type { DataCommander } from "@/components/Workflow/interface/response/Main";
import DialogHeader from "@/components/DialogHeader.vue"; import DialogHeader from "@/components/DialogHeader.vue";
@ -58,16 +60,30 @@ const columns = ref<QTableProps["columns"]>([
}, },
]); ]);
const total = ref<number>(0);
const totalList = ref<number>(1);
const isAcceptSetting = ref<boolean>(false); const isAcceptSetting = ref<boolean>(false);
const isApproveSetting = ref<boolean>(false); const isApproveSetting = ref<boolean>(false);
const isReasonSetting = ref<boolean>(false); const isReasonSetting = ref<boolean>(false);
const formDataQuery = reactive<DataQuery>({
page: 1,
pageSize: 10,
isAct: false,
keyword: "",
});
async function fetchLists() { async function fetchLists() {
showLoader(); showLoader();
await http await http
.get(config.API.workflow + `commander/${props.type}`) .put(config.API.workflow + `commander/${props.type}`, formDataQuery)
.then(async (res) => { .then(async (res) => {
rows.value = res.data.result; totalList.value = Math.ceil(
res.data.result.total / formDataQuery.pageSize
);
total.value = res.data.result.total;
rows.value = res.data.result.data;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -102,6 +118,11 @@ function onSubmit() {
}); });
} }
function onSearchData() {
formDataQuery.page = 1;
fetchLists();
}
function onCloseModal() { function onCloseModal() {
modal.value = false; modal.value = false;
selected.value = []; selected.value = [];
@ -109,6 +130,10 @@ function onCloseModal() {
isAcceptSetting.value = false; isAcceptSetting.value = false;
isApproveSetting.value = false; isApproveSetting.value = false;
isReasonSetting.value = false; isReasonSetting.value = false;
formDataQuery.page = 1;
formDataQuery.pageSize = 10;
formDataQuery.isAct = false;
formDataQuery.keyword = "";
} }
watch(modal, (val) => { watch(modal, (val) => {
@ -116,6 +141,21 @@ watch(modal, (val) => {
fetchLists(); fetchLists();
} }
}); });
watch(
() => [formDataQuery.isAct, formDataQuery.pageSize],
() => {
onSearchData();
}
);
/**
* function updatePagination
* @param newPagination อม Pagination ใหม
*/
function updatePagination(newPagination: Pagination) {
formDataQuery.pageSize = newPagination.rowsPerPage;
}
</script> </script>
<template> <template>
@ -126,6 +166,39 @@ watch(modal, (val) => {
<q-separator /> <q-separator />
<q-card-section> <q-card-section>
<div class="row q-col-gutter-sm items-start q-mb-sm">
<div class="col-12 col-sm-4 col-md-4">
<q-input
v-model="formDataQuery.keyword"
outlined
clearable
hide-bottom-space
dense
label="คำค้น"
@clear="formDataQuery.keyword = ''"
/>
</div>
<q-checkbox
keep-color
v-model="formDataQuery.isAct"
label="แสดงเฉพาะรักษาการแทน"
color="primary"
>
<q-tooltip>แสดงเฉพาะรกษาการแทน </q-tooltip>
</q-checkbox>
<q-space />
<div class="col-12 col-sm-6 col-md-3">
<q-btn
color="primary"
icon="search"
label="ค้นหา"
class="full-width q-pa-sm"
@click.prevent="onSearchData"
>
</q-btn>
</div>
</div>
<d-table <d-table
ref="table" ref="table"
:columns="columns" :columns="columns"
@ -138,6 +211,7 @@ watch(modal, (val) => {
:rows-per-page-options="[10, 25, 50, 100]" :rows-per-page-options="[10, 25, 50, 100]"
selection="single" selection="single"
v-model:selected="selected" v-model:selected="selected"
@update:pagination="updatePagination"
> >
<template v-slot:header-selection="scope"> <template v-slot:header-selection="scope">
<q-checkbox <q-checkbox
@ -172,6 +246,21 @@ watch(modal, (val) => {
</q-td> </q-td>
</q-tr> </q-tr>
</template> </template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="formDataQuery.page"
active-color="primary"
color="dark"
:max="Number(totalList)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="fetchLists()"
></q-pagination>
</template>
</d-table> </d-table>
<div class="q-gutter-xs q-pt-sm"> <div class="q-gutter-xs q-pt-sm">
<div> <div>

View file

@ -8,4 +8,11 @@ interface Permission {
isSing: boolean; isSing: boolean;
} }
export type { Permission }; interface Pagination {
descending: boolean;
page: number;
rowsPerPage: number;
sortBy: string;
}
export type { Permission, Pagination };

View file

@ -0,0 +1,8 @@
interface DataQuery {
page: number;
pageSize: number;
isAct: boolean;
keyword: string;
}
export type { DataQuery };