Merge branch 'oat_dev' into develop

This commit is contained in:
oat_dev 2024-03-15 10:28:27 +07:00
commit ce75d1da6c
2 changed files with 108 additions and 69 deletions

View file

@ -85,16 +85,10 @@ const filterKeyword = ref<string>("");
const dialog = ref<boolean>(false);
const posTypeName = ref<string>("");
const posTypeNameRef = ref<QInput | null>(null);
const posTypeRank = ref<number | undefined>();
const posTypeRank = ref<number | null>(null);
const posTypeRankRef = ref<QInput | null>(null);
const dialogStatus = ref<string>("");
const visibleColumns = ref<string[]>([
"posTypeName",
"posTypeRank",
// "createdAt",
// "lastUpdatedAt",
// "lastUpdateFullName",
]);
const visibleColumns = ref<string[]>(["posTypeName", "posTypeRank"]);
async function fetchData() {
showLoader();
@ -112,24 +106,53 @@ async function fetchData() {
}
async function addData() {
await http.post(config.API.orgPosType, {
posTypeName: posTypeName.value,
posTypeRank: posTypeRank.value,
});
fetchData();
await http
.post(config.API.orgPosType, {
posTypeName: posTypeName.value,
posTypeRank: posTypeRank.value,
})
.then(() => {
fetchData();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function editData(id: string) {
await http.put(config.API.orgPosTypeId(id), {
posTypeName: posTypeName.value,
posTypeRank: posTypeRank.value,
});
fetchData();
await http
.put(config.API.orgPosTypeId(id), {
posTypeName: posTypeName.value,
posTypeRank: posTypeRank.value,
})
.then(() => {
fetchData();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
async function deleteData(id: string) {
await http.delete(config.API.orgPosTypeId(id));
fetchData();
await http
.delete(config.API.orgPosTypeId(id))
.then(() => {
fetchData();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
onMounted(async () => {
@ -151,14 +174,15 @@ function validateForm() {
}
async function onSubmit() {
if (posTypeName.value.length > 0) {
console.log(posTypeRank.value);
if (posTypeName.value.length > 0 && posTypeRank.value !== null) {
dialogConfirm(
$q,
async () => {
dialogStatus.value === "create" ? addData() : editData(editId.value);
closeDialog();
posTypeName.value = "";
posTypeRank.value = undefined;
posTypeRank.value = null;
},
"ยืนยันการบันทึกข้อมูล",
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
@ -276,7 +300,7 @@ async function onSubmit() {
</d-table>
<q-dialog v-model="dialog" class="dialog" persistent>
<q-card style="min-width: 350px" class="bg-grey-11">
<q-card style="min-width: 350px">
<form @submit.prevent="validateForm">
<q-card-section class="flex justify-between" style="padding: 0">
<dialog-header
@ -287,32 +311,34 @@ async function onSubmit() {
<q-separator color="grey-4" />
<q-card-section class="q-pa-none">
<q-input
ref="posTypeNameRef"
outlined
v-model="posTypeName"
label="ประเภทตำแหน่ง"
dense
lazy-rules
borderless
class="col-12 bg-white q-ma-md"
:rules="[(val) => val.length > 0 || 'กรุณากรอกประเภทตำแหน่ง']"
hide-bottom-space
/>
<q-input
ref="posTypeRankRef"
outlined
v-model="posTypeRank"
label="ระดับ"
dense
type="number"
lazy-rules
borderless
min="1"
class="col-12 bg-white q-ma-md"
:rules="[(val) => val != undefined || 'กรุณากรอกระดับ']"
hide-bottom-space
/>
<div class="col-12 q-ma-md">
<q-input
ref="posTypeNameRef"
outlined
v-model="posTypeName"
label="ประเภทตำแหน่ง"
dense
lazy-rules
borderless
:rules="[(val) => val.length > 0 || 'กรุณากรอกประเภทตำแหน่ง']"
hide-bottom-space
/>
</div>
<div class="col-12 q-ma-md">
<q-input
ref="posTypeRankRef"
outlined
v-model="posTypeRank"
label="ระดับ"
dense
lazy-rules
borderless
min="1"
:rules="[(val) => val != undefined || 'กรุณากรอกระดับ']"
hide-bottom-space
mask="############"
/>
</div>
</q-card-section>
<q-card-actions align="right">

View file

@ -13,16 +13,23 @@ import config from "@/app.config";
const store = usePositionDataStore();
const storeOption = useMainOptionDataStore();
const storeName = usePositionTypeDataStore();
const router = useRouter();
const mixin = useCounterMixin();
const posName = defineModel<string>("posName", {
required: true,
});
const { dialogRemove, dialogConfirm, showLoader, hideLoader, messageError } =
mixin;
const {
dialogRemove,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
} = mixin;
const $q = useQuasar();
const columns = [
{
name: "no",
@ -123,20 +130,15 @@ const editId = ref<string>("");
const posLevelName = ref<string>("");
const posLevelRank = ref<number>();
const posLevelAuthority = ref<string>("");
const posTypeId = ref<null>();
const posLevelNameRef = ref<QInput | null>(null);
const posLevelRankRef = ref<QInput | null>(null);
const posTypeIdRef = ref<QInput | null>(null);
const name = ref<string>("");
const visibleColumns = ref<string[]>([
"no",
"posTypeName",
"posLevelName",
"posLevelRank",
"posLevelAuthority",
// "createdAt",
// "lastUpdatedAt",
// "lastUpdateFullName",
]);
async function fetchData() {
@ -165,9 +167,13 @@ async function addData() {
})
.then(() => {
fetchData();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
@ -182,9 +188,13 @@ async function editData(editId: string) {
})
.then(() => {
fetchData();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
@ -196,19 +206,12 @@ async function deleteData(id: string) {
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
onMounted(async () => {
fetchName();
storeName.row.forEach((e) => {
if (e.id === id.value) {
posName.value = e.posTypeName ? e.posTypeName : "";
}
});
fetchData();
});
function closeDialog() {
dialog.value = false;
}
@ -240,6 +243,11 @@ async function fetchName() {
.get(config.API.orgPosType)
.then(async (res) => {
storeName.save(res.data.result);
storeName.row.forEach((e) => {
if (e.id === id.value) {
posName.value = e.posTypeName ? e.posTypeName : "";
}
});
})
.catch((err) => {
messageError($q, err);
@ -248,6 +256,11 @@ async function fetchName() {
hideLoader();
});
}
onMounted(async () => {
fetchName();
fetchData();
});
</script>
<template>
@ -398,13 +411,13 @@ async function fetchName() {
v-model="posLevelRank"
label="ระดับ"
dense
type="number"
lazy-rules
borderless
min="1"
bg-color="white"
:rules="[(val) => val != undefined || 'กรุณากรอกระดับ']"
:rules="[(val) => val != null || 'กรุณากรอกระดับ']"
hide-bottom-space
mask="############"
/>
</div>