[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">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue