Template สำหรับลงในตำแหน่ง/เงินเดือน API

This commit is contained in:
STW_TTTY\stwtt 2024-09-16 14:38:11 +07:00
parent 4c4cd03f0b
commit 1267b04af3
3 changed files with 194 additions and 126 deletions

View file

@ -1,7 +1,17 @@
import env from "../index"; import env from "../index";
const order = `${env.API_URI}/org`; const order = `${env.API_URI}/org`;
const commandSys = `${env.API_URI}/org/commandSys`;
const commandSalary = `${env.API_URI}/org/commandSalary`;
export default { export default {
commandType: `${order}/commandType`, commandType: `${order}/commandType`,
commandSysList: `${order}/commandSys/list`, commandSysList: `${commandSys}/list`,
commandSalary,
commandSalaryDetail: (
page: number,
pageSize: number,
isActive: boolean,
commandSysId: string
) =>
`${commandSalary}/admin?page=${page}&pageSize=${pageSize}&isActive=${isActive}&commandSysId=${commandSysId}`,
commandSalaryById:(id:string)=>`${commandSalary}/${id}`
}; };

View file

@ -7,6 +7,16 @@ interface DateOption {
id: string; id: string;
} }
interface CommandSysType {
id: string;
createdAt: Date | null;
lastUpdatedAt: Date | null;
createdFullName: string;
lastUpdateFullName: string;
sysName: string;
sysDescription: string;
}
interface ActiveOptions { interface ActiveOptions {
value: boolean; value: boolean;
label: string; label: string;
@ -22,9 +32,9 @@ interface ListOrder {
} }
interface ListTemplateSalary { interface ListTemplateSalary {
id: number | null; id: string;
name: string; name: string;
status?: boolean; isActive?: boolean;
} }
interface Tabs { interface Tabs {
@ -38,4 +48,5 @@ export type {
ListOrder, ListOrder,
Tabs, Tabs,
ListTemplateSalary, ListTemplateSalary,
CommandSysType
}; };

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, reactive } from "vue"; import { ref, onMounted, reactive, watch } from "vue";
import { useQuasar, type QTableProps } from "quasar"; import { useQuasar, type QTableProps } from "quasar";
import http from "@/plugins/http"; import http from "@/plugins/http";
@ -9,12 +9,13 @@ import { useCounterMixin } from "@/stores/mixin";
import { useDataStore } from "@/modules/05_command/stores/main"; import { useDataStore } from "@/modules/05_command/stores/main";
import type { import type {
ActiveOptions, CommandSysType,
ListTemplateSalary, ListTemplateSalary,
DateOption, ActiveOptions,
} from "@/modules/05_command/interface/index/Main"; } from "@/modules/05_command/interface/index/Main";
import Header from "@/components/DialogHeader.vue"; import Header from "@/components/DialogHeader.vue";
import { options } from "@fullcalendar/core/preact";
const $q = useQuasar(); const $q = useQuasar();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
@ -28,20 +29,39 @@ const {
messageError, messageError,
} = mixin; } = mixin;
const filter = ref<string>(""); // const total = ref<number>(0);
const listOrder = ref<DateOption[]>([]); const totalList = ref<number>(1);
const activeOrderId = ref<string>(""); // id = class const pagination = ref({
sortBy: "createdAt",
descending: true,
page: 1,
rowsPerPage: 10,
});
const filter = ref<string>(""); //
const listOrder = ref<CommandSysType[]>([]);
const activeOrderId = ref<string>(""); // id = class
const isActive = ref<boolean>(true); //
const isActiveOption = ref<ActiveOptions[]>([
{
value: true,
label: "ใช้งาน",
},
{
value: false,
label: "ไม่ได้ใช้งาน",
},
]);
const dataForm = reactive<ListTemplateSalary>({ const dataForm = reactive<ListTemplateSalary>({
id: null, id: '',
name: "", name: "",
status: false, isActive: false,
}); });
const isEdit = ref<boolean>(false); // true/false const isEdit = ref<boolean>(false); // true/false
const dialogForm = ref<boolean>(false); // model const dialogForm = ref<boolean>(false); // model
const rows = ref<ListTemplateSalary[]>([]); const rows = ref<ListTemplateSalary[]>([]);
const visibleColumns = ref<String[]>(["no", "name", "status"]); const visibleColumns = ref<String[]>(["no", "name", "isActive"]);
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
name: "no", name: "no",
@ -55,7 +75,7 @@ const columns = ref<QTableProps["columns"]>([
{ {
name: "name", name: "name",
align: "left", align: "left",
label: "ชื่อ", label: "ข้อความ Template สำหรับลงในตำแหน่ง/เงินเดือน",
sortable: true, sortable: true,
field: "name", field: "name",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
@ -64,11 +84,11 @@ const columns = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
{ {
name: "status", name: "isActive",
align: "center", align: "center",
label: "สถานะการใช้งาน", label: "สถานะการใช้งาน",
sortable: false, sortable: false,
field: "status", field: "isActive",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
}, },
@ -86,7 +106,7 @@ function onDialogAdd() {
function onDialogEdit(data: ListTemplateSalary) { function onDialogEdit(data: ListTemplateSalary) {
dataForm.id = data.id; dataForm.id = data.id;
dataForm.name = data.name; dataForm.name = data.name;
dataForm.status = data.status; dataForm.isActive = data.isActive;
isEdit.value = true; isEdit.value = true;
dialogForm.value = true; dialogForm.value = true;
@ -98,21 +118,27 @@ function onDialogEdit(data: ListTemplateSalary) {
*/ */
function onDelete(id: string) { function onDelete(id: string) {
dialogRemove($q, () => { dialogRemove($q, () => {
// http showLoader();
// .delete(config.API.) http
// .then((res) => {}) .delete(config.API.commandSalaryById(id))
// .catch((e) => { .then(async (res) => {
// messageError($q, e); success($q, "ลบข้อมูลเสร็จสิ้น");
// }) await fetchSalaryList();
// .finally(() => {}); hideLoader();
})
.catch((e) => {
messageError($q, e);
hideLoader();
})
.finally(() => {});
}); });
} }
/** ปิด dialog */ /** ปิด dialog */
function closeDialog() { function closeDialog() {
dataForm.id = null; dataForm.id = "";
dataForm.name = ""; dataForm.name = "";
dataForm.status = false; dataForm.isActive = false;
isEdit.value = false; isEdit.value = false;
dialogForm.value = false; dialogForm.value = false;
@ -120,13 +146,33 @@ function closeDialog() {
/** บันทึกข้อมูล dialog */ /** บันทึกข้อมูล dialog */
function onSubmit() { function onSubmit() {
dialogConfirm($q, () => {}); dialogConfirm($q, () => {
const url = isEdit.value
? config.API.commandSalaryById(dataForm.id)
: config.API.commandSalary;
showLoader();
http[isEdit.value ? "put" : "post"](url, {
name: dataForm.name,
commandSysId: activeOrderId.value,
isActive: dataForm.isActive,
})
.then(async (res) => {
closeDialog();
success($q, "บันทึกข้อมูลสำเร็จ");
await fetchSalaryList();
hideLoader();
})
.catch((e) => {
messageError($q, e);
hideLoader();
})
.finally(() => {});
});
} }
/** เก็บ id list คำสั่งที่เลือก เพื่อใช้ class */ /** เก็บ id list คำสั่งที่เลือก เพื่อใช้ class */
function selectInbox(data: DateOption) { function selectInbox(data: CommandSysType) {
activeOrderId.value = data.id; activeOrderId.value = data.id;
fetchSalaryList(); fetchSalaryList();
} }
@ -135,96 +181,62 @@ function selectInbox(data: DateOption) {
*/ */
async function fetchSalaryList() { async function fetchSalaryList() {
showLoader(); showLoader();
setTimeout(() => { await http
rows.value = [ .get(
{ config.API.commandSalaryDetail(
id: 1, pagination.value.page,
name: "เลื่อนเงินเดือน", pagination.value.rowsPerPage,
status: true, isActive.value,
}, activeOrderId.value
{ )
id: 2, )
name: "เลื่อนเงินเดือน (ดีเด่น)", .then(async (res) => {
status: false, totalList.value = Math.ceil(
}, res.data.result.total / pagination.value.rowsPerPage
{ );
id: 3, total.value = res.data.result.total;
name: "เลื่อนเงินเดือน (เพิ่มเติม)", rows.value = res.data.result.commandSalarys;
status: false, })
}, .catch((err) => {
messageError($q, err);
{ })
id: 4, .finally(() => {
name: "ปรับเงินเดือน", hideLoader();
status: true, });
},
{
id: 5,
name: "ปรับเงินเดือนเพิ่มเติมตามคุณวุฒิการศึกษา",
status: true,
},
{
id: 6,
name: "ปรับเงินเดือนเพิ่มเติมตามคุณวุฒิการศึกษา (เพิ่มเติม)",
status: true,
},
{
id: 7,
name: "เลื่อนเงินเดือนและให้ข้าราชการ กทม. สามัญได้รับเงินเดือนสูงกว่าขั้นสูงของตำแหน่งที่ได้รับแต่งตั้ง",
status: true,
},
{
id: 8,
name: "เลื่อนเงินเดือนกรณีพิเศษให้แก่ผู้ปฏิบัติงานด้านยาเสพติด",
status: true,
},
{
id: 9,
name: "{ประเภทตำแหน่ง} {ชื่อตำแหน่ง} สำนัก{ชื่อสำนัก}",
status: true,
},
{
id: 10,
name: "แต่งตั้งข้าราชการ {ประเภทตำแหน่ง} {ชื่อตำแหน่ง} สำนัก{ชื่อสำนัก}",
status: true,
},
{
id: 11,
name: "แก้ไขคำสั่ง {หน่วยงาน/สำนัก} ที่ {เลขที่}/{ปีงบประมาณ} ลว. {วันที่ลงนาม}",
status: true,
},
];
hideLoader();
}, 1000);
// showLoader();
// await http
// .get(config.API.commandType)
// .then(async (res) => {
// lists.value = res.data.result.map((item: any) => {
// return {
// id: item.id,
// name: item.name,
// status: true,
// };
// });
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// hideLoader();
// });
} }
/** ดึงข้อมูล list */
async function getMainData() {
showLoader();
await http
.get(config.API.commandSysList)
.then(async (res) => {
const data = await res.data.result;
listOrder.value = data;
hideLoader();
})
.catch((e) => {
messageError($q, e);
hideLoader();
})
.finally(() => {});
}
function updatePagination(newPagination: any) {
pagination.value.page = 1;
pagination.value.rowsPerPage = newPagination.rowsPerPage;
}
watch(
() => pagination.value.rowsPerPage,
async () => {
await fetchSalaryList();
}
);
/** เริ่มเมื่อโหลดหน้านี้*/ /** เริ่มเมื่อโหลดหน้านี้*/
onMounted(() => { onMounted(() => {
const data = [ getMainData();
{ id: "1", name: "บรรจุ แต่งตั้ง" },
{ id: "2", name: "เงินเดือน" },
{ id: "3", name: "ลงโทษวินัย" },
];
listOrder.value = data;
}); });
</script> </script>
@ -253,7 +265,7 @@ onMounted(() => {
> >
<q-item-section> <q-item-section>
<q-item-label> <q-item-label>
{{ item.name }} {{ item.sysName }}
</q-item-label> </q-item-label>
</q-item-section> </q-item-section>
</q-item> </q-item>
@ -269,6 +281,21 @@ onMounted(() => {
<div class="row q-pa-sm q-col-gutter-sm"> <div class="row q-pa-sm q-col-gutter-sm">
<div class="col-12"> <div class="col-12">
<div class="row q-gutter-sm"> <div class="row q-gutter-sm">
<div class="col-3">
<q-select
outlined
dense
v-model="isActive"
class="inputgreen"
label="สถานะการใช้งาน"
:options="isActiveOption"
option-label="label"
option-value="value"
emit-value
map-options
@update:model-value="fetchSalaryList"
></q-select>
</div>
<q-btn <q-btn
flat flat
dense dense
@ -323,8 +350,25 @@ onMounted(() => {
bordered bordered
:paging="true" :paging="true"
dense dense
:rows-per-page-options="[1, 25, 50, 100]"
@update:pagination="updatePagination"
:visible-columns="visibleColumns" :visible-columns="visibleColumns"
> >
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="pagination.page"
active-color="primary"
color="dark"
:max="Number(totalList)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="fetchSalaryList"
></q-pagination>
</template>
<template v-slot:header="props"> <template v-slot:header="props">
<q-tr :props="props"> <q-tr :props="props">
<q-th auto-width></q-th> <q-th auto-width></q-th>
@ -366,16 +410,17 @@ onMounted(() => {
:props="props" :props="props"
> >
<div v-if="col.name == 'no'"> <div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }} {{
(pagination.page - 1) * pagination.rowsPerPage +
props.rowIndex +
1
}}
</div> </div>
<div v-else-if="col.name == 'status'"> <div v-else-if="col.name == 'isActive'">
<q-icon <q-icon
:color="props.row.status ? 'green' : 'orange'" size="sm"
:name=" :color="props.row.isActive ? 'teal' : 'orange'"
props.row.status :name="props.row.isActive ? 'mdi-check' : 'mdi-close'"
? 'mdi-check-circle'
: 'mdi-minus-circle'
"
/> />
</div> </div>
<div v-else> <div v-else>
@ -411,7 +456,9 @@ onMounted(() => {
<q-card class="col-12" style="min-width: 30%"> <q-card class="col-12" style="min-width: 30%">
<q-form greedy @submit.prevent @validation-success="onSubmit"> <q-form greedy @submit.prevent @validation-success="onSubmit">
<Header <Header
:tittle="isEdit ? 'แก้ไขคำสั่ง' : 'เพิ่มคำสั่ง'" :tittle="`${
isEdit ? 'แก้ไข' : 'เพิ่ม'
} Template สำหรบลงในตำแหน/เงนเดอน`"
:close="closeDialog" :close="closeDialog"
/> />
<q-separator /> <q-separator />
@ -433,7 +480,7 @@ onMounted(() => {
<div class="row items-center justify-between border_custom"> <div class="row items-center justify-between border_custom">
<p class="q-ma-none">สถานะการใชงาน</p> <p class="q-ma-none">สถานะการใชงาน</p>
<label :class="`toggle-control`"> <label :class="`toggle-control`">
<input type="checkbox" v-model="dataForm.status" /> <input type="checkbox" v-model="dataForm.isActive" />
<span class="control"></span> <span class="control"></span>
</label> </label>
</div> </div>