แก้อัตรากำลัง

This commit is contained in:
Warunee Tamkoo 2024-02-09 14:33:39 +07:00
parent 36c9512733
commit 4c43a053eb
2 changed files with 76 additions and 90 deletions

View file

@ -41,7 +41,7 @@ const isReadonly = ref<boolean>(false); // อ่านได้อย่าง
const isDisValidate = ref<boolean>(false);
const isPosition = ref<boolean>(false);
const succession = ref<boolean>(false);
const dataCopy = ref<any>()
const dataCopy = ref<any>();
const $q = useQuasar();
const mixin = useCounterMixin();
const {
@ -51,7 +51,7 @@ const {
messageError,
success,
dialogRemove,
dialogMessageNotify
dialogMessageNotify,
} = mixin;
const selected = ref<any>([]);
const search = ref<string>("");
@ -315,31 +315,31 @@ function validateForm() {
}
}
if (hasError.every((result) => result === true)) {
if(rows.value.length == 0 ){
dialogMessageNotify($q,'กรุณาเลือกตำแหน่งอย่างน้อย 1 ตำแหน่ง')
}else{
if (rows.value.length == 0) {
dialogMessageNotify($q, "กรุณาเลือกตำแหน่งอย่างน้อย 1 ตำแหน่ง");
} else {
onSubmit();
}
}
}
}
/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */
function validateFormPositionEdit() {
isDisValidate.value = false;
const hasError = [];
for (const key in objectPositionSelectRef) {
if (Object.prototype.hasOwnProperty.call(objectPositionSelectRef, key)) {
const property = objectPositionSelectRef[key];
if (property.value && typeof property.value.validate === "function") {
const isValid = property.value.validate();
hasError.push(isValid);
}
}
}
if (hasError.every((result) => result === true)) {
onSubmitSelectEdit();
}
}
// function validateFormPositionEdit() {
// isDisValidate.value = false;
// const hasError = [];
// for (const key in objectPositionSelectRef) {
// if (Object.prototype.hasOwnProperty.call(objectPositionSelectRef, key)) {
// const property = objectPositionSelectRef[key];
// if (property.value && typeof property.value.validate === "function") {
// const isValid = property.value.validate();
// hasError.push(isValid);
// }
// }
// }
// if (hasError.every((result) => result === true)) {
// onSubmitSelectEdit();
// }
// }
/** ฟังชั่น บันทึก */
function onSubmit() {
@ -363,6 +363,7 @@ function onSubmit() {
orgChild3Id: props.orgLevel === 3 ? props.treeId : null,
orgChild4Id: props.orgLevel === 4 ? props.treeId : null,
positions: positionsData,
succession: succession.value,
};
showLoader();
props.actionType === "ADD"
@ -404,46 +405,46 @@ function onSubmit() {
});
}
/** ฟังชั่น บันทึก */
function onSubmitSelectEdit() {
dialogConfirm(
$q,
async () => {
showLoader();
const body = {
posDictName: formPositionSelect.positionName,
posDictField: formPositionSelect.positionField, //
posTypeId: formPositionSelect.positionType, //*
posLevelId: formPositionSelect.positionLevel, //*
posExecutiveId:
formPositionSelect.positionExecutive !== ""
? formPositionSelect.positionExecutive
: null, //
posDictExecutiveField: formPositionSelect.positionExecutiveField, //
posDictArea: formPositionSelect.positionArea, ///
};
await http
.post(config.API.orgPosPosition, body)
.then(() => {
success($q, "เพิ่มข้อมูลสำเร็จ");
// function onSubmitSelectEdit() {
// dialogConfirm(
// $q,
// async () => {
// showLoader();
// const body = {
// posDictName: formPositionSelect.positionName,
// posDictField: formPositionSelect.positionField, //
// posTypeId: formPositionSelect.positionType, //*
// posLevelId: formPositionSelect.positionLevel, //*
// posExecutiveId:
// formPositionSelect.positionExecutive !== ""
// ? formPositionSelect.positionExecutive
// : null, //
// posDictExecutiveField: formPositionSelect.positionExecutiveField, //
// posDictArea: formPositionSelect.positionArea, ///
// };
// await http
// .post(config.API.orgPosPosition, body)
// .then(() => {
// success($q, "");
clearFormPositionSelect();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการเพิ่มตำแหน่ง",
"ต้องการยืนยันการเพิ่มตำแหน่งนี้ใช่หรือไม่?"
);
}
// clearFormPositionSelect();
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// hideLoader();
// });
// },
// "",
// "?"
// );
// }
/** input ค้นหา */
const searchRef = ref<any>(null);
async function searchInput() {
console.log(1)
console.log(1);
searchRef.value.validate();
if (!searchRef.value.hasError) {
showLoader();
@ -464,24 +465,23 @@ async function searchInput() {
}
}
function updateSelectType(val: string) {
const listLevel = dataLevel.value.find((e: any) => e.id === val);
levelOpsMain.value = listLevel.posLevels.map((e: OptionLevel) => ({
id: e.id,
name: e.posLevelName,
}));
levelOps.value = levelOpsMain.value;
formPositionSelect.positionLevel = "";
}
// function updateSelectType(val: string) {
// const listLevel = dataLevel.value.find((e: any) => e.id === val);
// levelOpsMain.value = listLevel.posLevels.map((e: OptionLevel) => ({
// id: e.id,
// name: e.posLevelName,
// }));
// levelOps.value = levelOpsMain.value;
// formPositionSelect.positionLevel = "";
// }
/**
* ดลอกขอม
* @param data อมลตำแหน
*/
function copyDetiail(data: RowDetailPositions) {
modalAdd.value = true
dataCopy.value = data
modalAdd.value = true;
dataCopy.value = data;
}
/**
@ -573,8 +573,8 @@ function close() {
async function emitSearch(keyword: string, typeSelect: string) {
search.value = await keyword;
type.value = await typeSelect;
await searchInput();
await searchInput();
}
</script>
@ -708,11 +708,7 @@ async function emitSearch(keyword: string, typeSelect: string) {
<q-card-actions class="bg-white q-pa-xs">
<q-btn
:icon="
!isPosition
? 'mdi-menu-right'
: 'mdi-menu-down'
"
:icon="!isPosition ? 'mdi-menu-right' : 'mdi-menu-down'"
flat
color="teal"
class="q-ml-sm"
@ -895,9 +891,9 @@ async function emitSearch(keyword: string, typeSelect: string) {
</form>
</q-card>
</q-dialog>
<DialogAddPosition
v-model:modalAdd="modalAdd"
:emitSearch="emitSearch"
:data="dataCopy"
<DialogAddPosition
v-model:modalAdd="modalAdd"
:emitSearch="emitSearch"
:data="dataCopy"
/>
</template>

View file

@ -555,11 +555,6 @@ watch([() => page.value, () => pageSize.value], () => {
option-value="id"
lazy-rules
hide-bottom-space
:rules="
!isDisValidate
? [(val) => !!val || `${'กรุณาเลือกประเภทตำแหน่ง'}`]
: []
"
><template v-if="formData.positionType" v-slot:append>
<q-icon
name="cancel"
@ -584,11 +579,6 @@ watch([() => page.value, () => pageSize.value], () => {
option-value="id"
lazy-rules
hide-bottom-space
:rules="
!isDisValidate
? [(val) => !!val || `${'กรุณาเลือกระดับตำแหน่ง'}`]
: []
"
>
<template v-if="formData.positionLevel" v-slot:append>
<q-icon