รายละเอียดทะเบียนประวัติลูกจ้าง

This commit is contained in:
Thanit Konmek 2023-07-07 15:29:37 +07:00
parent bdc7ab8df3
commit 1e02f42b58
26 changed files with 2419 additions and 1031 deletions

View file

@ -8,6 +8,7 @@
:changeBtn="changeBtn"
:disable="statusEdit"
:save="uploadData"
:addEmployee="statusAdd()"
/>
<div class="row col-12 q-pt-sm">
<q-card bordered flat class="full-width">
@ -153,6 +154,10 @@ const props = defineProps({
type: Function,
default: () => console.log("not function"),
},
statusAdd: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(["update:statusEdit"]);
@ -162,7 +167,9 @@ const $q = useQuasar(); // show dialog
const mixin = useCounterMixin();
const route = useRoute();
const { success, messageError } = mixin;
const profileId = ref<string>(route.params.id.toString());
const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const edit = ref<boolean>(false);
const uploader = ref<any>();
const files = ref<any>([]);
@ -171,22 +178,37 @@ const name = ref<string>("");
onMounted(async () => {
await getData();
defaultAdd();
});
const getData = async () => {
loaderPage(true);
await http
.get(config.API.profilePaperId(profileId.value))
.then((res) => {
const data = res.data.result;
files.value = data;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
if (profileId.value !== "") {
loaderPage(true);
await http
.get(config.API.profilePaperId(profileId.value))
.then((res) => {
const data = res.data.result;
files.value = data;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
loaderPage(false);
});
}
};
const statusAdd = () => props.statusAdd;
const defaultAdd = () => {
if (props.statusAdd) {
edit.value = props.statusAdd;
name.value = "";
if (uploader.value !== null) {
uploader.value.reset();
}
}
};
const deleteData = async (id: string) => {
@ -206,31 +228,33 @@ const deleteData = async (id: string) => {
const uploadData = async () => {
if (file.value.length > 0) {
const blob = file.value.slice(0, file.value[0].size);
const newFile = new File(blob, name.value, {
type: file.value[0].type,
});
const formData = new FormData();
formData.append("avatar", newFile);
formData.append("moss", "newFile");
console.log(formData);
loaderPage(true);
await http
.post(config.API.profilePaperId(profileId.value), formData)
.then((res) => {
const data = res.data.result;
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
uploader.value.reset();
name.value = "";
edit.value = false;
emit("update:statusEdit", false);
await getData();
if (profileId.value !== "") {
const blob = file.value.slice(0, file.value[0].size);
const newFile = new File(blob, name.value, {
type: file.value[0].type,
});
const formData = new FormData();
formData.append("avatar", newFile);
formData.append("moss", "newFile");
console.log(formData);
loaderPage(true);
await http
.post(config.API.profilePaperId(profileId.value), formData)
.then((res) => {
const data = res.data.result;
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
uploader.value.reset();
name.value = "";
edit.value = false;
emit("update:statusEdit", false);
await getData();
});
}
} else {
// modalError(
// $q,