|
|
@@ -1,233 +1,249 @@
|
|
|
<template>
|
|
|
<div class="AdminInvoiceShow"
|
|
|
:style="localOptions.style">
|
|
|
- <div class="title">
|
|
|
- <div class="static-title">
|
|
|
- سفارش
|
|
|
- </div>
|
|
|
- <div class="dynamic-title">
|
|
|
- <template v-if="entityLoading">
|
|
|
- <q-skeleton type="text"
|
|
|
- class="q-ml-lg"
|
|
|
- width="100px" />
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- {{ serviceTitle }}
|
|
|
- </template>
|
|
|
- </div>
|
|
|
- <div class="back-action">
|
|
|
+ <div class="title q-pb-lg">
|
|
|
+ <div class="static-title" />
|
|
|
+ <div class="dynamic-title" />
|
|
|
+ <div v-if="localOptions.showBackBtn"
|
|
|
+ class="back-action">
|
|
|
<q-btn flat
|
|
|
- :to="{name: 'AdminPanel.Invoice.List'}"
|
|
|
+ :to="{name: 'Admin.Invoice.List'}"
|
|
|
color="grey">
|
|
|
بازگشت
|
|
|
>
|
|
|
</q-btn>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <q-card class="form"
|
|
|
- flat>
|
|
|
- <entity-edit v-if="mounted"
|
|
|
- ref="entityEdit"
|
|
|
- v-model:value="inputs"
|
|
|
- :api="api"
|
|
|
- :entity-id-key="entityIdKey"
|
|
|
- :entity-param-key="entityParamKey"
|
|
|
- :show-route-name="showRouteName"
|
|
|
- :show-close-button="false"
|
|
|
- :show-edit-button="false"
|
|
|
- :show-expand-button="false"
|
|
|
- :show-save-button="false"
|
|
|
- :show-reload-button="false"
|
|
|
- :default-layout="false"
|
|
|
- :redirect-after-edit="false"
|
|
|
- :after-load-input-data="afterLoadInputData" />
|
|
|
- <div class="action">
|
|
|
- <div class="row q-mt-lg justify-end">
|
|
|
- <div class="col-md-4 col-12">
|
|
|
- <q-btn color="primary"
|
|
|
- class="full-width"
|
|
|
- :loading="entityLoading"
|
|
|
- @click="edit">
|
|
|
- ثبت تغییرات
|
|
|
+ <q-card v-if="invoice.item_info"
|
|
|
+ class="q-mt-lg">
|
|
|
+ <q-linear-progress v-if="invoice.loading"
|
|
|
+ indeterminate />
|
|
|
+ <q-card-section>
|
|
|
+ صورتحساب شناسه
|
|
|
+ {{ invoice.id }}
|
|
|
+ </q-card-section>
|
|
|
+ <q-separator />
|
|
|
+ <q-card-section>
|
|
|
+ <q-banner>
|
|
|
+ مشخصات خریدار
|
|
|
+ </q-banner>
|
|
|
+ <div class="row q-mt-md">
|
|
|
+ <div class="col-md-3 col-12">
|
|
|
+ نام و نام خانوادگی:
|
|
|
+ {{ invoice.owner_info?.firstname }}
|
|
|
+ {{ invoice.owner_info?.lastname }}
|
|
|
+ </div>
|
|
|
+ <div class="col-md-3 col-12">
|
|
|
+ کد ملی:
|
|
|
+ {{ invoice.owner_info?.national_code }}
|
|
|
+ </div>
|
|
|
+ <div class="col-md-3 col-12">
|
|
|
+ تلفن همراه:
|
|
|
+ {{ invoice.owner_info?.on_call_mobile_number }}
|
|
|
+ </div>
|
|
|
+ <div v-if="invoice.owner_info?.id"
|
|
|
+ class="col-md-3 col-12">
|
|
|
+ <q-btn outline
|
|
|
+ color="primary"
|
|
|
+ :to="{name: 'Admin.User.Show', params: {id: invoice.owner_info.id}}">
|
|
|
+ مشخصات کاربر
|
|
|
</q-btn>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- </q-card>
|
|
|
- <q-card v-if="invoice.products_info.list.length > 0"
|
|
|
- class="q-mt-lg">
|
|
|
+ </q-card-section>
|
|
|
+ <q-separator />
|
|
|
<q-card-section>
|
|
|
- <div class="selectedProductsList">
|
|
|
- <div class="selectedProductsList-row head">
|
|
|
- <div class="selectedProductsList-title">
|
|
|
- شرح خدمات
|
|
|
- </div>
|
|
|
- <div class="selectedProductsList-count">
|
|
|
- تعداد
|
|
|
- </div>
|
|
|
- <div class="selectedProductsList-price">
|
|
|
- مبلغ
|
|
|
- </div>
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-md-3 col-12">
|
|
|
+ <q-banner>
|
|
|
+ <q-icon name="isax:stickynote" />
|
|
|
+ {{ getDateTime(invoice.creation_time) }}
|
|
|
+ </q-banner>
|
|
|
</div>
|
|
|
- <div v-for="item in invoice.products_info.list"
|
|
|
- :key="item.id">
|
|
|
- <template v-if="item.registrations_info.list.length > 0">
|
|
|
- <div v-for="registrationsInfoItem in item.registrations_info.list"
|
|
|
- :key="registrationsInfoItem.id"
|
|
|
- class="selectedProductsList-row">
|
|
|
- <div class="selectedProductsList-title">
|
|
|
- {{ registrationsInfoItem.item_info.title }}
|
|
|
- </div>
|
|
|
- <div class="selectedProductsList-count">
|
|
|
- {{ registrationsInfoItem.count }}
|
|
|
- </div>
|
|
|
- <div class="selectedProductsList-price">
|
|
|
- {{ (registrationsInfoItem.item_info.unit_price).toLocaleString('fa') }}
|
|
|
- تومان
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <div class="selectedProductsList-row">
|
|
|
- <div class="selectedProductsList-title">
|
|
|
- {{ item.title }}
|
|
|
- </div>
|
|
|
- <div class="selectedProductsList-count">
|
|
|
- -
|
|
|
- </div>
|
|
|
- <div class="selectedProductsList-price">
|
|
|
- {{ (item.unit_price).toLocaleString('fa') }}
|
|
|
- تومان
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </div>
|
|
|
- <div class="selectedProductsList-row footer">
|
|
|
- <div class="selectedProductsList-title">
|
|
|
- قابل پرداخت
|
|
|
- </div>
|
|
|
- <div class="selectedProductsList-count" />
|
|
|
- <div class="selectedProductsList-price">
|
|
|
- {{ (invoice.amount) ? invoice.amount.toLocaleString('fa') : 0 }}
|
|
|
+ <div class="col-md-3 col-12">
|
|
|
+ <q-banner>
|
|
|
+ {{ (invoice.amount ? invoice.amount.toLocaleString('fa') : 0) }}
|
|
|
تومان
|
|
|
- </div>
|
|
|
+ </q-banner>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-3 col-12">
|
|
|
+ <q-banner>
|
|
|
+ شماره پیگیری
|
|
|
+ {{ invoice.id }}
|
|
|
+ </q-banner>
|
|
|
+ </div>
|
|
|
+ <div class="col-md-3 col-12">
|
|
|
+ <q-banner>
|
|
|
+ وضعیت:
|
|
|
+ {{ invoice.status_info.label }}
|
|
|
+ </q-banner>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </q-card-section>
|
|
|
+ <q-separator />
|
|
|
+ <q-card-section>
|
|
|
+ <div class="row">
|
|
|
+ <div class="col-md-4 col-12">
|
|
|
+ <q-img :src="invoice.item_info.thumbnail"
|
|
|
+ width="100px" />
|
|
|
+ {{ invoice.item_info.title }}
|
|
|
+ </div>
|
|
|
+ <div class="col-md-4 col-12">
|
|
|
+ <q-img :src="invoice.item_info.thumbnail"
|
|
|
+ width="100px" />
|
|
|
+ <q-icon name="isax:user" />
|
|
|
+ استاد:
|
|
|
+ {{ invoice.item_info.professor_info.firstname }}
|
|
|
+ {{ invoice.item_info.professor_info.lastname }}
|
|
|
+ </div>
|
|
|
+ <div class="col-md-4 col-12">
|
|
|
+ <q-img :src="invoice.item_info.thumbnail"
|
|
|
+ width="100px" />
|
|
|
+ <q-icon name="isax:card" />
|
|
|
+ قیمت:
|
|
|
+ {{ invoice.item_info?.price ? invoice.item_info.price.toLocaleString('fa') : 0 }}
|
|
|
+ تومان
|
|
|
</div>
|
|
|
</div>
|
|
|
</q-card-section>
|
|
|
</q-card>
|
|
|
+ <div v-if="false"
|
|
|
+ class="action q-mt-lg">
|
|
|
+ <q-card v-if="!invoice.loading && invoice.status!=='PAYING' && invoice.status!=='PAID_FULL' && invoice.status!=='PAID_IN_INSTALMENT'"
|
|
|
+ class="q-mb-md">
|
|
|
+ <q-card-section>
|
|
|
+ تنها در صورتی که وضعیت سفارش در حال پرداخت باشد امکان پرداخت با کیف پول وجود دارد
|
|
|
+ </q-card-section>
|
|
|
+ </q-card>
|
|
|
+ <q-card>
|
|
|
+ <q-card-section>
|
|
|
+ پرداخت
|
|
|
+ </q-card-section>
|
|
|
+ <q-separator />
|
|
|
+ <q-card-section>
|
|
|
+ <invoice-payment-card v-if="!invoice.loading && invoice.status!=='PAID_FULL' && invoice.status!=='PAID_IN_INSTALMENT'"
|
|
|
+ :wallet="wallet"
|
|
|
+ :invoice="invoice"
|
|
|
+ class="payment-card"
|
|
|
+ @onCancel="onCancel"
|
|
|
+ @onAccept="onAccept" />
|
|
|
+ </q-card-section>
|
|
|
+ </q-card>
|
|
|
+
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { EntityEdit } from 'quasar-crud'
|
|
|
+import Assist from 'assets/js/Assist.js'
|
|
|
+import { User } from 'src/models/User.js'
|
|
|
+import { Wallet } from 'src/models/Wallet.js'
|
|
|
import { Invoice } from 'src/models/Invoice.js'
|
|
|
import { mixinWidget } from 'src/mixin/Mixins.js'
|
|
|
import { APIGateway } from 'src/api/APIGateway.js'
|
|
|
+import InvoicePaymentCard from 'src/components/InvoicePaymentCard.vue'
|
|
|
|
|
|
export default {
|
|
|
name: 'AdminInvoiceShow',
|
|
|
- components: {
|
|
|
- EntityEdit
|
|
|
- },
|
|
|
+ components: { InvoicePaymentCard },
|
|
|
mixins: [mixinWidget],
|
|
|
+ props: {
|
|
|
+ invoiceId: {
|
|
|
+ type: Number,
|
|
|
+ default: null
|
|
|
+ }
|
|
|
+ },
|
|
|
data: () => {
|
|
|
return {
|
|
|
- mounted: false,
|
|
|
- entityLoading: true,
|
|
|
- serviceTitle: '',
|
|
|
- services: [],
|
|
|
+ user: new User(),
|
|
|
+ wallet: new Wallet(),
|
|
|
invoice: new Invoice(),
|
|
|
- api: APIGateway.invoice.APIAdresses.base,
|
|
|
- entityIdKey: 'id',
|
|
|
- entityParamKey: 'id',
|
|
|
- showRouteName: 'AdminPanel.Invoice.Show',
|
|
|
- indexRouteName: 'AdminPanel.Invoice.List',
|
|
|
- inputs: [
|
|
|
- {
|
|
|
- type: 'date',
|
|
|
- name: 'creation_time',
|
|
|
- responseKey: 'creation_time',
|
|
|
- label: 'تاریخ صورتحساب',
|
|
|
- placeholder: ' ',
|
|
|
- col: 'col-md-6 col-12'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'date',
|
|
|
- name: 'creation_time',
|
|
|
- responseKey: 'creation_time',
|
|
|
- label: 'تاریخ سررسید',
|
|
|
- placeholder: ' ',
|
|
|
- col: 'col-md-6 col-12'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'input',
|
|
|
- name: 'amount',
|
|
|
- responseKey: 'amount',
|
|
|
- label: 'مبلغ کل',
|
|
|
- placeholder: ' ',
|
|
|
- disable: true,
|
|
|
- col: 'col-md-6 col-12'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'select',
|
|
|
- name: 'status',
|
|
|
- responseKey: 'status',
|
|
|
- label: 'وضعیت',
|
|
|
- placeholder: ' ',
|
|
|
- options: (new Invoice()).statusEnums,
|
|
|
- col: 'col-md-6 col-12'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'input',
|
|
|
- name: 'amount',
|
|
|
- responseKey: 'owner_info.firstname',
|
|
|
- label: 'نام صاحب سفارش',
|
|
|
- placeholder: ' ',
|
|
|
- disable: true,
|
|
|
- col: 'col-md-6 col-12'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'input',
|
|
|
- name: 'amount',
|
|
|
- responseKey: 'owner_info.lastname',
|
|
|
- label: 'نام خانوادگی صاحب سفارش',
|
|
|
- placeholder: ' ',
|
|
|
- disable: true,
|
|
|
- col: 'col-md-6 col-12'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'hidden',
|
|
|
- name: 'id',
|
|
|
- responseKey: 'id'
|
|
|
- }
|
|
|
- ]
|
|
|
+ defaultOptions: {
|
|
|
+ showBackBtn: true
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
- created() {
|
|
|
- this.api = this.api + '/' + this.$route.params.id
|
|
|
- },
|
|
|
mounted() {
|
|
|
- this.mounted = true
|
|
|
+ this.loadAuthData()
|
|
|
+ this.getMyWallet()
|
|
|
+ this.getInvoice()
|
|
|
},
|
|
|
methods: {
|
|
|
- onUpdateServices () {
|
|
|
- this.$refs.entityEdit.getData()
|
|
|
+ loadAuthData() { // prevent Hydration node mismatch
|
|
|
+ this.user = this.$store.getters['Auth/user']
|
|
|
+ },
|
|
|
+ getDateTime (dateTime) {
|
|
|
+ return Assist.miladiToShamsi(dateTime)
|
|
|
+ },
|
|
|
+ onCancel () {
|
|
|
+ this.$router.push({ name: 'UserPanel.Invoice.List' })
|
|
|
+ },
|
|
|
+ onAccept () {
|
|
|
+ this.payInvoice()
|
|
|
},
|
|
|
- afterLoadInputData (response) {
|
|
|
- this.invoice = new Invoice(response)
|
|
|
- this.serviceTitle = response.title
|
|
|
- this.entityLoading = false
|
|
|
+ getMyWallet () {
|
|
|
+ this.wallet.loading = true
|
|
|
+ APIGateway.wallet.getMyWallet(this.user.id)
|
|
|
+ .then((wallet) => {
|
|
|
+ this.wallet = new Wallet(wallet)
|
|
|
+ this.wallet.loading = false
|
|
|
+ this.walletLoaded = true
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.wallet.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ amountOfDepositWalletNeeded () {
|
|
|
+ return this.invoice.amount - this.wallet.inventory
|
|
|
+ },
|
|
|
+ payInvoice () {
|
|
|
+ if (this.amountOfDepositWalletNeeded() > 0) {
|
|
|
+ this.payInvoiceByDepositWallet()
|
|
|
+ } else {
|
|
|
+ this.payInvoiceByWallet()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ payInvoiceByWallet () {
|
|
|
+ this.invoice.loading = true
|
|
|
+ APIGateway.invoice.pay(this.invoice.id)
|
|
|
+ .then((message) => {
|
|
|
+ this.invoice.loading = false
|
|
|
+ this.getInvoice()
|
|
|
+ this.$q.notify({
|
|
|
+ message,
|
|
|
+ type: 'positive'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.invoice.loading = false
|
|
|
+ })
|
|
|
},
|
|
|
- edit() {
|
|
|
- this.entityLoading = true
|
|
|
- this.$refs.entityEdit.editEntity(false)
|
|
|
- .then(() => {
|
|
|
- this.$refs.entityEdit.getData()
|
|
|
- this.entityLoading = false
|
|
|
+ payInvoiceByDepositWallet () {
|
|
|
+ this.invoice.loading = true
|
|
|
+ APIGateway.wallet.deposit({
|
|
|
+ amount: this.amountOfDepositWalletNeeded(),
|
|
|
+ invoice: this.invoice.id
|
|
|
+ })
|
|
|
+ .then((url) => {
|
|
|
+ window.location.href = url
|
|
|
})
|
|
|
.catch(() => {
|
|
|
- this.$refs.entityEdit.getData()
|
|
|
- this.entityLoading = false
|
|
|
+ this.depositLoading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getInvoiceId () {
|
|
|
+ return this.localOptions.invoiceId || this.$route.params.id
|
|
|
+ },
|
|
|
+ getInvoice () {
|
|
|
+ this.invoice.loading = true
|
|
|
+ const invoiceId = this.getInvoiceId()
|
|
|
+ APIGateway.invoice.get({ data: { id: invoiceId } })
|
|
|
+ .then((invoice) => {
|
|
|
+ this.invoice = new Invoice(invoice)
|
|
|
+ this.invoice.loading = false
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.invoice.loading = false
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
@@ -245,6 +261,7 @@ export default {
|
|
|
margin-bottom: 27px;
|
|
|
display: flex;
|
|
|
flex-flow: row;
|
|
|
+ position: relative;
|
|
|
.static-title {
|
|
|
|
|
|
}
|
|
|
@@ -257,87 +274,5 @@ export default {
|
|
|
top: 0;
|
|
|
}
|
|
|
}
|
|
|
- :deep(.form) {
|
|
|
- padding: 24px;
|
|
|
- }
|
|
|
-
|
|
|
- .selectedProductsList {
|
|
|
- width: 100%;
|
|
|
-
|
|
|
- .selectedProductsList-row {
|
|
|
- display: flex;
|
|
|
- flex-flow: row;
|
|
|
- justify-content: flex-start;
|
|
|
- align-items: center;
|
|
|
- padding: 16px 0;
|
|
|
- border-bottom: solid 1px #F6F6F6;
|
|
|
-
|
|
|
- &.head {
|
|
|
- .selectedProductsList-title {
|
|
|
- color: #6589C3;
|
|
|
- font-size: 16px;
|
|
|
- font-weight: 700;
|
|
|
- line-height: 140%;
|
|
|
- }
|
|
|
-
|
|
|
- .selectedProductsList-price,
|
|
|
- .selectedProductsList-count {
|
|
|
- color: #6589C3;
|
|
|
- font-size: 16px;
|
|
|
- font-weight: 700;
|
|
|
- line-height: 140%;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- &.footer {
|
|
|
- .selectedProductsList-title {
|
|
|
- color: #2FA84A;
|
|
|
- font-size: 16px;
|
|
|
- font-weight: 700;
|
|
|
- line-height: 140%;
|
|
|
- }
|
|
|
-
|
|
|
- .selectedProductsList-price {
|
|
|
- color: #2FA84A;
|
|
|
- font-size: 16px;
|
|
|
- font-weight: 700;
|
|
|
- line-height: 140%;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .selectedProductsList-title {
|
|
|
- width: calc(100% - 200px);
|
|
|
- color: #272727;
|
|
|
- font-size: 16px;
|
|
|
- font-weight: 500;
|
|
|
- line-height: 140%;
|
|
|
- }
|
|
|
-
|
|
|
- .selectedProductsList-count {
|
|
|
- width: 50px;
|
|
|
- color: #272727;
|
|
|
- font-size: 16px;
|
|
|
- line-height: 140%;
|
|
|
- }
|
|
|
-
|
|
|
- .selectedProductsList-price {
|
|
|
- width: 150px;
|
|
|
- color: #272727;
|
|
|
- font-size: 16px;
|
|
|
- line-height: 140%;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- :deep(.form) {
|
|
|
- padding: 24px;
|
|
|
-
|
|
|
- .action {
|
|
|
- display: flex;
|
|
|
- flex-flow: row;
|
|
|
- justify-content: flex-end;
|
|
|
- margin-top: 32px;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
</style>
|