fix fetchprofilePosition

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-25 13:17:18 +07:00
parent ae059a1d5f
commit efcfda8b0e
7 changed files with 49 additions and 475 deletions

View file

@ -7,6 +7,7 @@ import http from "@/plugins/http";
import config from "@/app.config";
import { useEvaluateStore } from "@/modules/06_evaluate/store";
import { useCounterMixin } from "@/stores/mixin";
import { useDataStore } from "@/stores/data";
/** import Components*/
import TableListEvaluate from "@/modules/06_evaluate/components/TableListEvaluate.vue"; //
@ -20,6 +21,7 @@ import type { OptionStatus } from "@/modules/06_evaluate/interface/main";
const $q = useQuasar();
const mixin = useCounterMixin();
const store = useEvaluateStore();
const dataStore = useDataStore();
const router = useRouter();
const { showLoader, hideLoader, messageError } = mixin;
@ -98,24 +100,33 @@ async function fetchEvaluteList() {
/** function เรียกรายการประเมิน*/
const statusSubmit = ref<boolean>(true);
async function getProfileCheck() {
await http
.get(config.API.profilePosition())
.then(async (res: any) => {
const data = res.data.result;
if (
data.posTypeRank != 2 ||
(data.posTypeRank == 2 && data.posLevelRank >= 4)
) {
statusSubmit.value = false;
} else {
listMenu.value = await listMenu.value.filter(
(x: ListMenu) => x.level > data.posLevelRank
);
}
})
.catch((err) => {
messageError($q, err);
});
if (!dataStore.dataprofilePosition) {
await http
.get(config.API.profilePosition())
.then(async (res: any) => {
const data = res.data.result;
checkProfilePosition(data);
})
.catch((err) => {
messageError($q, err);
});
} else {
const data = dataStore.dataprofilePosition;
checkProfilePosition(data);
}
}
function checkProfilePosition(data: any) {
if (
data.posTypeRank != 2 ||
(data.posTypeRank == 2 && data.posLevelRank >= 4)
) {
statusSubmit.value = false;
} else {
listMenu.value = listMenu.value.filter(
(x: ListMenu) => x.level > data.posLevelRank
);
}
}
const selectedStatus = ref<string[]>([

View file

@ -1,5 +1,4 @@
// registry
const probationPage = () => import("@/modules/11_probation/views/main.vue");
const probationDetail = () =>
import("@/modules/11_probation/views/mainDetail.vue");
@ -34,15 +33,6 @@ const probationAddevaluascore = () =>
import("@/modules/11_probation/component/addPage/04_addevaluascore.vue");
export default [
{
path: "/probation",
name: "probationMain",
component: probationPage,
meta: {
Auth: true,
Key: [11],
},
},
{
path: "/probation-detail/:id",
name: "probationMainDetail",

View file

@ -1,430 +0,0 @@
<script setup lang="ts">
import avatar from "@/assets/avatar_user.jpg";
import { ref, reactive, onMounted } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import { useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useQuasar, type QTableProps } from "quasar";
import type { ListMain } from "@/modules/11_probation/interface/index/main";
const profileId = ref<string>("");
const rows = ref<ListMain[]>([]);
const rowsData = ref<ListMain[]>([]);
const $q = useQuasar();
const mixin = useCounterMixin();
const {
messageError,
dialogConfirm,
findOrgName,
showLoader,
hideLoader,
date2Thai,
onSearchDataTable,
} = mixin;
const filter = ref<string>("");
const mode = ref<any>($q.screen.gt.xs);
const profileImg = ref<string>("");
const router = useRouter();
const formData = reactive<any>({
prefix: "",
firstName: "",
lastName: "",
position: "",
posExecutiveName: "",
posTypeName: "",
posLevelName: "",
org: "",
});
const sizeImg = ref<string>("");
/** ข้อมูลที่เเสดงในตาราง */
const visibleColumns = ref<string[]>([
"no",
"date_start",
"date_finish",
"mentors",
"commander",
]);
/** หัวตาราง */
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: false,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "date_start",
align: "left",
label: "ตั้งแต่วันที่",
sortable: true,
field: "date_start",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
},
{
name: "date_finish",
align: "left",
label: "ถึงวันที่",
sortable: true,
field: "date_finish",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => date2Thai(v),
},
{
name: "mentors",
align: "left",
label: "ผู้ดูแล",
sortable: true,
field: "mentors",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "commander",
align: "left",
label: "ผู้บังคับบัญชา",
sortable: true,
field: "commander",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
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() {
showLoader();
http
.get(config.API.profilePosition())
.then(async (res) => {
const data = 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);
} else {
profileImg.value = avatar;
}
await getList(data.profileId);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
function getList(id: string) {
http
.get(config.API.probationMain(id))
.then((res) => {
const data = res.data.data;
rows.value = data;
rowsData.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(() => {});
}
function onDetail(id: string) {
router.push(`/probation/detail/${profileId.value}/${id}`);
}
function onSearch() {
rows.value = onSearchDataTable(
filter.value,
rowsData.value,
columns.value ? columns.value : []
);
}
onMounted(async () => {
await getMain();
});
</script>
<template>
<div class="row justify-center">
<div class="col-xs-12 col-sm-12 col-md-11">
<div class="toptitle text-white col-12 row items-center">
รายละเอยดงานทไดบมอบหมาย
</div>
<div class="row q-col-gutter-md">
<div v-if="$q.screen.gt.xs" class="col-12">
<q-card>
<div class="bg-grey-1 row q-pa-sm items-center">
<span class="text-teal text-weight-bold text-body2">{{
formData.firstName
? `${formData.prefix}${formData.firstName} ${formData.lastName}`
: "-"
}}</span>
</div>
<q-resize-observer @resize="onResize" />
<q-card-section class="q-pa-md">
<div class="row">
<div class="col-2 text-center self-center">
<q-avatar :size="sizeImg" rounded>
<img
:src="profileImg"
style="border-radius: 10px; object-fit: cover"
/>
</q-avatar>
</div>
<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>
<div class="row">
<div class="col-4">
{{ formData.position ? formData.position : "-" }}
</div>
<div class="col-4">
{{ formData.posLevelName ? formData.posLevelName : "-" }}
</div>
<div class="col-4">
{{ formData.org ? formData.org : "-" }}
</div>
</div>
</div>
</div>
</q-card-section>
</q-card>
</div>
<div v-else class="col-12">
<q-card bordered>
<div class="bg-grey-1 row q-pa-sm items-center">
<span class="text-teal text-weight-bold text-body2">{{
formData.firstName
? `${formData.prefix}${formData.firstName} ${formData.lastName}`
: "-"
}}</span>
</div>
<q-resize-observer @resize="onResize" />
<q-card-section>
<div class="text-center q-mt-md">
<q-avatar :size="sizeImg" rounded>
<img
:src="profileImg"
style="border-radius: 10px; object-fit: cover"
/>
</q-avatar>
</div>
</q-card-section>
<q-list class="q-mt-md">
<q-item>
<q-item-section>
<q-item-label class="text-grey-6"
>ตำแหนงในสายงาน</q-item-label
>
<q-item-label>{{
formData.position ? formData.position : "-"
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label class="text-grey-6">ระด</q-item-label>
<q-item-label>{{
formData.posLevelName ? formData.posLevelName : "-"
}}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label class="text-grey-6">งก</q-item-label>
<q-item-label>{{
formData.org ? formData.org : "-"
}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-card>
</div>
<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}`)"
flat
round
color="primary"
icon="mdi-plus"
>
<q-tooltip>เพมงานทไดบมอบหมาย</q-tooltip>
</q-btn>
<q-space />
<q-input
class="inputgreen"
outlined
dense
v-model="filter"
label="ค้นหา"
:style="mode ? `max-width: 200px` : `max-width: 150px`"
@keydown.enter.prevent="onSearch"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
<q-select
v-if="$q.screen.gt.xs"
class="q-ml-sm"
dense
multiple
outlined
emit-value
map-options
options-dense
option-value="name"
style="min-width: 140px"
v-model="visibleColumns"
:options="columns"
:display-value="$q.lang.table.columns"
/>
</div>
<div class="q-mt-sm">
<d-table
flat
dense
bordered
ref="table"
virtual-scroll
:rows="rows"
:columns="columns"
:grid="!$q.screen.gt.xs"
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
:virtual-scroll-sticky-size-start="48"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
</q-tr>
</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)"
>
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'status'">
{{ props.row.status ? props.row.status : "-" }}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
<template v-else v-slot:item="props">
<div class="q-mb-xs col-xs-12 col-sm-6 col-md-4 col-lg-3">
<q-card bordered flat>
<q-list dense class="q-mt-lg relative-position">
<q-btn
icon="info"
color="info"
flat
dense
round
size="14px"
class="absolute_button"
@click="onDetail(props.row.id)"
>
<q-tooltip>ประวแกไขตำแหน/เงนเดอน</q-tooltip>
</q-btn>
<q-item v-for="col in props.cols" :key="col.name">
<q-item-section class="fix_top">
<q-item-label
class="text-grey-6 text-weight-medium"
>{{ col.label }}</q-item-label
>
</q-item-section>
<q-item-section class="fix_top">
<q-item-label
class="text-dark text-weight-medium"
>{{ col.value ? col.value : "-" }}</q-item-label
>
</q-item-section>
</q-item>
</q-list>
</q-card>
</div>
</template>
<template v-slot:no-data>
<div
class="full-width row flex-center q-pa-sm rounded-borders text-weight-medium"
>
<span> ไมพบขอม </span>
</div>
</template>
</d-table>
</div>
</q-card>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.absolute_button {
position: absolute;
right: 5px;
top: -20px;
}
.fix_top {
justify-content: start !important;
}
</style>

View file

@ -56,11 +56,11 @@ async function save() {
showLoader();
await http
.post(config.API.summarySurveyDetail(store.assignId), data)
.then((res: any) => {
.then(async () => {
await props.getSurveyData?.();
success($q, "บันทึกสำเร็จ");
props.getSurveyData?.();
})
.catch((e: any) => {
.catch((e) => {
messageError($q, e);
})
.finally(() => {
@ -93,17 +93,16 @@ watch(
}
);
/** get ค่า เมื่อโหลดหน้า */
onMounted(() => {
if (store.tabMain === "SURVEY") {
if (dataSurvey.value !== null) {
answer1.value = dataSurvey.value.answer1;
answer2.value = dataSurvey.value.answer2;
answer3.value = dataSurvey.value.answer3;
status.value = false;
}
if (dataSurvey.value !== null) {
answer1.value = dataSurvey.value.answer1;
answer2.value = dataSurvey.value.answer2;
answer3.value = dataSurvey.value.answer3;
status.value = false;
}
}
});
</script>
<template>

View file

@ -67,7 +67,6 @@ const formData = ref<ProbationReportType>({
* @param type type file
*/
async function clickdownloadFile() {
console.log(props.page);
showLoader();
await http
.get(
@ -80,13 +79,13 @@ async function clickdownloadFile() {
.then(async (res) => {
const data = res.data.downloadUrl;
window.open(data);
hideLoader();
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
hideLoader();
})
.finally(() => {});
.finally(() => {
hideLoader();
});
}
async function getData() {

View file

@ -185,11 +185,13 @@ async function dataEdit(id: string) {
const data = putDataEdit(id);
http
.put(config.API.saveEditAssign(id), data)
.then(() => {})
.then(async () => {
await getAssign();
})
.catch(() => {})
.finally(async () => {
isEdit.value = false;
getAssign();
hideLoader();
});
// } else {