hrms-mgt/src/modules/05_placement/components/PersonalDetail/Qualification.vue

106 lines
2.4 KiB
Vue
Raw Normal View History

2023-06-15 16:07:44 +07:00
<script setup lang="ts">
2023-07-13 09:10:43 +07:00
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
2023-07-13 09:10:43 +07:00
import { useRoute } from "vue-router";
import HeaderTop from "@/modules/05_placement/components/PersonalDetail/Information/top.vue";
2023-07-13 09:10:43 +07:00
import http from "@/plugins/http";
import config from "@/app.config";
import type { PropType } from "vue";
import type { Property } from "@/modules/05_placement/interface/index/Main";
const $q = useQuasar();
const mixin = useCounterMixin();
2023-07-13 09:10:43 +07:00
const route = useRoute();
const { showLoader, hideLoader, messageError, success } = mixin;
const props = defineProps({
statusEdit: {
type: Boolean,
required: true,
},
2023-07-13 09:10:43 +07:00
data: {
type: Array as PropType<Property[]>,
default: [],
},
fetch: {
type: Function,
default: () => console.log("not function"),
},
});
2023-07-13 09:10:43 +07:00
const emit = defineEmits(["update:statusEdit", "update:data"]);
const edit = ref<boolean>(false);
2023-07-13 09:10:43 +07:00
onMounted(() => {
emit("update:statusEdit", false);
});
const saveData = async () => {
2023-07-13 09:10:43 +07:00
showLoader();
await http
.put(
config.API.placementPropertyId(route.params.personalId.toString()),
props.data
)
.then((res: any) => {
success($q, "แก้ไขข้อมูลสำเร็จ");
})
.catch((e: any) => {
messageError($q, e);
})
.finally(async () => {
await props.fetch();
edit.value = false;
hideLoader();
changeBtn();
});
};
const changeBtn = async () => {
if (edit.value == true) {
if (props.statusEdit === true) {
edit.value = false;
} else {
emit("update:statusEdit", true);
}
} else {
emit("update:statusEdit", false);
}
};
const onCancel = async () => {
2023-07-13 09:10:43 +07:00
await props.fetch();
};
2023-06-15 16:07:44 +07:00
</script>
<template>
<div class="row col-12 q-px-lg q-pt-lg q-pb-sm no-border">
2023-07-13 09:10:43 +07:00
<HeaderTop
v-model:edit="edit"
header="การคัดกรองคุณสมบัติ"
icon="mdi-account-search"
:save="saveData"
:history="false"
:changeBtn="changeBtn"
:disable="statusEdit"
:cancel="onCancel"
/>
</div>
2023-06-30 11:11:32 +07:00
<div class="row q-px-lg">
2023-07-13 09:10:43 +07:00
<div v-for="item of props.data" :key="item.name" class="col-12 q-pt-sm">
<q-checkbox
size="xs"
v-model="item.value"
:label="item.name"
keep-color
color="gray-5"
:disable="!statusEdit"
/>
<q-separator />
2023-06-15 16:07:44 +07:00
</div>
</div>
2023-07-13 09:10:43 +07:00
</template>