[fix] แก้ไขกรณีแก้ไขตำแหน่ง/แก้ไขอัตรากำลังแล้วมีคนครองอยู่
This commit is contained in:
parent
762acf46bd
commit
0be2f0d037
4 changed files with 103 additions and 58 deletions
|
|
@ -44,6 +44,10 @@ const {
|
|||
* props
|
||||
*/
|
||||
const reqMaster = defineModel<FilterMaster>("reqMaster", { required: true }); // qurey
|
||||
const isPositionHolder = defineModel<boolean>("isPositionHolder", {
|
||||
default: false,
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
modal: Boolean,
|
||||
close: Function,
|
||||
|
|
@ -56,6 +60,7 @@ const props = defineProps({
|
|||
shortName: { type: String, required: true },
|
||||
orgShortName: { type: String, required: true },
|
||||
dataTree: { type: Object, default: () => [] },
|
||||
positionHolderInfo: { type: Object, default: () => ({}) },
|
||||
});
|
||||
|
||||
const isReadonly = ref<boolean>(false); // อ่านได้อย่างเดียว
|
||||
|
|
@ -104,9 +109,19 @@ const formPositionSelect = reactive<FormPositionSelect>({
|
|||
});
|
||||
|
||||
//Table
|
||||
const selectedPos = ref<RowDetailPositions[]>([]);
|
||||
const rows = ref<RowDetailPositions[]>([]); //ข้อมูลรายการอัตรากำลัง
|
||||
const rowsPositionSelect = ref<RowDetailPositions[]>([]); //ข้อมูลรายากรตำแหน่ง
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "checkbox",
|
||||
align: "center",
|
||||
label: "ครองในตำแหน่ง",
|
||||
sortable: false,
|
||||
field: "checkbox",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
|
|
@ -232,6 +247,15 @@ async function fetchPosition(id: string) {
|
|||
// formData.isStaff = data.isStaff;
|
||||
formData.positionSign = data.positionSign;
|
||||
rows.value = data.positions;
|
||||
const positionIsSelected = data.positions.find(
|
||||
(item: any) => item.id === props.positionHolderInfo.position
|
||||
);
|
||||
|
||||
if (positionIsSelected) {
|
||||
selectedPos.value.push(positionIsSelected);
|
||||
} else {
|
||||
selectedPos.value = [];
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -251,20 +275,29 @@ function onSubmit() {
|
|||
//ตราจสอบรายการตำแหน่งถ้าไม่มีแสดงข้อความแจ้งเตือน
|
||||
if (rows.value.length == 0) {
|
||||
dialogMessageNotify($q, "กรุณาเลือกตำแหน่งอย่างน้อย 1 ตำแหน่ง");
|
||||
} else if (selectedPos.value.length == 0 && isPositionHolder.value) {
|
||||
dialogMessageNotify($q, "กรุณาเลือกครองในตำแหน่ง");
|
||||
} else {
|
||||
//ถ้ามีแสดง dialog ยืนยัน
|
||||
dialogConfirm($q, async () => {
|
||||
const positionsData = rows.value.map((e: RowDetailPositions) => ({
|
||||
posDictName: e.positionName, //ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)
|
||||
posDictField: e.positionField, //สายงาน
|
||||
posTypeId: e.posTypeId, //*ตำแหน่งประเภท
|
||||
posLevelId: e.posLevelId, //*ระดับตำแหน่ง
|
||||
posExecutiveId: e.posExecutiveId ? e.posExecutiveId : "", //ตำแหน่งทางการบริหาร
|
||||
posDictExecutiveField: e.positionExecutiveField, //ด้านทางการบริหาร
|
||||
posDictArea: e.positionArea, //ด้าน/สาขา
|
||||
isSpecial: e.isSpecial,
|
||||
positionIsSelected: e.positionIsSelected,
|
||||
}));
|
||||
const positionsData = rows.value.map(
|
||||
(e: RowDetailPositions, index: number) => ({
|
||||
id: e.id, //id รายการตำแหน่ง
|
||||
posDictName: e.positionName, //ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)
|
||||
posDictField: e.positionField, //สายงาน
|
||||
posTypeId: e.posTypeId, //*ตำแหน่งประเภท
|
||||
posLevelId: e.posLevelId, //*ระดับตำแหน่ง
|
||||
posExecutiveId: e.posExecutiveId ? e.posExecutiveId : "", //ตำแหน่งทางการบริหาร
|
||||
posDictExecutiveField: e.positionExecutiveField, //ด้านทางการบริหาร
|
||||
posDictArea: e.positionArea, //ด้าน/สาขา
|
||||
isSpecial: e.isSpecial,
|
||||
positionIsSelected:
|
||||
isPositionHolder.value && selectedPos.value[0]?.id === e.id
|
||||
? true
|
||||
: false,
|
||||
orderNo: index,
|
||||
})
|
||||
);
|
||||
|
||||
const body = {
|
||||
posMasterNoPrefix: formData.prefixNo, //*Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)
|
||||
|
|
@ -280,46 +313,6 @@ function onSubmit() {
|
|||
orgChild2Id: getOrgIdByLevel(2),
|
||||
orgChild3Id: getOrgIdByLevel(3),
|
||||
orgChild4Id: getOrgIdByLevel(4),
|
||||
// orgRootId:
|
||||
// props.actionType === "ADD"
|
||||
// ? props.orgLevel === 0
|
||||
// ? props.treeId
|
||||
// : null
|
||||
// : orgLevel.value === 0
|
||||
// ? props.treeId
|
||||
// : null, //Id สำนัก
|
||||
// orgChild1Id:
|
||||
// props.actionType === "ADD"
|
||||
// ? props.orgLevel === 1
|
||||
// ? props.treeId
|
||||
// : null
|
||||
// : orgLevel.value === 1
|
||||
// ? orgId.value
|
||||
// : null,
|
||||
// orgChild2Id:
|
||||
// props.actionType === "ADD"
|
||||
// ? props.orgLevel === 2
|
||||
// ? props.treeId
|
||||
// : null
|
||||
// : orgLevel.value === 2
|
||||
// ? orgId.value
|
||||
// : null,
|
||||
// orgChild3Id:
|
||||
// props.actionType === "ADD"
|
||||
// ? props.orgLevel === 3
|
||||
// ? props.treeId
|
||||
// : null
|
||||
// : orgLevel.value === 3
|
||||
// ? orgId.value
|
||||
// : null,
|
||||
// orgChild4Id:
|
||||
// props.actionType === "ADD"
|
||||
// ? props.orgLevel === 4
|
||||
// ? props.treeId
|
||||
// : null
|
||||
// : orgLevel.value === 4
|
||||
// ? orgId.value
|
||||
// : null,
|
||||
positions: positionsData,
|
||||
};
|
||||
|
||||
|
|
@ -433,7 +426,7 @@ async function addPosition(data: RowDetailPositions) {
|
|||
item.positionName == data.positionName &&
|
||||
item.isSpecial == data.isSpecial
|
||||
);
|
||||
|
||||
data.id = null; // Reset id to ensure a new entry
|
||||
if (!isIdExist) {
|
||||
rows.value = [...rows.value, data];
|
||||
}
|
||||
|
|
@ -496,6 +489,7 @@ async function clearFormPositionSelect() {
|
|||
isPosition.value = false;
|
||||
// formData.isStaff = false;
|
||||
formData.positionSign = "";
|
||||
selectedPos.value = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -542,6 +536,18 @@ watch(
|
|||
if (props.actionType !== "ADD" && props.rowId) {
|
||||
fetchPosition(props.rowId);
|
||||
}
|
||||
|
||||
visibleColumns.value = [
|
||||
...(isPositionHolder.value ? ["checkbox"] : []),
|
||||
"no",
|
||||
"positionName",
|
||||
"positionField",
|
||||
"posTypeName",
|
||||
"posLevelName",
|
||||
"posExecutiveName",
|
||||
"positionExecutiveField",
|
||||
"positionArea",
|
||||
];
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -651,13 +657,15 @@ watch(
|
|||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
row-key="idcard"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
:visible-columns="visibleColumns"
|
||||
selection="single"
|
||||
v-model:selected="selectedPos"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
|
|
@ -687,12 +695,21 @@ watch(
|
|||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
|
||||
<q-td
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
>
|
||||
<div v-if="col.name == 'no'">
|
||||
<div v-if="col.name === 'checkbox'">
|
||||
<q-checkbox
|
||||
keep-color
|
||||
color="primary"
|
||||
dense
|
||||
v-model="props.selected"
|
||||
/>
|
||||
</div>
|
||||
<div v-else-if="col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div v-else-if="col.name === 'posExecutiveName'">
|
||||
|
|
@ -853,7 +870,9 @@ watch(
|
|||
:paging="true"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
:visible-columns="visibleColumns"
|
||||
:visible-columns="
|
||||
visibleColumns.filter((col) => col !== 'checkbox')
|
||||
"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch, computed } from "vue";
|
||||
import { ref, watch, computed, reactive } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import config from "@/app.config";
|
||||
|
|
@ -72,6 +72,15 @@ const modalSelectPerson = ref<boolean>(false); //เลือกคนครอ
|
|||
const rowId = ref<string>(""); //id ที่ต้องการกระทำ
|
||||
const actionType = ref<string>(""); //ประเภทการกระทำ
|
||||
const orgShortName = ref<string>(""); //ชื่อย่อหน่วยงาน
|
||||
|
||||
const isPositionHolder = ref<boolean>(false);
|
||||
const positionHolderInfo = reactive({
|
||||
posMaster: "",
|
||||
position: "",
|
||||
profileId: " ",
|
||||
isSit: false,
|
||||
});
|
||||
|
||||
/** ListMenu Table*/
|
||||
const listMenu = ref<ListMenu[]>([
|
||||
{
|
||||
|
|
@ -323,10 +332,22 @@ function onClickPosition(
|
|||
id: string,
|
||||
data: PosMaster2 = {} as PosMaster2
|
||||
) {
|
||||
actionType.value = type;
|
||||
orgShortName.value = type === "EDIT" ? data?.orgShortname : "";
|
||||
rowId.value = id ? id : "";
|
||||
actionType.value = type;
|
||||
dialogPosition.value = !dialogPosition.value;
|
||||
|
||||
if (type === "EDIT") {
|
||||
isPositionHolder.value = data.positionIsSelected !== "ว่าง";
|
||||
positionHolderInfo.posMaster = data.id || "";
|
||||
positionHolderInfo.position =
|
||||
data.positions.find((e) => e.positionIsSelected === true)?.id || "";
|
||||
positionHolderInfo.profileId =
|
||||
store.typeOrganizational === "current"
|
||||
? data.current_holderId || ""
|
||||
: data.next_holderId || "";
|
||||
positionHolderInfo.isSit = data.isSit || false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1019,6 +1040,8 @@ watch(
|
|||
v-model:reqMaster="reqMaster"
|
||||
:fetchDataTable="props.fetchDataTable"
|
||||
:getSummary="getSummary"
|
||||
:is-position-holder="isPositionHolder"
|
||||
:position-holder-info="positionHolderInfo"
|
||||
/>
|
||||
|
||||
<!-- จัดลำดับ -->
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ interface FormPositionSelectRef {
|
|||
}
|
||||
|
||||
interface RowDetailPositions {
|
||||
id: string;
|
||||
id: string | null;
|
||||
positionId: string;
|
||||
positionName: string;
|
||||
positionField: string;
|
||||
|
|
|
|||
|
|
@ -159,6 +159,9 @@ interface PosMaster2 {
|
|||
profilePoslevel: string;
|
||||
profilePostype: string;
|
||||
isDirector?: boolean;
|
||||
current_holderId?: string;
|
||||
next_holderId?: string;
|
||||
isSit?: boolean;
|
||||
}
|
||||
|
||||
interface HistoryPos {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue