fix CurrentPage ===> รายการตัวชี้วัดตามตำแหน่ง
This commit is contained in:
parent
6db8040e90
commit
e8eec83e17
2 changed files with 97 additions and 97 deletions
|
|
@ -8,8 +8,10 @@ import config from "@/app.config";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useStructureTree } from "@/stores/structureTree";
|
import { useStructureTree } from "@/stores/structureTree";
|
||||||
|
|
||||||
|
import type { DataStructureTree } from "@/interface/main";
|
||||||
import type { FormDataRole } from "@/modules/01_masterdata/interface/request/Main";
|
import type { FormDataRole } from "@/modules/01_masterdata/interface/request/Main";
|
||||||
import type { DataOption } from "@/modules/01_masterdata/interface/index/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 $q = useQuasar();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
@ -18,7 +20,7 @@ const { fetchStructureTree } = useStructureTree();
|
||||||
|
|
||||||
const heightSize = ref<string>("224");
|
const heightSize = ref<string>("224");
|
||||||
const filter = ref<string>("");
|
const filter = ref<string>("");
|
||||||
const node = ref<any>([]);
|
const node = ref<DataStructureTree[]>([]);
|
||||||
const expanded = ref<string[]>([]);
|
const expanded = ref<string[]>([]);
|
||||||
const orgName = ref<string>("");
|
const orgName = ref<string>("");
|
||||||
const nodeId = ref<string>("");
|
const nodeId = ref<string>("");
|
||||||
|
|
@ -103,21 +105,20 @@ function filterOption(val: string, update: Function) {
|
||||||
|
|
||||||
/** ดึงข้อมูลตำแหน่ง */
|
/** ดึงข้อมูลตำแหน่ง */
|
||||||
async function getOptions() {
|
async function getOptions() {
|
||||||
// showLoader();
|
|
||||||
await http
|
await http
|
||||||
.get(config.API.orgSalaryPosition)
|
.get(config.API.orgSalaryPosition)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const dataOp = res.data.result;
|
const dataOp = res.data.result;
|
||||||
const uniqueNames = new Set();
|
const uniqueNames = new Set();
|
||||||
const filteredData = dataOp
|
const filteredData = dataOp
|
||||||
.filter((item: any) => {
|
.filter((item: DataKPIPosition) => {
|
||||||
if (!uniqueNames.has(item.positionName)) {
|
if (!uniqueNames.has(item.positionName)) {
|
||||||
uniqueNames.add(item.positionName);
|
uniqueNames.add(item.positionName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.map((item: any) => ({
|
.map((item: DataKPIPosition) => ({
|
||||||
id: item.positionName,
|
id: item.positionName,
|
||||||
name: item.positionName,
|
name: item.positionName,
|
||||||
}));
|
}));
|
||||||
|
|
@ -126,17 +127,9 @@ async function getOptions() {
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
messageError($q, e);
|
messageError($q, e);
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
// hideLoader();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** เปิด Dialog หน่วยงาน */
|
|
||||||
function selectAgency() {
|
|
||||||
modalDialogSelect.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** บันทึกข้อมูล */
|
/** บันทึกข้อมูล */
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
const url = id.value
|
const url = id.value
|
||||||
|
|
@ -168,12 +161,14 @@ function onSubmit() {
|
||||||
if (form.nodeId == null) {
|
if (form.nodeId == null) {
|
||||||
dialogMessageNotify($q, "กรุณาเลือกหน่วยงาน/ส่วนราชการ");
|
dialogMessageNotify($q, "กรุณาเลือกหน่วยงาน/ส่วนราชการ");
|
||||||
} else {
|
} else {
|
||||||
dialogConfirm($q, () => {
|
dialogConfirm($q, async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
http[id.value ? "put" : "post"](url, body)
|
await http[id.value ? "put" : "post"](url, body)
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
|
id.value
|
||||||
|
? await getDetail()
|
||||||
|
: router.push(`/masterdata/indicator-role`);
|
||||||
success($q, "บันทึกสำเร็จ");
|
success($q, "บันทึกสำเร็จ");
|
||||||
id.value ? getDetail() : router.push(`/masterdata/indicator-role`);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -186,76 +181,73 @@ function onSubmit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDetail() {
|
async function getDetail() {
|
||||||
showLoader();
|
if (id.value !== "") {
|
||||||
await http
|
await http
|
||||||
.get(config.API.kpiRoleMainEdit + `/${id.value}`)
|
.get(config.API.kpiRoleMainEdit + `/${id.value}`)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = await res.data.result;
|
const data = await res.data.result;
|
||||||
form.position = data.position;
|
form.position = data.position;
|
||||||
form.year = data.year == null ? 0 : data.year;
|
form.year = data.year == null ? 0 : data.year;
|
||||||
form.round = data.round;
|
form.round = data.round;
|
||||||
form.including = data.including;
|
form.including = data.including;
|
||||||
form.includingName = data.includingName;
|
form.includingName = data.includingName;
|
||||||
form.target = data.target;
|
form.target = data.target;
|
||||||
form.unit = data.unit;
|
form.unit = data.unit;
|
||||||
form.weight = data.weight;
|
form.weight = data.weight;
|
||||||
form.meaning = data.meaning;
|
form.meaning = data.meaning;
|
||||||
form.formula = data.formula;
|
form.formula = data.formula;
|
||||||
form.documentInfoEvidence = data.documentInfoEvidence;
|
form.documentInfoEvidence = data.documentInfoEvidence;
|
||||||
nodeDnaId.value = data.nodeDnaId;
|
nodeDnaId.value = data.nodeDnaId;
|
||||||
|
|
||||||
formScore.score1 = data.achievement1;
|
formScore.score1 = data.achievement1;
|
||||||
formScore.score2 = data.achievement2;
|
formScore.score2 = data.achievement2;
|
||||||
formScore.score3 = data.achievement3;
|
formScore.score3 = data.achievement3;
|
||||||
formScore.score4 = data.achievement4;
|
formScore.score4 = data.achievement4;
|
||||||
formScore.score5 = data.achievement5;
|
formScore.score5 = data.achievement5;
|
||||||
|
|
||||||
form.node = data.node;
|
form.node = data.node;
|
||||||
form.nodeId = data.nodeId;
|
form.nodeId = data.nodeId;
|
||||||
form.orgRevisionId = data.orgRevisionId;
|
form.orgRevisionId = data.orgRevisionId;
|
||||||
const arrayExpanded = [
|
const arrayExpanded = [
|
||||||
data.root,
|
data.root,
|
||||||
data.child1,
|
data.child1,
|
||||||
data.child2,
|
data.child2,
|
||||||
data.child3,
|
data.child3,
|
||||||
data.child4,
|
data.child4,
|
||||||
];
|
];
|
||||||
expanded.value = arrayExpanded.filter((e) => e !== null).slice(0, -1);
|
expanded.value = arrayExpanded.filter((e) => e !== null).slice(0, -1);
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
messageError($q, e);
|
messageError($q, e);
|
||||||
})
|
});
|
||||||
.finally(() => {
|
}
|
||||||
hideLoader();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchStructure() {
|
async function fetchStructure() {
|
||||||
node.value = await fetchStructureTree(route.meta.Key as string, true);
|
node.value = await fetchStructureTree(route.meta.Key as string, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSelected(data: any) {
|
function updateSelected(data: DataStructureTree) {
|
||||||
nodeId.value = data.orgTreeId;
|
nodeId.value = data.orgTreeId;
|
||||||
orgName.value = data.orgTreeName;
|
orgName.value = data.orgTreeName;
|
||||||
form.node = data.orgLevel;
|
form.node = data.orgLevel;
|
||||||
form.nodeId = data.orgTreeId;
|
form.nodeId = data.orgTreeId;
|
||||||
form.orgRevisionId = data.orgRevisionId;
|
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}`;
|
heightSize.value = `${size.height - 99}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setModel(val: string) {
|
onMounted(async () => {
|
||||||
form.position = val;
|
showLoader();
|
||||||
}
|
try {
|
||||||
|
await Promise.all([fetchStructure(), getOptions()]);
|
||||||
|
|
||||||
onMounted(() => {
|
await getDetail();
|
||||||
fetchStructure();
|
} finally {
|
||||||
getOptions();
|
hideLoader();
|
||||||
if (id.value !== "") {
|
|
||||||
getDetail();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -295,7 +287,7 @@ onMounted(() => {
|
||||||
class="inputgreen"
|
class="inputgreen"
|
||||||
:options="positionOp"
|
:options="positionOp"
|
||||||
use-input
|
use-input
|
||||||
@filter="(inputValue:any,doneFn:Function) => filterOption(inputValue, doneFn) "
|
@filter="(inputValue:string,doneFn:Function) => filterOption(inputValue, doneFn) "
|
||||||
>
|
>
|
||||||
<template v-slot:no-option>
|
<template v-slot:no-option>
|
||||||
<q-item>
|
<q-item>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { checkPermission } from "@/utils/permissions";
|
import { checkPermission } from "@/utils/permissions";
|
||||||
|
import { updateCurrentPage } from "@/utils/function";
|
||||||
|
|
||||||
import type { FormListMainByRole } from "@/modules/01_masterdata/interface/request/Main";
|
import type { FormListMainByRole } from "@/modules/01_masterdata/interface/request/Main";
|
||||||
import type {
|
import type {
|
||||||
|
|
@ -16,6 +17,7 @@ import type {
|
||||||
IndicatorType,
|
IndicatorType,
|
||||||
IndicatorTotal,
|
IndicatorTotal,
|
||||||
} from "@/modules/01_masterdata/interface/index/Main";
|
} 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 DialogHistory from "@/modules/01_masterdata/components/Indicators/DialogHistory.vue";
|
||||||
import Summary from "@/modules/01_masterdata/components/Indicators/Summary.vue";
|
import Summary from "@/modules/01_masterdata/components/Indicators/Summary.vue";
|
||||||
|
|
@ -28,7 +30,7 @@ const { showLoader, hideLoader, dialogRemove, success, messageError } =
|
||||||
/** use*/
|
/** use*/
|
||||||
const dataHistory = ref<KpiRoleData[]>([]);
|
const dataHistory = ref<KpiRoleData[]>([]);
|
||||||
const modalHistory = ref<boolean>(false);
|
const modalHistory = ref<boolean>(false);
|
||||||
const total = ref<number>();
|
const total = ref<number>(0);
|
||||||
|
|
||||||
const positionOp = ref<DataOption[]>([{ id: "", name: "ทั้งหมด" }]);
|
const positionOp = ref<DataOption[]>([{ id: "", name: "ทั้งหมด" }]);
|
||||||
const positionMainOp = ref<DataOption[]>([{ id: "", name: "ทั้งหมด" }]);
|
const positionMainOp = ref<DataOption[]>([{ id: "", name: "ทั้งหมด" }]);
|
||||||
|
|
@ -103,7 +105,6 @@ const roundOp = ref<DataOption[]>([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
async function fetchList() {
|
async function fetchList() {
|
||||||
showLoader();
|
|
||||||
rows.value = [];
|
rows.value = [];
|
||||||
await http
|
await http
|
||||||
.post(config.API.kpiRoleMainList + `/search-edit`, {
|
.post(config.API.kpiRoleMainList + `/search-edit`, {
|
||||||
|
|
@ -124,9 +125,6 @@ async function fetchList() {
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
hideLoader();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,13 +139,18 @@ function onClickView(id: string = "") {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClickDelete(id: number) {
|
function onClickDelete(id: number) {
|
||||||
dialogRemove($q, () => {
|
dialogRemove($q, async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
http
|
await http
|
||||||
.delete(config.API.kpiRoleMainList + `/${id}`)
|
.delete(config.API.kpiRoleMainList + `/${id}`)
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
|
formFilter.page = await updateCurrentPage(
|
||||||
|
formFilter.page,
|
||||||
|
maxPage.value,
|
||||||
|
rows.value.length
|
||||||
|
);
|
||||||
|
await fetchList();
|
||||||
success($q, "ลบข้อมูลสำเร็จ");
|
success($q, "ลบข้อมูลสำเร็จ");
|
||||||
fetchList();
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -158,9 +161,14 @@ function onClickDelete(id: number) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePage(val: number) {
|
async function updatePage(val: number) {
|
||||||
formFilter.page = val;
|
showLoader();
|
||||||
fetchList();
|
try {
|
||||||
|
formFilter.page = val;
|
||||||
|
await fetchList();
|
||||||
|
} finally {
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePageSize(newPagination: NewPagination) {
|
function updatePageSize(newPagination: NewPagination) {
|
||||||
|
|
@ -170,8 +178,13 @@ function updatePageSize(newPagination: NewPagination) {
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => formFilter.pageSize,
|
() => formFilter.pageSize,
|
||||||
() => {
|
async () => {
|
||||||
fetchList();
|
showLoader();
|
||||||
|
try {
|
||||||
|
await fetchList();
|
||||||
|
} finally {
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -181,17 +194,16 @@ watch(
|
||||||
* @param update อัพเดทค่า
|
* @param update อัพเดทค่า
|
||||||
* @param refData ดาต้าที่ต้องการฟิลเตอร์
|
* @param refData ดาต้าที่ต้องการฟิลเตอร์
|
||||||
*/
|
*/
|
||||||
function filterOption(val: any, update: Function) {
|
function filterOption(val: string, update: Function) {
|
||||||
update(() => {
|
update(() => {
|
||||||
positionOp.value = positionMainOp.value.filter(
|
positionOp.value = positionMainOp.value.filter(
|
||||||
(v: any) => v.name.indexOf(val) > -1
|
(v: DataOption) => v.name.indexOf(val) > -1
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ดึงข้อมูลตำแหน่ง */
|
/** ดึงข้อมูลตำแหน่ง */
|
||||||
async function getOptions() {
|
async function getOptions() {
|
||||||
// showLoader();
|
|
||||||
await http
|
await http
|
||||||
.get(config.API.orgSalaryPosition)
|
.get(config.API.orgSalaryPosition)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
|
@ -199,14 +211,14 @@ async function getOptions() {
|
||||||
const uniqueNames = new Set();
|
const uniqueNames = new Set();
|
||||||
|
|
||||||
const filteredData = dataOp
|
const filteredData = dataOp
|
||||||
.filter((item: any) => {
|
.filter((item: DataKPIPosition) => {
|
||||||
if (!uniqueNames.has(item.positionName)) {
|
if (!uniqueNames.has(item.positionName)) {
|
||||||
uniqueNames.add(item.positionName);
|
uniqueNames.add(item.positionName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.map((item: any) => ({
|
.map((item: DataKPIPosition) => ({
|
||||||
id: item.positionName,
|
id: item.positionName,
|
||||||
name: item.positionName,
|
name: item.positionName,
|
||||||
}));
|
}));
|
||||||
|
|
@ -216,9 +228,6 @@ async function getOptions() {
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
// hideLoader();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,13 +236,14 @@ async function getOptions() {
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
function onClickHistory(id: string) {
|
function onClickHistory(id: string) {
|
||||||
|
dataHistory.value = [];
|
||||||
|
modalHistory.value = true;
|
||||||
showLoader();
|
showLoader();
|
||||||
http
|
http
|
||||||
.get(config.API.kpiRoleMainList + `/history/${id}`)
|
.get(config.API.kpiRoleMainList + `/history/${id}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data.result;
|
const data = res.data.result;
|
||||||
dataHistory.value = data;
|
dataHistory.value = data;
|
||||||
modalHistory.value = true;
|
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
messageError($q, e);
|
messageError($q, e);
|
||||||
|
|
@ -244,7 +254,6 @@ function onClickHistory(id: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getTotal() {
|
async function getTotal() {
|
||||||
// showLoader();
|
|
||||||
await http
|
await http
|
||||||
.post(config.API.indicatorSummary)
|
.post(config.API.indicatorSummary)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
|
|
@ -258,17 +267,16 @@ async function getTotal() {
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
messageError($q, e);
|
messageError($q, e);
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
// hideLoader();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
await Promise.all([getTotal(), getOptions(), fetchList()]).finally(() => {
|
try {
|
||||||
|
await Promise.all([getTotal(), getOptions(), fetchList()]);
|
||||||
|
} finally {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue