refactor: handle role can canceled
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
This commit is contained in:
parent
3ff6715528
commit
4a88a7fc55
3 changed files with 34 additions and 2 deletions
|
|
@ -23,6 +23,7 @@ import { useRequestList } from 'src/stores/request-list';
|
||||||
import { RequestData, RequestDataStatus } from 'src/stores/request-list/types';
|
import { RequestData, RequestDataStatus } from 'src/stores/request-list/types';
|
||||||
import { dialogWarningClose } from 'src/stores/utils';
|
import { dialogWarningClose } from 'src/stores/utils';
|
||||||
import { CancelButton, SaveButton } from 'src/components/button';
|
import { CancelButton, SaveButton } from 'src/components/button';
|
||||||
|
import { getRole } from 'src/services/keycloak';
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const navigatorStore = useNavigator();
|
const navigatorStore = useNavigator();
|
||||||
|
|
@ -92,6 +93,19 @@ function triggerCancel(id: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hideAction = computed(() => {
|
||||||
|
const role = getRole();
|
||||||
|
const allowedRoles = [
|
||||||
|
'head_of_admin',
|
||||||
|
'head_of_sale',
|
||||||
|
'admin',
|
||||||
|
'sale',
|
||||||
|
'system',
|
||||||
|
];
|
||||||
|
|
||||||
|
return !role || !role.some((r) => allowedRoles.includes(r));
|
||||||
|
});
|
||||||
|
|
||||||
function triggerView(opts: { requestData: RequestData }) {
|
function triggerView(opts: { requestData: RequestData }) {
|
||||||
const url = new URL(
|
const url = new URL(
|
||||||
`/request-list/${opts.requestData.id}`,
|
`/request-list/${opts.requestData.id}`,
|
||||||
|
|
@ -379,6 +393,7 @@ watch([() => pageState.inputSearch, () => pageState.statusFilter], () => {
|
||||||
:rows="data"
|
:rows="data"
|
||||||
:grid="pageState.gridView"
|
:grid="pageState.gridView"
|
||||||
:visible-columns="pageState.fieldSelected"
|
:visible-columns="pageState.fieldSelected"
|
||||||
|
:hide-action
|
||||||
@view="(data) => triggerView({ requestData: data })"
|
@view="(data) => triggerView({ requestData: data })"
|
||||||
@delete="(data) => triggerCancel(data.id)"
|
@delete="(data) => triggerCancel(data.id)"
|
||||||
@reject-cancel="
|
@reject-cancel="
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import { baseUrl } from 'src/stores/utils';
|
||||||
import { ProductRelation, PayCondition } from 'src/stores/quotations/types';
|
import { ProductRelation, PayCondition } from 'src/stores/quotations/types';
|
||||||
import { Step, RequestWorkStatus } from 'src/stores/request-list/types';
|
import { Step, RequestWorkStatus } from 'src/stores/request-list/types';
|
||||||
import BadgeComponent from 'src/components/BadgeComponent.vue';
|
import BadgeComponent from 'src/components/BadgeComponent.vue';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { getRole } from 'src/services/keycloak';
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
(
|
(
|
||||||
|
|
@ -34,6 +36,19 @@ const props = defineProps<{
|
||||||
orderAble?: boolean;
|
orderAble?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const canCanceled = computed(() => {
|
||||||
|
const role = getRole();
|
||||||
|
const allowedRoles = [
|
||||||
|
'head_of_admin',
|
||||||
|
'head_of_sale',
|
||||||
|
'admin',
|
||||||
|
'sale',
|
||||||
|
'system',
|
||||||
|
];
|
||||||
|
|
||||||
|
return !role || role.some((r) => allowedRoles.includes(r));
|
||||||
|
});
|
||||||
|
|
||||||
function changeableStatus(currentStatus?: RequestWorkStatus) {
|
function changeableStatus(currentStatus?: RequestWorkStatus) {
|
||||||
switch (currentStatus) {
|
switch (currentStatus) {
|
||||||
case RequestWorkStatus.Ready:
|
case RequestWorkStatus.Ready:
|
||||||
|
|
@ -53,7 +68,7 @@ function changeableStatus(currentStatus?: RequestWorkStatus) {
|
||||||
RequestWorkStatus.Ready,
|
RequestWorkStatus.Ready,
|
||||||
RequestWorkStatus.Ended,
|
RequestWorkStatus.Ended,
|
||||||
RequestWorkStatus.Canceled,
|
RequestWorkStatus.Canceled,
|
||||||
];
|
].filter((v) => canCanceled.value || v !== RequestWorkStatus.Canceled);
|
||||||
if (props.orderAble) {
|
if (props.orderAble) {
|
||||||
return props.requestCancel && !props.rejectRequestCancel
|
return props.requestCancel && !props.rejectRequestCancel
|
||||||
? [...statuses, RequestWorkStatus.RejectCancel]
|
? [...statuses, RequestWorkStatus.RejectCancel]
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ const props = withDefaults(
|
||||||
columns: QTableProps['columns'];
|
columns: QTableProps['columns'];
|
||||||
grid?: boolean;
|
grid?: boolean;
|
||||||
visibleColumns?: string[];
|
visibleColumns?: string[];
|
||||||
|
hideAction?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
row: () => [],
|
row: () => [],
|
||||||
|
|
@ -224,6 +225,7 @@ function getEmployeeName(
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<KebabAction
|
<KebabAction
|
||||||
|
v-if="!hideAction"
|
||||||
:id-name="`btn-kebab-${props.row.code}`"
|
:id-name="`btn-kebab-${props.row.code}`"
|
||||||
hide-edit
|
hide-edit
|
||||||
hide-toggle
|
hide-toggle
|
||||||
|
|
@ -255,7 +257,7 @@ function getEmployeeName(
|
||||||
hide-kebab-view
|
hide-kebab-view
|
||||||
hide-kebab-edit
|
hide-kebab-edit
|
||||||
hide-kebab-delete
|
hide-kebab-delete
|
||||||
use-cancel
|
:use-cancel="!hideAction"
|
||||||
class="full-height"
|
class="full-height"
|
||||||
:use-reject-cancel="
|
:use-reject-cancel="
|
||||||
props.row.customerRequestCancel && !props.row.rejectRequestCancel
|
props.row.customerRequestCancel && !props.row.rejectRequestCancel
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue