ย้าย code ส่วนที่อยู่ในข้อมูลหลักไว้ module 01_metadataNew (ตัวชี้วัด, สมรรถนะ, ยุทธศาสตร์)

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-05-08 10:48:10 +07:00
parent 10a34f7ba5
commit 94b67c81ec
29 changed files with 698 additions and 214 deletions

View file

@ -1,271 +0,0 @@
<script setup lang="ts">
import { ref, onMounted, reactive, watch } from "vue";
import type { QTableProps } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import type { DataOption } from "@/modules/14_KPI/interface/index/Main";
import type { FormQueryCapacity } from "@/modules/14_KPI/interface/request/Main";
import type { ResDataCapacity } from "@/modules/14_KPI/interface/response/Main";
import { useKPIDataStore } from "@/modules/14_KPI/store/KPIStore";
import http from "@/plugins/http";
import config from "@/app.config";
import type { NewPagination } from "@/modules/14_KPI/interface/index/Main";
const total = ref<number>();
const store = useKPIDataStore();
const router = useRouter();
const $q = useQuasar();
const mixin = useCounterMixin();
const { dialogRemove, messageError, showLoader, hideLoader, success } = mixin;
const competencyTypeOp = ref<DataOption[]>([
{
id: "HEAD",
name: "สมรรถนะหลัก",
},
{
id: "GROUP",
name: "สมรรถนะประจำกลุ่มงาน",
},
{
id: "EXECUTIVE",
name: "สมรรถนะประจำผู้บริหารกรุงเทพมหานคร",
},
{
id: "DIRECTOR",
name: "สมรรถนะเฉพาะสำหรับตำแหน่ง ผอ.เขต ผช.ผอ.เขต และหัวหน้าฝ่ายในสังกัด สนง.เขต",
},
{
id: "INSPECTOR",
name: "สมรรถนะเฉพาะสำหรับตำแหน่งผู้ตรวจราชการ กทม. และผู้ตรวจราชการ",
},
]);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
align: "left",
label: "ชื่อสมรรถนะ",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const visibleColumns = ref<string[]>(["name"]);
const rows = ref<ResDataCapacity[]>([]);
const formQuery = reactive<FormQueryCapacity>({
page: 1,
pageSize: 10,
keyword: "",
});
const totalList = ref<number>(1); //
/** ดึงข้อมูล */
async function fetchList() {
showLoader();
await http
.get(
config.API.kpiCapacity +
`?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}&type=${store.competencyTypeVal}`
)
.then(async (res) => {
total.value = res.data.result.total;
const data: ResDataCapacity[] = res.data.result.data;
totalList.value = Math.ceil(res.data.result.total / formQuery.pageSize);
rows.value = data;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function onViewDetail(id: string) {
router.push(`/KPI-competency/${id}`);
}
function deleteData(id: string) {
dialogRemove($q, () => {
http
.delete(config.API.kpiCapacity + `/${id}`)
.then(() => {
fetchList();
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
}
/** เปลี่ยนเป็นหน้าเพิ่มข้อมูล */
function onAdd() {
router.push(`/KPI-competency/add`);
}
function fetchNewList() {
formQuery.page = 1;
fetchList();
}
/**
* function updatePagination
* @param newPagination อม Pagination ใหม
*/
function updatePagination(newPagination: NewPagination) {
formQuery.page = 1;
formQuery.pageSize = newPagination.rowsPerPage;
}
watch(
() => formQuery.pageSize,
() => {
fetchNewList();
}
);
onMounted(() => {
fetchList();
});
</script>
<template>
<q-toolbar style="padding: 0">
<q-select
v-model="store.competencyTypeVal"
outlined
label="ประเภทสมรรถนะ"
dense
option-label="name"
option-value="id"
:options="competencyTypeOp"
style="min-width: 200px"
emit-value
map-options
@update:model-value="fetchNewList"
/>
<q-btn flat round color="primary" icon="add" @click="onAdd()">
<q-tooltip> เพมขอม </q-tooltip>
</q-btn>
<q-space />
<div class="row q-gutter-sm">
<q-input
outlined
dense
v-model="formQuery.keyword"
label="ค้นหา"
@keyup.enter="fetchNewList()"
>
<template v-slot:append>
<q-icon v-if="formQuery.keyword == ''" name="search" />
<q-icon
v-if="formQuery.keyword !== ''"
name="clear"
class="cursor-pointer"
@click="(formQuery.keyword = ''), fetchNewList()"
/>
</template>
</q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
style="min-width: 150px"
/>
</div>
</q-toolbar>
<d-table
ref="table"
:columns="columns"
:rows="rows"
row-key="id"
flat
bordered
:paging="true"
dense
:rows-per-page-options="[10, 25, 50, 100]"
class="custom-header-table"
:visible-columns="visibleColumns"
@update:pagination="updatePagination"
>
<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-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id">
{{ col.value }}
</q-td>
<q-td auto-width>
<q-btn
color="edit"
flat
dense
round
size="12px"
icon="edit"
clickable
@click.stop="onViewDetail(props.row.id)"
v-close-popup
>
<q-tooltip>แกไข</q-tooltip>
</q-btn>
<q-btn
color="red"
flat
dense
round
size="12px"
icon="mdi-delete"
clickable
@click.stop="deleteData(props.row.id)"
v-close-popup
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="formQuery.page"
active-color="primary"
color="dark"
:max="Number(totalList)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="fetchList"
></q-pagination>
</template>
</d-table>
</template>

View file

@ -1,354 +0,0 @@
<script setup lang="ts">
import { ref, onMounted, reactive, watch } from "vue";
import type { QTableProps } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import dialogHeader from "@/components/DialogHeader.vue";
import type {
DataOption,
NewPagination,
} from "@/modules/14_KPI/interface/index/Main";
import type { ResponseObject } from "@/modules/14_KPI/interface/response/KpiGroup";
import http from "@/plugins/http";
import config from "@/app.config";
const total = ref<number>()
const modal = ref<boolean>(false);
const rows = ref<ResponseObject[]>([]);
const groupName = ref<string>("");
const editStatus = ref<boolean>(false);
const editId = ref<string>("");
const competencyTypeOp = ref<DataOption[]>([
{
id: "ID1",
name: "สมรรถนะหลัก",
},
{
id: "ID2",
name: "สมรรถนะประจำกลุ่มงาน",
},
{
id: "ID3",
name: "สมรรถนะประจำผู้บริหารกรุงเทพมหานคร",
},
{
id: "ID4",
name: "สมรรถนะเฉพาะสำหรับตำแหน่ง ผอ.เขต ผช.ผอ.เขต และหัวหน้าฝ่ายในสังกัด สนง.เขต",
},
{
id: "ID5",
name: "สมรรถนะเฉพาะสำหรับตำแหน่งผู้ตรวจราชการ กทม. และผู้ตรวจราชการ",
},
]);
const columns = ref<QTableProps["columns"]>([
{
name: "nameGroupKPI",
align: "left",
label: "รายการกลุ่มงาน",
sortable: true,
field: "nameGroupKPI",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const $q = useQuasar();
const mixin = useCounterMixin();
const {
dialogRemove,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
} = mixin;
const visibleColumns = ref<string[]>(["nameGroupKPI"]);
const formQuery = reactive({
page: 1,
pageSize: 10,
keyword: "",
});
const totalList = ref<number>(1); //
/** ดึงข้อมูล */
async function fetchData() {
showLoader();
await http
.get(
config.API.kpiGroup +
`?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}`
)
.then(async (res) => {
total.value = res.data.result.total
const data = res.data.result;
totalList.value = Math.ceil(res.data.result.total / formQuery.pageSize);
rows.value = data.data;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function addData() {
await http
.post(config.API.kpiGroup, {
nameGroupKPI: groupName.value,
})
.then(() => {
fetchData();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function editData(id: string) {
await http
.put(config.API.kpiGroupById(id), {
nameGroupKPI: groupName.value,
})
.then(() => {
fetchData();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function deleteData(id: string) {
await http
.delete(config.API.kpiGroupById(id))
.then(() => {
fetchData();
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** เปลี่ยนเป็นหน้าเพิ่มข้อมูล */
function onAdd() {
modal.value = true;
}
function closeDialog() {
modal.value = false;
editStatus.value = false;
groupName.value = "";
}
function onEdit(data: any) {
modal.value = true;
editStatus.value = true;
groupName.value = data.nameGroupKPI;
editId.value = data.id;
}
async function onSubmit() {
dialogConfirm(
$q,
async () => {
editStatus.value ? editData(editId.value) : addData();
closeDialog();
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
/**
* function updatePagination
* @param newPagination อม Pagination ใหม
*/
function updatePagination(newPagination: NewPagination) {
formQuery.page = 1;
formQuery.pageSize = newPagination.rowsPerPage;
}
function fetchNewList() {
formQuery.page = 1;
fetchData();
}
watch(
() => formQuery.pageSize,
() => {
fetchNewList();
}
);
onMounted(async () => {
fetchData();
});
</script>
<template>
<q-toolbar style="padding: 0">
<q-btn flat round color="primary" icon="add" @click="onAdd()">
<q-tooltip> เพมขอม </q-tooltip>
</q-btn>
<q-space />
<div class="row q-gutter-sm">
<q-input
outlined
dense
v-model="formQuery.keyword"
label="ค้นหา"
@keyup.enter="fetchNewList()"
>
<template v-slot:append>
<q-icon v-if="formQuery.keyword == ''" name="search" />
<q-icon
v-if="formQuery.keyword !== ''"
name="clear"
class="cursor-pointer"
@click="(formQuery.keyword = ''), fetchNewList()"
/> </template
></q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
style="min-width: 150px"
/>
</div>
</q-toolbar>
<d-table
ref="table"
:columns="columns"
:rows="rows"
row-key="id"
flat
bordered
:paging="true"
dense
class="custom-header-table"
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
@update:pagination="updatePagination"
>
<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-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id">
{{ col.value }}
</q-td>
<q-td auto-width>
<q-btn
color="edit"
flat
dense
round
class="q-mr-xs"
size="12px"
icon="edit"
clickable
@click="onEdit(props.row)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
color="red"
flat
dense
round
size="12px"
icon="mdi-delete"
clickable
@click.stop="
dialogRemove($q, async () => await deleteData(props.row.id))
"
v-close-popup
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="formQuery.page"
active-color="primary"
color="dark"
:max="Number(totalList)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="fetchData"
></q-pagination>
</template>
</d-table>
<q-dialog v-model="modal" persistent>
<q-card flat bordered style="min-width: 50vh">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<dialog-header
:tittle="editStatus ? 'แก้ไขกลุ่มงาน' : 'เพิ่มกลุ่มงาน'"
:close="closeDialog"
/>
<q-separator />
<q-card-section>
<q-input
label="กลุ่มงาน"
v-model="groupName"
outlined
dense
class="inputgreen"
:rules="[(val:string) => !!val || `${'กรุณากรอกกลุ่มงาน'}`,]"
hide-bottom-space
/>
</q-card-section>
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn
type="submit"
for="#submitForm"
unelevated
dense
class="q-px-md items-center"
color="public"
label="บันทึก"
/>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</template>

View file

@ -1,590 +0,0 @@
<script setup lang="ts">
import { ref, onMounted, reactive, watch } from "vue";
import type { QTableProps } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import Header from "@/components/DialogHeader.vue";
import type {
DataOption,
NewPagination,
} from "@/modules/14_KPI/interface/index/Main";
import type { ListGroup } from "@/modules/14_KPI/interface/request/Main";
import http from "@/plugins/http";
import config from "@/app.config";
const total = ref<number>()
const id = ref<string>("");
const modal = ref<boolean>(false);
const rows = ref<any>([]);
const editStatus = ref<boolean>(false);
const groupName = ref<any>();
const position = ref<any>();
const competency = ref<any>();
const groupNameOp = ref<DataOption[]>([]);
const groupNameOpMain = ref<DataOption[]>([]);
const positionOp = ref<DataOption[]>([]);
const positionMainOp = ref<DataOption[]>([]);
const competencyOp = ref<DataOption[]>([]);
const competencyOpMain = ref<DataOption[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "groupName",
align: "left",
label: "กลุ่มงาน",
sortable: true,
field: "groupName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "positions",
align: "left",
label: "ตำแหน่ง",
sortable: true,
field: "positions",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "capacitys",
align: "left",
label: "สมรรถนะประจำกลุ่มงาน",
sortable: true,
field: "capacitys",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const $q = useQuasar();
const mixin = useCounterMixin();
const {
dialogRemove,
messageError,
showLoader,
hideLoader,
success,
dialogConfirm,
} = mixin;
const competencyType = ref<string>("ID1");
const filterKeyword = ref<string>("");
const visibleColumns = ref<string[]>(["groupName", "positions", "capacitys"]);
const formQuery = reactive({
page: 1,
pageSize: 10,
keyword: "",
});
const totalList = ref<number>(1); //
/** ดึงข้อมูล */
async function getData() {
showLoader();
http
.get(
config.API.kpiLink +
`?page=${formQuery.page}&pageSize=${formQuery.pageSize}&keyword=${formQuery.keyword}`
)
.then((res) => {
total.value = res.data.result.total
const data = res.data.result;
totalList.value = Math.ceil(res.data.result.total / formQuery.pageSize);
rows.value = data.data;
})
.finally(() => {
hideLoader();
});
}
async function deleteData(id: string) {
await http
.delete(config.API.kpiLink + `/${id}`)
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
close();
getData();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** ดึงข้อมูล */
async function getListGroup() {
showLoader();
await http
.get(config.API.kpiGroup+`?pageSize=50`)
.then(async (res) => {
const dataOp = res.data.result.data;
const uniqueNames = new Set();
const filteredData = dataOp
.filter((item: any) => {
if (!uniqueNames.has(item.id)) {
uniqueNames.add(item.nameGroupKPI);
return true;
}
return false;
})
.map((item: any) => ({
id: item.id,
name: item.nameGroupKPI,
}));
groupNameOpMain.value = filteredData;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** ดึงข้อมูล */
async function getCompetency() {
showLoader();
await http
.get(config.API.kpiCapacity + `?type=GROUP&pageSize=50`)
.then(async (res) => {
const dataOp = res.data.result.data;
const uniqueNames = new Set();
const filteredData = dataOp
.filter((item: any) => {
if (!uniqueNames.has(item.id)) {
uniqueNames.add(item.name);
return true;
}
return false;
})
.map((item: any) => ({
id: item.id,
name: item.name,
}));
competencyOpMain.value = filteredData;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** เปลี่ยนเป็นหน้าเพิ่มข้อมูล */
function onAdd() {
getOptions();
getListGroup();
getCompetency();
modal.value = true;
}
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) => ({
id:i.id,
name:i.name
}));
})
.finally(() => {
hideLoader();
});
}
function onSubmit() {
const url = editStatus.value
? config.API.kpiLink + `/${id.value}`
: config.API.kpiLink;
const body = {
kpiGroupId: groupName.value.id,
positions: position.value,
kpiCapacityIds: competency.value.map((i:any)=> i.id)
};
dialogConfirm($q, () => {
http[editStatus.value ? "put" : "post"](url, body)
.then(() => {
success($q, "บันทึกสำเร็จ");
close();
getData();
})
.finally(() => {});
});
}
function close() {
modal.value = false;
editStatus.value = false;
groupName.value = "";
position.value = null;
competency.value = null;
}
function getOptions() {
http.get(config.API.orgSalaryPosition).then((res) => {
const dataOp = res.data.result;
const uniqueNames = new Set();
const filteredData = dataOp
.filter((item: any) => {
if (!uniqueNames.has(item.positionName)) {
uniqueNames.add(item.positionName);
return true;
}
return false;
})
.map((item: any) => ({
id: item.positionName,
name: item.positionName,
}));
positionMainOp.value = filteredData;
});
}
/**
* function นหาขอมลของ Option
* @param val าทองการฟลเตอร
* @param update พเดทค
* @param refData ดาตาทองการฟลเตอร
*/
function filterOptionGroup(val: any, update: Function) {
update(() => {
groupNameOp.value = groupNameOpMain.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
}
/**
* function นหาขอมลของ Option
* @param val าทองการฟลเตอร
* @param update พเดทค
* @param refData ดาตาทองการฟลเตอร
*/
function filterOption(val: any, update: Function) {
update(() => {
positionOp.value = positionMainOp.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
}
/**
* function นหาขอมลของ Option
* @param val าทองการฟลเตอร
* @param update พเดทค
* @param refData ดาตาทองการฟลเตอร
*/
function filterOptionCompetency(val: any, update: Function) {
update(() => {
competencyOp.value = competencyOpMain.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
}
/**
* function updatePagination
* @param newPagination อม Pagination ใหม
*/
function updatePagination(newPagination: NewPagination) {
formQuery.page = 1;
formQuery.pageSize = newPagination.rowsPerPage;
}
function fetchNewList() {
formQuery.page = 1;
getData();
}
watch(
() => formQuery.pageSize,
() => {
fetchNewList();
}
);
onMounted(async () => {
getData();
});
</script>
<template>
<q-toolbar style="padding: 0">
<q-btn flat round color="primary" icon="add" @click="onAdd()">
<q-tooltip> เพมขอม </q-tooltip>
</q-btn>
<q-space />
<div class="row q-gutter-sm">
<q-input
outlined
dense
v-model="formQuery.keyword"
label="ค้นหา"
@keyup.enter="fetchNewList()"
>
<template v-slot:append>
<q-icon v-if="formQuery.keyword == ''" name="search" />
<q-icon
v-if="formQuery.keyword !== ''"
name="clear"
class="cursor-pointer"
@click="(formQuery.keyword = ''), fetchNewList()"
/> </template
></q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
style="min-width: 150px"
>
</q-select>
</div>
</q-toolbar>
<d-table
ref="table"
:columns="columns"
:rows="rows"
row-key="id"
flat
bordered
dense
class="custom-header-table"
:visible-columns="visibleColumns"
:separator="'cell'"
:rows-per-page-options="[10, 25, 50, 100]"
@update:pagination="updatePagination"
>
<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-th auto-width />
</q-tr>
</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 == 'positions'">
<div v-if="col.value.length !== 0">
<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 == 'capacitys'">
<div v-if="col.value.length !== 0">
<div v-for="competency in col.value" :key="competency.id">
{{ competency ? `- ${competency.name}` : "-" }}
</div>
</div>
<div v-else>-</div>
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td auto-width>
<q-btn
color="edit"
flat
dense
round
class="q-mr-xs"
size="12px"
icon="edit"
clickable
@click="onEdit(props.row.id)"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
color="red"
flat
dense
round
size="12px"
icon="mdi-delete"
clickable
@click.stop="
dialogRemove($q, async () => await deleteData(props.row.id))
"
v-close-popup
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="formQuery.page"
active-color="primary"
color="dark"
:max="Number(totalList)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="getData"
></q-pagination>
</template>
</d-table>
<q-dialog v-model="modal" persistent>
<q-card flat bordered style="min-width: 80vh">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<Header
:tittle="
editStatus ? 'แก้ไขกลุ่มงานและตำแหน่ง' : 'เพิ่มกลุ่มงานและตำแหน่ง'
"
:close="close"
/>
<q-separator />
<q-card-section>
<div class="row q-col-gutter-sm">
<div class="col-4">
<q-select
dense
v-model="groupName"
label="กลุ่มงาน"
outlined
class="inputgreen"
map-options
option-label="name"
option-value="id"
:options="groupNameOp"
use-input
@filter="(inputValue:any,doneFn:Function) => filterOptionGroup(inputValue, doneFn) "
hide-bottom-space
lazy-rules
:rules="[(val:string) => !!val || `${'กรุณาเลือกกลุ่มงาน'}`,]"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template></q-select
>
</div>
<div class="col-4">
<q-select
dense
v-model="position"
label="ตำแหน่ง"
outlined
multiple
emit-value
map-options
class="inputgreen"
option-label="name"
option-value="name"
:options="positionOp"
:rules="[(val:string) => !!val || `${'กรุณาเลือกตำแหน่ง'}`,]"
hide-bottom-space
lazy-rules
use-input
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) "
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template></q-select
>
</div>
<div class="col-4">
<q-select
dense
class="inputgreen"
v-model="competency"
label="สมรรถนะประจำกลุ่ม"
outlined
multiple
map-options
option-label="name"
option-value="id"
:rules="[(val:string) => !!val || `${'กรุณาเลือกสมรรถนะประจำกลุ่ม'}`,]"
hide-bottom-space
lazy-rules
:options="competencyOp"
use-input
@filter="(inputValue:any,doneFn:Function) => filterOptionCompetency(inputValue, doneFn) "
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template></q-select
>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn
type="submit"
for="#submitForm"
unelevated
dense
class="q-px-md items-center"
color="public"
label="บันทึก"
/>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</template>

View file

@ -1,153 +0,0 @@
<script setup lang="ts">
import { ref, reactive, onMounted, watch } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { useQuasar } from "quasar";
const $q = useQuasar();
const dataLevel = ref<any>();
const { showLoader, hideLoader, success } = useCounterMixin();
const fieldLabels = {
score5: "5",
score4: "4",
score3: "3",
score2: "2",
score1: "1",
};
const formScore = reactive<any>({
score5: "",
score4: "",
score3: "",
score2: "",
score1: "",
});
interface FormScore {
score5: string;
score4: string;
score3: string;
score2: string;
score1: string;
[key: string]: any;
}
function onSubmit() {
const body = {
formScore: dataLevel.value.map((item: any) => {
const { level, ...rest } = item;
return rest;
}),
};
http
.put(config.API.kpiEvaluation, body.formScore)
.then((res) => {
success($q, "บันทึกสำเร็จ");
})
.finally(() => {});
}
function getData() {
showLoader();
http
.get(config.API.kpiEvaluation)
.then((res) => {
dataLevel.value = res.data.result.data;
})
.finally(() => {
hideLoader();
});
}
onMounted(() => {
getData();
});
</script>
<template>
<q-card flat bordered>
<q-form greedy @submit.prevent @validation-success="onSubmit">
<q-card-section class="bg-grey-3 q-pa-sm">
<div class="row text-dark text-body2 text-weight-medium">
<div class="text-center col-8">เกณฑการประเม</div>
<div class="text-center col-4">ระดบคะแนน</div>
</div>
</q-card-section>
<q-card-section class="q-pa-none">
<div v-for="(field, index) in dataLevel" :key="field.id">
<div class="row q-pa-sm">
<div class="col-8 text-left">
<q-field
class="q_field_p_none"
ref="fieldRef"
v-model="field.description"
label-slot
borderless
:rules="[(val) => !!val || 'กรุณากรอกมาตรฐานพฤติกรรม']"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="field.description"
:dense="$q.screen.lt.md"
min-height="5rem"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
<!-- <q-input
v-model="formScore[field]"
dense
outlined
class="inputgreen"
label="กรอกข้อความเพื่อไว้ใช้อ้างอิงเท่านั้น"
:rules="[(val:string) => !!val || `${'กรุณากรอกข้อความเพื่อไว้ใช้อ้างอิงเท่านั้น'}`,]"
hide-bottom-space
/> -->
</div>
<div
class="col-4 text-center text-body1 text-weight-bold self-center"
>
{{ field.level }}
</div>
</div>
<div
class="col-12"
v-if="index !== Object.keys(fieldLabels).length - 1"
>
<q-separator />
</div>
</div>
</q-card-section>
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="บันทึก" color="secondary" type="submit"
><q-tooltip>นทกขอม</q-tooltip></q-btn
>
</q-card-actions>
</q-form>
</q-card>
</template>

View file

@ -1,328 +0,0 @@
<script setup lang="ts"></script>
<template>
<div class="display-table">
<q-card flat bordered class="q-mb-lg">
<q-card-section>
<div class="text-h6 text-bold">ประเภทสมรรถนะ</div>
</q-card-section>
<q-card-section class="q-pt-none">
ใหประเมนจากสมรรถนะทเกยวของกบการปฏราชการตามท .. กำหนด
รายละเอยดดงน
</q-card-section>
<q-separator inset />
<div style="border: 1px solid black">
<div class="row text-center" style="background-color: #e0e4f4">
<div class="col-3 text-bold flex justify-center items-center">
ประเภทสมรรถนะ
</div>
<div class="col-5">
<div class="row text-bold flex justify-center">
ประเภทและระดบตำแหน
</div>
<div class="row">
<div class="col-3">
<div class="text-bold">วไป</div>
<div>ปฏงาน</div>
<div>ชำนาญงาน</div>
<div>อาวโส</div>
</div>
<div class="col-3">
<div class="text-bold">ชาการ</div>
<div>ปฏการ</div>
<div>ชำนาญการ</div>
<div>ชำนาญการพเศษ</div>
<div>เชยวชาญ</div>
<div>ทรงคณว</div>
</div>
<div class="col-3">
<div class="text-bold">อำนวยการ</div>
<div> </div>
</div>
<div class="col-3">
<div class="text-bold">บรหาร</div>
<div> </div>
</div>
</div>
</div>
<div class="col-4 column">
<div class="row text-bold flex justify-center">ดำรงตำแหน</div>
<div class="row" style="flex-grow: 1">
<div class="col-6">
ตรวจราชการกรงเทพมหานครและผตรวจราชการ
</div>
<div class="col-6 flex justify-center">อำนวยการเขต</div>
</div>
</div>
</div>
<div class="row">
<div class="col-3 q-pa-sm">
<div class="text-bold">สมรรถนะหล</div>
<div>(5 สมรรถนะ)</div>
</div>
<div class="col-5 column">
<div class="row col-grow">
<div class="col-3 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
<div class="col-3 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
<div class="col-3 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
<div class="col-3 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
</div>
</div>
<div class="col-4 column">
<div class="row col-grow">
<div class="col-6 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
<div class="col-6 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-3 q-pa-sm">
<div class="text-bold">สมรรถนะประจำกลมงาน</div>
<div>(3 สมรรถนะ ตามกลมงาน)</div>
</div>
<div class="col-5 column">
<div class="row col-grow">
<div class="col-3 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
<div class="col-3 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
<div class="col-3"></div>
<div class="col-3"></div>
</div>
</div>
<div class="col-4 column">
<div class="row col-grow">
<div class="col-6"></div>
<div class="col-6"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-3 q-pa-sm">
<div class="text-bold">สมรรถนะประจำผบรหารกรงเทพมหานคร</div>
<div>(7 สมรรถนะ)</div>
</div>
<div class="col-5 column">
<div class="row col-grow">
<div class="col-3"></div>
<div class="col-3"></div>
<div class="col-3 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
<div class="col-3 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
</div>
</div>
<div class="col-4 column">
<div class="row col-grow">
<div class="col-6"></div>
<div class="col-6"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-3 q-pa-sm">
<div class="text-bold">สมรรถนะเฉพาะสำหรบตำแหนงผอำนวยการเขต</div>
<div>(4 สมรรถนะ)</div>
</div>
<div class="col-5 column">
<div class="row col-grow">
<div class="col-3"></div>
<div class="col-3"></div>
<div class="col-3"></div>
<div class="col-3"></div>
</div>
</div>
<div class="col-4 column">
<div class="row col-grow">
<div class="col-6"></div>
<div class="col-6 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-3 q-pa-sm">
<div class="text-bold">
สมรรถนะเฉพาะสำหรบตำแหนงผตรวจราชการกรงเทพมหานครและผตรวจราชการ
</div>
<div>(2 สมรรถนะ)</div>
</div>
<div class="col-5 column">
<div class="row col-grow">
<div class="col-3"></div>
<div class="col-3"></div>
<div class="col-3"></div>
<div class="col-3"></div>
</div>
</div>
<div class="col-4 column">
<div class="row col-grow">
<div class="col-6 flex items-center justify-center">
<q-icon name="check" size="32px" />
</div>
<div class="col-6"></div>
</div>
</div>
</div>
<div class="row text-bold">
<div class="col-3 q-pa-sm">
<div class="text-bold flex justify-end">รวมสมรรถนะ</div>
</div>
<div class="col-5 column">
<div class="row col-grow">
<div class="col-3 flex justify-center items-center">8</div>
<div class="col-3 flex justify-center items-center">8</div>
<div class="col-3 flex justify-center items-center">12</div>
<div class="col-3 flex justify-center items-center">12</div>
</div>
</div>
<div class="col-4 column">
<div class="row col-grow">
<div class="col-6 flex justify-center items-center">7</div>
<div class="col-6 flex justify-center items-center">9</div>
</div>
</div>
</div>
</div>
</q-card>
<q-card flat bordered>
<q-card-section>
<div class="text-h6 text-bold">ระดบสมรรถนะ</div>
</q-card-section>
<q-card-section class="q-pt-none">
สมรรถนะหลกและสมรรถนะประจำกลมงาน
กำหนดระดบสมรรถนะทคาดหวงจำแนกตามประเภทและระดบตำแหนงของขาราชการกรงเทพมหานครสาม
รายละเอยดดงน
</q-card-section>
<q-separator inset />
<div style="border: 1px solid black">
<div
class="row text-bold text-center"
style="background-color: #c0d4ec"
>
<div class="col-3">ประเภทตำแหน</div>
<div class="col-3">ระดบตำแหน</div>
<div class="col-3">สมรรถนะหล</div>
<div class="col-3">สมรรถนะประจำกลมงาน</div>
</div>
<div class="row text-center">
<div class="col-3 flex justify-center items-center">บรหาร</div>
<div class="col-6">
<div class="row">
<div class="col-6"></div>
<div class="col-6">5</div>
</div>
<div class="row">
<div class="col-6"></div>
<div class="col-6">4</div>
</div>
</div>
<div class="col-3" style="background-color: #bcbcc4"></div>
</div>
<div class="row text-center">
<div class="col-3 flex justify-center items-center">อำนวยการ</div>
<div class="col-6">
<div class="row">
<div class="col-6"></div>
<div class="col-6">4</div>
</div>
<div class="row">
<div class="col-6"></div>
<div class="col-6">3</div>
</div>
</div>
<div class="col-3" style="background-color: #bcbcc4"></div>
</div>
<div class="row text-center">
<div class="col-3 flex justify-center items-center">ชาการ</div>
<div class="col-9">
<div class="row">
<div class="col-4">ทรงคณว</div>
<div class="col-4">5</div>
<div class="col-4">5</div>
</div>
<div class="row">
<div class="col-4">เชยวชาญ</div>
<div class="col-4">4</div>
<div class="col-4">4</div>
</div>
<div class="row">
<div class="col-4">ชำนาญการพเศษ</div>
<div class="col-4">3</div>
<div class="col-4">4</div>
</div>
<div class="row">
<div class="col-4">ชำนาญการ</div>
<div class="col-4">2</div>
<div class="col-4">3</div>
</div>
<div class="row">
<div class="col-4">ปฏการ</div>
<div class="col-4">1</div>
<div class="col-4">2</div>
</div>
</div>
</div>
<div class="row text-center">
<div class="col-3 flex justify-center items-center">วไป</div>
<div class="col-9">
<div class="row">
<div class="col-4">กษะพเศษ</div>
<div class="col-4">4</div>
<div class="col-4">4</div>
</div>
<div class="row">
<div class="col-4">อาวโส</div>
<div class="col-4">3</div>
<div class="col-4">3</div>
</div>
<div class="row">
<div class="col-4">ชำนาญงาน</div>
<div class="col-4">2</div>
<div class="col-4">2</div>
</div>
<div class="row">
<div class="col-4">ปฏงาน</div>
<div class="col-4">1</div>
<div class="col-4">1</div>
</div>
</div>
</div>
</div>
</q-card>
</div>
</template>
<style scoped lang="scss">
.display-table {
& .row:not(:last-child) {
border-bottom: 1px solid black;
}
& [class^="col-"]:not(:last-child) {
border-right: 1px solid black;
}
}
</style>

View file

@ -1,121 +0,0 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { useRouter } from "vue-router";
import Main from "@/modules/14_KPI/components/competency/Forms/Main.vue";
// import FormMain from "@/modules/14_KPI/components/competency/Forms/01_FormMain.vue";
// import FormGroup from "@/modules/14_KPI/components/competency/Forms/02_FormGroup.vue";
// import FormExecutive from "@/modules/14_KPI/components/competency/Forms/03_FormExecutive.vue";
// import FormExecutivePosition from "@/modules/14_KPI/components/competency/Forms/04_FormExecutivePosition.vue";
// import FormExecutiveLevel from "@/modules/14_KPI/components/competency/Forms/05_FormExecutiveLevel.vue";
import { useKPIDataStore } from "@/modules/14_KPI/store/KPIStore";
import type { DataOption } from "@/modules/14_KPI/interface/index/Main";
import type { FormCompetency } from "@/modules/14_KPI/interface/request/Main";
const router = useRouter();
const store = useKPIDataStore();
const formData = reactive<FormCompetency>({
competencyType: "",
competencyName: "",
definition: "",
level_1: ["", "", "", "", "", ""],
level_2: "",
level_3: "",
level_4: "",
level_5: "",
evaluation: "",
});
const competencyTypeOp = ref<DataOption[]>([
{
id: "HEAD",
name: "สมรรถนะหลัก",
},
{
id: "GROUP",
name: "สมรรถนะประจำกลุ่มงาน",
},
{
id: "EXECUTIVE",
name: "สมรรถนะประจำผู้บริหารกรุงเทพมหานคร",
},
{
id: "DIRECTOR",
name: "สมรรถนะเฉพาะสำหรับตำแหน่ง ผอ.เขต ผช.ผอ.เขต และหัวหน้าฝ่ายในสังกัด สนง.เขต",
},
{
id: "INSPECTOR",
name: "สมรรถนะเฉพาะสำหรับตำแหน่งผู้ตรวจราชการ กทม. และผู้ตรวจราชการ",
},
]);
const itemsFormCard = ref<any>([
{
id: "",
name: "",
},
]);
function ocClickAdd() {
if (itemsFormCard.value.length !== 6) {
const data = {
id: "",
name: "",
};
itemsFormCard.value.push(data);
}
}
/** บันทึก */
function onSubmit() {
console.log(formData);
}
</script>
<template>
<div>
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="router.go(-1)"
/>
<span class="toptitle text-dark">เพ/แกไขสมรรถนะ</span>
</div>
<q-card flat bordered>
<!-- @submit.prevent @validation-success="onSubmit" -->
<!-- <q-form greedy> -->
<q-card-section>
<div class="row q-col-gutter-sm">
<div class="col-12">
<q-select
v-model="store.competencyTypeVal"
outlined
label="เลือกประเภทสมรรถนะ"
dense
option-label="name"
option-value="id"
:options="competencyTypeOp"
emit-value
map-options
:rules="[(val:string) => !!val || `${'กรุณาเลือกประเภทสมรรถนะ'}`,]"
hide-bottom-space
/>
</div>
<Main />
<!-- <FormMain v-if="store.competencyType === 'ID1'" />
<FormGroup v-else-if="store.competencyType === 'ID2'" />
<FormExecutive v-else-if="store.competencyType === 'ID3'" />
<FormExecutivePosition v-else-if="store.competencyType === 'ID4'" />
<FormExecutiveLevel v-else-if="store.competencyType === 'ID5'" /> -->
</div>
</q-card-section>
</q-card>
</template>

View file

@ -1,206 +0,0 @@
div
<script setup lang="ts">
import { ref, reactive } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import { useKPIDataStore } from "@/modules/14_KPI/store/KPIStore";
import { useRouter } from "vue-router";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
const $q = useQuasar();
const mixin = useCounterMixin();
const { dialogConfirm, showLoader, hideLoader, success, messageError } = mixin;
const router = useRouter();
const store = useKPIDataStore();
const formData = reactive({
competencyType: "",
competencyName: "",
definition: "",
levels: [
{
level: "1",
description: "",
},
],
evaluation: "",
});
function ocClickAdd() {
if (formData.levels.length !== 6) {
const levelName = formData.levels.length + 1;
const data = {
level: levelName.toString(),
description: "",
};
formData.levels.push(data);
}
}
function onSubmit() {
dialogConfirm($q, () => {
const body = {
competencyType: store.competencyTypeVal,
competencyName: formData.competencyName,
definition: formData.definition,
levels: formData.levels,
evaluation: formData.evaluation,
};
// showLoader()
// http
// .put(config.API.???,body)
// .then((res)=>{
// success($q,'')
// router.push(`/KPI-competency`)
// }).catch((e)=>{
// messageError($q,e)
// }).finally(()=>{
// hideLoader()
// })
console.log(body);
});
}
</script>
<template>
<q-form greedy @submit.prevent @validation-success="onSubmit" class="col-12">
<div class="row q-col-gutter-sm">
<div class="col-12">
<q-input
v-model="formData.competencyName"
dense
outlined
label="ชื่อสมรรถนะ"
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อสมรรถนะ'}`,]"
hide-bottom-space
/>
</div>
<div class="col-12">
<q-input
v-model="formData.definition"
label="คำจำกัดความ"
dense
type="textarea"
outlined
:rules="[(val:string) => !!val || `${'กรุณากรอกคำจำกัดความ'}`,]"
hide-bottom-space
/>
</div>
<div class="col-12">
<q-card flat bordered>
<q-card-section class="bg-grey-4">
<div
class="row items-center text-dark text-body2 text-weight-medium"
>
<div class="col-3">
<div class="row items-center">
<div class="col-1">
<q-btn
dense
flat
round
color="primary"
icon="add"
@click="ocClickAdd"
>
<q-tooltip>เพ</q-tooltip></q-btn
>
</div>
<div class="col-11 text-center">
<span>ระด</span>
</div>
</div>
</div>
<div class="col-4">
<span>คำอธบายระด</span>
</div>
</div>
</q-card-section>
<q-card-section>
<div
class="row q-pa-sm"
v-for="(items, index) in formData.levels"
key="index"
>
<div
class="col-3 text-center self-center text-body1 text-weight-medium"
>
<span>{{ items.level }}</span>
</div>
<div class="col-9">
<q-field
class="q_field_p_none"
ref="fieldRef"
v-model="formData.levels[index].description"
label-slot
borderless
:rules="[(val) => !!val || 'กรุณากรอกมาตรฐานพฤติกรรม']"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="formData.levels[index].description"
:dense="$q.screen.lt.md"
min-height="5rem"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</div>
</q-card-section>
</q-card>
</div>
<div class="col-12">
<q-input
v-model="formData.evaluation"
label="กำหนดเกณฑ์การประเมิน"
dense
type="textarea"
outlined
/>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 row justify-end">
<q-btn
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
type="submit"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</div>
</div>
</q-form>
</template>
<style scoped></style>

View file

@ -1,204 +0,0 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import { useKPIDataStore } from "@/modules/14_KPI/store/KPIStore";
import { useRouter } from "vue-router";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
const $q = useQuasar();
const mixin = useCounterMixin();
const { dialogConfirm, showLoader, hideLoader, success, messageError } = mixin;
const router = useRouter;
const store = useKPIDataStore();
interface DetailLevelType {
level_01: any;
level_02: any;
level_03: any;
level_04: any;
level_05: any;
}
interface FormGroup {
name: string;
definition: string;
detailLevel: DetailLevelType[];
evaluation: string;
}
const fieldLabels = {
score1: "1",
score2: "2",
score3: "3",
score4: "4",
score5: "5",
};
const formScore = reactive<any>({
score1: "",
score2: "",
score3: "",
score4: "",
score5: "",
});
const formData = reactive<FormGroup>({
name: "",
definition: "",
detailLevel: [],
evaluation: "",
});
function onSubmit() {
dialogConfirm($q, () => {
const body = {
competencyType: store.competencyTypeVal,
competencyName: formData.definition,
definition: formData.definition,
levels1: formScore.score1,
levels2: formScore.score2,
levels3: formScore.score3,
levels4: formScore.score4,
levels5: formScore.score5,
evaluation: formData.evaluation,
};
// showLoader()
// http
// .put(config.API.???,body)
// .then((res)=>{
// success($q,'')
// router.push(`/KPI-competency`)
// }).catch((e)=>{
// messageError($q,e)
// }).finally(()=>{
// hideLoader()
// })
console.log(body);
});
}
</script>
<template>
<q-form greedy @submit.prevent @validation-success="onSubmit" class="col-12">
<div class="row q-col-gutter-sm">
<div class="col-12">
<q-input
label="ชื่อสมรรถนะ"
outlined
v-model="formData.name"
dense
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อสมรรถนะ'}`,]"
hide-bottom-space
/>
</div>
<div class="col-12">
<q-input
label="คำจำกัดความ"
outlined
v-model="formData.definition"
dense
type="textarea"
:rules="[(val:string) => !!val || `${'กรุณากรอกคำจำกัดความ'}`,]"
hide-bottom-space
/>
</div>
<div class="col-12">
<q-card flat bordered>
<q-card-section class="bg-grey-4 q-pa-sm">
<div class="row text-dark text-body2 text-weight-medium">
<div class="text-center col-4">ระด</div>
<div class="col-8">มาตรฐานพฤตกรรม</div>
</div>
</q-card-section>
<q-card-section class="q-pa-none">
<div
v-for="(field, index) in Object.keys(fieldLabels)"
:key="index + 1"
>
<div class="row q-pa-sm">
<div
class="col-4 text-center text-body1 text-weight-bold self-center"
>
{{ fieldLabels[field as keyof typeof fieldLabels] }}
</div>
<div class="col-8 text-left">
<q-field
class="q_field_p_none"
ref="fieldRef"
v-model="formScore[field]"
label-slot
borderless
:rules="[(val) => !!val || 'กรุณากรอกมาตรฐานพฤติกรรม']"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="formScore[field]"
:dense="$q.screen.lt.md"
min-height="5rem"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</div>
<div
class="col-12"
v-if="index !== Object.keys(fieldLabels).length - 1"
>
<q-separator />
</div>
</div>
</q-card-section>
</q-card>
</div>
<div class="col-12">
<q-input
v-model="formData.evaluation"
label="กำหนดเกณฑ์การประเมิน"
dense
type="textarea"
outlined
/>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 row justify-end">
<q-btn
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
type="submit"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</div>
</div>
</q-form>
</template>

View file

@ -1,321 +0,0 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import { useKPIDataStore } from "@/modules/14_KPI/store/KPIStore";
import { useRouter } from "vue-router";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
const $q = useQuasar();
const { dialogConfirm, showLoader, success, hideLoader, messageError } =
useCounterMixin();
const router = useRouter;
const store = useKPIDataStore();
const formData = reactive({
competencyType: "",
competencyName: "",
definition: "",
level: ["", "", "", "", "", ""],
form: [
{
posType: "",
posLevel: "",
description: "",
description2: "",
},
],
evaluation: "",
});
const dataLevel = ref<any>([]);
const typeOp = ref<any>([]);
const levelOp = ref<any>([]);
const typeOpsMain = ref<any>([]);
const levelOpsMain = ref<any>([]);
function ocClickAdd() {
if (formData.form.length !== 6) {
const data = {
posType: "",
posLevel: "",
description: "",
description2: "",
};
formData.form.push(data);
}
}
/** function เรียกรายการประเภทตำแหน่ง */
function fetchType() {
showLoader();
http
.get(config.API.orgPosType)
.then((res) => {
const data = res.data.result;
dataLevel.value = data;
typeOpsMain.value = data.map((e: any) => ({
id: e.id,
name: e.posTypeName,
}));
typeOp.value = typeOpsMain.value;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
function updateSelectType(val: string, index: number) {
const listLevel = dataLevel.value.find((e: any) => e.id === val);
levelOpsMain.value = listLevel.posLevels.map((e: any) => ({
id: e.id,
name: e.posLevelName,
}));
levelOp.value = levelOpsMain.value;
formData.form[index].posLevel = "";
}
function onSubmit() {
dialogConfirm($q, () => {
const body = {
competencyType: store.competencyTypeVal,
competencyName: formData.competencyName,
definition: formData.definition,
postype: formData.form,
evaluation: formData.evaluation,
};
// showLoader()
// http
// .put(config.API.???,body)
// .then((res)=>{
// success($q,'')
// router.push(`/KPI-competency`)
// }).catch((e)=>{
// messageError($q,e)
// }).finally(()=>{
// hideLoader()
// })
console.log(body);
});
}
onMounted(() => {
fetchType();
});
</script>
<template>
<q-form greedy @submit.prevent @validation-success="onSubmit" class="col-12">
<div class="row q-col-gutter-sm">
<div class="col-12">
<q-input
v-model="formData.competencyName"
dense
outlined
label="ชื่อสมรรถนะ"
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อสมรรถนะ'}`,]"
hide-bottom-space
/>
</div>
<div class="col-12">
<q-input
v-model="formData.definition"
label="คำจำกัดความ"
dense
type="textarea"
outlined
:rules="[(val:string) => !!val || `${'กรุณากรอกคำจำกัดความ'}`,]"
hide-bottom-space
/>
</div>
<div class="col-12">
<q-card flat bordered>
<q-card-section class="bg-grey-4">
<div
class="row items-center text-dark text-body2 text-weight-medium"
>
<div class="col-3">
<div class="row items-center">
<div class="col-1">
<q-btn
dense
flat
round
color="primary"
icon="add"
@click="ocClickAdd"
>
<q-tooltip>เพ</q-tooltip></q-btn
>
</div>
<div class="col-11 text-center">
<span>ประเภทตำแหน</span>
</div>
</div>
</div>
<div class="col-3 text-center">
<span>ระด</span>
</div>
<div class="col-6">
<span>มาตรฐานพฤตกรรม</span>
</div>
</div>
</q-card-section>
<q-card-section>
<div
class="row q-pa-sm q-col-gutter-sm"
v-for="(items, index) in formData.form"
key="index"
>
<div class="col-3 text-center">
<q-select
v-model="formData.form[index].posType"
outlined
label="ประเภทตำแหน่ง"
dense
option-label="name"
option-value="id"
:options="typeOp"
emit-value
map-options
:rules="[(val:string) => !!val || `${'กรุณาเลือกประเภทตำแหน่ง'}`,]"
hide-bottom-space
@update:model-value="
updateSelectType(formData.form[index].posType, index)
"
/>
</div>
<div class="col-3 text-center">
<q-select
v-model="formData.form[index].posLevel"
outlined
label="ระดับตำแหน่ง"
dense
option-label="name"
option-value="id"
:options="levelOp"
emit-value
map-options
:rules="[(val:string) => !!val || `${'กรุณาเลือกระดับตำแหน่ง'}`,]"
hide-bottom-space
/>
</div>
<div class="col-6">
<q-field
class="q_field_p_none"
ref="fieldRef"
v-model="formData.form[index].description"
label-slot
borderless
:rules="[(val) => !!val || 'กรุณากรอกมาตรฐานพฤติกรรม']"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="formData.form[index].description"
:dense="$q.screen.lt.md"
min-height="5rem"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
<q-field
class="q_field_p_none"
ref="fieldRef"
v-model="formData.form[index].description2"
label-slot
borderless
:rules="[(val) => !!val || 'กรุณากรอกมาตรฐานพฤติกรรม']"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="formData.form[index].description2"
:dense="$q.screen.lt.md"
min-height="5rem"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
<div class="col-12"><q-separator /></div>
</div>
</q-card-section>
</q-card>
</div>
<div class="col-12">
<q-input
v-model="formData.evaluation"
label="กำหนดเกณฑ์การประเมิน"
dense
type="textarea"
outlined
/>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 row justify-end">
<q-btn
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
type="submit"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</div>
</div>
</q-form>
</template>
<style scoped></style>

View file

@ -1,319 +0,0 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import type { QTableProps } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useKPIDataStore } from "@/modules/14_KPI/store/KPIStore";
import { useRouter } from "vue-router";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
const router = useRouter();
const mixin = useCounterMixin();
const $q = useQuasar();
const mode = ref<string>("table");
const {
dialogRemove,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
date2Thai,
} = mixin;
const store = useKPIDataStore();
const formData = reactive({
competencyType: "",
competencyName: "",
definition: "",
level1: "",
level2: "",
level3: "",
evaluation: "",
});
function onSubmit() {
dialogConfirm($q, () => {
const body = {
competencyType: store.competencyTypeVal,
competencyName: formData.competencyName,
definition: formData.definition,
levels1: formData.level1,
levels2: formData.level2,
levels3: formData.level3,
evaluation: formData.evaluation,
};
// showLoader()
// http
// .put(config.API.???,body)
// .then((res)=>{
// success($q,'')
// router.push(`/KPI-competency`)
// }).catch((e)=>{
// messageError($q,e)
// }).finally(()=>{
// hideLoader()
// })
console.log(body);
});
}
</script>
<template>
<div class="full-width">
<q-form @submit.prevent greedy @validation-success="onSubmit()">
<div class="col-12">
<q-input
outlined
v-model="formData.competencyName"
dense
label="ชื่อสมรรถนะ"
hide-bottom-space
:rules="[(val) => !!val || `${'กรุณากรอกชื่อสมรรถนะ'}`]"
/>
</div>
<q-card-section class="col-12 q-px-none">
<div>
<q-field
class="q_field_p_none"
ref="fieldRef"
v-model="formData.definition"
label-slot
borderless
:rules="[(val) => !!val || 'กรุณากรอกคำจำกัดความ']"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="formData.definition"
:dense="$q.screen.lt.md"
min-height="7rem"
placeholder="คำจำกัดความ"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</q-card-section>
<div class="col-12">
<q-card flat bordered>
<q-card-section class="bg-grey-4 q-py-sm">
<div class="row text-dark text-body2 text-weight-medium">
<div class="col-6 q-pl-xl">ระบบตำแหน</div>
<div class="col-6">
คำอธบายระด/พฤตกรรมทคาดหว/พฤตกรรมยอย
</div>
</div>
</q-card-section>
<div class="row items-center">
<q-card-section class="q-pa-none q-pl-xl col-6">
<span class="text-dark text-subtitle1 text-weight-medium">
L1 ระด วหนาฝายในสงก
</span>
</q-card-section>
<q-card-section class="q-pa-none col-6">
<div class="q-mr-md">
<q-field
ref="fieldRef"
v-model="formData.level1"
label-slot
borderless
:rules="[
(val) =>
!!val || 'กรุณาระบุคำอธิบาย L1 ระดับ หัวหน้าฝ่ายในสังกัด',
]"
hide-bottom-space
>
<template #control>
<q-editor
v-model="formData.level1"
:dense="$q.screen.lt.md"
min-height="5rem"
class="full-width"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</q-card-section>
</div>
<div class="row items-center">
<q-card-section class="q-pa-none q-pl-xl col-6">
<span class="text-dark text-subtitle1 text-weight-medium">
L2 ระด วยผอำนวยการเขต
</span>
</q-card-section>
<q-card-section class="q-pa-none col-6">
<div class="q-mr-md">
<q-field
ref="fieldRef"
v-model="formData.level2"
label-slot
borderless
:rules="[
(val) =>
!!val ||
'กรุณาระบุคำอธิบาย L2 ระดับ ผู้ช่วยผู้อำนวยการเขต',
]"
hide-bottom-space
>
<template #control>
<q-editor
v-model="formData.level2"
:dense="$q.screen.lt.md"
min-height="5rem"
class="full-width"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</q-card-section>
</div>
<div class="row items-center">
<q-card-section class="q-pa-none q-pl-xl col-6">
<span class="text-dark text-subtitle1 text-weight-medium">
L3 ระด อำนวยการเขต
</span>
</q-card-section>
<q-card-section class="q-pa-none col-6">
<div class="q-mr-md">
<q-field
ref="fieldRef"
v-model="formData.level3"
label-slot
borderless
:rules="[
(val) =>
!!val || 'กรุณาระบุคำอธิบาย L3 ระดับ ผู้อำนวยการเขต',
]"
hide-bottom-space
>
<template #control>
<q-editor
v-model="formData.level3"
:dense="$q.screen.lt.md"
min-height="5rem"
class="full-width"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</q-card-section>
</div>
</q-card>
<div class="col-12 q-mt-md">
<q-input
v-model="formData.evaluation"
label="กำหนดเกณฑ์การประเมิน"
dense
type="textarea"
outlined
/>
</div>
<q-separator color="grey-4" />
<div class="col-12 row justify-end q-mt-md">
<q-btn
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
type="submit"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</div>
</div>
</q-form>
</div>
</template>

View file

@ -1,261 +0,0 @@
<script setup lang="ts">
import { ref, reactive } from "vue";
import type { QTableProps } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useKPIDataStore } from "@/modules/14_KPI/store/KPIStore";
import { useRouter } from "vue-router";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
const router = useRouter();
const mixin = useCounterMixin();
const $q = useQuasar();
const mode = ref<string>("table");
const {
dialogRemove,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
date2Thai,
} = mixin;
const store = useKPIDataStore();
const formData = reactive({
competencyType: "",
competencyName: "",
definition: "",
level1: "",
level2: "",
evaluation: "",
});
function onSubmit() {
dialogConfirm($q, () => {
const body = {
competencyType: store.competencyTypeVal,
competencyName: formData.competencyName,
definition: formData.definition,
levels1: formData.level1,
levels2: formData.level2,
evaluation: formData.evaluation,
};
// showLoader()
// http
// .put(config.API.???,body)
// .then((res)=>{
// success($q,'')
// router.push(`/KPI-competency`)
// }).catch((e)=>{
// messageError($q,e)
// }).finally(()=>{
// hideLoader()
// })
console.log(body);
});
}
</script>
<template>
<div class="full-width">
<q-form @submit.prevent greedy @validation-success="onSubmit()">
<div class="col-12">
<q-input
outlined
v-model="formData.competencyName"
dense
hide-bottom-space
:rules="[(val) => !!val || `${'กรุณากรอกชื่อสมรรถนะ'}`]"
label="ชื่อสมรรถนะ"
/>
</div>
<q-card-section class="col-12 q-px-none">
<div>
<q-field
class="q_field_p_none"
ref="fieldRef"
v-model="formData.definition"
label-slot
borderless
:rules="[(val) => !!val || 'กรุณากรอกคำจำกัดความ']"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="formData.definition"
:dense="$q.screen.lt.md"
min-height="7rem"
placeholder="คำจำกัดความ"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</q-card-section>
<div class="col-12">
<q-card flat bordered>
<q-card-section class="bg-grey-4 q-py-sm">
<div class="row text-dark text-body2 text-weight-medium">
<div class="col-6 q-pl-xl">ระบบตำแหน</div>
<div class="col-6">
คำอธบายระด/พฤตกรรมทคาดหว/พฤตกรรมยอย
</div>
</div>
</q-card-section>
<div class="row items-center">
<q-card-section class="q-pa-none q-pl-xl col-6">
<span class="text-dark text-subtitle1 text-weight-medium">
L1 ประเภทอำนวยการ ระดบส
</span>
</q-card-section>
<q-card-section class="q-pa-none col-6">
<div class="q-mr-md">
<q-field
ref="fieldRef"
v-model="formData.level1"
label-slot
borderless
:rules="[
(val) =>
!!val || 'กรุณาระบุคำอธิบาย L1 ประเภทอำนวยการ ระดับสูง',
]"
hide-bottom-space
>
<template #control>
<q-editor
v-model="formData.level1"
:dense="$q.screen.lt.md"
min-height="5rem"
class="full-width"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</q-card-section>
</div>
<div class="row items-center">
<q-card-section class="q-pa-none q-pl-xl col-6">
<span class="text-dark text-subtitle1 text-weight-medium">
L2 ประเภทบรหาร ระดบส
</span>
</q-card-section>
<q-card-section class="q-pa-none col-6">
<div class="q-mr-md">
<q-field
ref="fieldRef"
v-model="formData.level2"
label-slot
borderless
:rules="[
(val) =>
!!val || 'กรุณาระบุคำอธิบาย L2 ประเภทบริหาร ระดับสูง',
]"
hide-bottom-space
>
<template #control>
<q-editor
v-model="formData.level2"
:dense="$q.screen.lt.md"
min-height="5rem"
class="full-width"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</q-card-section>
</div>
</q-card>
<div class="col-12 q-mt-md">
<q-input
v-model="formData.evaluation"
outlined
label="กำหนดเกณฑ์การประเมิน"
type="textarea"
dense
/>
</div>
<q-separator color="grey-4" />
<div class="col-12 row justify-end q-mt-md">
<q-btn
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
type="submit"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</div>
</div>
</q-form>
</div>
</template>

View file

@ -1,295 +0,0 @@
div
<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/** importStore*/
import { useCounterMixin } from "@/stores/mixin";
import { useKPIDataStore } from "@/modules/14_KPI/store/KPIStore";
/**use*/
const $q = useQuasar();
const mixin = useCounterMixin();
const { dialogConfirm, showLoader, hideLoader, success, messageError } = mixin;
const router = useRouter();
const route = useRoute();
const store = useKPIDataStore();
const competencyId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const formData = reactive({
competencyType: "",
competencyName: "",
definition: "",
levels: [
{
level: "1",
description: "",
},
],
});
function fetchDetail() {
showLoader();
http
.get(config.API.kpiCapacity + `/${competencyId.value}`)
.then((res) => {
const data = res.data.result;
formData.competencyType = data.type;
formData.competencyName = data.name;
formData.definition = data.description;
formData.levels = data.capacityDetails;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
function onClickAddLevels() {
const levelName = formData.levels.length + 1;
const data = {
level:
(store.competencyTypeVal === "HEAD" ||
store.competencyTypeVal === "GROUP") &&
levelName <= 6
? levelName.toString()
: "",
description: "",
};
levelName <= 6 && formData.levels.push(data);
}
function onSubmit() {
dialogConfirm($q, async () => {
const formBody = {
type: store.competencyTypeVal,
name: formData.competencyName,
description: formData.definition,
capacityDetails: formData.levels,
};
try {
const url = competencyId.value
? config.API.kpiCapacity + `/${competencyId.value}`
: config.API.kpiCapacity;
const method = competencyId.value ? "put" : "post";
await http[method](url, formBody);
if (!competencyId.value) {
router.push(`/KPI-competency`);
} else {
fetchDetail();
}
success($q, "บันทึกข้อมูลสำเร็จ");
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
});
}
function onDeleteLevels(index: number) {
formData.levels.splice(index, 1);
}
onMounted(() => {
if (competencyId.value) {
fetchDetail();
}
});
</script>
<template>
<q-form greedy @submit.prevent @validation-success="onSubmit" class="col-12">
<div class="row">
<div class="col-12">
<q-input
v-model="formData.competencyName"
dense
outlined
label="ชื่อสมรรถนะ"
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อสมรรถนะ'}`,]"
hide-bottom-space
/>
</div>
<q-card-section class="col-12 q-px-none">
<div>
<q-field
class="q_field_p_none"
ref="fieldRef"
v-model="formData.definition"
label-slot
borderless
:rules="[(val) => !!val || 'กรุณากรอกคำจำกัดความสมรรถนะ']"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="formData.definition"
:dense="$q.screen.lt.md"
min-height="7rem"
placeholder="คำจำกัดความสมรรถนะ"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field>
</div>
</q-card-section>
<div class="col-12">
<q-card flat bordered>
<q-card-section class="bg-grey-4">
<div
class="row items-center text-dark text-body2 text-weight-medium"
>
<div class="col-3">
<div class="row items-center">
<div class="col-1">
<q-btn
dense
flat
round
color="primary"
icon="add"
@click="onClickAddLevels"
>
<q-tooltip>เพ</q-tooltip></q-btn
>
</div>
<div class="col-11 text-center">
<span>ระดบสมรรถนะ</span>
</div>
</div>
</div>
<div class="col-4">
<span>พฤตกรรมทคาดหว/พฤตกรรมยอย</span>
</div>
</div>
</q-card-section>
<q-card-section>
<div
class="row q-pa-sm"
v-for="(items, index) in formData.levels"
key="index"
>
<div class="col-3 align-center q-pr-lg">
<q-input
:readonly="
store.competencyTypeVal === 'HEAD' ||
store.competencyTypeVal === 'GROUP'
"
v-model="formData.levels[index].level"
dense
outlined
:rules="[(val:string) => !!val || `${'กรุณากรอกระดับสมรรถนะ'}`,]"
hide-bottom-space
/>
</div>
<div class="col-9">
<div class="row q-col-gutter-md">
<div class="col-11">
<q-field
class="q_field_p_none"
ref="fieldRef"
v-model="formData.levels[index].description"
label-slot
borderless
:rules="[
(val) =>
!!val || 'กรุณากรอกพฤติกรรมที่คาดหวัง/พฤติกรรมย่อย',
]"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="formData.levels[index].description"
:dense="$q.screen.lt.md"
min-height="5rem"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
/>
</template>
</q-field>
</div>
<div class="col-1 text-center">
<q-btn
dense
flat
round
color="red"
icon="delete"
@click="onDeleteLevels(index)"
v-if="
(store.competencyTypeVal === 'HEAD' && index > 4) ||
(store.competencyTypeVal === 'GROUP' && index > 4) ||
((store.competencyTypeVal === 'EXECUTIVE' ||
store.competencyTypeVal === 'DIRECTOR' ||
store.competencyTypeVal === 'INSPECTOR') &&
index > 0)
"
>
<q-tooltip>ลบ</q-tooltip></q-btn
>
</div>
</div>
</div>
</div>
</q-card-section>
</q-card>
</div>
<div class="col-12 q-my-sm"><q-separator /></div>
<div class="col-12 row justify-end">
<q-btn
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
type="submit"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</div>
</div>
</q-form>
</template>
<style scoped></style>

View file

@ -1,31 +0,0 @@
<script setup lang="ts">
import { ref } from "vue";
import { useRouter, useRoute } from "vue-router";
import IndicatorByPlan from "@/modules/14_KPI/components/indicatorByPlan/IndicatorByPlan.vue";
const router = useRouter();
const route = useRoute();
const title = ref<string>(route.params.id ? "แก้ไข" : "เพิ่ม");
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
<q-btn
flat
round
dense
class="q-mr-sm"
icon="mdi-arrow-left"
color="primary"
@click="router.push(`/KPI-indicator-plan`)"
/>
{{ `${title}ตัวชี้วัดตามแผนฯ` }}
</div>
<q-card flat bordered>
<IndicatorByPlan />
</q-card>
</template>
<style scoped></style>

View file

@ -1,682 +0,0 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import { QForm, useQuasar } from "quasar";
import { useRoute, useRouter } from "vue-router";
import config from "@/app.config";
import http from "@/plugins/http";
/** importType*/
import type { DataOption } from "@/modules/14_KPI/interface/index/Main";
/** importStore*/
import { usePositionEmp } from "@/modules/16_positionEmployee/store/organizational";
import { useCounterMixin } from "@/stores/mixin";
/**use*/
const $q = useQuasar();
const route = useRoute();
const router = useRouter();
const store = usePositionEmp();
const mixin = useCounterMixin();
const {
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
dialogMessageNotify,
} = mixin;
const id = ref<string>(route.params.id ? route.params.id.toLocaleString() : "");
const editCheck = ref<boolean>(route.params.id ? true : false);
/**form ตัวชี้วัดตามแผนฯ*/
const planData = reactive({
period: "", //(->APR, ->OCT)
including: "", //
includingName: "", //
target: "", //
unit: "", //
weight: null, //
achievement1: "", // 1
achievement2: "", // 2
achievement3: "", // 3
achievement4: "", // 4
achievement5: "", // 5
meaning: "", //
formula: "", //
node: null, //
nodeId: null, //id
orgRevisionId: "", //RevisionId
strategy: null, //
strategyId: "", //id
documentInfoEvidence: "", //
});
const year = ref<number | null>(0); //
const roundOp = ref<DataOption[]>([
{ id: "APR", name: "รอบเมษายน" },
{ id: "OCT", name: "รอบตุลาคม" },
]);
const nodeplan = ref<any>([]);
const nodeAgency = ref<any>([]);
const filter = ref<string>("");
const filterAgency = ref<string>("");
const expandedPlan = ref<string[]>([]);
const expandedAgency = ref<string[]>([]);
const editStatus = ref<boolean>(false);
const inputRef = ref<any>(null);
/** function fetch หาโครงสร้างที่ใช้งาน*/
function fetchOrganizationActive() {
http
.get(config.API.activeOrganization)
.then((res) => {
const data = res.data.result;
if (data) {
store.fetchDataActive(data);
store.activeId && fetchTreeAgency(store.activeId);
fetchTreeStrategy();
}
})
.catch((err) => {
messageError($q, err);
});
}
/** function fetchTree ยุทธศาสตร์ / แผน*/
function fetchTreeStrategy() {
http
.get(config.API.devStrategy)
.then((res) => {
const data = res.data.result;
nodeplan.value = data;
})
.catch((err) => {
messageError($q, err);
});
}
/** functioon fetchcTree หน่วยงาน/ส่วนราชการ*/
function fetchTreeAgency(id: string) {
http
.get(config.API.orgByid(id.toString()))
.then(async (res) => {
const data = res.data.result;
nodeAgency.value = data;
store.treeId = "";
})
.catch((err) => {
messageError($q, err);
});
}
/** function fetch ข้อมูลตัวชี้วัด*/
function fetchDataById(id: string) {
showLoader();
http
.get(config.API.kpiPlanById(id))
.then((res) => {
const data = res.data.result;
year.value = data.year;
planData.period = data.round;
planData.including = data.including;
planData.includingName = data.includingName;
planData.target = data.target;
planData.unit = data.unit;
planData.weight = data.weight;
planData.achievement1 = data.achievement1;
planData.achievement2 = data.achievement2;
planData.achievement3 = data.achievement3;
planData.achievement4 = data.achievement4;
planData.achievement5 = data.achievement5;
planData.meaning = data.meaning;
planData.formula = data.formula;
planData.node = data.node;
planData.nodeId = data.nodeId;
planData.orgRevisionId = data.orgRevisionId;
planData.strategy = data.strategy;
planData.strategyId = data.strategyId;
// /
const arrayexpandedAgency = [
data.root,
data.child1,
data.child2,
data.child3,
data.child4,
];
expandedAgency.value = arrayexpandedAgency
.filter((e) => e !== null)
.slice(0, -1);
// /
const arrayexpandedPlan = [
data.strategyChild1,
data.strategyChild2,
data.strategyChild3,
data.strategyChild4,
data.strategyChild5,
];
expandedPlan.value = arrayexpandedPlan
.filter((e) => e !== null)
.slice(0, -1);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
setTimeout(() => {
hideLoader();
}, 1000);
});
}
/** funtion เลือกหรืออัปดเดท ยุทธศาสตร์ / แผน*/
function updateSelected(data: any) {
planData.strategyId = data.id;
planData.strategy = data.level;
}
/** funtion เลือกหรืออัปดเดท หน่วยงาน/ส่วนราชการ*/
function updateSelectedAgency(data: any, isUpdate: boolean = false) {
if (
planData.node === data.orgLevel &&
planData.nodeId === data.orgTreeId &&
!isUpdate
) {
planData.node = null;
planData.nodeId = null;
} else {
planData.node = data.orgLevel;
planData.nodeId = data.orgTreeId;
}
planData.orgRevisionId = data.orgRevisionId;
}
/**function ยืนยันการบันทึกข้อมูล */
function onSubmit() {
if (planData.nodeId == null || planData.strategyId == "") {
dialogMessageNotify(
$q,
`กรุณาเลือกหน่วยงาน/ส่วนราชการ หรือ ยุทธศาสตร์/แผน`
);
} else {
dialogConfirm(
$q,
async () => {
const body = {
year: year.value == 0 ? null : year.value,
period: planData.period,
includingName: planData.includingName,
target: planData.target,
unit: planData.unit,
weight: planData.weight,
achievement1: planData.achievement1,
achievement2: planData.achievement2,
achievement3: planData.achievement3,
achievement4: planData.achievement4,
achievement5: planData.achievement5,
meaning: planData.meaning,
formula: planData.formula,
node: planData.node,
nodeId: planData.nodeId,
orgRevisionId: planData.orgRevisionId,
strategy: planData.strategy,
strategyId: planData.strategyId,
documentInfoEvidence: planData.documentInfoEvidence,
};
showLoader();
// editStatus.value ? editData(id.value) : addData();
try {
const url = editStatus.value
? config.API.kpiPlanById(id.value)
: config.API.kpiPlan;
const method = editStatus.value ? "put" : "post";
const res = await http[method](url, body);
success($q, "บันทึกข้อมูลสำเร็จ");
editStatus.value
? fetchDataById(id.value)
: router.push(`/KPI-indicator-plan/${res.data.result}`);
} catch (e) {
messageError($q, e);
} finally {
hideLoader();
}
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
}
}
onMounted(() => {
fetchOrganizationActive();
if (id.value) {
editStatus.value = true;
fetchDataById(id.value);
}
});
</script>
<template>
<q-form @submit.prevent greedy @validation-success="onSubmit()">
<div>
<div class="row q-col-gutter-md q-pa-md">
<div class="col-2" v-if="editCheck">
<q-input
outlined
v-model="planData.including"
label="ลำดับ/รหัสตัวชี้วัด"
bg-color="white"
readonly
dense
class="inputgreen"
/>
</div>
<div :class="`${editCheck ? 'col-6' : 'col-8'}`">
<q-input
outlined
v-model="planData.includingName"
label="ชื่อตัวชี้วัด"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกชิ่อตัวชี้วัด'}`]"
hide-bottom-space
/>
</div>
<div class="col-2">
<datepicker
menu-class-name="modalfix"
v-model="year"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
@update:modelValue="planData.period = ''"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
outlined
class="inputgreen"
hide-bottom-space
:model-value="!!year ? year + 543 : null"
:label="`${'ปีงบประมาณ'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
<template v-slot:append>
<q-icon
v-if="year"
name="cancel"
class="cursor-pointer"
@click.stop.prevent="
year = 0;
planData.period = '';
"
/>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-2">
<q-select
ref="inputRef"
:readonly="year == 0"
dense
outlined
v-model="planData.period"
:options="roundOp"
label="รอบการประเมิน"
option-label="name"
option-value="id"
map-options
emit-value
class="inputgreen"
/>
</div>
<div class="col-4">
<q-input
outlined
v-model="planData.target"
label="ค่าเป้าหมาย"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกค่าเป้าหมาย'}`]"
hide-bottom-space
/>
</div>
<div class="col-4">
<q-input
outlined
v-model="planData.unit"
label="หน่วยนับ"
bg-color="white"
dense
lazy-rules
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกหน่วยนับ'}`]"
hide-bottom-space
/>
</div>
<div class="col-4">
<q-input
outlined
v-model="planData.weight"
label="น้ำหนัก"
type="number"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกน้ำหนัก'}`]"
hide-bottom-space
/>
</div>
<div class="col-12 row">
<div class="col-6">
<q-card flat bordered>
<q-card bordered>
<q-card-actions class="bg-grey-3 row">
<div class="col-4 flex justify-center items-center">
<div>ระดบคะแนน</div>
</div>
<div class="col-8 q-px-xl">ผลสำเรจของงาน</div>
</q-card-actions>
</q-card>
<div class="row">
<div class="col-4 flex justify-center items-center">
<div>5</div>
</div>
<div class="col-8 q-pa-sm">
<q-input
outlined
v-model="planData.achievement5"
label="กรอกผลสำเร็จของงาน"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกผลสำเร็จของงาน'}`]"
hide-bottom-space
/>
</div>
</div>
<div class="row">
<div class="col-4 flex justify-center items-center">
<div>4</div>
</div>
<div class="col-8 q-pa-sm">
<q-input
outlined
v-model="planData.achievement4"
label="กรอกผลสำเร็จของงาน"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกผลสำเร็จของงาน'}`]"
hide-bottom-space
/>
</div>
</div>
<div class="row">
<div class="col-4 flex justify-center items-center">
<div>3</div>
</div>
<div class="col-8 q-pa-sm">
<q-input
outlined
v-model="planData.achievement3"
label="กรอกผลสำเร็จของงาน"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกผลสำเร็จของงาน'}`]"
hide-bottom-space
/>
</div>
</div>
<div class="row">
<div class="col-4 flex justify-center items-center">
<div>2</div>
</div>
<div class="col-8 q-pa-sm">
<q-input
outlined
v-model="planData.achievement2"
label="กรอกผลสำเร็จของงาน"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกผลสำเร็จของงาน'}`]"
hide-bottom-space
/>
</div>
</div>
<div class="row">
<div class="col-4 flex justify-center items-center">
<div>1</div>
</div>
<div class="col-8 q-pa-sm">
<q-input
outlined
v-model="planData.achievement1"
label="กรอกผลสำเร็จของงาน"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกผลสำเร็จของงาน'}`]"
hide-bottom-space
/>
</div>
</div>
</q-card>
</div>
</div>
<div class="col-12">
<q-input
outlined
v-model="planData.meaning"
label="นิยามหรือความหมาย"
type="textarea"
bg-color="white"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกนิยามหรือความหมาย'}`]"
hide-bottom-space
/>
</div>
<div class="col-12">
<q-input
outlined
v-model="planData.formula"
label="สูตรคำนวณ"
bg-color="white"
type="textarea"
dense
class="inputgreen"
:rules="[(val) => !!val || `${'กรุณากรอกสูตรคำนวณ'}`]"
hide-bottom-space
/>
</div>
<div class="col-6">
<q-card bordered class="col-12">
<div
class="col-xs-12 col-sm-12 text-weight-medium bg-grey-1 q-py-xs q-px-md"
>
หนวยงาน/วนราชการ
</div>
<q-separator />
<q-card-section class="q-pa-sm">
<q-input
dense
outlined
v-model="filterAgency"
label="ค้นหา"
class="inputgreen"
>
<template v-slot:append>
<q-icon
v-if="filterAgency !== ''"
name="clear"
class="cursor-pointer"
@click="filterAgency = ''"
/>
<q-icon v-else name="search" color="grey-5" />
</template>
</q-input>
<q-tree
style="height: 350px; overflow: scroll"
dense
:nodes="nodeAgency"
node-key="orgTreeId"
label-key="orgTreeName"
selected-color="primary"
:filter="filterAgency"
no-results-label="ไม่พบข้อมูลที่ค้นหา"
no-nodes-label="ไม่มีข้อมูล"
v-model:expanded="expandedAgency"
v-model:selected="planData.nodeId"
>
<template v-slot:default-header="prop">
<q-item
clickable
@click.stop="updateSelectedAgency(prop.node)"
:active="planData.nodeId == prop.node.orgTreeId"
active-class="my-list-link text-primary text-weight-medium"
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
>
<div>
<div class="text-weight-medium">
{{ prop.node.orgTreeName }}
</div>
<div class="text-weight-light text-grey-8">
{{
prop.node.orgCode == null ? null : prop.node.orgCode
}}
{{
prop.node.orgTreeShortName == null
? null
: prop.node.orgTreeShortName
}}
</div>
</div>
</q-item>
</template>
</q-tree>
</q-card-section>
</q-card>
</div>
<div class="col-6">
<q-card bordered class="col-12">
<div
class="col-xs-12 col-sm-12 text-weight-medium bg-grey-1 q-py-xs q-px-md"
>
ทธศาสตร / แผน
</div>
<q-separator />
<q-card-section class="q-pa-sm">
<q-input
dense
outlined
v-model="filter"
label="ค้นหา"
class="inputgreen"
>
<template v-slot:append>
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
<q-icon v-else name="search" color="grey-5" />
</template>
</q-input>
<q-tree
style="height: 350px; overflow: scroll"
dense
:nodes="nodeplan"
selected-color="primary"
node-key="id"
label-key="name"
:filter="filter"
no-results-label="ไม่พบข้อมูลที่ค้นหา"
no-nodes-label="ไม่มีข้อมูล"
v-model:expanded="expandedPlan"
v-model:selected="planData.strategyId"
>
<template v-slot:default-header="prop">
<q-item
clickable
@click.stop="updateSelected(prop.node)"
:active="planData.strategyId == prop.node.id"
active-class="my-list-link text-primary text-weight-medium"
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
>
<div>
<div class="text-weight-medium">
{{ prop.node.name }}
</div>
</div>
</q-item>
</template>
</q-tree>
</q-card-section>
</q-card>
</div>
<div class="col-12">
<q-input
class="inputgreen"
v-model="planData.documentInfoEvidence"
label="ข้อมูลเอกสารหลักฐาน"
outlined
dense
type="textarea"
></q-input>
</div>
</div>
<q-separator color="grey-4" />
</div>
<q-toolbar class="fit row wrap justify-end items-start content-start">
<q-btn
dense
unelevated
label="บันทึก"
id="onSubmit"
type="submit"
color="public"
class="q-px-md"
>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</q-toolbar>
</q-form>
</template>
<style lang="scss" scoped>
.my-list-link {
color: rgb(118, 168, 222);
border-radius: 5px;
background: #a3d3fb48 !important;
font-weight: 600;
border: 1px solid rgba(175, 185, 196, 0.217);
}
</style>

View file

@ -1,659 +0,0 @@
<script setup lang="ts">
import { ref, reactive, onMounted, watch } from "vue";
import { useQuasar } from "quasar";
import { useRouter, useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import type { FormDataRole } from "@/modules/14_KPI/interface/request/Main";
import type { DataOption } from "@/modules/14_KPI/interface/index/Main";
const $q = useQuasar();
const route = useRoute();
const router = useRouter();
const heightSize = ref<string>("224");
const filter = ref<string>("");
const node = ref<any>([]);
const expanded = ref<string[]>([]);
const orgName = ref<string>("");
const nodeId = ref<string>("");
const id = ref<string>(route.params.id ? route.params.id.toLocaleString() : "");
const {
showLoader,
hideLoader,
messageError,
success,
dialogConfirm,
dialogMessageNotify,
} = useCounterMixin();
const title = ref<string>(route.params.id ? "แก้ไข" : "เพิ่ม");
const modalDialogSelect = ref<boolean>(false);
const form = reactive<FormDataRole>({
position: "", //
year: new Date().getFullYear(), //
round: "", //
org: "", ///
including: "", //
includingName: "", //
target: "", //
unit: "", //
weight: "", //
meaning: "", //
formula: "", //
documentInfoEvidence: "", //
node: null,
nodeId: null,
orgRevisionId: null,
});
const fieldLabels = {
score5: "5",
score4: "4",
score3: "3",
score2: "2",
score1: "1",
};
const formScore = reactive<any>({
score5: "",
score4: "",
score3: "",
score2: "",
score1: "",
});
const positionOp = ref<DataOption[]>([]);
const positionMainOp = ref<DataOption[]>([]);
/** Option รอบการประเมิน*/
const roundOp = ref<DataOption[]>([
{ id: "APR", name: "รอบเมษายน" },
{ id: "OCT", name: "รอบตุลาคม" },
]);
/**
* function นหาขอมลของ Option
* @param val าทองการฟลเตอร
* @param update พเดทค
* @param refData ดาตาทองการฟลเตอร
*/
function filterOption(val: any, update: Function) {
update(() => {
positionOp.value = positionMainOp.value.filter(
(v: any) => v.name.indexOf(val) > -1
);
});
}
/** ดึงข้อมูลตำแหน่ง */
function getOptions() {
http.get(config.API.orgSalaryPosition).then((res) => {
const dataOp = res.data.result;
const uniqueNames = new Set();
const filteredData = dataOp
.filter((item: any) => {
if (!uniqueNames.has(item.positionName)) {
uniqueNames.add(item.positionName);
return true;
}
return false;
})
.map((item: any) => ({
id: item.positionName,
name: item.positionName,
}));
positionMainOp.value = filteredData;
});
}
/** เปิด Dialog หน่วยงาน */
function selectAgency() {
modalDialogSelect.value = true;
}
/** บันทึกข้อมูล */
function onSubmit() {
const url = id.value
? config.API.kpiRoleMainList + `/${id.value}`
: config.API.kpiRoleMainList;
const body = {
year: form.year == 0 ? null:form.year,
position: form.position, //
period: form.round, //(->APR, ->OCT)
includingName: form.includingName, //
target: form.target, //
unit: form.unit, //
weight: form.weight, //
achievement1: formScore.score1, // 1
achievement2: formScore.score2, // 2
achievement3: formScore.score3, // 3
achievement4: formScore.score4, // 4
achievement5: formScore.score5, // 5
meaning: form.meaning, //
formula: form.formula, //
documentInfoEvidence: form.documentInfoEvidence, //
node: form.node, //
nodeId: form.nodeId, //id
orgRevisionId: form.orgRevisionId, //RevisionId
};
if (form.nodeId == null) {
dialogMessageNotify($q, "กรุณาเลือกหน่วยงาน/ส่วนราชการ");
} else {
dialogConfirm($q, () => {
showLoader();
http[id.value ? "put" : "post"](url, body)
.then(() => {
success($q, "บันทึกสำเร็จ");
id.value ? getDetail() : router.push(`/KPI-indicator-role`);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
}
}
//
//
function getDetail() {
showLoader();
http
.get(config.API.kpiRoleMainList + `/${id.value}`)
.then((res) => {
const data = res.data.result;
form.position = data.position;
form.year = data.year == null ? 0 : data.year;
form.round = data.round;
form.including = data.including;
form.includingName = data.includingName;
form.target = data.target;
form.unit = data.unit;
form.weight = data.weight;
form.meaning = data.meaning;
form.formula = data.formula;
formScore.score1 = data.achievement1;
formScore.score2 = data.achievement2;
formScore.score3 = data.achievement3;
formScore.score4 = data.achievement4;
formScore.score5 = data.achievement5;
form.node = data.node;
form.nodeId = data.nodeId;
form.orgRevisionId = data.orgRevisionId;
const arrayExpanded = [
data.root,
data.child1,
data.child2,
data.child3,
data.child4,
];
expanded.value = arrayExpanded.filter((e) => e !== null).slice(0, -1);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
function fetchActive() {
showLoader();
http
.get(config.API.activeOrganization)
.then((res) => {
const data = res.data.result;
fetchTree(data.activeId);
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
async function fetchTree(id: string) {
showLoader();
http
.get(config.API.orgByid(id.toString()))
.then((res) => {
const data = res.data.result;
node.value = data;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
function updateSelected(data: any) {
nodeId.value = data.orgTreeId;
orgName.value = data.orgTreeName;
form.node = data.orgLevel;
form.nodeId = data.orgTreeId;
form.orgRevisionId = data.orgRevisionId;
}
function statusTothai(val: string) {
switch (val) {
case "SPECIAL":
return "รอบพิเศษ";
case "APR":
return "รอบเมษายน";
case "OCT":
return "รอบตุลาคม";
default:
return "-";
}
}
function onResize(size: any) {
heightSize.value = `${size.height - 99}`;
}
function setModel(val: string) {
form.position = val;
}
onMounted(() => {
fetchActive();
getOptions();
if (id.value !== "") {
getDetail();
}
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
<q-btn
flat
round
dense
class="q-mr-sm"
icon="mdi-arrow-left"
color="primary"
@click="router.go(-1)"
/>
{{ `${title}ตัวชี้วัดตามตำแหน่ง` }}
</div>
<q-card flat>
<q-form greedy @submit.prevent @validation-success="onSubmit">
<q-card-section>
<div class="row q-col-gutter-sm">
<div class="col-8">
<q-select
dense
:model-value="form.position"
label="ตำแหน่งในสายงาน"
outlined
emit-value
map-options
fill-input
hide-selected
lazy-rules
:rules="[(val:string) => !!val || `${'กรุณาเลือกตำแหน่งในสายงาน'}`,]"
hide-bottom-space
option-label="name"
option-value="id"
class="inputgreen"
:options="positionOp"
use-input
@input-value="setModel"
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) "
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template></q-select
>
</div>
<div class="col-2">
<datepicker
menu-class-name="modalfix"
v-model="form.year"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
@update:model-value="form.round = ''"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
class="inputgreen"
outlined
:model-value="
form.year === 0 ? null : Number(form.year) + 543
"
:label="`${'ปีงบประมาณ'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
<template v-slot:append>
<q-icon
v-if="form.year"
name="cancel"
class="cursor-pointer"
@click.stop.prevent="
form.year = 0;
form.round = '';
"
/>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-2">
<q-select
:readonly="form.year == 0"
dense
outlined
v-model="form.round"
:options="roundOp"
option-label="name"
option-value="id"
emit-value
map-options
input-class="text-red"
label="รอบการประเมิน"
class="inputgreen"
/>
</div>
<div class="col-2" v-if="id">
<q-input
label="ลำดับ/รหัสตัวชี้วัด"
v-model="form.including"
outlined
readonly
dense
class="inputgreen"
/>
</div>
<div class="col-4">
<q-input
label="ชื่อตัวชี้วัด"
v-model="form.includingName"
outlined
dense
class="inputgreen"
lazy-rules
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อตัวชี้วัด'}`,]"
hide-bottom-space
/>
</div>
<div class="col-2">
<q-input
label="ค่าเป้าหมาย"
v-model="form.target"
outlined
dense
class="inputgreen"
lazy-rules
:rules="[(val:string) => !!val || `${'กรุณากรอกค่าเป้าหมาย'}`,]"
hide-bottom-space
/>
</div>
<div class="col-2">
<q-input
label="หน่วยนับ"
v-model="form.unit"
outlined
dense
class="inputgreen"
lazy-rules
:rules="[(val:string) => !!val || `${'กรุณากรอกหน่วยนับ'}`,]"
hide-bottom-space
/>
</div>
<div class="col-2">
<q-input
label="น้ำหนัก"
v-model="form.weight"
outlined
dense
class="inputgreen"
lazy-rules
:rules="[(val:string) => !!val || `${'กรุณากรอกน้ำหนัก'}`,]"
hide-bottom-space
/>
</div>
<div class="col-4">
<q-card flat bordered class="full-height">
<q-card-section class="bg-grey-3 q-pa-sm">
<div class="text-dark text-body2 text-weight-medium">
หนวยงาน/วนราชการ
</div>
</q-card-section>
<q-card-section class="q-pa-sm">
<q-input
dense
outlined
v-model="filter"
label="ค้นหา"
class="inputgreen"
>
<template v-slot:append>
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
<q-icon v-else name="search" color="grey-5" />
</template>
</q-input>
<q-scroll-area
visible
:style="{ height: `${heightSize}px`, marginTop: '5px' }"
>
<q-tree
dense
:nodes="node"
node-key="orgTreeId"
label-key="orgTreeName"
v-model:expanded="expanded"
:filter="filter"
no-results-label="ไม่พบข้อมูลที่ค้นหา"
no-nodes-label="ไม่มีข้อมูล"
>
<template v-slot:default-header="prop">
<q-item
clickable
@click.stop="updateSelected(prop.node)"
:active="form.nodeId === prop.node.orgTreeId"
active-class="my-list-link text-primary text-weight-medium"
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
>
<div>
<div class="text-weight-medium">
{{ prop.node.orgTreeName }}
</div>
<div class="text-weight-light text-grey-8">
{{
prop.node.orgCode == null
? null
: prop.node.orgCode
}}
{{
prop.node.orgTreeShortName == null
? null
: prop.node.orgTreeShortName
}}
</div>
</div>
</q-item>
</template>
</q-tree>
</q-scroll-area>
</q-card-section>
</q-card>
</div>
<div class="col-8">
<q-card flat bordered>
<q-resize-observer @resize="onResize" />
<q-card-section class="bg-grey-3 q-pa-sm">
<div class="row text-dark text-body2 text-weight-medium">
<div class="text-center col-4">ระดบคะแนน</div>
<div class="col-8">ผลสำเรจของงาน</div>
</div>
</q-card-section>
<q-card-section class="q-pa-none">
<div
v-for="(field, index) in Object.keys(fieldLabels)"
:key="index + 1"
>
<div class="row q-pa-sm">
<div
class="col-4 text-center text-body1 text-weight-bold self-center"
>
{{ fieldLabels[field as keyof typeof fieldLabels] }}
</div>
<div class="col-8 text-left">
<!-- <q-field
class="q_field_p_none"
ref="fieldRef"
v-model="formScore[field]"
label-slot
borderless
:rules="[(val) => !!val || 'กรุณากรอกมาตรฐานพฤติกรรม']"
hide-bottom-space
>
<template #control>
<q-editor
class="full-width"
v-model="formScore[field]"
:dense="$q.screen.lt.md"
min-height="5rem"
:toolbar="[
[
'bold',
'italic',
'strike',
'underline',
'subscript',
'superscript',
],
['unordered', 'ordered'],
]"
:fonts="{
arial: 'Arial',
arial_black: 'Arial Black',
comic_sans: 'Comic Sans MS',
courier_new: 'Courier New',
impact: 'Impact',
lucida_grande: 'Lucida Grande',
times_new_roman: 'Times New Roman',
verdana: 'Verdana',
}"
/>
</template>
</q-field> -->
<q-input
v-model="formScore[field]"
dense
outlined
class="inputgreen"
label="กรอกผลสำเร็จของงาน"
:rules="[(val:string) => !!val || `${'กรุณากรอกผลสำเร็จของงาน'}`,]"
hide-bottom-space
/>
</div>
</div>
<div
class="col-12"
v-if="index !== Object.keys(fieldLabels).length - 1"
>
<q-separator />
</div>
</div>
</q-card-section>
</q-card>
</div>
<div class="col-12">
<q-input
v-model="form.meaning"
label="นิยามหรือความหมาย"
dense
outlined
lazy-rules
class="inputgreen"
:rules="[(val:string) => !!val || `${'กรุณากรอกนิยามหรือความหมาย'}`,]"
hide-bottom-space
type="textarea"
/>
</div>
<div class="col-12">
<q-input
v-model="form.formula"
label="สูตรคำนวณ"
dense
outlined
lazy-rules
class="inputgreen"
:rules="[(val:string) => !!val || `${'กรุณากรอกสูตรคำนวณ'}`,]"
hide-bottom-space
type="textarea"
/>
</div>
<div class="col-12">
<q-input
class="inputgreen"
v-model="form.documentInfoEvidence"
label="ข้อมูลเอกสารหลักฐาน"
outlined
dense
type="textarea"
></q-input>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn color="public" label="บันทึก" type="submit" unelevated>
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</q-card-actions>
</q-form>
</q-card>
</template>
<style scoped>
.my-list-link {
color: rgb(118, 168, 222);
border-radius: 5px;
background: #a3d3fb48 !important;
font-weight: 600;
border: 1px solid rgba(175, 185, 196, 0.217);
}
</style>