This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-16 10:26:09 +07:00
parent 51707646e7
commit df481043b1
9 changed files with 138 additions and 91 deletions

View file

@ -133,10 +133,9 @@ function saveSelectEdit() {
};
await http
.put(url, body)
.then(() => {
success($q, "เพิ่มข้อมูลสำเร็จ");
props.getData?.();
.then(async () => {
await props.getData?.();
await success($q, "เพิ่มข้อมูลสำเร็จ");
close();
})
.catch((err) => {
@ -192,10 +191,12 @@ function onSubmitSelectEdit() {
await http
.post(url, body)
.then(() => {
success($q, "เพิ่มข้อมูลสำเร็จ");
props.emitSearch?.(formPositionSelect.positionName, "positionName");
.then(async () => {
await props.emitSearch?.(
formPositionSelect.positionName,
"positionName"
);
await success($q, "เพิ่มข้อมูลสำเร็จ");
close();
})
.catch((err) => {
@ -241,7 +242,12 @@ function inputEdit(val: boolean) {
};
}
/**
* function เลอกประเภทตำแหน
* @param val id ประเภทตำแหน
*/
function updateSelectType(val: string) {
//
const listLevel = dataLevel.value.find((e: any) => e.id === val);
levelOpsMain.value = listLevel.posLevels.map((e: OptionLevel) => ({
id: e.id,
@ -257,8 +263,7 @@ function close() {
}
async function fetchType() {
showLoader();
await http
http
.get(config.API.orgPosType)
.then((res) => {
dataLevel.value = res.data.result;
@ -270,16 +275,12 @@ async function fetchType() {
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** function เรียกรายการตำแหน่งทางการบริหาร */
async function fetchExecutive() {
showLoader();
await http
function fetchExecutive() {
http
.get(config.API.orgPosExecutive)
.then((res) => {
executiveOpsMain.value = res.data.result.map((e: OptionExecutive) => ({
@ -290,9 +291,6 @@ async function fetchExecutive() {
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
@ -300,8 +298,9 @@ watch(
() => modal.value,
async () => {
if (modal.value === true) {
await fetchType();
await fetchExecutive();
showLoader();
await Promise.all([fetchType(), fetchExecutive()]);
hideLoader();
if (props.data) {
const dataList = props.data;

View file

@ -149,13 +149,14 @@ function onSubmit() {
formData.responsibility != null ? formData.responsibility : "",
};
//
if (actionType.value === "ADD") {
await http
.post(config.API.createOrgLevel(type.toLocaleLowerCase()), body)
.then(() => {
props.fetchDataTree(store.draftId);
success($q, "บันทึกข้อมูลสำเร็จ");
closeClear();
.then(async () => {
await props.fetchDataTree(store.draftId);
await success($q, "บันทึกข้อมูลสำเร็จ");
await closeClear();
})
.catch((err) => {
messageError($q, err);
@ -164,6 +165,7 @@ function onSubmit() {
hideLoader();
});
} else {
//
props.dataNode &&
(await http
.put(
@ -173,32 +175,35 @@ function onSubmit() {
),
body
)
.then(() => {
props.fetchDataTree(store.draftId);
props.edit?.(
.then(async () => {
await props.fetchDataTree(store.draftId);
await props.edit?.(
props.dataNode?.orgTreeId,
type,
body,
props.dataNode?.orgRootCode
);
closeClear();
props.fetchDataTable(
await props.fetchDataTable(
props?.dataNode?.orgTreeId,
props?.dataNode?.orgLevel,
false
);
success($q, "บันทึกข้อมูลสำเร็จ");
await success($q, "บันทึกข้อมูลสำเร็จ");
await closeClear();
})
.catch((err) => {
messageError($q, err);
})
.finally(async () => {
.finally(() => {
hideLoader();
}));
}
});
}
/**
* function เช formdata กลบไปคาวาง และป popup
*/
function closeClear() {
formData.orgName = "";
formData.orgShortName = "";
@ -211,14 +216,14 @@ function closeClear() {
props.close?.();
}
/**
* callback function ทำงานเมอมการเป popup
*/
watch(
() => props.modal,
() => {
if (props.modal === true) {
if (actionType.value === "ADD") {
// console.log(props.dataNode);
// console.log(level.value);
if (props.dataNode) {
formData.orgCode =
props?.dataNode?.orgLevel !== 0
@ -261,6 +266,9 @@ watch(
}
);
/**
* title ของ popup
*/
const tittleName = computed(() => {
let name = "";
if (actionType.value === "ADD") {
@ -272,6 +280,11 @@ const tittleName = computed(() => {
return name;
});
/**
* function เลอกระดบของสวนราชการ
* @param val
* @param status
*/
function selectOrgLevele(val: string, status: boolean = true) {
formData.orgLevelSub = status ? "" : formData.orgLevelSub;
switch (val) {

View file

@ -1,7 +1,6 @@
<script setup lang="ts">
import { ref, reactive, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
@ -27,7 +26,7 @@ import type { FilterMaster } from "@/modules/02_organization/interface/request/o
* importComponents
*/
import DialogHeader from "@/components/DialogHeader.vue";
import DialogAddPosition from "@/modules/02_organization/components/DialogAddPosition.vue";
import DialogAddPosition from "@/modules/02_organization/components/DialogAddPosition.vue"; //
/**
* importStore
@ -224,6 +223,10 @@ const visibleColumns = ref<string[]>([
"positionArea",
]);
/**
* function fetch อมลอตรากำล
* @param id ตรากำล
*/
async function fetchPosition(id: string) {
showLoader();
await http
@ -249,7 +252,7 @@ async function fetchPosition(id: string) {
const dataLevel = ref<any>();
/** function เรียกรายการประเภทตำแหน่ง */
async function fetchType() {
showLoader();
// showLoader();
await http
.get(config.API.orgPosType)
.then((res) => {
@ -264,13 +267,13 @@ async function fetchType() {
messageError($q, err);
})
.finally(() => {
hideLoader();
// hideLoader();
});
}
/** function เรียกรายการตำแหน่งทางการบริหาร */
async function fetchExecutive() {
showLoader();
// showLoader();
await http
.get(config.API.orgPosExecutive)
.then((res) => {
@ -284,7 +287,7 @@ async function fetchExecutive() {
messageError($q, err);
})
.finally(() => {
hideLoader();
// hideLoader();
});
}
@ -336,7 +339,6 @@ function onSubmit() {
orgChild3Id: props.orgLevel === 3 ? props.treeId : null,
orgChild4Id: props.orgLevel === 4 ? props.treeId : null,
positions: positionsData,
// succession: succession.value,
};
showLoader();
@ -435,10 +437,11 @@ function inputEdit(val: boolean) {
watch(
() => props.modal,
() => {
async () => {
if (props.modal === true) {
fetchType();
fetchExecutive();
props.actionType === "ADD" && showLoader();
await Promise.all([fetchType(), fetchExecutive()]);
props.actionType === "ADD" && hideLoader();
if (props.actionType === "ADD") {
rowsPositionSelect.value = [];
@ -474,30 +477,41 @@ async function addPosition(data: RowDetailPositions) {
}
}
/**
* function ลบขอมลอตรากำล
* @param id อมลอตรากำล
*/
function deleteData(id: string) {
const dataRow = rows.value;
const updatedRows = dataRow.filter((item: any) => item.id !== id);
rows.value = updatedRows;
}
/**
* function ลบตำแหน
* @param id ตำแหน
*/
function deletePos(id: string) {
dialogRemove($q, () => {
showLoader();
http
.delete(config.API.orgPosPositionById(id))
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
.then(async () => {
await searchInput();
await success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
searchInput();
hideLoader();
});
});
}
/**
* function เคลยร formData
*/
async function clearFormPositionSelect() {
isDisValidate.value = await true;
formPositionSelect.positionId = "";
@ -514,9 +528,12 @@ async function clearFormPositionSelect() {
}, 1000);
}
/**
* function popup
*/
function close() {
props.close?.();
clearFormPositionSelect();
props.close?.();
isPosition.value = false;
}
@ -648,8 +665,7 @@ async function emitSearch(keyword: string, typeSelect: string) {
<q-btn
flat
dense
icon="mdi-delete"
class="q-pa-none q-ml-xs"
icon="delete"
color="red"
@click="deleteData(props.row.id)"
>
@ -821,9 +837,9 @@ async function emitSearch(keyword: string, typeSelect: string) {
<q-btn
flat
dense
icon="mdi-dots-vertical"
class="q-pa-none q-ml-xs"
color="grey-13"
color="secondary"
icon="mdi-dots-horizontal-circle-outline"
round
>
<q-menu anchor="bottom middle" self="top middle">
<q-list
@ -846,7 +862,7 @@ async function emitSearch(keyword: string, typeSelect: string) {
<q-icon
:color="item.color"
:name="item.icon"
size="sm"
size="xs"
/>
</q-item-section>
<q-item-section>{{
@ -910,6 +926,8 @@ async function emitSearch(keyword: string, typeSelect: string) {
</form>
</q-card>
</q-dialog>
<!-- เพมขอมลตำแหน -->
<DialogAddPosition
v-model:modalAdd="modalAdd"
:emitSearch="emitSearch"

View file

@ -128,10 +128,10 @@ function onClickMovePos() {
showLoader();
await http
.post(config.API.orgPosMove, body)
.then(() => {
props.fetchDataTree?.(store.draftId);
.then(async () => {
await props.fetchDataTree?.(store.draftId);
await success($q, "ย้ายตำแหน่งสำเร็จ");
modal.value = false;
success($q, "ย้ายตำแหน่งสำเร็จ");
})
.catch((err) => {
messageError($q, err);

View file

@ -112,21 +112,21 @@ function onSubmit() {
showLoader();
http
.post(config.API.createOrganization, formData)
.then((res) => {
.then(async (res) => {
await props.fetchActive();
status.value = true;
store.typeOrganizational = "draft";
store.draftId = res.data.result.id;
store.statusView = "list";
success($q, "บันทึกข้อมูลสำเร็จ");
props.fetchActive();
})
.catch((err) => {
messageError($q, err);
})
.finally(async () => {
modal.value = await false;
await close();
await hideLoader();
.finally(() => {
modal.value = false;
hideLoader();
close();
});
},
"ยืนยันการเพิ่มโครงสร้าง",

View file

@ -56,7 +56,6 @@ async function fetchTree() {
await http
.get(config.API.orgByid(id))
.then((res) => {
console.log(res);
nodeTree.value = res.data.result;
})
.catch((err) => {
@ -164,7 +163,6 @@ function onClickConfirm() {
dialogConfirm(
$q,
async () => {
console.log(props.rowId, selectedPos.value[0].id);
const body: Inherit = {
draftPositionId: props.rowId,
publishPositionId: selectedPos.value[0].id,

View file

@ -297,15 +297,15 @@ async function onClickEdit(node: OrgTree) {
* @param id ID โครงสราง
* @param rootId RootID
*/
async function onClickDel(type: number, id: string, rootId: string) {
function onClickDel(type: number, id: string, rootId: string) {
const level = store.checkLevel(type);
dialogRemove($q, async () => {
showLoader();
await http
.delete(config.API.orgLevelByid(level.toLocaleLowerCase(), id))
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
deleteUpdate(rootId, id);
.then(async () => {
await deleteUpdate(rootId, id);
await success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
@ -321,7 +321,7 @@ async function onClickDel(type: number, id: string, rootId: string) {
* @param id ID โครงสราง
* @param level ระดบโครงสราง
*/
async function onClickSort(id: string, level: number) {
function onClickSort(id: string, level: number) {
type.value = level;
modalSortAgency.value = true;
if (id) {

View file

@ -19,13 +19,13 @@ import type {
import type { DataPosition } from "@/modules/02_organization/interface/index/organizational";
/** importComponents*/
import DialogFormPosotion from "@/modules/02_organization/components/DialogFormPosition.vue";
import DialogPositionDetail from "@/modules/02_organization/components/DialogPositionDetail.vue";
import DialogSort from "@/modules/02_organization/components/DialogSortPosition.vue";
import DialogMovePos from "@/modules/02_organization/components/DialogMovePos.vue";
import DialogHistoryPos from "@/modules/02_organization/components/DialogHistoryPos.vue";
import DialogSelectPerson from "@/modules/02_organization/components/DialogSelectPerson.vue";
import DialogSuccession from "@/modules/02_organization/components/DialogSuccession.vue";
import DialogFormPosotion from "@/modules/02_organization/components/DialogFormPosition.vue"; //
import DialogPositionDetail from "@/modules/02_organization/components/DialogPositionDetail.vue"; //
import DialogSort from "@/modules/02_organization/components/DialogSortPosition.vue"; //
import DialogMovePos from "@/modules/02_organization/components/DialogMovePos.vue"; //
import DialogHistoryPos from "@/modules/02_organization/components/DialogHistoryPos.vue"; //
import DialogSelectPerson from "@/modules/02_organization/components/DialogSelectPerson.vue"; //
import DialogSuccession from "@/modules/02_organization/components/DialogSuccession.vue"; //
/** importStore*/
import { useOrganizational } from "@/modules/02_organization/store/organizational";
@ -291,10 +291,17 @@ function onClickDelete(id: string) {
showLoader();
await http
.delete(config.API.orgPosMasterById(id))
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
props.fetchDataTable?.(reqMaster.value.id, reqMaster.value.type, false);
getSummary();
.then(async () => {
await Promise.all([
props.fetchDataTable?.(
reqMaster.value.id,
reqMaster.value.type,
false
),
getSummary(),
]);
await success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
@ -357,14 +364,16 @@ function removePerson(id: string) {
showLoader();
await http
.post(config.API.orgDeleteProfile(id))
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
props.fetchDataTable?.(
reqMaster.value.id,
reqMaster.value.type,
false
);
getSummary();
.then(async () => {
await Promise.all([
props.fetchDataTable?.(
reqMaster.value.id,
reqMaster.value.type,
false
),
getSummary(),
]);
await success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
@ -571,7 +580,7 @@ watch(
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" >
<q-tr :props="props">
<q-td>
<q-btn
v-if="store.typeOrganizational === 'draft'"

View file

@ -67,8 +67,13 @@ function fetchOrganization(id: string) {
});
}
/**
* function เลอกตำแหนงทจะใหกษาการ
* @param data อมลตำแหน
*/
async function updateSelected(data: PosMaster) {
posmasterId.value = data.posmasterId;
// function fetch ,fetch
await Promise.all([fetchPosMaster(), fetchListAct()]);
}
@ -165,6 +170,10 @@ function fetchPosMaster() {
});
}
/**
* function แสดงตำแหนงทงหมด
* @param val แสดงตำแหนงทงหมด
*/
function updateIsAll(val: boolean) {
isAll.value = val;
fetchPosMaster();
@ -241,6 +250,7 @@ function onDelete(id: string) {
http
.delete(config.API.orgPosAct + `/${id}`)
.then(async () => {
// function fetch ,fetch
await Promise.all([fetchPosMaster(), fetchListAct()]);
})
.catch((err) => {