จัดการผู้ใช้งาน => เพิ่มเมนูสำหรับระงับการใช้งาน/เปิดใช้งาน
This commit is contained in:
parent
b964f1087c
commit
cf3b94495f
1 changed files with 58 additions and 7 deletions
|
|
@ -23,8 +23,14 @@ import { useCounterMixin } from "@/stores/mixin";
|
||||||
/** use*/
|
/** use*/
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { dialogRemove, messageError, showLoader, hideLoader, success } =
|
const {
|
||||||
useCounterMixin();
|
dialogRemove,
|
||||||
|
messageError,
|
||||||
|
showLoader,
|
||||||
|
hideLoader,
|
||||||
|
success,
|
||||||
|
dialogConfirm,
|
||||||
|
} = useCounterMixin();
|
||||||
|
|
||||||
/** Table*/
|
/** Table*/
|
||||||
const rows = ref<Users[]>([]);
|
const rows = ref<Users[]>([]);
|
||||||
|
|
@ -115,6 +121,18 @@ const itemMenu = ref<ItemsMenu[]>([
|
||||||
// color: "edit",
|
// color: "edit",
|
||||||
// type: "edit",
|
// type: "edit",
|
||||||
// },
|
// },
|
||||||
|
{
|
||||||
|
label: "ระงับการใช้งาน",
|
||||||
|
icon: "mdi-lock-outline",
|
||||||
|
color: "orange-10",
|
||||||
|
type: "close",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "เปิดใช้งาน",
|
||||||
|
icon: "mdi-lock-open-outline",
|
||||||
|
color: "primary",
|
||||||
|
type: "open",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "จัดการสิทธิ์",
|
label: "จัดการสิทธิ์",
|
||||||
icon: "mdi-account-group",
|
icon: "mdi-account-group",
|
||||||
|
|
@ -141,7 +159,6 @@ function fetchListUsers() {
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data.data;
|
const data = res.data.data;
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
total.value = res.data.total;
|
total.value = res.data.total;
|
||||||
maxPage.value = Math.ceil(total.value / pageSize.value);
|
maxPage.value = Math.ceil(total.value / pageSize.value);
|
||||||
|
|
@ -155,8 +172,6 @@ function fetchListUsers() {
|
||||||
e.name === "USER"
|
e.name === "USER"
|
||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
console.log(rows.value);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -180,6 +195,9 @@ function onClickAction(type: string, data: Users) {
|
||||||
onDeleteUser(data.id);
|
onDeleteUser(data.id);
|
||||||
} else if (type === "managementRole") {
|
} else if (type === "managementRole") {
|
||||||
data && router.push(`/users/roles/${data.id}`);
|
data && router.push(`/users/roles/${data.id}`);
|
||||||
|
} else if (type === "open" || type === "close") {
|
||||||
|
const status = type === "open" ? true : false;
|
||||||
|
onLockUser(data.id, status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,11 +229,42 @@ function onDeleteUser(id: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* function ระงับการใช้งาน
|
||||||
|
* @param id ผู้ใช้งาน
|
||||||
|
* @param type เปิดใช้งาน,ระงับการใช้งาน
|
||||||
|
*/
|
||||||
|
function onLockUser(id: string, type: boolean) {
|
||||||
|
dialogConfirm(
|
||||||
|
$q,
|
||||||
|
() => {
|
||||||
|
showLoader();
|
||||||
|
http
|
||||||
|
.put(config.API.managementUser + `/${id}/enableStatus/${type}`)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res.data);
|
||||||
|
success($q, type ? "เปิดใช้งานสำเร็จ" : "ระงับการใช้งานสำเร็จ");
|
||||||
|
fetchListUsers();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
type ? "ยืนยันการเปิดใช้" : "ยืนยันการระงับใช้งาน",
|
||||||
|
type
|
||||||
|
? "ต้องการยืนยันการเปิดใช้นี้หรือไม่ ?"
|
||||||
|
: "ต้องการยืนยันระงับการใช้งานนี้หรือไม่ ?"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function อัปเดท paging
|
* function อัปเดท paging
|
||||||
* @param initialPagination ข้อมูล pagination
|
* @param initialPagination ข้อมูล pagination
|
||||||
*/
|
*/
|
||||||
async function updatePagination(initialPagination: Pagination) {
|
function updatePagination(initialPagination: Pagination) {
|
||||||
currentPage.value = 1;
|
currentPage.value = 1;
|
||||||
pageSize.value = initialPagination.rowsPerPage;
|
pageSize.value = initialPagination.rowsPerPage;
|
||||||
}
|
}
|
||||||
|
|
@ -314,7 +363,9 @@ onMounted(() => {
|
||||||
<q-menu>
|
<q-menu>
|
||||||
<q-list dense style="min-width: 200px">
|
<q-list dense style="min-width: 200px">
|
||||||
<q-item
|
<q-item
|
||||||
v-for="(item, index) in itemMenu"
|
v-for="(item, index) in props.row.enabled
|
||||||
|
? itemMenu.filter((e) => e.type !== 'open')
|
||||||
|
: itemMenu.filter((e) => e.type !== 'close')"
|
||||||
:key="index"
|
:key="index"
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue