no message

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-08-29 15:40:02 +07:00
parent e58c87fc72
commit 4b5298961e
2 changed files with 1 additions and 482 deletions

View file

@ -4,6 +4,7 @@ import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useRetirementDataStore } from "@/modules/06_retirement/store";
import DialogHeader from "@/modules/06_retirement/components/DialogHeader.vue";
import http from "@/plugins/http";
import config from "@/app.config";
@ -183,7 +184,6 @@ const columns2 = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "positionTypeOld",
align: "left",

View file

@ -982,67 +982,6 @@ const statusOrder = (val: boolean) => {
</div>
</q-form>
</q-card>
<!-- <q-dialog v-model="modalPass" persistent>
<q-card style="width: 800px">
<q-form ref="myForm">
<DialogHeader
:title="`${modalPass ? 'อนุมัติ' : 'ยับยั้ง'}`"
:close="clickClose"
/>
<q-separator />
<q-card-section class="q-p-sm">
<div class="col-xs-12 col-sm-12 col-md-12">
<q-input
hide-bottom-space
dense
lazy-rules
outlined
:rules="[(val) => !!val || 'กรุณากรอกเหตุผล']"
v-model="userNote"
:label="`${'กรอกเหตุผล'}`"
type="textarea"
/>
</div>
</q-card-section>
<q-separator />
<DialogFooter
:editvisible="true"
:save="modalPass ? savePass : savePassNot"
/>
</q-form>
</q-card>
</q-dialog>
<q-dialog v-model="modalPassNot" persistent>
<q-card style="width: 800px">
<q-form ref="myForm">
<DialogHeader
:title="`${modalPass ? 'อนุมัติ' : 'ยับยั้ง'}`"
:close="clickClose"
/>
<q-separator />
<q-card-section class="q-p-sm">
<div class="col-xs-12 col-sm-12 col-md-12">
<q-input
hide-bottom-space
dense
outlined
lazy-rules
:rules="[(val) => !!val || 'กรุณากรอกเหตุผล']"
v-model="userNote"
:label="`${'กรอกเหตุผล'}`"
type="textarea"
/>
</div>
</q-card-section>
<q-separator />
<DialogFooter
:editvisible="true"
:save="modalPass ? savePass : savePassNot"
/>
</q-form>
</q-card>
</q-dialog> -->
<q-dialog v-model="modal" persistent>
<q-card style="width: 800px">
<q-form ref="myFormConfirm">
@ -1115,426 +1054,6 @@ const statusOrder = (val: boolean) => {
</q-dialog>
</template>
<!-- import CurrencyInput from "@/components/CurruncyInput.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import type {
ResponseItems,
TypeFile,
} from "@/modules/06_retirement/interface/response/Main";
import type { QTableProps } from "quasar";
const $q = useQuasar();
const route = useRoute();
const router = useRouter();
const mixin = useCounterMixin();
const RetirementData = useRetirementDataStore();
const {
messageError,
date2Thai,
showLoader,
hideLoader,
success,
dialogMessage,
} = mixin;
const { statusText } = RetirementData;
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 dataDetail = ref<ResponseItems>({
datetext: "",
activeDate: new Date(),
createdAt: new Date(),
firstName: "",
id: "",
isActive: true,
lastName: "",
location: "",
organizationPositionOld: "",
positionLevelOld: "",
positionNumberOld: "",
positionTypeOld: "",
prefix: "",
profileId: "",
reason: "",
salary: 0,
sendDate: new Date(),
status: "",
statustext: "",
fullname: "",
});
const organizationPositionOld = ref<string>("");
const positionTypeOld = ref<string>("");
const positionLevelOld = ref<string>("");
const posNo = ref<string>("");
const salary = ref<number>(0);
const date = ref<Date | null>(null);
const dateLeave = ref<Date | null>(null);
const reason = ref<string>("");
const location = ref<string>("");
const status = ref<string>("");
const modal = ref<boolean>(false);
const actionPass = ref<boolean>(false);
const reasonReign = ref<string>("");
const dateBreak = ref<Date | null>(null);
const rows = ref<TypeFile[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: true,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "fileName",
align: "left",
label: "ชื่อไฟล์",
sortable: true,
field: "fileName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "btnMicrosoft",
align: "right",
label: "ปุ่ม",
sortable: true,
field: "btnMicrosoft",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const rowsFileDownload = ref<TypeFile[]>([
{fileName: "หนังสือลาออกจากราขการ",
pathName: ""}]);
const closeModal = () => (modal.value = false);
const openModal = () => (modal.value = true);
// const modalPass = ref<boolean>(false);
// const modalPassNot = ref<boolean>(false);
onMounted(() => {
fetchData(id.value);
// fetchAttachment('pdf',id.value)
// fetchAttachment('docx',id.value)
// downloadAttachment('pdf',id.value)
});
const diffDate = () => {
if (date.value !== null && dateLeave.value !== null) {
const time = dateLeave.value.getTime() - date.value.getTime();
// -
const day = time / (1000 * 3600 * 24);
if (day < 30) {
return true;
}
return false;
}
return false;
};
const fetchData = async (id: string) => {
showLoader();
await http
.get(config.API.resingByid(id))
.then((res: any) => {
const data = res.data.result;
// console.log(data);
let list: TypeFile[] = [];
if (data.docs.length > 0) {
data.docs.map((doc: TypeFile) => {
list.push({
pathName: doc.pathName ?? "",
fileName: doc.fileName ?? "",
});
console.log(doc.fileName);
});
}
rows.value = list;
dataDetail.value = data;
organizationPositionOld.value = data.organizationPositionOld ?? "";
positionTypeOld.value = data.positionTypeOld ?? "";
positionLevelOld.value = data.positionLevelOld ?? "";
posNo.value = data.positionNumberOld ?? "";
salary.value = data.salary ? data.salary : 0;
date.value = data.sendDate ? new Date(data.sendDate) : null;
dateLeave.value = data.activeDate ? new Date(data.activeDate) : null;
reason.value = data.reason ?? "";
location.value = data.location ?? "";
status.value = data.status ?? "";
})
.catch((e) => {
console.log(e);
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
const fetchAttachment = async (type:string , id: string) => {
showLoader();
await http
.get(config.API.reportResignList(type, id))
.then((res: any) => {
const data = res.data.result;
// console.log(data);
let list: TypeFile[] = [];
if (data.docs.length > 0) {
data.docs.map((doc: TypeFile) => {
list.push({
pathName: doc.pathName ?? "",
fileName: doc.fileName ?? "",
});
console.log(doc.fileName);
});
}
rowsFileDownload.value = list;
})
.catch((e) => {
console.log(e);
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
const downloadAttachment = async (type:string , id: string) => {
showLoader();
await http
.get(config.API.reportResignList(type, id), {
responseType: "blob",
})
.then(async (res) => {
const data = res.data.result;
console.log(data);
let list: TypeFile[] = [];
downloadFile(res, `หนังสือลาออกจากราขการ.${type}`);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
const downloadFile = (response: any, filename: string) => {
const link = document.createElement("a");
var fileName = filename;
link.href = window.URL.createObjectURL(new Blob([response.data]));
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
const popUp = (action: "pass" | "passNot") => {
reasonReign.value = "";
dateBreak.value = null;
actionPass.value = action === "pass";
openModal();
// if (action === "pass") {
// $q.dialog({
// title: "",
// message: "?",
// cancel: {
// flat: true,
// color: "negative",
// },
// persistent: true,
// }).onOk(async () => {
// confirmpopUp();
// });
// } else if (action === "passNot") {
// $q.dialog({
// title: "",
// message: "?",
// cancel: {
// flat: true,
// color: "negative",
// },
// persistent: true,
// }).onOk(async () => {
// rejectpopUp();
// });
// }
};
const conditionPopup = () => {
if (myFormConfirm.value !== null) {
myFormConfirm.value.validate().then(async (check) => {
if (check) {
if (actionPass.value) {
await confirmpopUp();
} else {
await rejectpopUp();
}
}
});
}
};
const confirmpopUp = async () => {
const body = {
reason: reasonReign.value,
};
await http
.put(config.API.resignConfirm(id.value), body)
.then(() => {
console.log("ยืนยัน");
success($q, "การอนุมัติสำเร็จ");
closeModal();
})
.catch((e) => {
console.log(e);
messageError($q, e);
})
.finally(() => {
fetchData(id.value);
});
};
const rejectpopUp = async () => {
const body = {
reason: reasonReign.value,
};
await http
.put(config.API.resignReject(id.value), body)
.then(() => {
success($q, "การยับยั้งสำเร็จ");
closeModal();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
fetchData(id.value);
});
};
const redirectToRegistry = (id: string) => {
router.push(`/registry/${id}`);
};
const conditionSave = () => {
if (myForm.value !== null) {
myForm.value.validate().then((success) => {
if (success) {
dialogMessage(
$q,
"ต้องการแก้ไขข้อมูลหรือไม่?",
"แก้ไขข้อมูลรายละเอียดการลาออก",
"mdi-help-circle-outline",
"ตกลง",
"public",
async () => await saveData(),
undefined
);
}
});
}
};
const saveData = async () => {
const formData = new FormData();
const send = date.value !== null ? new Date(date.value).toUTCString() : "";
const activeDate =
dateLeave.value !== null ? new Date(dateLeave.value).toUTCString() : "";
formData.append("Location", location.value);
formData.append("SendDate", send);
formData.append("ActiveDate", activeDate);
formData.append("Reason", reason.value);
formData.append("OrganizationPositionOld", organizationPositionOld.value);
formData.append("PositionTypeOld", positionTypeOld.value);
formData.append("PositionLevelOld", positionLevelOld.value);
formData.append("PositionNumberOld", posNo.value);
formData.append("AmountOld", salary.value.toString());
salary;
showLoader();
await http
.put(config.API.resingByid(id.value), formData)
.then((res: any) => {
// const data = res.data.result;
// console.log(data);
success($q, "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้ายสำเร็จ");
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await fetchData(id.value);
hideLoader();
});
};
// const clickClose = () => {
// userNote.value = "";
// modalPass.value = false;
// modalPassNot.value = false;
// };
// const savePass = () => {
// $q.dialog({
// title: "",
// message: " ?",
// cancel: {
// flat: true,
// const: "negative",
// },
// persistent: true,
// })
// .onOk(() => {
// modalPass.value = false;
// console.log("----MSG---- :", userNote.value);
// console.log("passSave (close)");
// userNote.value = "";
// })
// .onCancel(() => {})
// .onDismiss(() => {});
// };
// const savePassNot = () => {
// $q.dialog({
// title: "",
// message: " ?",
// cancel: {
// flat: true,
// const: "negative",
// },
// persistent: true,
// })
// .onOk(() => {
// modalPass.value = false;
// console.log("----MSG---- :", userNote.value);
// console.log("passSaveNot (close)");
// userNote.value = "";
// })
// .onCancel(() => {})
// .onDismiss(() => {});
// };
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
</script> -->
<style lang="scss" scope>
.q-img {
border-radius: 5px;