diff --git a/src/api/14_KPI/api.KPI.ts b/src/api/14_KPI/api.KPI.ts index 7132bd98b..c79f6b90b 100644 --- a/src/api/14_KPI/api.KPI.ts +++ b/src/api/14_KPI/api.KPI.ts @@ -6,6 +6,7 @@ const kpiUserEvaluation = `${env.API_URI}/kpi/user/evaluation`; const kpiAchievement = `${env.API_URI}/kpi/user/achievement`; const kpiGroup = `${env.API_URI}/kpi/group`; const kpiPlan = `${env.API_URI}/kpi/plan`; +const kpiSpecial = `${env.API_URI}/kpi/special`; const kpiCapacity = `${env.API_URI}/kpi/capacity`; const kpiLink = `${env.API_URI}/kpi/link`; const KpiUser = `${env.API_URI}/kpi/user`; @@ -25,6 +26,7 @@ export default { kpiGroupById: (id: string) => `${kpiGroup}/${id}`, kpiPlan, kpiPlanById: (id: string) => `${kpiPlan}/${id}`, + kpiSpecial, /** สมรรถนะ */ kpiCapacity, diff --git a/src/modules/01_metadataNew/components/Indicators/Assignment/DetailView.vue b/src/modules/01_metadataNew/components/Indicators/Assignment/DetailView.vue index bd5d8ff1a..62a63bca6 100644 --- a/src/modules/01_metadataNew/components/Indicators/Assignment/DetailView.vue +++ b/src/modules/01_metadataNew/components/Indicators/Assignment/DetailView.vue @@ -13,29 +13,14 @@ import type { DataOption } from "@/modules/01_metadataNew/interface/index/Main"; const $q = useQuasar(); const route = useRoute(); const router = useRouter(); +const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin(); const heightSize = ref("224"); -const filter = ref(""); -const node = ref([]); -const expanded = ref([]); -const orgName = ref(""); -const nodeId = ref(""); - const id = ref(route.params.id ? route.params.id.toLocaleString() : ""); -const { - showLoader, - hideLoader, - messageError, - success, - dialogConfirm, - dialogMessageNotify, -} = useCounterMixin(); -const title = ref(route.params.id ? "แก้ไข" : "เพิ่ม"); -const modalDialogSelect = ref(false); const form = reactive({ position: "", //ตำแหน่งในสายงาน - year: new Date().getFullYear(), //ปีงบประมาณ + year: null, //ปีงบประมาณ round: "", //รอบการประเมิน org: "", //หน่วยงาน/ส่วนราชการ including: "", //รหัสตัวชี้วัด @@ -50,6 +35,7 @@ const form = reactive({ node: null, nodeId: null, orgRevisionId: null, + date: [null, null], }); const fieldLabels = { @@ -68,170 +54,36 @@ const formScore = reactive({ score1: "", }); -const positionOp = ref([]); -const positionMainOp = ref([]); - /** Option รอบการประเมิน*/ const roundOp = ref([ { 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() { +function fetchspecialByid(id: string) { showLoader(); http - .get(config.API.kpiRoleMainList + `/${id.value}`) + .get(config.API.kpiSpecial + `/${id}`) .then((res) => { const data = res.data.result; - form.position = data.position; - form.year = data.year == null ? 0 : data.year; - form.round = data.round; + form.year = data.year; + form.round = data.period; 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; + form.formula = data.formula; + form.meaning = data.meaning; + form.documentInfoEvidence = data.documentInfoEvidence; + if (data.startDate && data.endDate) { + form.date = [data.startDate, data.endDate]; + } }) .catch((err) => { messageError($q, err); @@ -241,28 +93,12 @@ async function fetchTree(id: string) { }); } -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 onResize(size: any) { heightSize.value = `${size.height - 99}`; } -function setModel(val: string) { - form.position = val; -} - onMounted(() => { - fetchActive(); -// getOptions(); -// if (id.value !== "") { -// getDetail(); -// } + fetchspecialByid(id.value); }); - + diff --git a/src/modules/01_metadataNew/interface/request/Main.ts b/src/modules/01_metadataNew/interface/request/Main.ts index a2448b81a..5cb7bdbfd 100644 --- a/src/modules/01_metadataNew/interface/request/Main.ts +++ b/src/modules/01_metadataNew/interface/request/Main.ts @@ -35,6 +35,7 @@ interface FormDataRole { node: number | null; nodeId: string | null; orgRevisionId: string | null; + date: any | null; } interface FormCompetency { diff --git a/src/modules/01_metadataNew/views/Assignment.vue b/src/modules/01_metadataNew/views/Assignment.vue index d38186ddb..4912a42ed 100644 --- a/src/modules/01_metadataNew/views/Assignment.vue +++ b/src/modules/01_metadataNew/views/Assignment.vue @@ -1,7 +1,14 @@ @@ -72,15 +128,92 @@ onMounted(() => {
+
+ + + + + + + + +
- + @@ -115,6 +248,7 @@ onMounted(() => { class="custom-header-table" :rows-per-page-options="[10, 25, 50, 100]" :visible-columns="visibleColumns" + @update:pagination="updatePageSize" > +
diff --git a/src/modules/01_metadataNew/views/indicatorByPlan.vue b/src/modules/01_metadataNew/views/indicatorByPlan.vue index a2d64691e..fcda07998 100644 --- a/src/modules/01_metadataNew/views/indicatorByPlan.vue +++ b/src/modules/01_metadataNew/views/indicatorByPlan.vue @@ -204,13 +204,7 @@ onMounted(async () => {
หน่วยงาน/ส่วนราชการ
- + { + showLoader(); http .delete(config.API.kpiRoleMainList + `/${id}`) - .then((res) => { + .then(() => { success($q, "ลบข้อมูลสำเร็จ"); fetchList(); }) - .finally(() => {}); + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); }); } @@ -301,7 +307,6 @@ onMounted(async () => { hide-bottom-space option-label="name" option-value="id" - class="inputgreen" :options="positionOp" use-input @input-value="setModel" @@ -325,19 +330,8 @@ onMounted(async () => { - {