feat:Change Round Multiple

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-03-24 13:08:17 +07:00
parent 1d99705b65
commit f899f05527
4 changed files with 358 additions and 189 deletions

View file

@ -27,7 +27,11 @@ const {
convertDateToAPI,
} = mixin;
const emit = defineEmits(["update:change-page"]);
const emit = defineEmits(["update:change-page", "update:selected"]);
const isMultiple = defineModel<boolean>("isMultiple", {
default: false,
});
/**Props */
const props = defineProps({
@ -40,6 +44,10 @@ const props = defineProps({
type: String,
default: "",
},
selectedMultiple: {
type: Array,
default: () => [],
},
});
/**FormData */
@ -118,18 +126,35 @@ function onSubmit() {
async function changeRound() {
const formattedDateForAPI = await convertDateToAPI(formData.effectiveDate);
const url =
const urlAPI =
props.type == "emp" ? config.API.leaveRoundEMP() : config.API.leaveRound();
showLoader();
await http
.post(url, {
const urlFull = isMultiple.value ? urlAPI + `/multiple ` : urlAPI;
let payload: any;
if (isMultiple.value && props.selectedMultiple.length > 0) {
payload = props.selectedMultiple.map((item: any) => ({
profileId: item.profileId,
roundId: formData.round,
effectiveDate: formattedDateForAPI,
remark: formData.reson,
}));
} else {
payload = {
profileId: props.personId,
roundId: formData.round,
effectiveDate: formattedDateForAPI,
remark: formData.reson,
})
};
}
await http
.post(urlFull, payload)
.then(() => {
success($q, "บันทึกข้อมูลเปลี่ยนรอบเวลา");
if (isMultiple.value) {
emit("update:selected");
isMultiple.value = false;
}
props.closeDialog?.();
})
.catch((err) => {
@ -242,10 +267,10 @@ watch(
? "เปลี่ยนรอบการปฏิบัติงาน"
: "ประวัติการเปลี่ยนรอบการปฏิบัติงาน"
}}
<span class="text-teal-6">{{
props.DataRow ? props.DataRow.fullName : ""
}}</span></q-toolbar-title
>
<span class="text-teal-6" v-if="!isMultiple">
{{ props.DataRow ? props.DataRow.fullName : "" }}
</span>
</q-toolbar-title>
<q-btn
icon="close"
unelevated
@ -259,7 +284,7 @@ watch(
<q-separator />
<q-card-section style="max-height: 50vh" class="scroll q-pa-none">
<div class="q-pa-md">
<div class="row">
<div class="row" v-if="!isMultiple">
<q-icon
name="mdi-label-variant"
class="cursor-pointer self-center"
@ -267,12 +292,12 @@ watch(
size="md"
>
</q-icon>
<span class="self-center text-bold text-blue text-subtitle1"
>รอบปจจ</span
>
<span class="self-center text-subtitle1 q-ml-sm">{{
props.DataRow ? `${props.DataRow.currentRound} น.` : ""
}}</span>
<span class="self-center text-bold text-blue text-subtitle1">
รอบปจจ
</span>
<span class="self-center text-subtitle1 q-ml-sm">
{{ props.DataRow ? `${props.DataRow.currentRound} น.` : "" }}
</span>
</div>
<div class="row q-mt-sm q-col-gutter-sm">
<div class="col-6">