ผังบัญชีค่าจ้างลูกจ้างประจำ => fix bug

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-07-10 15:56:34 +07:00
parent 7ab0dcd8e6
commit 2c32b6d064
3 changed files with 172 additions and 41 deletions

View file

@ -132,6 +132,17 @@ watch(
} }
} }
); );
/**
* class ดรปแบบแสดงระหวางขอมลทแกไขหรอแสดงเฉยๆ
* @param val อม input สำหรบแกไขหรอไม
*/
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
</script> </script>
<template> <template>
<q-dialog v-model="modal" persistent> <q-dialog v-model="modal" persistent>
@ -153,6 +164,7 @@ watch(
<div class="col-xs-12 col-md-4"> <div class="col-xs-12 col-md-4">
<q-input <q-input
:readonly="isReadonly" :readonly="isReadonly"
:class="getClass(!isReadonly)"
ref="nameRef" ref="nameRef"
dense dense
hide-bottom-space hide-bottom-space
@ -171,12 +183,14 @@ watch(
ref="groupRef" ref="groupRef"
week-start="0" week-start="0"
:readonly="isReadonly" :readonly="isReadonly"
:class="getClass(!isReadonly)"
dense dense
outlined outlined
v-model="formData.group" v-model="formData.group"
label="กลุ่มของผังบัญชีอัตราค่าจ้าง" label="กลุ่มของผังบัญชีอัตราค่าจ้าง"
hide-bottom-space hide-bottom-space
mask="########" mask="#"
reverse-fill-mask
:rules="[ :rules="[
(val) => !!val || 'กรุณากรอกกลุ่มของผังบัญชีอัตราค่าจ้าง', (val) => !!val || 'กรุณากรอกกลุ่มของผังบัญชีอัตราค่าจ้าง',
]" ]"
@ -206,6 +220,7 @@ watch(
:enableTimePicker="false" :enableTimePicker="false"
week-start="0" week-start="0"
:readonly="isReadonly" :readonly="isReadonly"
:class="getClass(!isReadonly)"
> >
<template #year="{ year }"> <template #year="{ year }">
{{ year + 543 }} {{ year + 543 }}
@ -242,6 +257,7 @@ watch(
<div class="col-xs-12 col-md-4"> <div class="col-xs-12 col-md-4">
<datepicker <datepicker
:readonly="isReadonly" :readonly="isReadonly"
:class="getClass(!isReadonly)"
menu-class-name="modalfix" menu-class-name="modalfix"
v-model="formData.startDate" v-model="formData.startDate"
:locale="'th'" :locale="'th'"
@ -286,6 +302,7 @@ watch(
<div class="col-xs-12 col-md-4"> <div class="col-xs-12 col-md-4">
<datepicker <datepicker
:readonly="isReadonly" :readonly="isReadonly"
:class="getClass(!isReadonly)"
menu-class-name="modalfix" menu-class-name="modalfix"
v-model="formData.endDate" v-model="formData.endDate"
:locale="'th'" :locale="'th'"
@ -329,6 +346,7 @@ watch(
<div class="col-12"> <div class="col-12">
<q-input <q-input
:readonly="isReadonly" :readonly="isReadonly"
:class="getClass(!isReadonly)"
v-model="formData.details" v-model="formData.details"
outlined outlined
dense dense

View file

@ -32,9 +32,11 @@ const props = defineProps({
}); });
const posTypeOp = ref<DataOptions[]>([]); const posTypeOp = ref<DataOptions[]>([]);
const posTypeOpMain = ref<DataOptions[]>([]);
const posNameOp = ref<DataOptions[]>([]); const posNameOp = ref<DataOptions[]>([]);
const posNameOpMain = ref<DataOptions[]>([]); const posNameOpMain = ref<DataOptions[]>([]);
const groupOldOp = ref<DataOptions[]>([]); const groupOldOp = ref<DataOptions[]>([]);
const groupOldOpMain = ref<DataOptions[]>([]);
const posLevelOp = ref<any[]>([]); const posLevelOp = ref<any[]>([]);
const posNameListOp = ref<DataListOptions[]>([]); const posNameListOp = ref<DataListOptions[]>([]);
@ -123,10 +125,12 @@ function getPosType() {
.get(config.API.salaryEmployeePosType()) .get(config.API.salaryEmployeePosType())
.then((res) => { .then((res) => {
const dataOp = res.data.result; const dataOp = res.data.result;
posTypeOp.value = dataOp.map((item: any) => ({ const option = dataOp.map((item: any) => ({
id: item.id, id: item.id,
name: item.posTypeName, name: item.posTypeName,
})); }));
posTypeOpMain.value = option;
posTypeOp.value = option;
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
@ -138,29 +142,31 @@ function getPosType() {
/** ดึงข้อมูล ตำแหน่ง */ /** ดึงข้อมูล ตำแหน่ง */
function getPosName() { function getPosName() {
formData.posName = ""; if (formData.posType) {
formData.posLevel = ""; formData.posName = "";
showLoader(); formData.posLevel = "";
http showLoader();
.get(config.API.salaryEmployeePositionType(formData.posType.name)) http
.then((res) => { .get(config.API.salaryEmployeePositionType(formData.posType.name))
const dataOp = res.data.result; .then((res) => {
posNameListOp.value = res.data.result; const dataOp = res.data.result;
posNameOpMain.value = [ posNameListOp.value = res.data.result;
...new Map( posNameOpMain.value = [
dataOp.map((i: DataListOptions) => [i.posDictName, i]) ...new Map(
).values(), dataOp.map((i: DataListOptions) => [i.posDictName, i])
].map((i: any) => ({ ).values(),
id: i.id, ].map((i: any) => ({
name: i.posDictName, id: i.id,
})); name: i.posDictName,
}) }));
.catch((e) => { })
messageError($q, e); .catch((e) => {
}) messageError($q, e);
.finally(() => { })
hideLoader(); .finally(() => {
}); hideLoader();
});
}
} }
/** ดึงข้อมูล ตำแหน่ง */ /** ดึงข้อมูล ตำแหน่ง */
@ -218,10 +224,12 @@ function getSalaryGroup() {
.then((res) => { .then((res) => {
const list = res.data.result; const list = res.data.result;
const data = list.sort((a: any, b: any) => a.group - b.group); const data = list.sort((a: any, b: any) => a.group - b.group);
groupOldOp.value = data.map((item: any) => ({ const option = data.map((item: any) => ({
id: item.id, id: item.id,
name: `กลุ่มที่ ${item.group}`, name: `กลุ่มที่ ${item.group}`,
})); }));
groupOldOp.value = option;
groupOldOpMain.value = option;
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
@ -272,13 +280,47 @@ watch(
* @param update พเดทค * @param update พเดทค
* @param refData ดาตาทองการฟลเตอร * @param refData ดาตาทองการฟลเตอร
*/ */
function filterOption(val: any, update: Function) { function filterOption(val: any, update: Function, type: string) {
update(() => { switch (type) {
posNameOp.value = posNameOpMain.value.filter( case "group":
(v: any) => v.name.indexOf(val) > -1 update(() => {
); formData.posType = "";
}); posTypeOp.value = posTypeOpMain.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
break;
case "pos":
update(() => {
formData.posName = "";
posNameOp.value = posNameOpMain.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
break;
case "groupOld":
update(() => {
groupOldOp.value = groupOldOpMain.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
break;
default:
break;
}
} }
/**
* class ดรปแบบแสดงระหวางขอมลทแกไขหรอแสดงเฉยๆ
* @param val อม input สำหรบแกไขหรอไม
*/
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
</script> </script>
<template> <template>
@ -296,6 +338,7 @@ function filterOption(val: any, update: Function) {
<div class="col-4"> <div class="col-4">
<q-select <q-select
ref="posTypeRef" ref="posTypeRef"
:class="getClass(true)"
dense dense
outlined outlined
v-model="formData.posType" v-model="formData.posType"
@ -307,12 +350,23 @@ function filterOption(val: any, update: Function) {
map-options map-options
lazy-rules lazy-rules
hide-bottom-space hide-bottom-space
use-input
@update:model-value="getPosName()" @update:model-value="getPosName()"
/> @filter="(inputValue:string,doneFn:Function) => filterOption(inputValue, doneFn,'group') "
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template></q-select
>
</div> </div>
<div class="col-4"> <div class="col-4">
<q-select <q-select
ref="posNameRef" ref="posNameRef"
:class="getClass(true)"
dense dense
:readonly="formData.posType" :readonly="formData.posType"
outlined outlined
@ -325,7 +379,7 @@ function filterOption(val: any, update: Function) {
emit-value emit-value
lazy-rules lazy-rules
use-input use-input
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) " @filter="(inputValue:string,doneFn:Function) => filterOption(inputValue, doneFn,'pos')"
hide-bottom-space hide-bottom-space
@update:model-value="getPosLevel()" @update:model-value="getPosLevel()"
> >
@ -341,6 +395,7 @@ function filterOption(val: any, update: Function) {
<div class="col-4"> <div class="col-4">
<q-select <q-select
:readonly="formData.posName" :readonly="formData.posName"
:class="getClass(true)"
ref="posLevelRef" ref="posLevelRef"
dense dense
outlined outlined
@ -353,11 +408,20 @@ function filterOption(val: any, update: Function) {
:rules="[(val) => !!val || 'กรุณาเลือกระดับชั้นงาน']" :rules="[(val) => !!val || 'กรุณาเลือกระดับชั้นงาน']"
lazy-rules lazy-rules
hide-bottom-space hide-bottom-space
/> >
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div> </div>
<div class="col-8"> <div class="col-8">
<q-input <q-input
:class="getClass(true)"
dense dense
outlined outlined
v-model="formData.reson" v-model="formData.reson"
@ -368,12 +432,13 @@ function filterOption(val: any, update: Function) {
<div class="col-12 text-bold">ตราคาจาง</div> <div class="col-12 text-bold">ตราคาจาง</div>
<div class="col-4"> <div class="col-4">
<q-input <q-input
:class="getClass(true)"
ref="rateOldMinRef" ref="rateOldMinRef"
dense dense
outlined outlined
v-model="formData.rateOldMin" v-model="formData.rateOldMin"
label="ขั้นต่ำสุด" label="ขั้นต่ำสุด"
mask="###,###,###,###" mask="###,###,###,###,###,###,###,###"
reverse-fill-mask reverse-fill-mask
:rules="[ :rules="[
(val) => !!val || `${'กรุณากรอกอัตราค่าจ้าง ขั้นต่ำสุด'}`, (val) => !!val || `${'กรุณากรอกอัตราค่าจ้าง ขั้นต่ำสุด'}`,
@ -384,6 +449,7 @@ function filterOption(val: any, update: Function) {
</div> </div>
<div class="col-4"> <div class="col-4">
<q-select <q-select
:class="getClass(true)"
ref="groupOldRef" ref="groupOldRef"
dense dense
outlined outlined
@ -401,16 +467,27 @@ function filterOption(val: any, update: Function) {
option-value="id" option-value="id"
lazy-rules lazy-rules
hide-bottom-space hide-bottom-space
/> use-input
@filter="(inputValue:string,doneFn:Function) => filterOption(inputValue, doneFn,'groupOld')"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div> </div>
<div class="col-4"> <div class="col-4">
<q-input <q-input
:class="getClass(true)"
ref="rateMaxOldRef" ref="rateMaxOldRef"
dense dense
outlined outlined
v-model="formData.rateMaxOld" v-model="formData.rateMaxOld"
label="ขั้นสูงสุดเดิม" label="ขั้นสูงสุดเดิม"
mask="###,###,###,###" mask="###,###,###,###,###,###,###,###"
reverse-fill-mask reverse-fill-mask
:rules="[ :rules="[
(val) => (val) =>
@ -426,6 +503,7 @@ function filterOption(val: any, update: Function) {
</div> </div>
<div class="col-4"> <div class="col-4">
<q-select <q-select
:class="getClass(true)"
ref="groupRateHighRef" ref="groupRateHighRef"
dense dense
outlined outlined
@ -441,16 +519,27 @@ function filterOption(val: any, update: Function) {
option-value="id" option-value="id"
emit-value emit-value
hide-bottom-space hide-bottom-space
/> use-input
@filter="(inputValue:string,doneFn:Function) => filterOption(inputValue, doneFn,'groupOld')"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div> </div>
<div class="col-4"> <div class="col-4">
<q-input <q-input
:class="getClass(true)"
ref="rateHighMaxRef" ref="rateHighMaxRef"
dense dense
outlined outlined
v-model="formData.rateHighMax" v-model="formData.rateHighMax"
label="อัตราค่าจ้างขั้นสูงใหม่" label="อัตราค่าจ้างขั้นสูงใหม่"
mask="###,###,###,###" mask="###,###,###,###,###,###,###,###"
reverse-fill-mask reverse-fill-mask
:rules="[ :rules="[
(val) => !!val || `${'กรุณากรอกอัตราค่าจ้างขั้นสูงใหม่'}`, (val) => !!val || `${'กรุณากรอกอัตราค่าจ้างขั้นสูงใหม่'}`,

View file

@ -144,8 +144,9 @@ const modalForm = ref<boolean>(false);
const isStatusEdit = ref<boolean>(false); const isStatusEdit = ref<boolean>(false);
const dataRow = ref<ListData>(); const dataRow = ref<ListData>();
const posTypeOpMain = ref<DataOption[]>([]);
const posTypeOp = ref<DataOption[]>([]); const posTypeOp = ref<DataOption[]>([]);
const posType = ref<string>(""); const posType = ref<string | null>("");
const maxPage = ref<number>(1); const maxPage = ref<number>(1);
const totalList = ref<number>(0); const totalList = ref<number>(0);
@ -168,6 +169,7 @@ function getPosType() {
option.push(...test); option.push(...test);
posTypeOp.value = option; posTypeOp.value = option;
posTypeOpMain.value = option;
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
@ -254,6 +256,20 @@ function onClickDelete(id: string) {
}); });
} }
/**
* function นหาคำใน select
* @param val คำคนหา
* @param update function
*/
function filterSelector(val: string, update: Function) {
update(() => {
posType.value = null;
posTypeOp.value = posTypeOpMain.value.filter(
(v: DataOption) => v.name.toLowerCase().indexOf(val) > -1
);
});
}
/** callbackFuntioon ทำงานเมื่อมี่การอัปเดทแถว */ /** callbackFuntioon ทำงานเมื่อมี่การอัปเดทแถว */
watch( watch(
() => formFilter.pageSize, () => formFilter.pageSize,
@ -292,7 +308,10 @@ onMounted(() => {
option-value="id" option-value="id"
emit-value emit-value
map-options map-options
use-input
@update:model-value="filterFn" @update:model-value="filterFn"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn )"
> >
<template v-if="posType" v-slot:append> <template v-if="posType" v-slot:append>
<q-icon <q-icon
@ -304,6 +323,11 @@ onMounted(() => {
class="cursor-pointer" class="cursor-pointer"
/> />
</template> </template>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template>
</q-select> </q-select>
</div> </div>
<q-btn flat round dense icon="add" @click="() => (modalForm = true)"> <q-btn flat round dense icon="add" @click="() => (modalForm = true)">