Merge branch 'Nice' into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-15 12:13:34 +07:00
commit b8d74d6302
2 changed files with 97 additions and 97 deletions

View file

@ -8,8 +8,10 @@ import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useStructureTree } from "@/stores/structureTree";
import type { DataStructureTree } from "@/interface/main";
import type { FormDataRole } from "@/modules/01_masterdata/interface/request/Main";
import type { DataOption } from "@/modules/01_masterdata/interface/index/Main";
import type { DataKPIPosition } from "@/modules/01_masterdata/interface/response/Main";
const $q = useQuasar();
const route = useRoute();
@ -18,7 +20,7 @@ const { fetchStructureTree } = useStructureTree();
const heightSize = ref<string>("224");
const filter = ref<string>("");
const node = ref<any>([]);
const node = ref<DataStructureTree[]>([]);
const expanded = ref<string[]>([]);
const orgName = ref<string>("");
const nodeId = ref<string>("");
@ -103,21 +105,20 @@ function filterOption(val: string, update: Function) {
/** ดึงข้อมูลตำแหน่ง */
async function getOptions() {
// showLoader();
await http
.get(config.API.orgSalaryPosition)
.then((res) => {
const dataOp = res.data.result;
const uniqueNames = new Set();
const filteredData = dataOp
.filter((item: any) => {
.filter((item: DataKPIPosition) => {
if (!uniqueNames.has(item.positionName)) {
uniqueNames.add(item.positionName);
return true;
}
return false;
})
.map((item: any) => ({
.map((item: DataKPIPosition) => ({
id: item.positionName,
name: item.positionName,
}));
@ -126,17 +127,9 @@ async function getOptions() {
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
// hideLoader();
});
}
/** เปิด Dialog หน่วยงาน */
function selectAgency() {
modalDialogSelect.value = true;
}
/** บันทึกข้อมูล */
function onSubmit() {
const url = id.value
@ -168,12 +161,14 @@ function onSubmit() {
if (form.nodeId == null) {
dialogMessageNotify($q, "กรุณาเลือกหน่วยงาน/ส่วนราชการ");
} else {
dialogConfirm($q, () => {
dialogConfirm($q, async () => {
showLoader();
http[id.value ? "put" : "post"](url, body)
.then(() => {
await http[id.value ? "put" : "post"](url, body)
.then(async () => {
id.value
? await getDetail()
: router.push(`/masterdata/indicator-role`);
success($q, "บันทึกสำเร็จ");
id.value ? getDetail() : router.push(`/masterdata/indicator-role`);
})
.catch((err) => {
messageError($q, err);
@ -186,76 +181,73 @@ function onSubmit() {
}
async function getDetail() {
showLoader();
await http
.get(config.API.kpiRoleMainEdit + `/${id.value}`)
.then(async (res) => {
const data = await 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;
form.documentInfoEvidence = data.documentInfoEvidence;
nodeDnaId.value = data.nodeDnaId;
if (id.value !== "") {
await http
.get(config.API.kpiRoleMainEdit + `/${id.value}`)
.then(async (res) => {
const data = await 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;
form.documentInfoEvidence = data.documentInfoEvidence;
nodeDnaId.value = data.nodeDnaId;
formScore.score1 = data.achievement1;
formScore.score2 = data.achievement2;
formScore.score3 = data.achievement3;
formScore.score4 = data.achievement4;
formScore.score5 = data.achievement5;
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();
});
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);
});
}
}
async function fetchStructure() {
node.value = await fetchStructureTree(route.meta.Key as string, true);
}
function updateSelected(data: any) {
function updateSelected(data: DataStructureTree) {
nodeId.value = data.orgTreeId;
orgName.value = data.orgTreeName;
form.node = data.orgLevel;
form.nodeId = data.orgTreeId;
form.orgRevisionId = data.orgRevisionId;
nodeDnaId.value = data.orgTreeDnaId;
nodeDnaId.value = data.orgTreeDnaId ?? "";
}
function onResize(size: any) {
function onResize(size: { width: number; height: number }) {
heightSize.value = `${size.height - 99}`;
}
function setModel(val: string) {
form.position = val;
}
onMounted(async () => {
showLoader();
try {
await Promise.all([fetchStructure(), getOptions()]);
onMounted(() => {
fetchStructure();
getOptions();
if (id.value !== "") {
getDetail();
await getDetail();
} finally {
hideLoader();
}
});
</script>
@ -295,7 +287,7 @@ onMounted(() => {
class="inputgreen"
:options="positionOp"
use-input
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) "
@filter="(inputValue:string,doneFn:Function) => filterOption(inputValue, doneFn) "
>
<template v-slot:no-option>
<q-item>

View file

@ -7,6 +7,7 @@ import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
import { updateCurrentPage } from "@/utils/function";
import type { FormListMainByRole } from "@/modules/01_masterdata/interface/request/Main";
import type {
@ -16,6 +17,7 @@ import type {
IndicatorType,
IndicatorTotal,
} from "@/modules/01_masterdata/interface/index/Main";
import type { DataKPIPosition } from "@/modules/01_masterdata/interface/response/Main";
import DialogHistory from "@/modules/01_masterdata/components/Indicators/DialogHistory.vue";
import Summary from "@/modules/01_masterdata/components/Indicators/Summary.vue";
@ -28,7 +30,7 @@ const { showLoader, hideLoader, dialogRemove, success, messageError } =
/** use*/
const dataHistory = ref<KpiRoleData[]>([]);
const modalHistory = ref<boolean>(false);
const total = ref<number>();
const total = ref<number>(0);
const positionOp = ref<DataOption[]>([{ id: "", name: "ทั้งหมด" }]);
const positionMainOp = ref<DataOption[]>([{ id: "", name: "ทั้งหมด" }]);
@ -103,7 +105,6 @@ const roundOp = ref<DataOption[]>([
]);
async function fetchList() {
showLoader();
rows.value = [];
await http
.post(config.API.kpiRoleMainList + `/search-edit`, {
@ -124,9 +125,6 @@ async function fetchList() {
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
@ -141,13 +139,18 @@ function onClickView(id: string = "") {
}
function onClickDelete(id: number) {
dialogRemove($q, () => {
dialogRemove($q, async () => {
showLoader();
http
await http
.delete(config.API.kpiRoleMainList + `/${id}`)
.then(() => {
.then(async () => {
formFilter.page = await updateCurrentPage(
formFilter.page,
maxPage.value,
rows.value.length
);
await fetchList();
success($q, "ลบข้อมูลสำเร็จ");
fetchList();
})
.catch((err) => {
messageError($q, err);
@ -158,9 +161,14 @@ function onClickDelete(id: number) {
});
}
function updatePage(val: number) {
formFilter.page = val;
fetchList();
async function updatePage(val: number) {
showLoader();
try {
formFilter.page = val;
await fetchList();
} finally {
hideLoader();
}
}
function updatePageSize(newPagination: NewPagination) {
@ -170,8 +178,13 @@ function updatePageSize(newPagination: NewPagination) {
watch(
() => formFilter.pageSize,
() => {
fetchList();
async () => {
showLoader();
try {
await fetchList();
} finally {
hideLoader();
}
}
);
@ -181,17 +194,16 @@ watch(
* @param update พเดทค
* @param refData ดาตาทองการฟลเตอร
*/
function filterOption(val: any, update: Function) {
function filterOption(val: string, update: Function) {
update(() => {
positionOp.value = positionMainOp.value.filter(
(v: any) => v.name.indexOf(val) > -1
(v: DataOption) => v.name.indexOf(val) > -1
);
});
}
/** ดึงข้อมูลตำแหน่ง */
async function getOptions() {
// showLoader();
await http
.get(config.API.orgSalaryPosition)
.then(async (res) => {
@ -199,14 +211,14 @@ async function getOptions() {
const uniqueNames = new Set();
const filteredData = dataOp
.filter((item: any) => {
.filter((item: DataKPIPosition) => {
if (!uniqueNames.has(item.positionName)) {
uniqueNames.add(item.positionName);
return true;
}
return false;
})
.map((item: any) => ({
.map((item: DataKPIPosition) => ({
id: item.positionName,
name: item.positionName,
}));
@ -216,9 +228,6 @@ async function getOptions() {
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
// hideLoader();
});
}
@ -227,13 +236,14 @@ async function getOptions() {
* @param id
*/
function onClickHistory(id: string) {
dataHistory.value = [];
modalHistory.value = true;
showLoader();
http
.get(config.API.kpiRoleMainList + `/history/${id}`)
.then((res) => {
const data = res.data.result;
dataHistory.value = data;
modalHistory.value = true;
})
.catch((e) => {
messageError($q, e);
@ -244,7 +254,6 @@ function onClickHistory(id: string) {
}
async function getTotal() {
// showLoader();
await http
.post(config.API.indicatorSummary)
.then(async (res) => {
@ -258,17 +267,16 @@ async function getTotal() {
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
// hideLoader();
});
}
onMounted(async () => {
showLoader();
await Promise.all([getTotal(), getOptions(), fetchList()]).finally(() => {
try {
await Promise.all([getTotal(), getOptions(), fetchList()]);
} finally {
hideLoader();
});
}
});
</script>