โครงสร้างอัตรากำลัง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-01-29 13:14:13 +07:00
parent 0ca406eb04
commit b92c9283a5
6 changed files with 60 additions and 13 deletions

View file

@ -6,6 +6,7 @@ export default {
/** โครงสร้างอัตรากำลัง*/
activeOrganization: `${organization}/active`,
createOrganization: `${organization}/draft`,
createOrgLevel: (type: string) => `${organization}/${type}`,
organizationHistoryNew:`${organization}/history`,
organizationHistoryNew: `${organization}/history`,
};

View file

@ -1,14 +1,20 @@
<script setup lang="ts">
import { ref, reactive, watch } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import DialogHeader from "@/components/DialogHeader.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import type {
FormDataAgency,
FormAgencyRef,
DataOption,
} from "@/modules/02_organizationalNew/interface/index/Main";
import DialogHeader from "@/components/DialogHeader.vue";
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
import { useCounterMixin } from "@/stores/mixin";
const level = defineModel<string>("orgLevel", { required: true });
const props = defineProps({
modal: Boolean,
@ -16,8 +22,9 @@ const props = defineProps({
});
const $q = useQuasar();
const store = useOrganizational();
const mixin = useCounterMixin();
const { dialogConfirm } = mixin;
const { dialogConfirm, showLoader, hideLoader } = mixin;
const orgLevelOptionMain = ref<DataOption[]>([
{ name: "ระดับสำนัก", id: "DEPARTMENT" },
@ -46,7 +53,6 @@ const formData = reactive<FormDataAgency>({
orgPhoneEx: "",
orgPhoneIn: "",
orgFax: "",
orgRevisionId: "",
orgLevel: "",
});
@ -81,8 +87,40 @@ function validateForm() {
/** ฟังชั่น บันทึก */
function onSubmit() {
dialogConfirm($q, () => {
console.log(formData);
dialogConfirm($q, async () => {
showLoader();
const type =
level.value === "DEPARTMENT"
? "Root"
: level.value === "OFFICE"
? "Child1"
: level.value === "DIVISION"
? "Child2"
: level.value === "SECTION"
? "Child3"
: "child4";
const body = {
["org" + type + "Name"]: formData.orgName,
["org" + type + "ShortName"]: formData.orgShortName,
["org" + type + "Code"]: formData.orgCode,
["org" + type + "PhoneEx"]: formData.orgPhoneEx,
["org" + type + "PhoneIn"]: formData.orgPhoneIn,
["org" + type + "Fax"]: formData.orgFax,
["org" + type + "Rank"] : formData.orgLevel,
orgRevisionId: store.draftId,
};
console.log(body);
await http
.post(config.API.createOrgLevel(type.toLocaleLowerCase()), body)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
})
.finally(() => {
hideLoader();
});
});
}
@ -94,7 +132,7 @@ watch(
formData.orgLevel = level.value;
orgLevelOption.value = orgLevelOptionMain.value;
} else {
orgLevelOption.value = orgLevelOptionMain.value.splice(1, 4);
orgLevelOption.value = orgLevelOptionMain.value.slice(1, 4);
formData.orgLevel = "";
}
}
@ -108,7 +146,6 @@ watch(
<form @submit.prevent="validateForm">
<DialogHeader :tittle="`เพิ่มหน่วยงาน`" :close="props.close" />
<q-separator />
<q-card-section>
<div class="row q-col-gutter-sm">
<div class="col-4">

View file

@ -25,6 +25,13 @@ const modal = defineModel<boolean>("newStructure", { required: true });
const status = defineModel<boolean>("status", { required: true });
const type = defineModel<string>("type", { default: "NEW" });
const props = defineProps({
fetchActive: {
type: Function,
require: true,
},
});
const typeOp = ref<DataOption[]>([
{
id: "NEW",
@ -43,7 +50,6 @@ const typeOp = ref<DataOption[]>([
name: "ทำสำเนาโครงสร้าง ตำแหน่ง และคนครอง",
},
]);
const orgRevisionId = ref<string>("");
const orgRevisionOpMain = ref<DataOption[]>([]);
const orgRevisionOp = ref<DataOption[]>([]);
@ -89,9 +95,10 @@ function onSubmit() {
http
.post(config.API.createOrganization, formData)
.then(() => {
status.value = true;
store.typeOrganizational = "draft";
// status.value = true;
// store.typeOrganizational = "draft";
success($q, "บันทึกข้อมูลสำเร็จ");
props.fetchActive?.();
})
.catch((err) => {
messageError($q, err);

View file

@ -14,7 +14,6 @@ interface FormDataAgency {
orgPhoneEx: string;
orgPhoneIn: string;
orgFax: string;
orgRevisionId: string;
orgLevel: string;
}

View file

@ -23,5 +23,7 @@ export const useOrganizational = defineStore("organizationalStore", () => {
//
fetchDataActive,
draftId,
activeId,
};
});

View file

@ -228,6 +228,7 @@ onMounted(async () => {
v-model:new-structure="modalNewStructure"
v-model:status="isStatusData"
v-model:type="typeStructure"
:fetchActive="fetchOrganizationActive"
/>
<!-- งเวลาเผยแพร -->