[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ChefListComponent.vue
<template> <LoadingComponent :props="loading" /> <div class="col-12"> <div class="db-card"> <div class="db-card-header border-none"> <h3 class="db-card-title">{{ $t("menu.chefs") }}</h3> <div class="db-card-filter"> <TableLimitComponent :method="list" :search="props.search" :page="paginationPage" /> <FilterComponent @click.prevent="handleSlide('chef-filter')" /> <div class="dropdown-group"> <ExportComponent /> <div class="dropdown-list db-card-filter-dropdown-list transition-all duration-300 scale-y-0 origin-top"> <PrintComponent :props="printObj" /> <ExcelComponent :method="xls" /> </div> </div> <ChefCreateComponent :props="props" v-if="permissionChecker('chefs_create')" /> </div> </div> <div class="table-filter-div" id="chef-filter"> <form class="p-4 sm:p-5 mb-5" @submit.prevent="search"> <div class="row"> <div class="col-12 sm:col-6 md:col-4 xl:col-3"> <label for="searchName" class="db-field-title after:hidden">{{ $t("label.name") }}</label> <input id="searchName" v-model="props.search.name" type="text" class="db-field-control" /> </div> <div class="col-12 sm:col-6 md:col-4 xl:col-3"> <label for="searchEmail" class="db-field-title after:hidden">{{ $t("label.email") }}</label> <input id="searchEmail" v-model="props.search.email" type="text" class="db-field-control" /> </div> <div class="col-12 sm:col-6 md:col-4 xl:col-3"> <label for="searchPhone" class="db-field-title after:hidden">{{ $t("label.phone") }}</label> <input id="searchPhone" v-model="props.search.phone" v-on:keypress="phoneNumber($event)" type="text" class="db-field-control" /> </div> <div class="col-12 sm:col-6 md:col-4 xl:col-3"> <label for="searchStatus" class="db-field-title after:hidden">{{ $t("label.status") }}</label> <vue-select class="db-field-control f-b-custom-select" id="searchStatus" v-model="props.search.status" :options="[{ id: enums.statusEnum.ACTIVE, name: $t('label.active') }, { id: enums.statusEnum.INACTIVE, name: $t('label.inactive') },]" label-by="name" value-by="id" :closeOnSelect="true" :searchable="true" :clearOnClose="true" placeholder="--" search-placeholder="--" /> </div> <div class="col-12 sm:col-6 md:col-4 xl:col-3" v-if="branches.length > 1 && authBranch === 0"> <label for="searchBranch" class="db-field-title after:hidden"> {{ $t('label.branch') }} </label> <vue-select class="db-field-control f-b-custom-select" id="searchBranch" v-model="props.search.branch_id" :options="[{ id: defaultAccess.branch_id, name: $t('label.current_branch') }, { id: 0, name: $t('label.all_branch') }]" label-by="name" value-by="id" :closeOnSelect="true" :searchable="true" :clearOnClose="true" placeholder="--" search-placeholder="--" /> </div> <div class="col-12"> <div class="flex flex-wrap gap-3 mt-4"> <button class="db-btn py-2 text-white bg-primary"> <i class="lab lab-search-line lab-font-size-16"></i> <span>{{ $t("button.search") }}</span> </button> <button class="db-btn py-2 text-white bg-gray-600" @click="clear"> <i class="lab lab-cross-line-2 lab-font-size-22"></i> <span>{{ $t("button.clear") }}</span> </button> </div> </div> </div> </form> </div> <div class="db-table-responsive"> <table class="db-table stripe" id="print"> <thead class="db-table-head"> <tr class="db-table-head-tr"> <th class="db-table-head-th">{{ $t("label.name") }}</th> <th class="db-table-head-th">{{ $t("label.email") }}</th> <th class="db-table-head-th">{{ $t("label.phone") }}</th> <th class="db-table-head-th">{{ $t("label.status") }}</th> <th class="db-table-head-th hidden-print" v-if="permissionChecker('chefs_show') || permissionChecker('chefs_edit') || permissionChecker('chefs_delete')"> {{ $t("label.action") }}</th> </tr> </thead> <tbody class="db-table-body" v-if="chefs.length > 0"> <tr class="db-table-body-tr" v-for="chef in chefs" :key="chef"> <td class="db-table-body-td"> {{ textShortener(chef.name, 20) }} </td> <td class="db-table-body-td"> {{ chef.email }} </td> <td class="db-table-body-td"> {{ chef.phone ? chef.country_code + '' + chef.phone : '' }} </td> <td class="db-table-body-td"> <span :class="statusClass(chef.status)"> {{ enums.statusEnumArray[chef.status] }} </span> </td> <td class="db-table-body-td hidden-print" v-if="permissionChecker('chefs_show') || permissionChecker('chefs_edit') || permissionChecker('chefs_delete')"> <div class="flex justify-start items-center sm:items-start sm:justify-start gap-1.5"> <SmIconViewComponent :link="'admin.chefs.show'" :id="chef.id" v-if="permissionChecker('chefs_show')" /> <SmIconSidebarModalEditComponent @click="edit(chef)" v-if="permissionChecker('chefs_edit')" /> <SmIconDeleteComponent @click="destroy(chef.id)" v-if="permissionChecker('chefs_delete')" /> </div> </td> </tr> </tbody> </table> </div> <div class="flex items-center justify-between border-t border-gray-200 bg-white px-4 py-6"> <PaginationSMBox :pagination="pagination" :method="list" /> <div class="hidden sm:flex sm:flex-1 sm:items-center sm:justify-between"> <PaginationTextComponent :props="{ page: paginationPage }" /> <PaginationBox :pagination="pagination" :method="list" /> </div> </div> </div> </div> </template> <script> import LoadingComponent from "../components/LoadingComponent"; import alertService from "../../../services/alertService"; import PaginationTextComponent from "../components/pagination/PaginationTextComponent"; import PaginationBox from "../components/pagination/PaginationBox"; import PaginationSMBox from "../components/pagination/PaginationSMBox"; import appService from "../../../services/appService"; import statusEnum from "../../../enums/modules/statusEnum"; import TableLimitComponent from "../components/TableLimitComponent"; import SmIconViewComponent from "../components/buttons/SmIconViewComponent"; import SmIconSidebarModalEditComponent from "../components/buttons/SmIconSidebarModalEditComponent"; import SmIconDeleteComponent from "../components/buttons/SmIconDeleteComponent"; import print from "vue3-print-nb"; import FilterComponent from "../components/buttons/collapse/FilterComponent"; import ExportComponent from "../components/buttons/export/ExportComponent"; import PrintComponent from "../components/buttons/export/PrintComponent"; import ExcelComponent from "../components/buttons/export/ExcelComponent"; import ChefCreateComponent from "./ChefCreateComponent.vue"; export default { name: "ChefListComponent", components: { ChefCreateComponent, TableLimitComponent, PaginationSMBox, PaginationBox, PaginationTextComponent, LoadingComponent, SmIconViewComponent, SmIconSidebarModalEditComponent, SmIconDeleteComponent, FilterComponent, ExportComponent, PrintComponent, ExcelComponent, }, data() { return { loading: { isActive: false, }, enums: { statusEnum: statusEnum, statusEnumArray: { [statusEnum.ACTIVE]: this.$t("label.active"), [statusEnum.INACTIVE]: this.$t("label.inactive"), }, }, printLoading: true, printObj: { id: "print", popTitle: this.$t("menu.chefs"), }, props: { form: { name: "", email: "", phone: "", password: "", password_confirmation: "", branch_id: null, country_code: "", status: statusEnum.ACTIVE, }, search: { paginate: 1, page: 1, per_page: 10, order_column: "id", order_type: "desc", name: "", email: "", phone: "", branch_id: null, status: null, }, }, country_code: "", }; }, mounted() { this.list(); this.$store.dispatch("defaultAccess/show"); this.$store.dispatch("branch/lists", { order_column: "id", order_type: "asc", status: statusEnum.ACTIVE, }); this.$store.dispatch('company/lists').then(companyRes => { this.loading.isActive = true; this.$store.dispatch('countryCode/show', companyRes.data.data.company_country_code).then(res => { this.country_code = res.data.data.calling_code; this.loading.isActive = false; }).catch((err) => { this.loading.isActive = false; }); }).catch((err) => { this.loading.isActive = false; }); }, computed: { defaultAccess: function () { return this.$store.getters["defaultAccess/show"]; }, branches: function () { return this.$store.getters["branch/lists"]; }, authBranch: function () { return this.$store.getters.authBranchId; }, chefs: function () { return this.$store.getters["chef/lists"]; }, pagination: function () { return this.$store.getters["chef/pagination"]; }, paginationPage: function () { return this.$store.getters["chef/page"]; }, countryCode: function () { return this.$store.getters['countryCode/show']; } }, methods: { permissionChecker(e) { return appService.permissionChecker(e); }, statusClass: function (status) { return appService.statusClass(status); }, phoneNumber(e) { return appService.phoneNumber(e); }, textShortener: function (text, number = 30) { return appService.textShortener(text, number); }, handleSlide: function (id) { return appService.handleSlide(id); }, search: function () { this.list(); }, clear: function () { this.props.search.paginate = 1; this.props.search.page = 1; this.props.search.name = ""; this.props.search.email = ""; this.props.search.phone = ""; this.props.search.branch_id = null; this.props.search.status = null; this.list(); }, list: function (page = 1) { this.loading.isActive = true; this.props.search.page = page; this.$store .dispatch("chef/lists", this.props.search) .then((res) => { this.loading.isActive = false; }) .catch((err) => { this.loading.isActive = false; }); }, edit: function (chef) { appService.sideDrawerShow(); this.loading.isActive = true; this.$store .dispatch("chef/edit", chef.id) .then((res) => { this.loading.isActive = false; this.props.errors = {}; this.props.form = { name: chef.name, email: chef.email, phone: chef.phone, password: chef.password, branch_id: chef.branch_id === 0 ? 0 : chef.branch_id, status: chef.status, country_code: this.country_code, }; }) .catch((err) => { alertService.error(err.response.data.message); }); }, destroy: function (id) { appService .destroyConfirmation() .then((res) => { try { this.loading.isActive = true; this.$store .dispatch("chef/destroy", { id: id, search: this.props.search, }) .then((res) => { this.loading.isActive = false; alertService.successFlip(null, this.$t("menu.chefs")); }) .catch((err) => { this.loading.isActive = false; alertService.error(err.response.data.message); }); } catch (err) { this.loading.isActive = false; alertService.error(err.response.data.message); } }) .catch((err) => { this.loading.isActive = false; }); }, xls: function () { this.loading.isActive = true; this.$store .dispatch("chef/export", this.props.search) .then((res) => { this.loading.isActive = false; const blob = new Blob([res.data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", }); const link = document.createElement("a"); link.href = URL.createObjectURL(blob); link.download = this.$t("menu.chefs"); link.click(); URL.revokeObjectURL(link.href); }) .catch((err) => { this.loading.isActive = false; alertService.error(err.response.data.message); }); }, }, }; </script> <style scoped> @media print { .hidden-print { display: none !important; } } </style>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.8 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002