สมรรถนะ

This commit is contained in:
STW_TTTY\stwtt 2024-04-22 09:28:14 +07:00
parent adadddc222
commit 8efa1c227e
2 changed files with 98 additions and 135 deletions

View file

@ -12,11 +12,12 @@ import type { ListGroup } from "@/modules/14_KPI/interface/request/Main";
import http from "@/plugins/http";
import config from "@/app.config";
const id = ref<string>("");
const modal = ref<boolean>(false);
const router = useRouter();
const rows = ref<any>([]);
const editStatus = ref<boolean>(false);
const groupName = ref<string>("");
const groupName = ref<any>();
const position = ref<any>(null);
const competency = ref<any>(null);
@ -56,22 +57,22 @@ const columns = ref<QTableProps["columns"]>([
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "position",
name: "positions",
align: "left",
label: "ตำแหน่ง",
sortable: true,
field: "position",
field: "positions",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "competency",
name: "capacitys",
align: "left",
label: "สมรรถนะประจำกลุ่มงาน",
sortable: true,
field: "competency",
field: "capacitys",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -81,131 +82,48 @@ const columns = ref<QTableProps["columns"]>([
const $q = useQuasar();
const mixin = useCounterMixin();
const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin;
const {
dialogRemove,
messageError,
showLoader,
hideLoader,
success,
dialogConfirm,
} = mixin;
const competencyType = ref<string>("ID1");
const filterKeyword = ref<string>("");
const visibleColumns = ref<string[]>(["groupName", "position", "competency"]);
const visibleColumns = ref<string[]>(["groupName", "positions", "capacitys"]);
/** ดึงข้อมูล */
async function getData() {
const data = [
{
id: "ID1",
groupName: "รายการสมรรถะ 1",
position: [
{
id: "SUB1",
name: "นักจัดการงานทั่วไป",
},
{
id: "SUB2",
name: "เจ้าพนักงานธุรการ",
},
{
id: "SUB3",
name: "เจ้าพนักงานพัสดุ",
},
{
id: "SUB4",
name: "นักวิชาการพัสดุ",
},
],
competency: [
{
id: "SUB1",
name: "การจัดการและควบคุม",
},
{
id: "SUB2",
name: "ความละเอียดรอบคอบ",
},
{
id: "SUB3",
name: "การปรับตัวในการทำงานภายใต้ภาวะกดดัน",
},
],
},
{
id: "ID2",
groupName: "รายการสมรรถะ 1",
position: [
{
id: "SUB1",
name: "นักวิชาการสถิติ",
},
{
id: "SUB2",
name: "เจ้าพนักงานสถิติ",
},
{
id: "SUB3",
name: "เจ้าพนักงานเวชสถิติ",
},
],
competency: [
{
id: "SUB1",
name: "การคิดวิเคราะห์",
},
{
id: "SUB2",
name: "การสืบเสาะหาข้อมูล",
},
{
id: "SUB3",
name: "ความละเอียดรอบคอบ",
},
],
},
];
rows.value = data;
// showLoader();
// await http
// .get(config.API.orgPrefix)
// .then(async (res) => {
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// hideLoader();
// });
}
async function editData(id: string) {
console.log(id);
// await http
// .put(config.API.orgPrefixId(id), {
// name: prefix.value,
// })
// .then(() => {
// getData();
// success($q, "");
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// hideLoader();
// });
showLoader();
http
.get(config.API.kpiLink)
.then((res) => {
const data = res.data.result.data;
rows.value = data;
})
.finally(() => {
hideLoader();
});
}
async function deleteData(id: string) {
console.log(id);
// await http
// .delete(config.API.orgPrefixId(id))
// .then(() => {
// getData();
// success($q, "");
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// hideLoader();w
// });
await http
.delete(config.API.kpiLink + `/${id}`)
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
close();
getData();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** ดึงข้อมูล */
@ -256,20 +174,60 @@ function onAdd() {
modal.value = true;
}
function onEdit(data: any) {
getOptions();
async function onEdit(data: any) {
id.value = data;
await getOptions();
await getListGroup();
await getCompetency();
await getDataEdit(id.value);
modal.value = true;
editStatus.value = true;
}
function getDataEdit(id: string) {
showLoader();
http
.get(config.API.kpiLink + `/${id}`)
.then((res) => {
const data = res.data.result;
groupName.value = {
id:data.groupId,
name:data.groupName
}
position.value = data.positions.map((i:any) => i.name);
competency.value = data.capacitys.map((i:any) => i.id);
})
.finally(() => {
hideLoader();
});
}
function onSubmit() {
console.log("save");
close();
const url = editStatus.value
? config.API.kpiLink + `/${id.value}`
: config.API.kpiLink;
const body = {
kpiGroupId: groupName.value.id,
positions: position.value,
kpiCapacityIds: competency.value,
};
dialogConfirm($q, () => {
http[editStatus.value ? "put" : "post"](url, body)
.then((res) => {
success($q, "บันทึกสำเร็จ");
close();
getData();
})
.finally(() => {});
});
}
function close() {
modal.value = false;
editStatus.value = false;
groupName.value = "";
position.value = [];
competency.value = [];
}
function getOptions() {
@ -374,23 +332,24 @@ onMounted(async () => {
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id" class="vertical-top">
<div v-if="col.name == 'position'">
<q-td
v-for="col in props.cols"
:key="col.id"
class="vertical-top"
@click="onEdit(props.row.id)"
>
<div v-if="col.name == 'positions'">
<div v-if="col.value.length !== 0">
<div
v-for="(pos, index) in col.value"
:key="pos.id"
@click="onEdit(props.row)"
>
<div v-for="(pos, index) in col.value" :key="pos.id">
{{ pos ? `- ${pos.name}` : "-" }}
</div>
</div>
<div v-else>-</div>
</div>
<div v-else-if="col.name == 'competency'">
<div v-else-if="col.name == 'capacitys'">
<div v-if="col.value.length !== 0">
<div v-for="competency in col.value" :key="competency.id">
{{ `- ${competency.name}` }}
{{ competency ? `- ${competency.name}` : "-" }}
</div>
</div>
<div v-else>-</div>
@ -458,7 +417,6 @@ onMounted(async () => {
v-model="groupName"
label="กลุ่มงาน"
outlined
emit-value
class="inputgreen"
map-options
option-label="name"
@ -475,8 +433,9 @@ onMounted(async () => {
multiple
emit-value
map-options
class="inputgreen"
option-label="name"
option-value="id"
option-value="name"
:options="positionOp"
use-input
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) "
@ -493,6 +452,7 @@ onMounted(async () => {
<div class="col-4">
<q-select
dense
class="inputgreen"
v-model="competency"
label="สมรรถนะประจำกลุ่ม"
outlined