จัดโค้ด

This commit is contained in:
setthawutttty 2023-11-16 10:09:09 +07:00
parent 8403cd82bc
commit c0eeb559d6
2 changed files with 78 additions and 49 deletions

View file

@ -317,7 +317,7 @@ async function saveformdata(data: any){
* แกไขขอม
* @param data อมลทปเดต
*/
async function editData = async (data: any){
async function editData(data: any){
await http
.put(config.API.editFormEvaluate(assignId.value, evaluate_id.value), data)
.then((res: any) => {

View file

@ -25,6 +25,7 @@ const {
dialogConfirm,
dialogMessageNotify,
} = mixin;
const { ratingColors } = probationStore;
const assignId = ref<string>(route.params.form.toString());
const personalId = ref<string>(route.params.id.toString());
@ -40,46 +41,6 @@ const checkArray = ref<number>(0);
const alerts = Array(20)
.fill(null)
.map(() => ref<boolean>(false));
onMounted(async () => {
await fecthFormdata(assignId.value);
});
const fecthFormdata = async (id: string) => {
await http
.get(config.API.formevaluateRecord(id))
.then((res: any) => {
evaluate_no.value = res.data.data.evaluate_no;
start_date.value = res.data.data.start_date;
date_finish.value = res.data.data.end_date;
round.value = res.data.data.evaluate_no;
person.value = res.data.data.person;
assign.value = res.data.data.assign;
option.value.push(res.data.data.director);
Autherise.value =
res.data.data.director.name +
` (${res.data.data.director.PositionLineName}, ${res.data.data.director.PositionLevelName}, ${res.data.data.director.Oc})`;
list1_1.value = res.data.data.assign_output;
res.data.data.assign_output.forEach((e: any) => {
list1_2.push({ id: "", label: "" });
});
evaluate_expenct_level.value = res.data.data.assign_output.map(
(e: any) => ({
id: e.id,
labal: e.output_desc,
})
);
evaluate_ouptut.value = res.data.data.assign_output.map((e: any) => ({
id: e.id,
text: "",
}));
checkArray.value = list1_1.value.length;
})
.catch((e: any) => {});
};
const list1_1 = ref<any>([]);
const list1_2 = [{ id: "", label: "" }];
@ -161,7 +122,48 @@ const variablesToWatch = [
success_level,
];
const ArrayCountbotton = [orientation, self_learning, training_seminar];
const savaForm = () => {
/**
* get อม ลง วแปร
* @param id personal id
*/
async function fecthFormdata(id: string) {
await http
.get(config.API.formevaluateRecord(id))
.then((res: any) => {
evaluate_no.value = res.data.data.evaluate_no;
start_date.value = res.data.data.start_date;
date_finish.value = res.data.data.end_date;
round.value = res.data.data.evaluate_no;
person.value = res.data.data.person;
assign.value = res.data.data.assign;
option.value.push(res.data.data.director);
Autherise.value =
res.data.data.director.name +
` (${res.data.data.director.PositionLineName}, ${res.data.data.director.PositionLevelName}, ${res.data.data.director.Oc})`;
list1_1.value = res.data.data.assign_output;
res.data.data.assign_output.forEach((e: any) => {
list1_2.push({ id: "", label: "" });
});
evaluate_expenct_level.value = res.data.data.assign_output.map(
(e: any) => ({
id: e.id,
labal: e.output_desc,
})
);
evaluate_ouptut.value = res.data.data.assign_output.map((e: any) => ({
id: e.id,
text: "",
}));
checkArray.value = list1_1.value.length;
})
.catch((e: any) => {});
}
/** เช็คค่าว่าง ก่อน save */
function savaForm() {
achievement_strengthRef.value.validate();
behavio_strengthRef.value.validate();
@ -235,9 +237,10 @@ const savaForm = () => {
} else {
putformData();
}
};
}
const putformData = () => {
/** อัปเดต ข้อมูล */
function putformData() {
const data = {
evaluate_no: evaluate_no.value,
start_date: start_date.value,
@ -275,9 +278,13 @@ const putformData = () => {
assessor_dated: dateToISO(dateAutherise.value),
};
dialogConfirm($q, async () => await saveformdata(data));
};
}
const saveformdata = async (data: any) => {
/**
* save อม
* @param data อมลทไดจาก งช putformData
*/
async function saveformdata(data: any) {
await http
.post(config.API.createformevaluate(assignId.value), data)
.then(() => {
@ -287,7 +294,7 @@ const saveformdata = async (data: any) => {
.catch((e: any) => {
messageError($q, e);
});
};
}
variablesToWatch.forEach((variable, index) => {
watch(variable, (item: any) => {
@ -296,6 +303,7 @@ variablesToWatch.forEach((variable, index) => {
}
});
});
ArrayCountbotton.forEach((variable, index) => {
watch(variable, (item: any) => {
if (item !== null) {
@ -303,36 +311,47 @@ ArrayCountbotton.forEach((variable, index) => {
}
});
});
watch(lengthevaluate_expenct_level, (newLength) => {
if (newLength === evaluate_expenct_level.value.length) {
alerts[0].value = false;
}
});
watch(lengthevaluate_ouptut, (newLength) => {
if (newLength === evaluate_ouptut.value.length) {
alerts[1].value = false;
}
});
watch(lengthconduct, (newLength) => {
if (newLength === 4) {
alerts[8].value = false;
}
});
watch(lengthmoral_level, (newLength) => {
if (newLength === 3) {
alerts[9].value = false;
}
});
watch(lengthdiscipline_level, (newLength) => {
if (newLength === 5) {
alerts[10].value = false;
}
});
const getBordered = (i: boolean) => {
/** return class เมื่อ true */
function getBordered(i: boolean) {
return {
border_custom: i,
};
};
}
onMounted(async () => {
await fecthFormdata(assignId.value);
});
</script>
<template>
@ -545,6 +564,7 @@ const getBordered = (i: boolean) => {
</q-list>
</q-card>
</div>
<div class="col-12 row">
<div class="col-xs-12 col-sm-11 col-md-10 offset-md-1 text-top2">
ผลผลตของงานทเกดขนจร
@ -1048,6 +1068,7 @@ const getBordered = (i: boolean) => {
</q-list>
</q-card>
</div>
<div class="col-12 row">
<div class="col-12 text-top0 row items-center q-pl-lg">
<q-icon name="mdi-label" color="grey-4" class="q-pr-sm" />
@ -1102,6 +1123,7 @@ const getBordered = (i: boolean) => {
</q-list>
</q-card>
</div>
<div class="col-12 row">
<div class="col-12 text-top0 row items-center q-pl-lg">
<q-icon name="mdi-label" color="grey-4" class="q-pr-sm" />
@ -1156,6 +1178,7 @@ const getBordered = (i: boolean) => {
</q-list>
</q-card>
</div>
<div class="col-12 row">
<div class="col-12 text-top0 row items-center q-pl-lg">
<q-icon name="mdi-label" color="grey-4" class="q-pr-sm" />
@ -1230,6 +1253,7 @@ const getBordered = (i: boolean) => {
</q-card>
</div>
<!-- <FormComment /> -->
<div class="row col-12 q-gutter-lg no-margin">
<div class="col-12 row">
<div class="col-12 text-top0 row items-center q-pl-lg">
@ -1312,6 +1336,7 @@ const getBordered = (i: boolean) => {
</q-item-section>
</q-item>
<q-separator class="q-my-xs" />
<q-item
dense
tag="label"
@ -1340,7 +1365,9 @@ const getBordered = (i: boolean) => {
</div>
</q-item-section>
</q-item>
<q-separator class="q-my-xs" />
<q-item
dense
tag="label"
@ -1369,7 +1396,9 @@ const getBordered = (i: boolean) => {
</div>
</q-item-section>
</q-item>
<q-separator class="q-my-xs" />
<q-item dense tag="label" v-ripple>
<q-item-section>
<q-item-label