complete Complete User Request Submission section RAD-1
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
<script setup>
|
||||
import Master from "../../layouts/master.vue";
|
||||
import {ref , onMounted , onUnmounted} from 'vue';
|
||||
import {Link} from "@inertiajs/inertia-vue3";
|
||||
import {usePermissionStore} from "../../store/Permission.js";
|
||||
import Card from "../../components/ui/Card.vue";
|
||||
|
||||
const permissionStore = usePermissionStore();
|
||||
|
||||
const props = defineProps({
|
||||
is_edit : {
|
||||
type: Boolean,
|
||||
default: () => false
|
||||
},
|
||||
permission: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
permissions: {
|
||||
type: Object,
|
||||
default: () => []
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
if (props.is_edit) {
|
||||
permissionStore.setEditData(props.permission);
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
permissionStore.resetCreateForm();
|
||||
permissionStore.is_edit_form = false;
|
||||
permissionStore.errorsCreateForm = [];
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<master>
|
||||
<Card class="mb-4">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-[1fr_auto] justify-between items-center gap-4">
|
||||
<h2 class="font-bold text-client-Fontcolor">{{ permissionStore.pageTitle }}</h2>
|
||||
<Button severity="secondary" asChild v-slot="slotProps" class="w-full sm:w-auto">
|
||||
<Link :class="slotProps.class" :href="permissionStore.endpoints.index">
|
||||
<span class="text-sm">{{ permissionStore.indexPageTitle }}</span>
|
||||
<i class="fi fi-rr-list flex text-sm"></i>
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<section class="grid w-full grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
<div class="lg:col-span-2">
|
||||
<Card>
|
||||
<Form ref="formRef" v-slot="$form" class="flex flex-col gap-4 !w-full">
|
||||
<FormField v-slot="$field" name="name" initialValue="" class="flex flex-col gap-1">
|
||||
<label>نام سطح</label>
|
||||
<InputText type="text" :class="[
|
||||
'placeholder:!text-sm',
|
||||
permissionStore.errorsCreateForm?.name && !permissionStore.createForm.name ? 'p-invalid' : ''
|
||||
]" v-model="permissionStore.createForm.name" placeholder="نام سطح را وارد کنید" />
|
||||
<Message v-if="permissionStore.errorsCreateForm?.name"
|
||||
severity="error" size="small" variant="simple">{{ permissionStore.errorsCreateForm?.name[0] }}</Message>
|
||||
</FormField>
|
||||
<FormField v-slot="$field" name="label" initialValue="" class="flex flex-col gap-1">
|
||||
<label>نام فارسی سطح</label>
|
||||
<InputText type="text" :class="[
|
||||
'placeholder:!text-sm',
|
||||
permissionStore.errorsCreateForm?.label && !permissionStore.createForm.label ? 'p-invalid' : ''
|
||||
]" v-model="permissionStore.createForm.label" placeholder="نام فارسی سطح را وارد کنید" />
|
||||
<Message v-if="permissionStore.errorsCreateForm?.label" severity="error" size="small" variant="simple">{{ permissionStore.errorsCreateForm?.label[0] }}</Message>
|
||||
</FormField>
|
||||
<FormField v-slot="$field" name="parent_id" initialValue="" class="flex flex-col gap-1">
|
||||
<label> والد (مرتبط با) </label>
|
||||
<Select v-model="permissionStore.createForm.parent_id" optionLabel="label" optionValue="id" :pt="{option : '!text-sm'}"
|
||||
:options="permissions.data" filter
|
||||
placeholder="انتخاب سطح" class="w-full">
|
||||
<template #empty>
|
||||
<div class="flex justify-center py-4 items-center h-full">
|
||||
<span class="text-center text-sm">هیچ سطحی پیدا نشده!</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #emptyfilter>
|
||||
<div class="flex justify-center py-4 items-center h-full">
|
||||
<span class="text-center text-sm">هیچ سطحی پیدا نشده!</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #value="slotProps">
|
||||
<div v-if="slotProps.value" class="flex items-center">
|
||||
<div>
|
||||
{{ permissions.data.find(item => item.id === slotProps.value)?.label || 'انتخاب سطح' }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Select>
|
||||
</FormField>
|
||||
</Form>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div class="lg:col-span-1">
|
||||
<Card>
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
<div class="grid grid-cols-1 justify-between items-center">
|
||||
<span>زمان انتشار:</span>
|
||||
<CustomDatePicker v-model="permissionStore.createForm.datetime" class="mt-2" type="datetime" compact-time></CustomDatePicker>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 justify-start">
|
||||
<Button :loading="permissionStore.loaderCreateForm" @click="permissionStore.update_and_store" type="button" severity="secondary" :label="permissionStore.buttonLabel" class="w-full sm:w-auto" />
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</section>
|
||||
</master>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
<script setup>
|
||||
import Master from "../../layouts/master.vue";
|
||||
import { ref, reactive } from 'vue';
|
||||
import TableGeneric from "../../components/TableGeneric.vue";
|
||||
import { Link } from "@inertiajs/inertia-vue3";
|
||||
import { useConfirm } from 'primevue/useconfirm';
|
||||
import { useToast } from 'primevue/usetoast';
|
||||
import {usePermissionStore} from "../../store/Permission.js";
|
||||
const toast = useToast();
|
||||
|
||||
const props = defineProps({
|
||||
permissions: {
|
||||
type: Object,
|
||||
},
|
||||
search: {
|
||||
type: String
|
||||
},
|
||||
level: {
|
||||
type: String
|
||||
}
|
||||
})
|
||||
const permissionStore = usePermissionStore();
|
||||
|
||||
const permissions = ref(props.permissions ?? []);
|
||||
const selectedItems = ref([]);
|
||||
const searchLoader = ref(false);
|
||||
|
||||
const columns = ref(permissionStore.columns)
|
||||
|
||||
const queryParams = reactive({
|
||||
search: props.search ?? '',
|
||||
level: props.level ?? ''
|
||||
})
|
||||
|
||||
const confirm = useConfirm();
|
||||
|
||||
const onPageChange = (event) => {
|
||||
permissionStore.navigateToPage(event.page + 1);
|
||||
};
|
||||
|
||||
const searchData = () => {
|
||||
searchLoader.value = true;
|
||||
permissionStore.search(queryParams).then((response) => {
|
||||
searchLoader.value = false;
|
||||
permissions.value = response.props.permissions.data;
|
||||
});
|
||||
}
|
||||
|
||||
const exportData = () => {
|
||||
permissionStore.exportData({
|
||||
level: queryParams.level,
|
||||
search: queryParams.search
|
||||
});
|
||||
}
|
||||
|
||||
const onSelectionChange = (selection) => {
|
||||
selectedItems.value = selection;
|
||||
};
|
||||
|
||||
const onSearchChange = (value) => {
|
||||
queryParams.search = value;
|
||||
searchData();
|
||||
};
|
||||
|
||||
const showDeleteConfirm = (data) => {
|
||||
confirm.require({
|
||||
group: 'deleteTemplate',
|
||||
header: 'مطمعن هستید؟',
|
||||
message: 'اگر به عملیات اطمینان دارید، تأیید کنید.',
|
||||
icon: 'fi fi-rr-info',
|
||||
rejectProps: {
|
||||
label: 'انصراف',
|
||||
icon: 'fi fi-rr-ban',
|
||||
outlined: true,
|
||||
size: 'small',
|
||||
class: '!text-xs !flex pt-1 !item-center',
|
||||
iconClass: '!flex !text-xs',
|
||||
},
|
||||
acceptProps: {
|
||||
label: 'حذف',
|
||||
icon: 'fi fi-rr-check',
|
||||
size: 'small',
|
||||
class: '!text-xs !flex pt-1 !item-center',
|
||||
iconClass: '!flex !text-xs',
|
||||
},
|
||||
accept: () => {
|
||||
permissionStore.deleteRecord(data.id);
|
||||
},
|
||||
reject: () => {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const confirmDeleteSelected = (ids) => {
|
||||
confirm.require({
|
||||
group: 'deleteTemplate',
|
||||
header: 'مطمعن هستید؟',
|
||||
message: 'اگر به عملیات اطمینان دارید، تأیید کنید.',
|
||||
icon: 'fi fi-rr-info',
|
||||
rejectProps: {
|
||||
label: 'انصراف',
|
||||
icon: 'fi fi-rr-ban',
|
||||
outlined: true,
|
||||
size: 'small',
|
||||
class: '!text-xs !flex pt-1 !item-center',
|
||||
iconClass: '!flex !text-xs',
|
||||
},
|
||||
acceptProps: {
|
||||
label: 'حذف',
|
||||
icon: 'fi fi-rr-check',
|
||||
size: 'small',
|
||||
class: '!text-xs !flex pt-1 !item-center',
|
||||
iconClass: '!flex !text-xs',
|
||||
},
|
||||
accept: () => {
|
||||
permissionStore.bulkDelete(ids);
|
||||
},
|
||||
reject: () => {
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<master>
|
||||
<div class="mb-4 grid grid-cols-2a justify-between items-center bg-white border-[1px] border-client-gray/20 py-4 px-4 rounded-2xl">
|
||||
<h2 class="font-bold text-client-Fontcolor">{{ permissionStore.indexPageTitle }}</h2>
|
||||
<Button severity="secondary" asChild v-slot="slotProps">
|
||||
<Link :class="slotProps.class" :href="permissionStore.endpoints.create">
|
||||
<span class="text-sm">{{ permissionStore.pageTitle }}</span>
|
||||
<i class="fi fi-rr-plus flex text-sm"></i>
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
<div class="card border-[1px] border-client-gray/20 bg-white rounded-2xl">
|
||||
<TableGeneric
|
||||
:data="permissions.data"
|
||||
:columns="columns"
|
||||
:selectable="true"
|
||||
:pagination="permissions.meta"
|
||||
:searchable="true"
|
||||
:searchValue="queryParams.search"
|
||||
v-model="selectedItems"
|
||||
@selection-change="onSelectionChange"
|
||||
@page-change="onPageChange"
|
||||
@search-change="onSearchChange"
|
||||
>
|
||||
<template #bulk-action="{ selection }">
|
||||
<Button
|
||||
label="حذف همه"
|
||||
size="small"
|
||||
:pt="{icon : 'flex'}"
|
||||
icon="fi fi-rr-trash"
|
||||
severity="danger"
|
||||
class="!text-xs !flex"
|
||||
outlined
|
||||
@click="() => confirmDeleteSelected(selection.map(user => user.id))"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #toolbar-actions>
|
||||
<div class="grid grid-cols-a gap-4 justify-start">
|
||||
<Button
|
||||
label="خروجی اکسل"
|
||||
:pt="{icon : 'flex'}"
|
||||
icon="fi fi-rr-file-export"
|
||||
class="!text-xs !bg-client-primary"
|
||||
@click="exportData"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #column-actions="{ data }">
|
||||
<div class="grid grid-cols-2a">
|
||||
<Button
|
||||
type="button"
|
||||
class="!w-8 !h-8"
|
||||
variant="outlined"
|
||||
severity="danger"
|
||||
icon="fi fi-rr-trash"
|
||||
:pt="{icon : '!mt-2 !text-xs'}"
|
||||
@click="showDeleteConfirm(data)"
|
||||
/>
|
||||
<Button severity="info" variant="outlined" asChild v-slot="slotProps">
|
||||
<Link :class="[slotProps.class , '!w-8 !h-8']" :href="permissionStore.endpoints.edit(data.id)">
|
||||
<i class="fi fi-rr-pen-clip flex !text-xs"></i>
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
</TableGeneric>
|
||||
</div>
|
||||
</master>
|
||||
</template>
|
||||
Reference in New Issue
Block a user