feat: add delete is OWNER

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-05-29 10:12:16 +07:00
parent aa3d41b7b3
commit 21401ed519
6 changed files with 174 additions and 45 deletions

View file

@ -10,25 +10,25 @@ import type {
} from "@/modules/05_placement/interface/request/Main";
import type { FormOrderPlacementMainData } from "@/modules/05_placement/interface/request/Main";
export const useProfileDataStore = defineStore("profilePlacenent", () => {
interface profile {
main: { columns: String[] };
education: { columns: String[] };
certicate: { columns: String[] };
train: { columns: String[] };
insignia: { columns: String[] };
coined: { columns: String[] };
assessment: { columns: String[] };
salary: { columns: String[] };
discipline: { columns: String[] };
leave: { columns: String[] };
talent: { columns: String[] };
work: { columns: String[] };
record: { columns: String[] };
other: { columns: String[] };
document: { columns: String[] };
}
interface profile {
main: { columns: String[] };
education: { columns: String[] };
certicate: { columns: String[] };
train: { columns: String[] };
insignia: { columns: String[] };
coined: { columns: String[] };
assessment: { columns: String[] };
salary: { columns: String[] };
discipline: { columns: String[] };
leave: { columns: String[] };
talent: { columns: String[] };
work: { columns: String[] };
record: { columns: String[] };
other: { columns: String[] };
document: { columns: String[] };
}
export const useProfileDataStore = defineStore("profilePlacenent", () => {
const birthDate = ref<Date>(new Date());
const retireText = ref<string | null>(null);
const changeRetireText = (val: string | null) => {
@ -87,15 +87,15 @@ export const useProfileDataStore = defineStore("profilePlacenent", () => {
changeRetireText,
};
});
interface placement {
mappingPosition: { columns: String[] };
}
export const usePlacementDataStore = defineStore("placement", () => {
const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง
const tabsMain = ref<string>("probation");
const isOfficer = ref<boolean | null>(null);
const isStaff = ref<boolean | null>(null);
const { hideLoader } = mixin;
interface placement {
mappingPosition: { columns: String[] };
}
const placementData = ref<placement>({
mappingPosition: { columns: [] },
});
@ -218,10 +218,10 @@ export const usePlacementDataStore = defineStore("placement", () => {
isStaff,
};
});
interface placementOrder {
mappingPosition: { columns: String[] };
}
export const useOrderPlacementDataStore = defineStore("placementOrder", () => {
interface placementOrder {
mappingPosition: { columns: String[] };
}
const placementOrderData = ref<placementOrder>({
mappingPosition: { columns: [] },
});
@ -369,6 +369,8 @@ export const useTransferDataStore = defineStore("transferDataStore", () => {
]);
const statusOp = ref<DataOptions[]>(statusMainOp.value);
const statusDelete = ["REPORT", "WAITING", "DONE"];
const statusText = (val: string) => {
switch (val) {
case "WAITTING":
@ -438,5 +440,6 @@ export const useTransferDataStore = defineStore("transferDataStore", () => {
statusOp,
statusMainOp,
filterOption,
statusDelete,
};
});

View file

@ -2,7 +2,7 @@
import { ref, onMounted, computed } from "vue";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { useRouter, useRoute } from "vue-router";
import {
checkPermission,
checkPermissionList,
@ -20,11 +20,19 @@ import DialogOrders from "@/modules/05_placement/components/Transfer/DialogOrder
const $q = useQuasar();
const router = useRouter();
const route = useRoute();
const mixin = useCounterMixin();
const store = useTransferDataStore();
const { statusText, filterOption } = useTransferDataStore();
const { date2Thai, messageError, showLoader, hideLoader, onSearchDataTable } =
mixin;
const {
date2Thai,
messageError,
showLoader,
hideLoader,
onSearchDataTable,
dialogRemove,
success,
} = mixin;
const modal = ref<boolean>(false); //
const dataTransfer = ref<ResponseData[]>([]); //
@ -141,6 +149,15 @@ const visibleColumns = ref<string[]>([
"createdAt",
]);
const isPermissionDelete = computed(() => {
return (status: string) => {
return (
checkPermission(route)?.attrOwnership === "OWNER" &&
!store.statusDelete.includes(status)
);
};
});
/** ฟังก์ชันดึงข้อมูรายการขอโอน*/
async function fetchData() {
showLoader();
@ -194,6 +211,21 @@ function onSearch() {
);
}
function handleDelete(id: string) {
dialogRemove($q, async () => {
try {
showLoader();
await http.delete(config.API.transfer + `/admin/${id}`);
await fetchData();
success($q, "ลบข้อมูลสำเร็จ");
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
});
}
/**
* ทำงานเม Components กเรยกใชงาน
* จะเรยกใช fetchData เพอดงขอมลรายการขอโอน
@ -337,6 +369,18 @@ onMounted(async () => {
>
<q-tooltip>รายละเอยด</q-tooltip>
</q-btn>
<q-btn
v-if="isPermissionDelete(props.row.status)"
flat
round
dense
icon="mdi-delete"
color="red"
@click.prevent="handleDelete(props.row.id)"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.id">
<div v-if="col.name === 'no'">

View file

@ -313,7 +313,7 @@ function openDelete(id: string) {
dialogRemove($q, async () => {
showLoader();
await http
.delete(config.API.receiveDataId(id))
.delete(config.API.receiveData() + `/admin/${id}`)
.then(async () => {
await fecthlistRecevice();
await success($q, "ลบข้อมูลสำเร็จ");
@ -606,8 +606,10 @@ onMounted(async () => {
<q-item
v-if="
checkPermission($route)?.attrIsDelete &&
checkPermission($route)?.attrOwnership ===
'OWNER' &&
props.row.status !== 'REPORT' &&
props.row.status !== 'WAITING' &&
props.row.status !== 'DONE'
"
clickable