This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-30 11:16:21 +07:00
parent db60969d3f
commit 2f95271b1b
5 changed files with 139 additions and 99 deletions

View file

@ -89,9 +89,9 @@ const router = useRouter();
async function fetchEvaluation() {
showLoader();
await http
.get(config.API.kpiEvaluationUser + `/${id.value}`)
.get(config.API.kpiEvaluationUser + `/admin/${id.value}`)
.then(async (res) => {
const data = res.data.result;
const data = await res.data.result;
store.dataEvaluation = await data;
formProfile.status = await store.convertStatus(data.evaluationStatus);
formProfile.result = await store.convertResults(data.evaluationResults);
@ -240,7 +240,7 @@ async function getProfile() {
.then(async (res) => {
const data = await res.data.result;
store.dataProfile = await data;
await setTimeout(() => {
setTimeout(() => {
store.checkStep();
}, 1000);
})

View file

@ -112,7 +112,7 @@ function fetchRoundOption() {
roundOp.value = list;
store.formQuery.round = list[0].id;
fetchList();
await fetchList();
} else {
roundOp.value = [];
store.formQuery.round = "";
@ -127,7 +127,7 @@ function fetchRoundOption() {
}
// const status = ref<string>("");
function fetchList() {
async function fetchList() {
showLoader();
const body = {
page: formQuery.page,
@ -136,13 +136,12 @@ function fetchList() {
keyword: store.formQuery.keyword
? store.formQuery.keyword.replace(/\s+/g, "")
: store.formQuery.keyword,
// status: status.value,
};
http
await http
.post(config.API.kpiUserEvaluation + `/list`, body)
.then((res) => {
const data = res.data.result;
.then(async (res) => {
const data = await res.data.result;
maxPage.value = Math.ceil(data.total / formQuery.pageSize);
totalList.value = data.total;
rows.value = data.data;

View file

@ -1,10 +1,8 @@
<script setup lang="ts">
import avatar from "@/assets/avatar_user.jpg";
import { ref, reactive, onMounted } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import avatar from "@/assets/avatar_user.jpg";
import { useRoute, useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { useQuasar, type QTableProps } from "quasar";
@ -20,19 +18,10 @@ interface ListMain {
}
const profileId = ref<string>("");
const rows = ref<ListMain[]>([]);
const $q = useQuasar();
const mixin = useCounterMixin();
const {
messageError,
dialogConfirm,
findOrgName,
showLoader,
hideLoader,
date2Thai,
} = mixin;
const { messageError, findOrgName, showLoader, hideLoader, date2Thai } = mixin;
const filter = ref<string>("");
const mode = ref<any>($q.screen.gt.xs);
const profileImg = ref<string>("");
const router = useRouter();
@ -50,16 +39,9 @@ const formData = reactive<any>({
});
const sizeImg = ref<string>("");
/** ข้อมูลที่เเสดงในตาราง */
const visibleColumns = ref<string[]>([
"no",
"date_start",
"date_finish",
"mentors",
"commander",
]);
/** หัวตาราง */
/** Table */
const rows = ref<ListMain[]>([]);
const filter = ref<string>("");
const columns = ref<QTableProps["columns"]>([
{
name: "no",
@ -109,38 +91,45 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const visibleColumns = ref<string[]>([
"no",
"date_start",
"date_finish",
"mentors",
"commander",
]);
function onResize(size: any) {
const width = size.width > 100 ? 100 : size.width;
sizeImg.value = `${width}px`;
}
function onMobile(type: string) {
router.push(`/registry/${type}`);
}
function getMain() {
/**
* fetch แมลสวนต
*/
async function getMain() {
showLoader();
http
await http
.get(config.API.profilePosition + `/${idEva.value}`)
.then(async (res) => {
const data = res.data.result;
const data = await res.data.result;
formData.prefix = data.prefix;
formData.firstName = data.firstName;
formData.lastName = data.lastName;
formData.position = data.position;
formData.posTypeName = data.posTypeName;
formData.posExecutiveName = data.posExecutiveName;
formData.posLevelName = data.posLevelName;
formData.org = findOrgName(data);
profileId.value = data.profileId;
if (data.avatarName) {
getImg(data.profileId, data.avatarName);
const promises = [];
promises.push(getList(data.profileId)); // fetch
if (profileId.value) {
promises.push(fetchProfilePhoto(profileId.value)); // fetch
} else {
profileImg.value = avatar;
}
await getList(data.profileId);
await Promise.all(promises);
})
.catch((e) => {
messageError($q, e);
@ -150,28 +139,71 @@ function getMain() {
});
}
function getList(id: string) {
http
/**
* fetch รายการทดลองงาน
* @param id โปรไฟล
*/
async function getList(id: string) {
showLoader();
await http
.get(config.API.probationGetAssignList(id))
.then((res) => {
const data = res.data.data;
.then(async (res) => {
const data = await res.data.data;
rows.value = data;
})
.catch((e) => {})
.finally(() => {});
}
function getImg(id: string, pathName: string) {
http
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName))
.then((res) => {
profileImg.value = res.data.downloadUrl;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {});
.finally(() => {
hideLoader();
});
}
/**
* chceck ปโปรไฟล
* @param id โปรไฟล
*/
async function fetchProfilePhoto(id: string) {
await http
.get(config.API.orgCheckAvatar(id))
.then(async (res) => {
// fetch
if (res.data.result.avatarName) {
await http
.get(
config.API.fileByFile(
"ทะเบียนประวัติ",
"โปรไฟล์",
id,
res.data.result.avatarName
)
)
.then(async (res) => {
profileImg.value = await res.data.downloadUrl;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
} else {
// set default
profileImg.value = avatar;
}
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* redairect การทดลองปฏหนาทราชการ
* @param id ทดลองงาน
*/
function onDetail(id: string) {
router.push(`/probation/detail/${profileId.value}/${id}`);
}
@ -209,7 +241,7 @@ onMounted(async () => {
<div class="row">
<div class="col-2 text-center self-center">
<q-avatar :size="sizeImg" rounded>
<img
<q-img
:src="profileImg"
style="border-radius: 10px; object-fit: cover"
/>
@ -218,7 +250,7 @@ onMounted(async () => {
<div class="col-10 column justify-center no-wrap">
<div class="row text-grey-6">
<div class="col-4">ตำแหนงในสายงาน</div>
<div class="col-4">ระด</div>
<div class="col-4">ประเภทตำแหน</div>
<div class="col-4">งก</div>
</div>
<div class="row">
@ -226,7 +258,13 @@ onMounted(async () => {
{{ formData.position ? formData.position : "-" }}
</div>
<div class="col-4">
{{ formData.posLevelName ? formData.posLevelName : "-" }}
{{
formData.posTypeName
? formData.posLevelName
? `${formData.posTypeName}(${formData.posLevelName})`
: formData.posTypeName
: "-"
}}
</div>
<div class="col-4">
{{ formData.org ? formData.org : "-" }}
@ -289,16 +327,6 @@ onMounted(async () => {
<div class="col-12 row">
<q-card bordered class="col-12 q-pa-md">
<div class="row">
<!-- <q-btn
@click="router.push(`/probation/add/${profileId}`)"
size="12px"
flat
round
color="add"
icon="mdi-plus"
>
<q-tooltip>เพมงานทไดบมอบหมาย</q-tooltip>
</q-btn> -->
<q-space />
<q-input
class="inputgreen"
@ -357,6 +385,7 @@ onMounted(async () => {
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width />
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
@ -364,12 +393,20 @@ onMounted(async () => {
</template>
<template v-if="$q.screen.gt.xs" v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td
v-for="(col, index) in props.cols"
:key="col.name"
@click="onDetail(props.row.id)"
>
<q-tr :props="props">
<q-td auto-width>
<q-btn
flat
dense
color="info"
icon="mdi-eye"
round
@click="onDetail(props.row.id)"
>
<q-tooltip> รายละเอยด </q-tooltip>
</q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.name">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>