ออกคำสั่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-10-24 16:09:11 +07:00
parent c6acb3e2b8
commit d9561ee830
2 changed files with 151 additions and 82 deletions

View file

@ -103,7 +103,7 @@ const columns = ref<QTableProps["columns"]>([
{
name: "datetext",
align: "left",
label: "วันที่ดำเนินการ",
label: "วันที่ยื่น",
sortable: true,
field: "datetext",
headerStyle: "font-size: 14px",

View file

@ -46,12 +46,11 @@ const {
/** ตัวแปร */
const modalPersonal = ref<boolean>(false);
const personId = ref<string>("");
// const roleUser = ref<string>("");
const roleUser = ref<string>("");
const dataProfile = ref<DataProfile>();
const id = ref<string>(route.params.id.toString());
const myForm = ref<QForm | null>(null);
const myFormConfirm = ref<QForm | null>(null);
const edit = ref<boolean>(false);
const conditions = ref<boolean>(false);
const dataDetail = ref<any>({
@ -95,13 +94,21 @@ const reasonReign = ref<string>("");
const dateBreak = ref<Date | null>(null);
const isCheckData = computed(() => {
console.log(workflowRef.value?.permission.isOperate);
if (
organizationPositionOld.value !== "" &&
positionTypeOld.value !== "" &&
positionLevelOld.value !== "" &&
posNo.value !== "" &&
salary.value !== 0 &&
date.value !== null
date.value !== null &&
(workflowRef.value?.permission.isOperate
? dataDetail.value.commanderReject !== null
: true) &&
(workflowRef.value?.permission.isSign
? dataDetail.value.oligarchReject !== null
: true)
) {
return true;
} else return false;
@ -140,8 +147,12 @@ const columns = ref<QTableProps["columns"]>([
]);
/**เปิด-ปิด modal */
const closeModal = () => (modal.value = false);
const openModal = () => (modal.value = true);
function closeModal() {
modal.value = false;
}
function openModal() {
modal.value = true;
}
const file = ref<any>(null);
const fileList = ref<FileList[]>([]);
@ -175,8 +186,8 @@ async function fetchData(id: string) {
showLoader();
await http
.get(config.API.resingByid(id))
.then((res: any) => {
const data = res.data.result;
.then(async (res) => {
const data = await res.data.result;
dataProfile.value = data as DataProfile;
let list: TypeFile[] = [];
@ -215,80 +226,87 @@ async function fetchData(id: string) {
}
/**Pop up */
function popUp(action: "pass" | "passNot") {
function popUp(action: "pass" | "passNot", type: string) {
reasonReign.value = "";
dateBreak.value = null;
actionPass.value = action === "pass";
roleUser.value = type;
openModal();
}
//pop up
// function conditionPopup() {
// if (myFormConfirm.value !== null) {
// myFormConfirm.value.validate().then(async (check) => {
// if (check) {
// if (actionPass.value) {
// await confirmpopUp();
// } else {
// await rejectpopUp();
// }
// }
// });
// }
// }
function onSubmit() {
if (actionPass.value) {
confirmpopUp();
} else {
rejectpopUp();
}
// if (myFormConfirm.value !== null) {
// myFormConfirm.value.validate().then(async (check) => {
// if (check) {
// }
// });
// }
}
//pop up
// async function confirmpopUp() {
// dialogConfirm(
// $q,
// async () => {
// const body = {
// reason: reasonReign.value,
// };
// await http
// .put(config.API.resignConfirm(roleUser.value, id.value), body)
// .then(() => {
// success($q, "");
// closeModal();
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// fetchData(id.value);
// });
// },
// "",
// " ?"
// );
// }
async function confirmpopUp() {
dialogConfirm(
$q,
async () => {
showLoader();
const body = {
reason: reasonReign.value,
};
await http
.put(config.API.resignConfirm(roleUser.value, id.value), body)
.then(async () => {
await fetchData(id.value);
closeModal();
success($q, "การอนุญาตสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการอนุญาต",
"ต้องการยืนยันการอนุญาตการลานี้หรือไม่ ?"
);
}
//pop up
// async function rejectpopUp() {
// dialogConfirm(
// $q,
// async () => {
// const body = {
// reason: reasonReign.value,
// date: dateBreak.value,
// };
// await http
// .put(config.API.resignReject(roleUser.value, id.value), body)
// .then(() => {
// success($q, "");
// closeModal();
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// fetchData(id.value);
// });
// },
// "",
// " ?"
// );
// }
async function rejectpopUp() {
dialogConfirm(
$q,
async () => {
showLoader();
const body = {
reason: reasonReign.value,
date: dateBreak.value,
};
await http
.put(config.API.resignReject(roleUser.value, id.value), body)
.then(async () => {
await fetchData(id.value);
closeModal();
success($q, "การยับยั้งสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการยับยั้ง",
"ต้องการยืนยันการยับยั้งนี้หรือไม่ ?"
);
}
/**
* กดยกเล
@ -316,8 +334,8 @@ function onSubmitConditions() {
isNoBurden: isNoBurden.value,
isDiscipline: isDiscipline.value,
})
.then(() => {
fetchData(id.value);
.then(async () => {
await fetchData(id.value);
success($q, "บันทึกเงื่อนไขต่าง ๆ สำเร็จ");
conditions.value = false;
})
@ -350,16 +368,16 @@ function onSubmitAttached() {
showLoader();
http
.put(config.API.resingByid(id.value), formData)
.then(() => {
edit.value = false;
.then(async () => {
await fetchData(id.value);
success($q, "บันทึกข้อมูลสำเร็จ");
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(id.value);
await hideLoader();
.finally(() => {
hideLoader();
});
});
}
@ -523,7 +541,7 @@ function removeFile(fileName: string) {
onMounted(async () => {
fetchData(id.value);
fetchFile();
const user = await tokenParsed();
// const user = await tokenParsed();
// if (user) {
// const commander = await user.role.includes("commander");
// const oligarch = await user.role.includes("oligarch");
@ -926,7 +944,7 @@ onMounted(async () => {
</q-card>
<!-- ผลการพจารณาของการเจาหนาทของหนวยงาน -->
<q-card bordered class="row col-12 text-dark q-mt-sm">
<!-- <q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
ผลการพจารณาของการเจาหนาทของหนวยงาน
@ -968,7 +986,7 @@ onMounted(async () => {
</div>
</div>
</div>
</q-card>
</q-card> -->
<!-- ผลการพจารณาของผงคบบญชา -->
<q-card bordered class="row col-12 text-dark q-mt-sm">
@ -976,7 +994,29 @@ onMounted(async () => {
<div class="q-pl-sm text-weight-bold text-dark">
ผลการพจารณาของผงคบบญชา
</div>
<q-space />
<div class="q-gutter-x-sm" v-if="workflowRef?.permission.isOperate">
<q-btn
outline
color="primary"
dense
icon-right="check"
class="q-px-sm"
label="อนุญาต"
@click="popUp('pass', 'commander')"
/>
<q-btn
outline
color="red"
dense
icon-right="close"
class="q-px-sm"
label="ยับยั้ง"
@click="popUp('passNot', 'commander')"
/>
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-pa-md">
<div class="col-12 row bg-white q-col-gutter-md">
@ -1020,6 +1060,27 @@ onMounted(async () => {
<div class="q-pl-sm text-weight-bold text-dark">
ผลการพจารณาของผอำนาจ
</div>
<q-space />
<div class="q-gutter-x-sm" v-if="workflowRef?.permission.isSign">
<q-btn
outline
color="primary"
dense
icon-right="check"
class="q-px-sm"
label="อนุญาต"
@click="popUp('pass', 'oligarch')"
/>
<q-btn
outline
color="red"
dense
icon-right="close"
class="q-px-sm"
label="ยับยั้ง"
@click="popUp('passNot', 'oligarch')"
/>
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-pa-md">
@ -1307,7 +1368,7 @@ onMounted(async () => {
<q-dialog v-model="modal" persistent>
<q-card style="width: 800px">
<q-form ref="myFormConfirm">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<DialogHeader
:tittle="`${actionPass ? 'อนุญาตการลาออก' : 'ยับยั้งการลาออก'}`"
:close="closeModal"
@ -1324,6 +1385,7 @@ onMounted(async () => {
v-model="reasonReign"
:label="`${'กรอกความคิดเห็น/เหตุผล'}`"
type="textarea"
class="inputgreen"
/>
</div>
<div class="col-xs-12 col-sm-12 col-md-12" v-if="!actionPass">
@ -1343,6 +1405,7 @@ onMounted(async () => {
<q-input
outlined
dense
class="inputgreen"
:model-value="
dateBreak !== null ? date2Thai(dateBreak) : null
"
@ -1354,6 +1417,7 @@ onMounted(async () => {
<q-icon
name="event"
class="cursor-pointer"
color="primary"
:style="
edit
? 'color: var(--q-primary)'
@ -1368,6 +1432,11 @@ onMounted(async () => {
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="บันทึก" color="secondary" type="submit"
><q-tooltip>นทกขอม</q-tooltip></q-btn
>
</q-card-actions>
<!-- <DialogFooter :editvisible="true" :save="conditionPopup" /> -->
</q-form>
</q-card>