Merge branch 'nice_dev' into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-27 16:58:47 +07:00
commit d48aeb9369
6 changed files with 209 additions and 73 deletions

View file

@ -10,12 +10,17 @@ import config from "@/app.config";
const $q = useQuasar(); const $q = useQuasar();
const modal = defineModel<boolean>("modal", { required: true }); const modal = defineModel<boolean>("modal", { required: true });
const amount = ref<number | null>(null); const amount = defineModel<number | null>("amount", { required: true });
const profileId = defineModel<string>("profileId", { required: true });
const props = defineProps({
fetchData: {
type: Function,
},
});
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { dialogConfirm, date2Thai, messageError } = mixin; const { dialogConfirm, success, messageError } = mixin;
/*** ฟังก์ชั่นสำหรับ validate ฟอร์ม */ /*** ฟังก์ชั่นสำหรับ validate ฟอร์ม */
function validateForm() { function validateForm() {
@ -24,25 +29,33 @@ function validateForm() {
function close() { function close() {
modal.value = false; modal.value = false;
amount.value = null amount.value = null;
} }
function onSubmit() { function onSubmit() {
dialogConfirm($q, () => { dialogConfirm($q, () => {
const body = { if (amount.value) {
profileId: '????????????????????????????????????????????', const amountString: string = amount.value.toString();
amount: amount.value, const body = {
}; profileId: profileId.value,
http amount:
.post(config.API.salaryPeriod() + `/change/amount`, body) typeof amount.value === "number"
.then((res) => { ? amount.value
modal.value = false; : Number(amountString.replace(/,/g, "")),
amount.value = null };
}) http
.catch((e) => { .post(config.API.salaryPeriod() + `/change/amount`, body)
messageError($q, e); .then(() => {
}) success($q, "บันทึกข้อมูลสำเร็จ");
.finally(() => {}); props.fetchData?.();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
close();
});
}
}); });
} }

View file

@ -6,18 +6,25 @@ import type { DataOption } from "@/modules/13_salary/interface/response/Main";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import http from "@/plugins/http"; import http from "@/plugins/http";
import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsStore";
import config from "@/app.config"; import config from "@/app.config";
const $q = useQuasar(); const $q = useQuasar();
const store = useSalaryListSDataStore();
const modal = defineModel<boolean>("modal", { required: true }); const modal = defineModel<boolean>("modal", { required: true });
const profileId = defineModel<string>("profileId", { required: true });
const props = defineProps({
group: { type: String },
fetchData: {
type: Function,
},
});
const group = ref<string>(""); const group = ref<string>("");
const isReadonly = ref<boolean>(false); // const isReadonly = ref<boolean>(false); //
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { dialogConfirm, date2Thai, messageError } = mixin; const { dialogConfirm, success, messageError, showLoader, hideLoader } = mixin;
const groupOp = ref<DataOption[]>([
{ id: "g1", name: "กลุ่ม1" },
{ id: "g2", name: "กลุ่ม2" },
]);
/*** ฟังก์ชั่นสำหรับ validate ฟอร์ม */ /*** ฟังก์ชั่นสำหรับ validate ฟอร์ม */
function validateForm() { function validateForm() {
@ -31,20 +38,24 @@ function close() {
function onSubmit() { function onSubmit() {
dialogConfirm($q, () => { dialogConfirm($q, () => {
showLoader();
const body = { const body = {
profileId: "????????????????????????????????????????????", profileId: profileId.value,
groupId: group.value, groupId: group.value,
}; };
http http
.post(config.API.salaryPeriod() + `/change/group`, body) .post(config.API.salaryPeriod() + `/change/group`, body)
.then((res) => { .then(() => {
modal.value = false; success($q, "บันทึกข้อมูลสำเร็จ");
group.value = ""; props.fetchData?.();
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => {}); .finally(() => {
hideLoader();
close();
});
}); });
} }
@ -75,7 +86,7 @@ function inputEdit(val: boolean) {
map-options map-options
option-label="name" option-label="name"
option-value="id" option-value="id"
:options="groupOp" :options="store.groupOp.filter((e) => e.name !== props.group)"
:rules="[(val) => !!val || `${'กรุณาเลือกรอบการขึ้นเงินเดือน'}`]" :rules="[(val) => !!val || `${'กรุณาเลือกรอบการขึ้นเงินเดือน'}`]"
lazy-rules lazy-rules
hide-bottom-space hide-bottom-space

View file

@ -7,13 +7,22 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsStore";
const $q = useQuasar(); const $q = useQuasar();
const store = useSalaryListSDataStore();
const modal = defineModel<boolean>("modal", { required: true }); const modal = defineModel<boolean>("modal", { required: true });
const profileId = defineModel<string>("profileId", { required: true });
const type = ref<string>(""); const type = ref<string>("");
const isReadonly = ref<boolean>(false); // const isReadonly = ref<boolean>(false); //
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { dialogConfirm, date2Thai, messageError } = mixin; const { dialogConfirm, success, messageError, showLoader, hideLoader } = mixin;
const props = defineProps({
fetchData: {
type: Function,
},
});
const typeOp = ref<DataOption[]>([ const typeOp = ref<DataOption[]>([
{ id: "NONE", name: "ไม่ได้เลื่อน" }, { id: "NONE", name: "ไม่ได้เลื่อน" },
{ id: "HAFT", name: "ครึ่งขั้น" }, { id: "HAFT", name: "ครึ่งขั้น" },
@ -33,20 +42,24 @@ function close() {
function onSubmit() { function onSubmit() {
dialogConfirm($q, () => { dialogConfirm($q, () => {
showLoader();
const body = { const body = {
profileId: "????????????????????????????????????????????", profileId: profileId.value,
type: type.value, type: type.value,
}; };
http http
.post(config.API.salaryPeriod() + `/change/type`, body) .post(config.API.salaryPeriod() + `/change/type`, body)
.then((res) => { .then(() => {
modal.value = false; success($q, "บันทึกข้อมูลสำเร็จ");
type.value = ""; props.fetchData?.();
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => {}); .finally(() => {
close();
hideLoader();
});
}); });
} }
@ -77,7 +90,7 @@ function inputEdit(val: boolean) {
map-options map-options
option-label="name" option-label="name"
option-value="id" option-value="id"
:options="typeOp" :options="typeOp.filter((e) => e.id !== store.tabType)"
:rules="[(val) => !!val || `${'กรุณาเลือก ขั้น'}`]" :rules="[(val) => !!val || `${'กรุณาเลือก ขั้น'}`]"
lazy-rules lazy-rules
hide-bottom-space hide-bottom-space

View file

@ -12,10 +12,17 @@ import type {
} from "@/modules/13_salary/interface/index/Main"; } from "@/modules/13_salary/interface/index/Main";
import type { DataFilter } from "@/modules/13_salary/interface/index/SalaryList"; import type { DataFilter } from "@/modules/13_salary/interface/index/SalaryList";
/** importComponents*/
import DialogFormEdit from "@/modules/13_salary/components/SalaryLists/DialogFormEdit.vue";
import DialogMoveGroup from "@/modules/13_salary/components/SalaryLists/DialogMoveGroup.vue";
import DialogMoveLevel from "@/modules/13_salary/components/SalaryLists/DialogMoveLevel.vue";
/** importStore*/ /** importStore*/
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsStore";
const $q = useQuasar(); const $q = useQuasar();
const store = useSalaryListSDataStore();
const { const {
date2Thai, date2Thai,
dialogRemove, dialogRemove,
@ -119,34 +126,28 @@ const visibleColumns = ref<string[]>([
"amountUse", "amountUse",
]); ]);
/** List Mune*/ /** modal*/
const itemMenu = ref<ItemsMenu[]>([ const modalDialogForm = ref<boolean>(false);
{ const modalDialogMoveGroup = ref<boolean>(false);
label: "แก้ไขเงินเดือน", const modalDialogMoveLeve = ref<boolean>(false);
icon: "edit",
color: "edit", const profileId = ref<string>("");
type: "edit", const amount = ref<number>(0);
}, function onClickEdit(id: string, amountSalary: number) {
{ profileId.value = id;
label: "ย้ายกลุ่ม", amount.value = amountSalary;
icon: "mdi-account-arrow-right-outline", modalDialogForm.value = !modalDialogForm.value;
color: "indigo-6", }
type: "moveGroup",
}, function onClickMovieGroup(id: string) {
{ profileId.value = id;
label: "ย้ายขั้น", modalDialogMoveGroup.value = !modalDialogMoveGroup.value;
icon: "mdi-account-arrow-left-outline", }
color: "green-6",
type: "moveStep", function onClickMoveLevel(id: string) {
}, profileId.value = id;
{ modalDialogMoveLeve.value = !modalDialogMoveLeve.value;
label: "ลบ", }
icon: "delete",
color: "red",
type: "delete",
},
]);
const filter = ref<string>("");
function onClickDelete(id: string) { function onClickDelete(id: string) {
dialogRemove($q, async () => { dialogRemove($q, async () => {
@ -232,7 +233,6 @@ watch(
bordered bordered
:paging="true" :paging="true"
dense dense
:filter="filter"
:rows-per-page-options="[10, 25, 50, 100]" :rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns" :visible-columns="visibleColumns"
@update:pagination="updatePageSizePagination" @update:pagination="updatePageSizePagination"
@ -282,12 +282,20 @@ watch(
<q-menu> <q-menu>
<q-list dense style="min-width: 150px"> <q-list dense style="min-width: 150px">
<q-item <q-item
v-for="(item, index) in itemMenu" v-for="(item, index) in store.itemMenu"
:key="index" :key="index"
clickable clickable
v-close-popup v-close-popup
@click=" @click="
item.type === 'delete' ? onClickDelete(props.row.id) : null item.type === 'edit'
? onClickEdit(props.row.id, props.row.amount)
: item.type === 'moveGroup'
? onClickMovieGroup(props.row.id)
: item.type === 'moveLevel'
? onClickMoveLevel(props.row.id)
: item.type === 'delete'
? onClickDelete(props.row.id)
: null
" "
> >
<q-item-section> <q-item-section>
@ -319,6 +327,25 @@ watch(
@update:model-value="updatePagePagination()" @update:model-value="updatePagePagination()"
></q-pagination> ></q-pagination>
</d-table> </d-table>
<DialogFormEdit
v-model:modal="modalDialogForm"
v-model:profileId="profileId"
v-model:amount="amount"
:fetchData="props.updatePagination"
/>
<DialogMoveGroup
v-model:modal="modalDialogMoveGroup"
v-model:profileId="profileId"
:group="store.tabGroup === 'group1' ? 'กลุ่ม1' : 'กลุ่ม2'"
:fetchData="props.updatePagination"
/>
<DialogMoveLevel
v-model:modal="modalDialogMoveLeve"
v-model:profileId="profileId"
:fetchData="props.updatePagination"
:type="store.tabType"
/>
</template> </template>
<style scoped></style> <style scoped></style>

View file

@ -7,6 +7,11 @@ import type { QTableProps } from "quasar";
import type { NewPagination } from "@/modules/13_salary/interface/index/Main"; import type { NewPagination } from "@/modules/13_salary/interface/index/Main";
import type { DataFilter } from "@/modules/13_salary/interface/index/SalaryList"; import type { DataFilter } from "@/modules/13_salary/interface/index/SalaryList";
/** importComponents*/
import DialogFormEdit from "@/modules/13_salary/components/SalaryLists/DialogFormEdit.vue";
import DialogMoveGroup from "@/modules/13_salary/components/SalaryLists/DialogMoveGroup.vue";
import DialogMoveLevel from "@/modules/13_salary/components/SalaryLists/DialogMoveLevel.vue";
/** importStore*/ /** importStore*/
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsStore"; import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsStore";
@ -130,7 +135,13 @@ const props = defineProps({
}, },
}); });
const filter = ref<string>(""); /** modal*/
const modalDialogForm = ref<boolean>(false);
const modalDialogMoveGroup = ref<boolean>(false);
const modalDialogMoveLeve = ref<boolean>(false);
const profileId = ref<string>("");
const amount = ref<number>(0);
function onClickDelete() { function onClickDelete() {
dialogRemove($q, () => { dialogRemove($q, () => {
@ -138,6 +149,22 @@ function onClickDelete() {
}); });
} }
function onClickEdit(id: string, amountSalary: number) {
profileId.value = id;
amount.value = amountSalary;
modalDialogForm.value = !modalDialogForm.value;
}
function onClickMovieGroup(id: string) {
profileId.value = id;
modalDialogMoveGroup.value = !modalDialogMoveGroup.value;
}
function onClickMoveLevel(id: string) {
profileId.value = id;
modalDialogMoveLeve.value = !modalDialogMoveLeve.value;
}
function updatePagePagination() { function updatePagePagination() {
props.updatePagination?.(); props.updatePagination?.();
} }
@ -307,7 +334,17 @@ watch(
:key="index" :key="index"
clickable clickable
v-close-popup v-close-popup
@click="item.type === 'delete' ? onClickDelete() : null" @click="
item.type === 'edit'
? onClickEdit(props.row.id, props.row.amount)
: item.type === 'moveGroup'
? onClickMovieGroup(props.row.id)
: item.type === 'moveLevel'
? onClickMoveLevel(props.row.id)
: item.type === 'delete'
? onClickDelete()
: null
"
> >
<q-item-section> <q-item-section>
<div class="row items-center"> <div class="row items-center">
@ -340,6 +377,24 @@ watch(
></q-pagination> ></q-pagination>
</template> </template>
</d-table> </d-table>
<DialogFormEdit
v-model:modal="modalDialogForm"
v-model:profileId="profileId"
v-model:amount="amount"
:fetchData="props.updatePagination"
/>
<DialogMoveGroup
v-model:modal="modalDialogMoveGroup"
v-model:profileId="profileId"
:group="store.tabGroup === 'group1' ? 'กลุ่ม1' : 'กลุ่ม2'"
:fetchData="props.updatePagination"
/>
<DialogMoveLevel
v-model:modal="modalDialogMoveLeve"
v-model:profileId="profileId"
:fetchData="props.updatePagination"
/>
</template> </template>
<style scoped></style> <style scoped></style>

View file

@ -2,13 +2,20 @@ import { defineStore } from "pinia";
import { ref } from "vue"; import { ref } from "vue";
/** importType*/ /** importType*/
import type { ItemsMenu } from "@/modules/13_salary/interface/index/Main"; import type {
ItemsMenu,
DataOption,
} from "@/modules/13_salary/interface/index/Main";
import type { DataPeriodLatest } from "@/modules/13_salary/interface/response/SalaryList"; import type { DataPeriodLatest } from "@/modules/13_salary/interface/response/SalaryList";
export const useSalaryListSDataStore = defineStore("salaryListStore", () => { export const useSalaryListSDataStore = defineStore("salaryListStore", () => {
const titelPage = ref<string>(""); const titelPage = ref<string>("");
const tabGroup = ref<string>("group1"); const tabGroup = ref<string>("group1");
const tabType = ref<string>("PENDING"); const tabType = ref<string>("PENDING");
const groupOp = ref<DataOption[]>([
{ id: "", name: "กลุ่ม1" },
{ id: "", name: "กลุ่ม2" },
]);
const groupId = ref<string>(""); const groupId = ref<string>("");
/** List Menu*/ /** List Menu*/
const itemMenu = ref<ItemsMenu[]>([ const itemMenu = ref<ItemsMenu[]>([
@ -28,7 +35,7 @@ export const useSalaryListSDataStore = defineStore("salaryListStore", () => {
label: "ย้ายขั้น", label: "ย้ายขั้น",
icon: "mdi-account-arrow-left-outline", icon: "mdi-account-arrow-left-outline",
color: "green-6", color: "green-6",
type: "moveStep", type: "moveLevel",
}, },
{ {
label: "ลบ", label: "ลบ",
@ -46,6 +53,16 @@ export const useSalaryListSDataStore = defineStore("salaryListStore", () => {
: data.period === "APR" : data.period === "APR"
? "รอบเมษายน" ? "รอบเมษายน"
: "รอบตุลาคม"; : "รอบตุลาคม";
groupOp.value[0].id = data.group1id;
groupOp.value[1].id = data.group2id;
} }
return { titelPage, tabGroup, tabType, itemMenu, groupId, fetchPeriodLatest }; return {
titelPage,
tabGroup,
tabType,
itemMenu,
groupId,
fetchPeriodLatest,
groupOp,
};
}); });