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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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