mirror of
https://github.com/crater-invoice/crater.git
synced 2025-11-01 06:01:08 -04:00
build version 400
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,258 +1,322 @@
|
||||
<template>
|
||||
<div class="customer-create main-content">
|
||||
<div class="page-header">
|
||||
<h3 class="page-title">{{ $t('customers.title') }}</h3>
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<router-link
|
||||
slot="item-title"
|
||||
to="dashboard">
|
||||
{{ $t('general.home') }}
|
||||
</router-link>
|
||||
</li>
|
||||
<li class="breadcrumb-item">
|
||||
<router-link
|
||||
slot="item-title"
|
||||
to="#">
|
||||
{{ $tc('customers.customer',2) }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ol>
|
||||
<div class="page-actions row">
|
||||
<div class="col-xs-2 mr-4">
|
||||
<base-button
|
||||
v-show="totalCustomers || filtersApplied"
|
||||
:outline="true"
|
||||
:icon="filterIcon"
|
||||
size="large"
|
||||
color="theme"
|
||||
right-icon
|
||||
@click="toggleFilter"
|
||||
>
|
||||
{{ $t('general.filter') }}
|
||||
</base-button>
|
||||
</div>
|
||||
<router-link slot="item-title" class="col-xs-2" to="customers/create">
|
||||
<base-button
|
||||
size="large"
|
||||
icon="plus"
|
||||
color="theme">
|
||||
{{ $t('customers.new_customer') }}
|
||||
</base-button>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<base-page class="customer-create">
|
||||
<sw-page-header :title="$t('customers.title')">
|
||||
<sw-breadcrumb slot="breadcrumbs">
|
||||
<sw-breadcrumb-item to="dashboard" :title="$t('general.home')" />
|
||||
<sw-breadcrumb-item
|
||||
to="#"
|
||||
:title="$tc('customers.customer', 2)"
|
||||
active
|
||||
/>
|
||||
</sw-breadcrumb>
|
||||
|
||||
<transition name="fade">
|
||||
<div v-show="showFilters" class="filter-section">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<label class="form-label">{{ $t('customers.display_name') }}</label>
|
||||
<base-input
|
||||
v-model="filters.display_name"
|
||||
type="text"
|
||||
name="name"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<label class="form-label">{{ $t('customers.contact_name') }}</label>
|
||||
<base-input
|
||||
v-model="filters.contact_name"
|
||||
type="text"
|
||||
name="address_name"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<label class="form-label">{{ $t('customers.phone') }}</label>
|
||||
<base-input
|
||||
v-model="filters.phone"
|
||||
type="text"
|
||||
name="phone"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
<label class="clear-filter" @click="clearFilter">{{ $t('general.clear_all') }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<div v-cloak v-show="showEmptyScreen" class="col-xs-1 no-data-info" align="center">
|
||||
<astronaut-icon class="mt-5 mb-4"/>
|
||||
<div class="row" align="center">
|
||||
<label class="col title">{{ $t('customers.no_customers') }}</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="description col mt-1" align="center">{{ $t('customers.list_of_customers') }}</label>
|
||||
</div>
|
||||
<div class="btn-container">
|
||||
<base-button
|
||||
:outline="true"
|
||||
color="theme"
|
||||
class="mt-3"
|
||||
size="large"
|
||||
@click="$router.push('customers/create')"
|
||||
<template slot="actions">
|
||||
<sw-button
|
||||
v-show="totalCustomers"
|
||||
size="lg"
|
||||
variant="primary-outline"
|
||||
@click="toggleFilter"
|
||||
>
|
||||
{{ $t('customers.add_new_customer') }}
|
||||
</base-button>
|
||||
</div>
|
||||
</div>
|
||||
{{ $t('general.filter') }}
|
||||
<component :is="filterIcon" class="h-4 ml-1 -mr-1 font-bold" />
|
||||
</sw-button>
|
||||
|
||||
<div v-show="!showEmptyScreen" class="table-container">
|
||||
<div class="table-actions mt-5">
|
||||
<p class="table-stats">{{ $t('general.showing') }}: <b>{{ customers.length }}</b> {{ $t('general.of') }} <b>{{ totalCustomers }}</b></p>
|
||||
<sw-button
|
||||
tag-name="router-link"
|
||||
to="customers/create"
|
||||
size="lg"
|
||||
variant="primary"
|
||||
class="ml-4"
|
||||
>
|
||||
<plus-sm-icon class="h-6 mr-1 -ml-2 font-bold" />
|
||||
{{ $t('customers.new_customer') }}
|
||||
</sw-button>
|
||||
</template>
|
||||
</sw-page-header>
|
||||
|
||||
<transition name="fade">
|
||||
<v-dropdown v-if="selectedCustomers.length" :show-arrow="false">
|
||||
<span slot="activator" href="#" class="table-actions-button dropdown-toggle">
|
||||
<slide-y-up-transition>
|
||||
<sw-filter-wrapper v-show="showFilters">
|
||||
<sw-input-group
|
||||
:label="$t('customers.display_name')"
|
||||
class="flex-1 mt-2"
|
||||
>
|
||||
<sw-input
|
||||
v-model="filters.display_name"
|
||||
type="text"
|
||||
name="name"
|
||||
class="mt-2"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</sw-input-group>
|
||||
|
||||
<sw-input-group
|
||||
:label="$t('customers.contact_name')"
|
||||
class="flex-1 mt-2 ml-0 lg:ml-6"
|
||||
>
|
||||
<sw-input
|
||||
v-model="filters.contact_name"
|
||||
type="text"
|
||||
name="address_name"
|
||||
class="mt-2"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</sw-input-group>
|
||||
|
||||
<sw-input-group
|
||||
:label="$t('customers.phone')"
|
||||
class="flex-1 mt-2 ml-0 lg:ml-6"
|
||||
>
|
||||
<sw-input
|
||||
v-model="filters.phone"
|
||||
type="text"
|
||||
name="phone"
|
||||
class="mt-2"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</sw-input-group>
|
||||
|
||||
<label
|
||||
class="absolute text-sm leading-snug text-black cursor-pointer"
|
||||
style="top: 10px; right: 15px"
|
||||
@click="clearFilter"
|
||||
>{{ $t('general.clear_all') }}</label
|
||||
>
|
||||
</sw-filter-wrapper>
|
||||
</slide-y-up-transition>
|
||||
|
||||
<sw-empty-table-placeholder
|
||||
v-show="showEmptyScreen"
|
||||
:title="$t('customers.no_customers')"
|
||||
:description="$t('customers.list_of_customers')"
|
||||
>
|
||||
<astronaut-icon class="mt-5 mb-4" />
|
||||
|
||||
<sw-button
|
||||
slot="actions"
|
||||
tag-name="router-link"
|
||||
to="/admin/customers/create"
|
||||
size="lg"
|
||||
variant="primary-outline"
|
||||
>
|
||||
{{ $t('customers.add_new_customer') }}
|
||||
</sw-button>
|
||||
</sw-empty-table-placeholder>
|
||||
|
||||
<div v-show="!showEmptyScreen" class="relative table-container">
|
||||
<div
|
||||
class="relative flex items-center justify-between h-10 mt-5 border-b-2 border-gray-200 border-solid"
|
||||
>
|
||||
<p class="text-sm">
|
||||
{{ $t('general.showing') }}: <b>{{ customers.length }}</b>
|
||||
{{ $t('general.of') }} <b>{{ totalCustomers }}</b>
|
||||
</p>
|
||||
|
||||
<sw-transition type="fade">
|
||||
<sw-dropdown v-if="selectedCustomers.length">
|
||||
<span
|
||||
slot="activator"
|
||||
class="flex block text-sm font-medium cursor-pointer select-none text-primary-400"
|
||||
>
|
||||
{{ $t('general.actions') }}
|
||||
<chevron-down-icon class="h-5" />
|
||||
</span>
|
||||
<v-dropdown-item>
|
||||
<div class="dropdown-item" @click="removeMultipleCustomers">
|
||||
<font-awesome-icon :icon="['fas', 'trash']" class="dropdown-item-icon" />
|
||||
{{ $t('general.delete') }}
|
||||
</div>
|
||||
</v-dropdown-item>
|
||||
</v-dropdown>
|
||||
</transition>
|
||||
|
||||
<sw-dropdown-item @click="removeMultipleCustomers">
|
||||
<trash-icon class="h-5 mr-3 text-gray-600" />
|
||||
{{ $t('general.delete') }}
|
||||
</sw-dropdown-item>
|
||||
</sw-dropdown>
|
||||
</sw-transition>
|
||||
</div>
|
||||
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input
|
||||
id="select-all"
|
||||
<div class="absolute z-10 items-center pl-4 mt-2 select-none md:mt-12">
|
||||
<sw-checkbox
|
||||
v-model="selectAllFieldStatus"
|
||||
type="checkbox"
|
||||
class="custom-control-input"
|
||||
variant="primary"
|
||||
size="sm"
|
||||
class="hidden md:inline"
|
||||
@change="selectAllCustomers"
|
||||
>
|
||||
<label for="select-all" class="custom-control-label selectall">
|
||||
<span class="select-all-label">{{ $t('general.select_all') }} </span>
|
||||
</label>
|
||||
/>
|
||||
|
||||
<sw-checkbox
|
||||
v-model="selectAllFieldStatus"
|
||||
:label="$t('general.select_all')"
|
||||
variant="primary"
|
||||
size="sm"
|
||||
class="md:hidden"
|
||||
@change="selectAllCustomers"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<table-component
|
||||
<sw-table-component
|
||||
ref="table"
|
||||
:show-filter="false"
|
||||
:data="fetchData"
|
||||
table-class="table"
|
||||
>
|
||||
<table-column
|
||||
<sw-table-column
|
||||
:sortable="false"
|
||||
:filterable="false"
|
||||
cell-class="no-click"
|
||||
>
|
||||
<template slot-scope="row">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input
|
||||
:id="row.id"
|
||||
v-model="selectField"
|
||||
:value="row.id"
|
||||
type="checkbox"
|
||||
class="custom-control-input"
|
||||
>
|
||||
<label :for="row.id" class="custom-control-label" />
|
||||
</div>
|
||||
</template>
|
||||
</table-column>
|
||||
<table-column
|
||||
<div class="relative block" slot-scope="row">
|
||||
<sw-checkbox
|
||||
:id="row.id"
|
||||
v-model="selectField"
|
||||
:value="row.id"
|
||||
variant="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
</sw-table-column>
|
||||
|
||||
<sw-table-column
|
||||
:sortable="true"
|
||||
:filterable="true"
|
||||
:label="$t('customers.display_name')"
|
||||
show="name"
|
||||
/>
|
||||
<table-column
|
||||
>
|
||||
<template slot-scope="row">
|
||||
<span>{{ $t('customers.display_name') }}</span>
|
||||
<router-link
|
||||
:to="{ path: `customers/${row.id}/view` }"
|
||||
class="font-medium text-primary-500"
|
||||
>
|
||||
{{ row.name }}
|
||||
</router-link>
|
||||
</template>
|
||||
</sw-table-column>
|
||||
|
||||
<sw-table-column
|
||||
:sortable="true"
|
||||
:label="$t('customers.contact_name')"
|
||||
show="contact_name"
|
||||
/>
|
||||
<table-column
|
||||
>
|
||||
<template slot-scope="row">
|
||||
<span>{{ $t('customers.contact_name') }}</span>
|
||||
<span>
|
||||
{{ row.contact_name ? row.contact_name : 'No Contact Name' }}
|
||||
</span>
|
||||
</template>
|
||||
</sw-table-column>
|
||||
|
||||
<sw-table-column
|
||||
:sortable="true"
|
||||
:label="$t('customers.phone')"
|
||||
show="phone"
|
||||
/>
|
||||
<table-column
|
||||
>
|
||||
<template slot-scope="row">
|
||||
<span>{{ $t('customers.phone') }}</span>
|
||||
<span>
|
||||
{{ row.phone ? row.phone : 'No Contact' }}
|
||||
</span>
|
||||
</template>
|
||||
</sw-table-column>
|
||||
|
||||
<sw-table-column
|
||||
:sortable="true"
|
||||
:label="$t('customers.amount_due')"
|
||||
show="due_amount"
|
||||
>
|
||||
<template slot-scope="row">
|
||||
<span> {{ $t('customers.amount_due') }} </span>
|
||||
<div v-html="$utils.formatMoney(row.due_amount, row.currency)"/>
|
||||
<div v-html="$utils.formatMoney(row.due_amount, row.currency)" />
|
||||
</template>
|
||||
</table-column>
|
||||
<table-column
|
||||
</sw-table-column>
|
||||
|
||||
<sw-table-column
|
||||
:sortable="true"
|
||||
:label="$t('customers.added_on')"
|
||||
sort-as="created_at"
|
||||
show="formattedCreatedAt"
|
||||
/>
|
||||
<table-column
|
||||
|
||||
<sw-table-column
|
||||
:sortable="false"
|
||||
:filterable="false"
|
||||
cell-class="action-dropdown"
|
||||
>
|
||||
<template slot-scope="row">
|
||||
<span> {{ $t('customers.action') }} </span>
|
||||
<v-dropdown>
|
||||
<a slot="activator" href="#">
|
||||
<dot-icon />
|
||||
</a>
|
||||
<v-dropdown-item>
|
||||
|
||||
<router-link :to="{path: `customers/${row.id}/edit`}" class="dropdown-item">
|
||||
<font-awesome-icon :icon="['fas', 'pencil-alt']" class="dropdown-item-icon"/>
|
||||
{{ $t('general.edit') }}
|
||||
</router-link>
|
||||
<sw-dropdown>
|
||||
<dot-icon slot="activator" />
|
||||
|
||||
</v-dropdown-item>
|
||||
<v-dropdown-item>
|
||||
<div class="dropdown-item" @click="removeCustomer(row.id)">
|
||||
<font-awesome-icon :icon="['fas', 'trash']" class="dropdown-item-icon" />
|
||||
{{ $t('general.delete') }}
|
||||
</div>
|
||||
</v-dropdown-item>
|
||||
</v-dropdown>
|
||||
<sw-dropdown-item
|
||||
tag-name="router-link"
|
||||
:to="`customers/${row.id}/edit`"
|
||||
>
|
||||
<pencil-icon class="h-5 mr-3 text-gray-600" />
|
||||
{{ $t('general.edit') }}
|
||||
</sw-dropdown-item>
|
||||
|
||||
<sw-dropdown-item
|
||||
tag-name="router-link"
|
||||
:to="`customers/${row.id}/view`"
|
||||
>
|
||||
<eye-icon class="h-5 mr-3 text-gray-600" />
|
||||
{{ $t('general.view') }}
|
||||
</sw-dropdown-item>
|
||||
|
||||
<sw-dropdown-item @click="removeCustomer(row.id)">
|
||||
<trash-icon class="h-5 mr-3 text-gray-600" />
|
||||
{{ $t('general.delete') }}
|
||||
</sw-dropdown-item>
|
||||
</sw-dropdown>
|
||||
</template>
|
||||
</table-column>
|
||||
</table-component>
|
||||
</sw-table-column>
|
||||
</sw-table-component>
|
||||
</div>
|
||||
</div>
|
||||
</base-page>
|
||||
</template>
|
||||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex'
|
||||
import { SweetModal, SweetModalTab } from 'sweet-modal-vue'
|
||||
import DotIcon from '../../components/icon/DotIcon'
|
||||
import { PlusSmIcon } from '@vue-hero-icons/solid'
|
||||
import {
|
||||
FilterIcon,
|
||||
XIcon,
|
||||
ChevronDownIcon,
|
||||
TrashIcon,
|
||||
PencilIcon,
|
||||
EyeIcon,
|
||||
} from '@vue-hero-icons/solid'
|
||||
import AstronautIcon from '../../components/icon/AstronautIcon'
|
||||
import BaseButton from '../../../js/components/base/BaseButton'
|
||||
import { request } from 'http'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
DotIcon,
|
||||
AstronautIcon,
|
||||
SweetModal,
|
||||
SweetModalTab,
|
||||
BaseButton
|
||||
ChevronDownIcon,
|
||||
PlusSmIcon,
|
||||
FilterIcon,
|
||||
XIcon,
|
||||
TrashIcon,
|
||||
PencilIcon,
|
||||
EyeIcon,
|
||||
},
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
showFilters: false,
|
||||
filtersApplied: false,
|
||||
isRequestOngoing: true,
|
||||
filters: {
|
||||
display_name: '',
|
||||
contact_name: '',
|
||||
phone: ''
|
||||
}
|
||||
phone: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
showEmptyScreen () {
|
||||
return !this.totalCustomers && !this.isRequestOngoing && !this.filtersApplied
|
||||
showEmptyScreen() {
|
||||
return !this.totalCustomers && !this.isRequestOngoing
|
||||
},
|
||||
filterIcon () {
|
||||
return (this.showFilters) ? 'times' : 'filter'
|
||||
filterIcon() {
|
||||
return this.showFilters ? 'x-icon' : 'filter-icon'
|
||||
},
|
||||
...mapGetters('customer', [
|
||||
'customers',
|
||||
'selectedCustomers',
|
||||
'totalCustomers',
|
||||
'selectAllField'
|
||||
'selectAllField',
|
||||
]),
|
||||
selectField: {
|
||||
get: function () {
|
||||
@ -260,7 +324,7 @@ export default {
|
||||
},
|
||||
set: function (val) {
|
||||
this.selectCustomer(val)
|
||||
}
|
||||
},
|
||||
},
|
||||
selectAllFieldStatus: {
|
||||
get: function () {
|
||||
@ -268,16 +332,16 @@ export default {
|
||||
},
|
||||
set: function (val) {
|
||||
this.setSelectAllState(val)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
filters: {
|
||||
handler: 'setFilters',
|
||||
deep: true
|
||||
}
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
destroyed () {
|
||||
destroyed() {
|
||||
if (this.selectAllField) {
|
||||
this.selectAllCustomers()
|
||||
}
|
||||
@ -289,19 +353,19 @@ export default {
|
||||
'selectCustomer',
|
||||
'deleteCustomer',
|
||||
'deleteMultipleCustomers',
|
||||
'setSelectAllState'
|
||||
'setSelectAllState',
|
||||
]),
|
||||
refreshTable () {
|
||||
refreshTable() {
|
||||
this.$refs.table.refresh()
|
||||
},
|
||||
async fetchData ({ page, filter, sort }) {
|
||||
async fetchData({ page, filter, sort }) {
|
||||
let data = {
|
||||
display_name: this.filters.display_name,
|
||||
contact_name: this.filters.contact_name,
|
||||
phone: this.filters.phone,
|
||||
orderByField: sort.fieldName || 'created_at',
|
||||
orderBy: sort.order || 'desc',
|
||||
page
|
||||
page,
|
||||
}
|
||||
|
||||
this.isRequestOngoing = true
|
||||
@ -312,60 +376,58 @@ export default {
|
||||
data: response.data.customers.data,
|
||||
pagination: {
|
||||
totalPages: response.data.customers.last_page,
|
||||
currentPage: page
|
||||
}
|
||||
currentPage: page,
|
||||
},
|
||||
}
|
||||
},
|
||||
setFilters () {
|
||||
this.filtersApplied = true
|
||||
setFilters() {
|
||||
this.refreshTable()
|
||||
},
|
||||
clearFilter () {
|
||||
clearFilter() {
|
||||
this.filters = {
|
||||
display_name: '',
|
||||
contact_name: '',
|
||||
phone: ''
|
||||
phone: '',
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.filtersApplied = false
|
||||
})
|
||||
},
|
||||
toggleFilter () {
|
||||
if (this.showFilters && this.filtersApplied) {
|
||||
toggleFilter() {
|
||||
if (this.showFilters) {
|
||||
this.clearFilter()
|
||||
this.refreshTable()
|
||||
}
|
||||
|
||||
this.showFilters = !this.showFilters
|
||||
},
|
||||
async removeCustomer (id) {
|
||||
|
||||
async removeCustomer(id) {
|
||||
swal({
|
||||
title: this.$t('general.are_you_sure'),
|
||||
text: this.$tc('customers.confirm_delete'),
|
||||
icon: '/assets/icon/trash-solid.svg',
|
||||
buttons: true,
|
||||
dangerMode: true
|
||||
dangerMode: true,
|
||||
}).then(async (willDelete) => {
|
||||
if (willDelete) {
|
||||
let res = await this.deleteCustomer(id)
|
||||
let res = await this.deleteCustomer({ ids: [id] })
|
||||
|
||||
if (res.data.success) {
|
||||
window.toastr['success'](this.$tc('customers.deleted_message'))
|
||||
this.refreshTable()
|
||||
window.toastr['success'](this.$tc('customers.deleted_message', 1))
|
||||
this.$refs.table.refresh()
|
||||
return true
|
||||
} else if (request.data.error) {
|
||||
window.toastr['error'](res.data.message)
|
||||
}
|
||||
|
||||
window.toastr['error'](res.data.message)
|
||||
return true
|
||||
}
|
||||
})
|
||||
},
|
||||
async removeMultipleCustomers () {
|
||||
|
||||
async removeMultipleCustomers() {
|
||||
swal({
|
||||
title: this.$t('general.are_you_sure'),
|
||||
text: this.$tc('customers.confirm_delete', 2),
|
||||
icon: '/assets/icon/trash-solid.svg',
|
||||
buttons: true,
|
||||
dangerMode: true
|
||||
dangerMode: true,
|
||||
}).then(async (willDelete) => {
|
||||
if (willDelete) {
|
||||
let request = await this.deleteMultipleCustomers()
|
||||
@ -377,7 +439,7 @@ export default {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
140
resources/assets/js/views/customers/View.vue
Normal file
140
resources/assets/js/views/customers/View.vue
Normal file
@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<base-page class="xl:pl-96">
|
||||
<sw-page-header :title="pageTitle">
|
||||
<template slot="actions">
|
||||
<sw-button
|
||||
tag-name="router-link"
|
||||
:to="`/admin/customers/${$route.params.id}/edit`"
|
||||
class="mr-3"
|
||||
variant="primary-outline"
|
||||
>
|
||||
{{ $t('general.edit') }}
|
||||
</sw-button>
|
||||
<sw-dropdown position="bottom-end">
|
||||
<sw-button slot="activator" class="mr-3" variant="primary">
|
||||
{{ $t('customers.new_transaction') }}
|
||||
</sw-button>
|
||||
<sw-dropdown-item
|
||||
tag-name="router-link"
|
||||
:to="`/admin/estimates/create?customer=${$route.params.id}`"
|
||||
>
|
||||
<document-icon class="h-5 mr-3 text-gray-600" />
|
||||
{{ $t('estimates.new_estimate') }}
|
||||
</sw-dropdown-item>
|
||||
<sw-dropdown-item
|
||||
tag-name="router-link"
|
||||
:to="`/admin/invoices/create?customer=${$route.params.id}`"
|
||||
>
|
||||
<document-text-icon class="h-5 mr-3 text-gray-600" />
|
||||
{{ $t('invoices.new_invoice') }}
|
||||
</sw-dropdown-item>
|
||||
<sw-dropdown-item
|
||||
tag-name="router-link"
|
||||
:to="`/admin/payments/create?customer=${$route.params.id}`"
|
||||
>
|
||||
<credit-card-icon class="h-5 mr-3 text-gray-600" />
|
||||
{{ $t('payments.new_payment') }}
|
||||
</sw-dropdown-item>
|
||||
<sw-dropdown-item
|
||||
tag-name="router-link"
|
||||
:to="`/admin/expenses/create?customer=${$route.params.id}`"
|
||||
>
|
||||
<calculator-icon class="h-5 mr-3 text-gray-600" />
|
||||
{{ $t('expenses.new_expense') }}
|
||||
</sw-dropdown-item>
|
||||
</sw-dropdown>
|
||||
<sw-dropdown>
|
||||
<sw-button slot="activator" variant="primary">
|
||||
<dots-horizontal-icon class="h-5 -ml-1 -mr-1" />
|
||||
</sw-button>
|
||||
|
||||
<sw-dropdown-item @click="removeCustomer($route.params.id)">
|
||||
<trash-icon class="h-5 mr-3 text-gray-600" />
|
||||
{{ $t('general.delete') }}
|
||||
</sw-dropdown-item>
|
||||
</sw-dropdown>
|
||||
</template>
|
||||
</sw-page-header>
|
||||
|
||||
<!-- sidebar -->
|
||||
<customer-view-sidebar />
|
||||
|
||||
<!-- Chart -->
|
||||
<customer-chart />
|
||||
</base-page>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
DotsHorizontalIcon,
|
||||
TrashIcon,
|
||||
DocumentIcon,
|
||||
DocumentTextIcon,
|
||||
CreditCardIcon,
|
||||
CalculatorIcon,
|
||||
} from '@vue-hero-icons/solid'
|
||||
import LineChart from '../../components/chartjs/LineChart'
|
||||
import CustomerViewSidebar from './partials/CustomerViewSidebar'
|
||||
import CustomerChart from './partials/CustomerChart'
|
||||
import { mapActions, mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
LineChart,
|
||||
DotsHorizontalIcon,
|
||||
CustomerViewSidebar,
|
||||
DocumentIcon,
|
||||
DocumentTextIcon,
|
||||
CreditCardIcon,
|
||||
CalculatorIcon,
|
||||
CustomerChart,
|
||||
TrashIcon,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
customer: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('customer', ['selectedViewCustomer']),
|
||||
pageTitle() {
|
||||
return this.selectedViewCustomer.customer
|
||||
? this.selectedViewCustomer.customer.name
|
||||
: ''
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.fetchViewCustomer({ id: this.$route.params.id })
|
||||
},
|
||||
methods: {
|
||||
...mapActions('customer', [
|
||||
'fetchViewCustomer',
|
||||
'selectCustomer',
|
||||
'deleteMultipleCustomers',
|
||||
]),
|
||||
|
||||
async removeCustomer(id) {
|
||||
swal({
|
||||
title: this.$t('general.are_you_sure'),
|
||||
text: this.$tc('customers.confirm_delete'),
|
||||
icon: '/assets/icon/trash-solid.svg',
|
||||
buttons: true,
|
||||
dangerMode: true,
|
||||
}).then(async (willDelete) => {
|
||||
if (willDelete) {
|
||||
let data = [id]
|
||||
this.selectCustomer(data)
|
||||
let res = await this.deleteMultipleCustomers()
|
||||
if (res.data.success) {
|
||||
window.toastr['success'](this.$tc('customers.deleted_message'))
|
||||
this.$router.push('/admin/customers')
|
||||
return true
|
||||
} else if (request.data.error) {
|
||||
window.toastr['error'](res.data.message)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
219
resources/assets/js/views/customers/partials/CustomerChart.vue
Normal file
219
resources/assets/js/views/customers/partials/CustomerChart.vue
Normal file
@ -0,0 +1,219 @@
|
||||
<template>
|
||||
<sw-card v-if="chartData" class="flex flex-col mt-6">
|
||||
<div class="grid grid-cols-12">
|
||||
<div class="col-span-12 xl:col-span-9 xxl:col-span-10">
|
||||
<div class="flex justify-between mt-1 mb-6">
|
||||
<h6 class="flex items-center sw-section-title">
|
||||
<chart-square-bar-icon class="h-5 text-primary-400" />{{
|
||||
$t('dashboard.monthly_chart.title')
|
||||
}}
|
||||
</h6>
|
||||
<div class="w-40 h-10">
|
||||
<sw-select
|
||||
v-model="selectedYear"
|
||||
:options="years"
|
||||
:allow-empty="false"
|
||||
:show-labels="false"
|
||||
:placeholder="$t('dashboard.select_year')"
|
||||
@select="onChangeYear"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<line-chart
|
||||
:format-money="$utils.formatMoney"
|
||||
:format-graph-money="$utils.formatGraphMoney"
|
||||
:invoices="getChartInvoices"
|
||||
:expenses="getChartExpenses"
|
||||
:receipts="getReceiptTotals"
|
||||
:income="getNetProfits"
|
||||
:labels="getChartMonths"
|
||||
class="sm:w-full"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="grid col-span-12 mt-6 text-center xl:mt-0 sm:grid-cols-4 xl:text-right xl:col-span-3 xl:grid-cols-1 xxl:col-span-2"
|
||||
>
|
||||
<div class="px-6 py-2">
|
||||
<span class="text-xs leading-5 lg:text-sm">
|
||||
{{ $t('dashboard.chart_info.total_sales') }}
|
||||
</span>
|
||||
<br />
|
||||
<span class="block mt-1 text-xl font-semibold leading-8">
|
||||
<div v-html="getFormattedSalesTotal" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="px-6 py-2">
|
||||
<span class="text-xs leading-5 lg:text-sm">
|
||||
{{ $t('dashboard.chart_info.total_receipts') }}
|
||||
</span>
|
||||
<br />
|
||||
<span
|
||||
class="block mt-1 text-xl font-semibold leading-8"
|
||||
style="color: #00c99c"
|
||||
>
|
||||
<div v-html="getFormattedTotalReceipts" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="px-6 py-2">
|
||||
<span class="text-xs leading-5 lg:text-sm">
|
||||
{{ $t('dashboard.chart_info.total_expense') }}
|
||||
</span>
|
||||
<br />
|
||||
<span
|
||||
class="block mt-1 text-xl font-semibold leading-8"
|
||||
style="color: #fb7178"
|
||||
>
|
||||
<div v-html="getFormattedTotalExpenses" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="px-6 py-2">
|
||||
<span class="text-xs leading-5 lg:text-sm">
|
||||
{{ $t('dashboard.chart_info.net_income') }}
|
||||
</span>
|
||||
<br />
|
||||
<span
|
||||
class="block mt-1 text-xl font-semibold leading-8"
|
||||
style="color: #5851d8"
|
||||
>
|
||||
<div v-html="getFormattedTotalNetProfit" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- basic info -->
|
||||
<customer-info />
|
||||
</sw-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CustomerInfo from './CustomerInfo'
|
||||
import LineChart from '../../../components/chartjs/LineChart'
|
||||
import { mapActions, mapGetters } from 'vuex'
|
||||
import { ChartSquareBarIcon } from '@vue-hero-icons/outline'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
LineChart,
|
||||
CustomerInfo,
|
||||
ChartSquareBarIcon,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
id: null,
|
||||
customers: [],
|
||||
isLoaded: false,
|
||||
chartData: null,
|
||||
years: ['This year', 'Previous year'],
|
||||
selectedYear: 'This year',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('company', ['defaultCurrency']),
|
||||
getChartInvoices() {
|
||||
if (this.chartData && this.chartData.invoiceTotals) {
|
||||
return this.chartData.invoiceTotals
|
||||
}
|
||||
return []
|
||||
},
|
||||
getChartExpenses() {
|
||||
if (this.chartData && this.chartData.expenseTotals) {
|
||||
return this.chartData.expenseTotals
|
||||
}
|
||||
return []
|
||||
},
|
||||
getReceiptTotals() {
|
||||
if (this.chartData && this.chartData.receiptTotals) {
|
||||
return this.chartData.receiptTotals
|
||||
}
|
||||
return []
|
||||
},
|
||||
getNetProfits() {
|
||||
if (this.chartData && this.chartData.netProfits) {
|
||||
return this.chartData.netProfits
|
||||
}
|
||||
return []
|
||||
},
|
||||
getChartMonths() {
|
||||
if (this.chartData && this.chartData.months) {
|
||||
return this.chartData.months
|
||||
}
|
||||
return []
|
||||
},
|
||||
getFormattedSalesTotal() {
|
||||
if (this.chartData && this.chartData.salesTotal) {
|
||||
return this.$utils.formatMoney(
|
||||
this.chartData.salesTotal,
|
||||
this.defaultCurrency
|
||||
)
|
||||
}
|
||||
return 0
|
||||
},
|
||||
getFormattedTotalReceipts() {
|
||||
if (this.chartData && this.chartData.totalReceipts) {
|
||||
return this.$utils.formatMoney(
|
||||
this.chartData.totalReceipts,
|
||||
this.defaultCurrency
|
||||
)
|
||||
}
|
||||
return 0
|
||||
},
|
||||
getFormattedTotalExpenses() {
|
||||
if (this.chartData && this.chartData.totalExpenses) {
|
||||
return this.$utils.formatMoney(
|
||||
this.chartData.totalExpenses,
|
||||
this.defaultCurrency
|
||||
)
|
||||
}
|
||||
return 0
|
||||
},
|
||||
getFormattedTotalNetProfit() {
|
||||
if (this.chartData && this.chartData.netProfit) {
|
||||
return this.$utils.formatMoney(
|
||||
this.chartData.netProfit,
|
||||
this.defaultCurrency
|
||||
)
|
||||
}
|
||||
return 0
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
$route(to, from) {
|
||||
this.loadCustomer()
|
||||
this.selectedYear = 'This year'
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.loadCustomer()
|
||||
},
|
||||
methods: {
|
||||
...mapActions('customer', ['fetchViewCustomer']),
|
||||
|
||||
async loadCustomer() {
|
||||
this.isLoaded = false
|
||||
let response = await this.fetchViewCustomer({ id: this.$route.params.id })
|
||||
if (response.data) {
|
||||
this.chartData = response.data.chartData
|
||||
}
|
||||
this.isLoaded = false
|
||||
},
|
||||
async onChangeYear(data) {
|
||||
if (data == 'Previous year') {
|
||||
let response = await this.fetchViewCustomer({
|
||||
id: this.$route.params.id,
|
||||
previous_year: true,
|
||||
})
|
||||
if (response.data) {
|
||||
this.chartData = response.data.chartData
|
||||
}
|
||||
return true
|
||||
}
|
||||
let response = await this.fetchViewCustomer({ id: this.$route.params.id })
|
||||
if (response.data) {
|
||||
this.chartData = response.data.chartData
|
||||
}
|
||||
return true
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
273
resources/assets/js/views/customers/partials/CustomerInfo.vue
Normal file
273
resources/assets/js/views/customers/partials/CustomerInfo.vue
Normal file
@ -0,0 +1,273 @@
|
||||
<template>
|
||||
<div
|
||||
class="pt-6 mt-5 border-t-2 border-solid lg:pt-8 md:pt-4"
|
||||
style="border-top-color: #f9fbff"
|
||||
>
|
||||
<div class="col-span-12">
|
||||
<p class="text-gray-500 uppercase sw-section-title">
|
||||
{{ $t('customers.basic_info') }}
|
||||
</p>
|
||||
<div
|
||||
class="grid grid-cols-1 gap-4 mt-5 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1"
|
||||
>
|
||||
<div>
|
||||
<p
|
||||
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
|
||||
>
|
||||
{{ $t('customers.display_name') }}
|
||||
</p>
|
||||
<p class="text-sm font-bold leading-5 text-black non-italic">
|
||||
{{
|
||||
selectedViewCustomer.customer &&
|
||||
selectedViewCustomer.customer.name
|
||||
? selectedViewCustomer.customer.name
|
||||
: ''
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p
|
||||
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
|
||||
>
|
||||
{{ $t('customers.primary_contact_name') }}
|
||||
</p>
|
||||
<p class="text-sm font-bold leading-5 text-black non-italic">
|
||||
{{
|
||||
selectedViewCustomer.customer &&
|
||||
selectedViewCustomer.customer.contact_name
|
||||
? selectedViewCustomer.customer.contact_name
|
||||
: ''
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p
|
||||
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
|
||||
>
|
||||
{{ $t('customers.email') }}
|
||||
</p>
|
||||
<p class="text-sm font-bold leading-5 text-black non-italic">
|
||||
{{
|
||||
selectedViewCustomer.customer &&
|
||||
selectedViewCustomer.customer.email
|
||||
? selectedViewCustomer.customer.email
|
||||
: ''
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="grid grid-cols-1 gap-4 mt-5 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1"
|
||||
>
|
||||
<div>
|
||||
<p
|
||||
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
|
||||
>
|
||||
{{ $t('wizard.currency') }}
|
||||
</p>
|
||||
<p class="text-sm font-bold leading-5 text-black non-italic">
|
||||
{{
|
||||
selectedViewCustomer.customer.currency
|
||||
? `${selectedViewCustomer.customer.currency.code} (${selectedViewCustomer.customer.currency.symbol})`
|
||||
: ''
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p
|
||||
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
|
||||
>
|
||||
{{ $t('customers.phone_number') }}
|
||||
</p>
|
||||
<p class="text-sm font-bold leading-5 text-black non-italic">
|
||||
{{
|
||||
selectedViewCustomer.customer &&
|
||||
selectedViewCustomer.customer.phone
|
||||
? selectedViewCustomer.customer.phone
|
||||
: ''
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<p
|
||||
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
|
||||
>
|
||||
{{ $t('customers.website') }}
|
||||
</p>
|
||||
<p class="text-sm font-bold leading-5 text-black non-italic">
|
||||
{{
|
||||
selectedViewCustomer.customer &&
|
||||
selectedViewCustomer.customer.website
|
||||
? selectedViewCustomer.customer.website
|
||||
: ''
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="
|
||||
getFormattedShippingAddress.length ||
|
||||
getFormattedBillingAddress.length
|
||||
"
|
||||
class="mt-8 text-gray-500 uppercase sw-section-title"
|
||||
>
|
||||
{{ $t('customers.address') }}
|
||||
</p>
|
||||
<div
|
||||
class="grid grid-cols-1 gap-4 md:grid-cols-2 sm:grid-cols-1 lg:grid-cols-2"
|
||||
>
|
||||
<div v-if="getFormattedBillingAddress.length" class="mt-5">
|
||||
<p
|
||||
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
|
||||
>
|
||||
{{ $t('customers.billing_address') }}
|
||||
</p>
|
||||
<p
|
||||
class="text-sm font-bold leading-5 text-black non-italic"
|
||||
v-html="getFormattedBillingAddress"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="getFormattedShippingAddress.length" class="mt-5">
|
||||
<p
|
||||
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
|
||||
>
|
||||
{{ $t('customers.shipping_address') }}
|
||||
</p>
|
||||
<p
|
||||
class="text-sm font-bold leading-5 text-black non-italic"
|
||||
v-html="getFormattedShippingAddress"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Custom Fields -->
|
||||
<p
|
||||
v-if="getCustomField.length > 0"
|
||||
class="mt-8 text-gray-500 uppercase sw-section-title"
|
||||
>
|
||||
{{ $t('settings.custom_fields.title') }}
|
||||
</p>
|
||||
|
||||
<div
|
||||
class="grid grid-cols-1 gap-4 mt-5 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1"
|
||||
>
|
||||
<div
|
||||
v-for="(field, index) in getCustomField"
|
||||
:key="index"
|
||||
:required="field.is_required ? true : false"
|
||||
>
|
||||
<p
|
||||
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
|
||||
>
|
||||
{{ field.custom_field.label }}
|
||||
</p>
|
||||
<p
|
||||
v-if="field.type === 'Switch'"
|
||||
class="text-sm font-bold leading-5 text-black non-italic"
|
||||
>
|
||||
<span v-if="field.defaultAnswer === 1"> Yes </span>
|
||||
<span v-else> No </span>
|
||||
</p>
|
||||
<p v-else class="text-sm font-bold leading-5 text-black non-italic">
|
||||
{{ field.defaultAnswer }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
customer: null,
|
||||
customFields: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
getFormattedBillingAddress() {
|
||||
let billingAddress = ``
|
||||
|
||||
if (!this.selectedViewCustomer.customer) {
|
||||
return billingAddress
|
||||
}
|
||||
|
||||
if (!this.selectedViewCustomer.customer.billing_address) {
|
||||
return billingAddress
|
||||
}
|
||||
|
||||
if (this.selectedViewCustomer.customer.billing_address.address_street_1) {
|
||||
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.address_street_1},</span><br>`
|
||||
}
|
||||
if (this.selectedViewCustomer.customer.billing_address.address_street_2) {
|
||||
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.address_street_2},</span><br>`
|
||||
}
|
||||
if (this.selectedViewCustomer.customer.billing_address.city) {
|
||||
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.city},</span> `
|
||||
}
|
||||
if (this.selectedViewCustomer.customer.billing_address.state) {
|
||||
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.state},</span><br>`
|
||||
}
|
||||
if (this.selectedViewCustomer.customer.billing_address.country) {
|
||||
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.country.name}.</span> `
|
||||
}
|
||||
if (this.selectedViewCustomer.customer.billing_address.zip) {
|
||||
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.zip}.</span> `
|
||||
}
|
||||
return billingAddress
|
||||
},
|
||||
getFormattedShippingAddress() {
|
||||
let shippingAddress = ``
|
||||
|
||||
if (!this.selectedViewCustomer.customer) {
|
||||
return shippingAddress
|
||||
}
|
||||
|
||||
if (!this.selectedViewCustomer.customer.shipping_address) {
|
||||
return shippingAddress
|
||||
}
|
||||
|
||||
if (
|
||||
this.selectedViewCustomer.customer.shipping_address.address_street_1
|
||||
) {
|
||||
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.address_street_1},</span><br>`
|
||||
}
|
||||
if (
|
||||
this.selectedViewCustomer.customer.shipping_address.address_street_2
|
||||
) {
|
||||
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.address_street_2},</span><br>`
|
||||
}
|
||||
if (this.selectedViewCustomer.customer.shipping_address.city) {
|
||||
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.city},</span> `
|
||||
}
|
||||
if (this.selectedViewCustomer.customer.shipping_address.state) {
|
||||
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.state},</span><br>`
|
||||
}
|
||||
if (this.selectedViewCustomer.customer.shipping_address.country) {
|
||||
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.country.name}.</span> `
|
||||
}
|
||||
if (this.selectedViewCustomer.customer.shipping_address.zip) {
|
||||
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.zip}.</span> `
|
||||
}
|
||||
return shippingAddress
|
||||
},
|
||||
|
||||
getCustomField() {
|
||||
if (this.selectedViewCustomer.customer.fields) {
|
||||
return this.selectedViewCustomer.customer.fields
|
||||
}
|
||||
return []
|
||||
},
|
||||
|
||||
...mapGetters('customer', ['selectedViewCustomer']),
|
||||
},
|
||||
watch: {
|
||||
$route(to, from) {
|
||||
this.customer = this.selectedViewCustomer
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@ -0,0 +1,273 @@
|
||||
<template>
|
||||
<div
|
||||
class="fixed top-0 left-0 hidden h-full pt-16 pb-4 ml-56 bg-white xl:ml-64 w-88 xl:block"
|
||||
>
|
||||
<div
|
||||
class="flex items-center justify-between px-4 pt-8 pb-2 border border-gray-200 border-solid height-full"
|
||||
>
|
||||
<sw-input
|
||||
v-model="searchData.searchText"
|
||||
:placeholder="$t('general.search')"
|
||||
class="mb-6"
|
||||
type="text"
|
||||
variant="gray"
|
||||
@input="onSearch()"
|
||||
>
|
||||
<search-icon slot="rightIcon" class="h-5" />
|
||||
</sw-input>
|
||||
|
||||
<div class="flex mb-6 ml-3" role="group" aria-label="First group">
|
||||
<sw-dropdown
|
||||
:close-on-select="false"
|
||||
align="left"
|
||||
position="bottom-start"
|
||||
>
|
||||
<sw-button slot="activator" size="md" variant="gray-light">
|
||||
<filter-icon class="h-5" />
|
||||
</sw-button>
|
||||
|
||||
<div
|
||||
class="px-2 py-1 pb-2 mb-2 text-sm border-b border-gray-200 border-solid"
|
||||
>
|
||||
{{ $t('general.sort_by') }}
|
||||
</div>
|
||||
|
||||
<sw-dropdown-item class="flex cursor-pointer">
|
||||
<sw-input-group class="-mt-3 font-normal">
|
||||
<sw-radio
|
||||
:label="$t('customers.create_date')"
|
||||
size="sm"
|
||||
id="filter_create_date"
|
||||
v-model="searchData.orderByField"
|
||||
name="filter"
|
||||
value="invoices.created_at"
|
||||
@change="onSearch"
|
||||
/>
|
||||
</sw-input-group>
|
||||
</sw-dropdown-item>
|
||||
|
||||
<sw-dropdown-item class="flex cursor-pointer">
|
||||
<sw-input-group class="-mt-3 font-normal">
|
||||
<sw-radio
|
||||
:label="$t('customers.display_name')"
|
||||
size="sm"
|
||||
id="filter_display_name"
|
||||
v-model="searchData.orderByField"
|
||||
name="filter"
|
||||
value="users.name"
|
||||
@change="onSearch"
|
||||
/>
|
||||
</sw-input-group>
|
||||
</sw-dropdown-item>
|
||||
</sw-dropdown>
|
||||
|
||||
<sw-button
|
||||
class="ml-1"
|
||||
v-tooltip.top-center="{ content: getOrderName }"
|
||||
size="md"
|
||||
variant="gray-light"
|
||||
@click="sortData"
|
||||
>
|
||||
<sort-ascending-icon v-if="getOrderBy" class="h-5" />
|
||||
<sort-descending-icon v-else class="h-5" />
|
||||
</sw-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<base-loader v-if="isSearching" :show-bg-overlay="true" />
|
||||
|
||||
<div
|
||||
v-else
|
||||
class="h-full pb-32 overflow-y-scroll border-l border-gray-200 border-solid sidebar sw-scroll"
|
||||
>
|
||||
<router-link
|
||||
v-for="(customer, index) in customers"
|
||||
:to="`/admin/customers/${customer.id}/view`"
|
||||
:key="index"
|
||||
:id="'customer-' + customer.id"
|
||||
:class="[
|
||||
'flex justify-between p-4 items-center cursor-pointer hover:bg-gray-100 border-l-4 border-transparent',
|
||||
{
|
||||
'bg-gray-100 border-l-4 border-primary-500 border-solid': hasActiveUrl(
|
||||
customer.id
|
||||
),
|
||||
},
|
||||
]"
|
||||
style="border-top: 1px solid rgba(185, 193, 209, 0.41)"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
class="pr-2 text-sm not-italic font-normal leading-5 text-black capitalize truncate"
|
||||
>
|
||||
{{ customer.name }}
|
||||
</div>
|
||||
<div
|
||||
class="mt-1 text-xs not-italic font-medium leading-5 text-gray-600"
|
||||
v-if="customer.contact_name"
|
||||
>
|
||||
{{ customer.contact_name }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-1 whitespace-no-wrap right">
|
||||
<div
|
||||
class="text-xl not-italic font-semibold leading-8 text-right text-gray-900"
|
||||
v-html="$utils.formatMoney(customer.due_amount, customer.currency)"
|
||||
/>
|
||||
</div>
|
||||
</router-link>
|
||||
<p
|
||||
v-if="!customers.length"
|
||||
class="flex justify-center px-4 mt-5 text-sm text-gray-600"
|
||||
>
|
||||
{{ $t('customers.no_matching_customers') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
FilterIcon,
|
||||
SortAscendingIcon,
|
||||
SortDescendingIcon,
|
||||
SearchIcon,
|
||||
} from '@vue-hero-icons/solid'
|
||||
import { mapActions, mapGetters } from 'vuex'
|
||||
const _ = require('lodash')
|
||||
|
||||
export default {
|
||||
components: {
|
||||
FilterIcon,
|
||||
SortAscendingIcon,
|
||||
SortDescendingIcon,
|
||||
SearchIcon,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
id: null,
|
||||
customers: [],
|
||||
customer: null,
|
||||
currency: null,
|
||||
searchData: {
|
||||
orderBy: null,
|
||||
orderByField: null,
|
||||
searchText: null,
|
||||
},
|
||||
isSearching: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
getOrderBy() {
|
||||
if (
|
||||
this.searchData.orderBy === 'asc' ||
|
||||
this.searchData.orderBy == null
|
||||
) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
getOrderName() {
|
||||
if (this.getOrderBy) {
|
||||
return this.$t('general.ascending')
|
||||
}
|
||||
return this.$t('general.descending')
|
||||
},
|
||||
...mapGetters('company', ['defaultCurrency']),
|
||||
|
||||
...mapGetters('customer', ['selectedViewCustomer']),
|
||||
},
|
||||
|
||||
watch: {
|
||||
$route(to, from) {
|
||||
this.loadCustomer()
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
this.loadCustomers()
|
||||
this.loadCustomer()
|
||||
this.onSearch = _.debounce(this.onSearch, 500)
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapActions('customer', ['fetchCustomers']),
|
||||
|
||||
hasActiveUrl(id) {
|
||||
return this.$route.params.id == id
|
||||
},
|
||||
|
||||
async loadCustomers() {
|
||||
let response = await this.fetchCustomers({
|
||||
limit: 'all',
|
||||
})
|
||||
|
||||
if (response.data.customers) {
|
||||
this.customers = response.data.customers.data
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.scrollToCustomer()
|
||||
}, 500)
|
||||
},
|
||||
|
||||
scrollToCustomer() {
|
||||
const el = document.getElementById(`customer-${this.$route.params.id}`)
|
||||
|
||||
if (el) {
|
||||
el.scrollIntoView({ behavior: 'smooth' })
|
||||
el.classList.add('shake')
|
||||
}
|
||||
},
|
||||
|
||||
async loadCustomer() {
|
||||
this.customer = this.selectedViewCustomer
|
||||
this.currency = this.selectedViewCustomer.currency
|
||||
},
|
||||
async onSearch() {
|
||||
let data = {}
|
||||
if (
|
||||
this.searchData.searchText !== '' &&
|
||||
this.searchData.searchText !== null &&
|
||||
this.searchData.searchText !== undefined
|
||||
) {
|
||||
data.display_name = this.searchData.searchText
|
||||
}
|
||||
|
||||
if (
|
||||
this.searchData.orderBy !== null &&
|
||||
this.searchData.orderBy !== undefined
|
||||
) {
|
||||
data.orderBy = this.searchData.orderBy
|
||||
}
|
||||
|
||||
if (
|
||||
this.searchData.orderByField !== null &&
|
||||
this.searchData.orderByField !== undefined
|
||||
) {
|
||||
data.orderByField = this.searchData.orderByField
|
||||
}
|
||||
|
||||
this.isSearching = true
|
||||
try {
|
||||
let response = await this.fetchCustomers({ ...data })
|
||||
this.isSearching = false
|
||||
if (response.data) {
|
||||
this.customers = response.data.customers.data
|
||||
}
|
||||
} catch (error) {
|
||||
this.isSearching = false
|
||||
}
|
||||
},
|
||||
sortData() {
|
||||
if (this.searchData.orderBy === 'asc') {
|
||||
this.searchData.orderBy = 'desc'
|
||||
this.onSearch()
|
||||
return true
|
||||
}
|
||||
this.searchData.orderBy = 'asc'
|
||||
this.onSearch()
|
||||
return true
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user