clear code + comment

This commit is contained in:
STW_TTTY\stwtt 2024-04-30 14:31:55 +07:00
parent a9609d2d7f
commit ac70090e22
19 changed files with 231 additions and 166 deletions

View file

@ -199,6 +199,15 @@ const posTypeOp = ref<DataOption[]>([]);
const posLevelOp = ref<DataOption[]>([]);
const posTypeMain = ref<ResGroup[]>([]);
/** เพิ่ม object ให้ตัวแปร */
const addGroupTargetData = async () => {
formGroupTarget.positions.push({
position: "",
posTypeId: "",
posLevelId: "",
});
};
/** function เรียกข้อมูลประเภทตำแหน่ง*/
function fetchType() {
if (posTypeMain.value.length === 0) {
@ -218,6 +227,7 @@ function fetchType() {
}
}
/** ดึงข้อมูล */
async function fetchData(id: string) {
showLoader();
await http
@ -237,6 +247,7 @@ async function fetchData(id: string) {
});
}
/** เปิด dialog */
function onClickOpenDialog(type: string, target: string) {
isTarget.value = target;
if (type === "group") {
@ -257,6 +268,7 @@ function onClickOpenDialog(type: string, target: string) {
}
}
/** เพิ่ม/แก้ไขกลุ่มเป้าหมาย */
async function onSubmitGroup() {
if (isTarget.value === "planned") {
await http
@ -325,6 +337,7 @@ async function onSubmitGroup() {
}, 100);
}
/** เพิ่มผู้เกี่ยวข้อง */
async function onSubmitRelate() {
if (isTarget.value === "planned") {
await http
@ -375,28 +388,7 @@ async function onSubmitRelate() {
}, 100);
}
function onclickDelete(index: number, type: string) {
dialogRemove($q, () => {
switch (type) {
case "plannedGoals":
plannedGoals.value.splice(index, 1);
break;
case "plannedPeoples":
plannedPeoples.value.splice(index, 1);
break;
case "actualGoals":
actualGoals.value.splice(index, 1);
break;
case "actualPeoples":
actualPeoples.value.splice(index, 1);
break;
default:
break;
}
});
}
/** clear form */
function cleanFormData() {
formGroupTarget.groupTarget = "";
formGroupTarget.groupTargetSub = "";
@ -410,6 +402,7 @@ function cleanFormData() {
isEdit.value = false;
}
/** ปิด dialog */
function onClickCloseDialog() {
newModalGroupTarget.value = false;
modalGroupTarget.value = false;
@ -418,6 +411,10 @@ function onClickCloseDialog() {
cleanFormData();
}
/**
* map อมลตาม option id
* @param id id
*/
function updatePosTypeName(id: string) {
const posLevel = posTypeMain.value.find((e: ResGroup) => e.id === id);
posLevelOp.value =
@ -428,6 +425,10 @@ function updatePosTypeName(id: string) {
formGroupTarget.posLevel = "";
}
/**
* กลมเปาหมาย
* @param val อม กลมเปาหมาย
*/
function updateGroupTarget(val: string) {
if (val === "OUTSIDERS") {
formGroupTarget.groupTargetSub = "NONE";
@ -437,33 +438,30 @@ function updateGroupTarget(val: string) {
} else formGroupTarget.groupTargetSub = "";
}
/** หาชื่อ ตาม id */
function convertNameGoals(id: string) {
const data = groupOp.value.find((e: DataOption) => e.id === id);
return data && data?.name;
}
/** หาชื่อ ตาม id */
function convertNameSubGoals(id: string) {
const data = groupSubOp.value.find((e: DataOption) => e.id === id);
return data && data?.name;
}
/** หาชื่อ ตาม id */
function convertNamePeoples(id: string) {
const data = peoplesOp.value.find((e: DataOption) => e.id === id);
return data && data?.name;
}
const addGroupTargetData = async () => {
formGroupTarget.positions.push({
position: "",
posTypeId: "",
posLevelId: "",
});
};
/** ลบข้อมูลออกตัวตัวแปร จาก ลำดับ */
function deleteTargetData(index: any) {
formGroupTarget.positions.splice(index, 1);
}
/** ดึงข้อมูลเมื่อคอมโพเนนต์โหลดเสร็จสมบูรณ์ */
onMounted(() => {
fetchType();
fetchData(projectId.value);
@ -474,7 +472,14 @@ onMounted(() => {
<q-card bordered style="border: 1px solid #d6dee1">
<div class="text-weight-medium bg-grey-1 q-py-sm q-px-md">
เปาหมายตามแผน
<q-btn v-if="store.projectStatus !== 'FINISH'" flat round dense icon="add" color="primary">
<q-btn
v-if="store.projectStatus !== 'FINISH'"
flat
round
dense
icon="add"
color="primary"
>
<q-menu>
<q-list style="min-width: 100px">
<q-item
@ -633,7 +638,12 @@ onMounted(() => {
</q-card>
<!--CARD เปาหมายตามจร -->
<q-card v-if="store.projectStatus === 'FINISH'" bordered style="border: 1px solid #d6dee1" class="q-mt-md">
<q-card
v-if="store.projectStatus === 'FINISH'"
bordered
style="border: 1px solid #d6dee1"
class="q-mt-md"
>
<div class="text-weight-medium bg-grey-1 q-py-sm q-px-md">
เปาหมายตามจร
<q-btn flat round dense icon="add" color="primary">