แก้ไขโครงสร้าง

This commit is contained in:
Warunee Tamkoo 2024-02-02 14:50:19 +07:00
parent 5465b33de1
commit a0959017c8
6 changed files with 106 additions and 35 deletions

View file

@ -90,26 +90,33 @@ function validateForm() {
/** ฟังชั่น บันทึก */ /** ฟังชั่น บันทึก */
function onSubmit() { function onSubmit() {
dialogConfirm($q, () => { dialogConfirm(
showLoader(); $q,
http () => {
.post(config.API.createOrganization, formData) showLoader();
.then((res) => { http
status.value = true; .post(config.API.createOrganization, formData)
store.typeOrganizational = "draft"; .then((res) => {
store.draftId = res.data.result.id; status.value = true;
success($q, "บันทึกข้อมูลสำเร็จ"); store.typeOrganizational = "draft";
// props.fetchActive?.(); store.draftId = res.data.result.id;
}) success($q, "บันทึกข้อมูลสำเร็จ");
.catch((err) => { // props.fetchActive?.();
messageError($q, err); })
}) .catch((err) => {
.finally(async () => { messageError($q, err);
modal.value = await false; })
await close(); .finally(async () => {
await hideLoader(); modal.value = await false;
}); await close();
}); await hideLoader();
});
},
"ยืนยันการเพิ่มโครงสร้าง",
store.draftId
? "คุณมีแบบร่างอยู่หากคุณกดยืนยันระบบจะทำการลบแบบร่างเดิมและสร้างแบบร่างใหม่ ต้องการยืนยันการเพิ่มโครงสร้างนี้ใช่หรือไม่?"
: "ต้องการยืนยันการเพิ่มโครงสร้างนี้ใช่หรือไม่?"
);
} }
function close() { function close() {

View file

@ -196,6 +196,28 @@ watch(
</div> </div>
<div v-else class="col-12 row items-center"> <div v-else class="col-12 row items-center">
<!-- summary -->
<div
v-if="nodeId"
class="row col-12 justify-between list-summary q-gutter-xs bg-grey-1"
>
<div class="row col q-pa-sm item">
<div class="ellipsis">ตำแหนงทงหมด</div>
<q-space />
<q-badge color="secondary" :label="store.sumPosition.total" />
</div>
<div class="row col q-pa-sm item bg-grey-1">
<div class="ellipsis">ตำแหนงทคนครอง</div>
<q-space />
<q-badge color="primary" :label="store.sumPosition.use" />
</div>
<div class="row col q-pa-sm item bg-grey-1">
<div class="ellipsis">ตำแหนงวาง</div>
<q-space />
<q-badge color="red" :label="store.sumPosition.vacant" />
</div>
</div>
<TableView <TableView
v-if="nodeId !== ''" v-if="nodeId !== ''"
v-model:nodeTree="nodeTree" v-model:nodeTree="nodeTree"
@ -220,4 +242,10 @@ watch(
</div> </div>
</template> </template>
<style scoped></style> <style scoped>
.list-summary .item {
border: 1px solid rgb(231, 231, 231);
border-radius: 4px;
background-color: white;
}
</style>

View file

@ -100,14 +100,22 @@ const orgLevel = ref<number>(0);
const type = ref<number>(0); const type = ref<number>(0);
const orgId = ref<string>(""); const orgId = ref<string>("");
const updateSelected = (id: string, level: number) => { const updateSelected = (data: any) => {
store.treeId = id; store.treeId = data.orgTreeId;
store.level = level; store.level = data.orgLevel;
if (id === nodeId.value) { if (data.orgTreeId === nodeId.value) {
nodeId.value = ""; nodeId.value = "";
} else { } else {
nodeId.value = id ? id : ""; nodeId.value = data.orgTreeId ? data.orgTreeId : "";
id && props.fetchDataTable?.(id, level, true); data.orgTreeId &&
props.fetchDataTable?.(data.orgTreeId, data.orgLevel, true);
store.getSumPosition({
totalPosition: data.totalPosition,
totalPositionCurrentUse: data.totalPositionCurrentUse,
totalPositionCurrentVacant: data.totalPositionCurrentVacant,
totalPositionNextUse: data.totalPositionNextUse,
totalPositionNextVacant: data.totalPositionNextVacant,
});
} }
}; };
@ -353,7 +361,7 @@ onMounted(async () => {});
<div <div
class="row items-center q-px-xs q-pt-xs q-gutter-sm" class="row items-center q-px-xs q-pt-xs q-gutter-sm"
@click="updateSelected(prop.node.orgTreeId, prop.node.orgLevel)" @click="updateSelected(prop.node)"
> >
<!--แสดงชอแผนก มพวหนา คลกแลวกาง/ Tree--> <!--แสดงชอแผนก มพวหนา คลกแลวกาง/ Tree-->
<div> <div>

View file

@ -3,8 +3,16 @@ interface DataActive {
activeName: string; activeName: string;
draftId: string; draftId: string;
draftName: string; draftName: string;
isPublic: boolean, isPublic: boolean;
orgPublishDate: Date | null, orgPublishDate: Date | null;
}
interface SumPosition {
totalPosition: number;
totalPositionCurrentUse: number;
totalPositionCurrentVacant: number;
totalPositionNextUse: number;
totalPositionNextVacant: number;
} }
interface OrgTree { interface OrgTree {
@ -80,7 +88,7 @@ interface Position {
interface PosMaster { interface PosMaster {
id: string; // id อัตรากำลัง posmaster id: string; // id อัตรากำลัง posmaster
orgShortname: string; // อักษรย่อตำแหน่ง orgShortname: string; // อักษรย่อตำแหน่ง
posMasterNoPrefix: string; // Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ) posMasterNoPrefix: string; // Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)
posMasterNo: number | string; // เลขที่ตำแหน่ง เป็นตัวเลข posMasterNo: number | string; // เลขที่ตำแหน่ง เป็นตัวเลข
posMasterNoSuffix: string | null; // Suffix หลังเลขที่ตำแหน่ง เช่น ช. posMasterNoSuffix: string | null; // Suffix หลังเลขที่ตำแหน่ง เช่น ช.
@ -114,7 +122,7 @@ interface Position2 {
interface PosMaster2 { interface PosMaster2 {
id: string; // id อัตรากำลัง posmaster id: string; // id อัตรากำลัง posmaster
orgShortname: string; // อักษรย่อตำแหน่ง orgShortname: string; // อักษรย่อตำแหน่ง
posMasterNoPrefix: string; // Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ) posMasterNoPrefix: string; // Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)
posMasterNo: number | string; // เลขที่ตำแหน่ง เป็นตัวเลข posMasterNo: number | string; // เลขที่ตำแหน่ง เป็นตัวเลข
posMasterNoSuffix: string | null; // Suffix หลังเลขที่ตำแหน่ง เช่น ช. posMasterNoSuffix: string | null; // Suffix หลังเลขที่ตำแหน่ง เช่น ช.
@ -144,4 +152,5 @@ export type {
PosMaster2, PosMaster2,
Position, Position,
Position2, Position2,
SumPosition
}; };

View file

@ -1,10 +1,10 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { ref } from "vue"; import { reactive, ref } from "vue";
/** importType*/ /** importType*/
import type { import type {
DataActive, DataActive,
Position, SumPosition,
PosMaster, PosMaster,
} from "@/modules/02_organizationalNew/interface/response/organizational"; } from "@/modules/02_organizationalNew/interface/response/organizational";
@ -19,6 +19,23 @@ export const useOrganizational = defineStore("organizationalStore", () => {
const level = ref<number>(); const level = ref<number>();
const isPublic = ref<boolean>(false); const isPublic = ref<boolean>(false);
const orgPublishDate = ref<Date | null>(null); const orgPublishDate = ref<Date | null>(null);
const sumPosition = reactive({
total: 0,
use: 0,
vacant: 0,
});
function getSumPosition(data: SumPosition) {
sumPosition.total = data.totalPosition;
sumPosition.use =
typeOrganizational.value == "draft"
? data.totalPositionNextUse
: data.totalPositionCurrentUse;
sumPosition.vacant =
typeOrganizational.value == "draft"
? data.totalPositionNextVacant
: data.totalPositionCurrentVacant;
}
function fetchDataActive(data: DataActive) { function fetchDataActive(data: DataActive) {
activeId.value = data.activeId; activeId.value = data.activeId;
@ -100,5 +117,7 @@ export const useOrganizational = defineStore("organizationalStore", () => {
isPublic, isPublic,
orgPublishDate, orgPublishDate,
fetchPosMaster, fetchPosMaster,
sumPosition,
getSumPosition,
}; };
}); });

View file

@ -240,7 +240,7 @@ onMounted(async () => {
</q-btn-dropdown> </q-btn-dropdown>
</q-btn-group> </q-btn-group>
<q-btn-dropdown color="green" label="ประวัติโครงสร้าง"> <q-btn-dropdown color="green" label="เพิ่มโครงสร้าง">
<q-list> <q-list>
<q-item <q-item
dense dense