InvoiceShow.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="InvoiceShow"
  3. :style="localOptions.style">
  4. <div class="title">
  5. <div class="static-title">
  6. مشاهده صورتحساب
  7. شماره:
  8. </div>
  9. <div class="dynamic-title">
  10. <template v-if="entityLoading">
  11. <q-skeleton type="text"
  12. class="q-ml-lg"
  13. width="100px" />
  14. </template>
  15. <template v-else>
  16. {{ entityId }}
  17. </template>
  18. </div>
  19. <div class="back-action">
  20. <q-btn flat
  21. :to="{name: 'UserPanel.Invoice.List'}"
  22. color="grey">
  23. بازگشت
  24. >
  25. </q-btn>
  26. </div>
  27. </div>
  28. <q-card class="form"
  29. flat>
  30. <entity-show v-if="mounted"
  31. ref="entityEdit"
  32. v-model:value="inputs"
  33. :api="api"
  34. :entity-id-key="entityIdKey"
  35. :entity-param-key="entityParamKey"
  36. :show-route-name="showRouteName"
  37. :show-close-button="false"
  38. :show-edit-button="false"
  39. :show-expand-button="false"
  40. :show-save-button="false"
  41. :show-reload-button="false"
  42. :default-layout="false"
  43. :redirect-after-edit="false"
  44. :after-load-input-data="afterLoadInputData" />
  45. </q-card>
  46. <q-card v-if="invoice.products_info.list.length > 0"
  47. class="q-mt-lg">
  48. <q-card-section>
  49. <div class="selectedProductsList">
  50. <div class="selectedProductsList-row head">
  51. <div class="selectedProductsList-title">
  52. شرح خدمات
  53. </div>
  54. <div class="selectedProductsList-price">
  55. مبلغ
  56. </div>
  57. </div>
  58. <div v-for="item in invoice.products_info.list[0].registrations_info.list"
  59. :key="item.id"
  60. class="selectedProductsList-row">
  61. <div class="selectedProductsList-title">
  62. {{ item.item_info.title }}
  63. </div>
  64. <div class="selectedProductsList-price">
  65. {{ (item.count * item.item_info.unit_price).toLocaleString('fa') }}
  66. تومان
  67. </div>
  68. </div>
  69. <div class="selectedProductsList-row footer">
  70. <div class="selectedProductsList-title">
  71. قابل پرداخت
  72. </div>
  73. <div class="selectedProductsList-price">
  74. {{ (invoice.products_info.list[0].amount) ? invoice.products_info.list[0].amount.toLocaleString('fa') : 0 }}
  75. تومان
  76. </div>
  77. </div>
  78. </div>
  79. </q-card-section>
  80. </q-card>
  81. <div class="action q-mt-lg">
  82. <q-card v-if="invoice.status!=='PAYING'"
  83. class="q-mb-md">
  84. <q-card-section>
  85. تنها در صورتی که وضعیت سفارش در حال پرداخت باشد امکان پرداخت با کیف پول وجود دارد
  86. </q-card-section>
  87. </q-card>
  88. <q-btn color="green"
  89. :disable="invoice.status!=='PAYING'"
  90. class="q-px-xl"
  91. @click="pay">
  92. پرداخت با کیف پول
  93. </q-btn>
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import { EntityShow } from 'quasar-crud'
  99. import { Invoice } from 'src/models/Invoice.js'
  100. import { mixinWidget } from 'src/mixin/Mixins.js'
  101. import { APIGateway } from 'src/api/APIGateway.js'
  102. export default {
  103. name: 'InvoiceShow',
  104. components: {
  105. EntityShow
  106. },
  107. mixins: [mixinWidget],
  108. props: {
  109. invoiceId: {
  110. type: Number,
  111. default: null
  112. }
  113. },
  114. data: () => {
  115. return {
  116. mounted: false,
  117. entityLoading: true,
  118. invoice: new Invoice(),
  119. entityId: '',
  120. api: null,
  121. entityIdKey: 'id',
  122. entityParamKey: 'id',
  123. showRouteName: 'UserPanel.Invoice.Show',
  124. indexRouteName: 'UserPanel.Invoice.List',
  125. inputs: [
  126. {
  127. type: 'date',
  128. name: 'creation_time',
  129. responseKey: 'creation_time',
  130. label: 'تاریخ صورت‌حساب',
  131. placeholder: ' ',
  132. col: 'col-md-6 col-12'
  133. },
  134. {
  135. type: 'select',
  136. name: 'status',
  137. responseKey: 'status',
  138. label: 'وضعیت',
  139. placeholder: ' ',
  140. options: (new Invoice()).statusEnums,
  141. col: 'col-md-6 col-12'
  142. },
  143. {
  144. type: 'hidden',
  145. name: 'id',
  146. responseKey: 'id'
  147. }
  148. ]
  149. }
  150. },
  151. computed: {
  152. localInvoiceId () {
  153. return this.invoiceId || this.$route.params.id
  154. }
  155. },
  156. mounted() {
  157. this.api = APIGateway.invoice.APIAdresses.byId(this.localInvoiceId)
  158. this.mounted = true
  159. },
  160. methods: {
  161. pay () {
  162. this.invoice.loading = true
  163. APIGateway.invoice.pay(this.invoice.id)
  164. .then((message) => {
  165. this.payMessage = message
  166. this.invoice.loading = false
  167. })
  168. .catch(() => {
  169. this.invoice.loading = false
  170. })
  171. },
  172. onUpdateServices () {
  173. this.$refs.entityEdit.getData()
  174. },
  175. afterLoadInputData (response) {
  176. this.invoice = new Invoice(response)
  177. this.entityId = response.id
  178. this.entityLoading = false
  179. },
  180. edit() {
  181. this.entityLoading = true
  182. this.$refs.entityEdit.editEntity()
  183. .then(() => {
  184. this.$refs.entityEdit.getData()
  185. this.entityLoading = false
  186. })
  187. .catch(() => {
  188. this.$refs.entityEdit.getData()
  189. this.entityLoading = false
  190. })
  191. }
  192. }
  193. }
  194. </script>
  195. <style scoped lang="scss">
  196. .InvoiceShow {
  197. .title {
  198. font-style: normal;
  199. font-weight: 700;
  200. font-size: 24px;
  201. line-height: 140%;
  202. color: #424242;
  203. margin-bottom: 27px;
  204. display: flex;
  205. flex-flow: row;
  206. position: relative;
  207. .static-title {
  208. }
  209. .dynamic-title {
  210. }
  211. .back-action {
  212. position: absolute;
  213. right: 0;
  214. top: 0;
  215. }
  216. }
  217. :deep(.form) {
  218. padding: 24px;
  219. }
  220. .selectedProductsList {
  221. width: 100%;
  222. .selectedProductsList-row {
  223. display: flex;
  224. flex-flow: row;
  225. justify-content: flex-start;
  226. align-items: center;
  227. padding: 16px 0;
  228. border-bottom: solid 1px #F6F6F6;
  229. &.head {
  230. .selectedProductsList-title {
  231. color: #6589C3;
  232. font-size: 16px;
  233. font-weight: 700;
  234. line-height: 140%;
  235. }
  236. .selectedProductsList-price {
  237. color: #6589C3;
  238. font-size: 16px;
  239. font-weight: 700;
  240. line-height: 140%;
  241. }
  242. }
  243. &.footer {
  244. .selectedProductsList-title {
  245. color: #2FA84A;
  246. font-size: 16px;
  247. font-weight: 700;
  248. line-height: 140%;
  249. }
  250. .selectedProductsList-price {
  251. color: #2FA84A;
  252. font-size: 16px;
  253. font-weight: 700;
  254. line-height: 140%;
  255. }
  256. }
  257. .selectedProductsList-title {
  258. width: calc(100% - 150px);
  259. color: #272727;
  260. font-size: 16px;
  261. font-weight: 500;
  262. line-height: 140%;
  263. }
  264. .selectedProductsList-price {
  265. width: 150px;
  266. color: #272727;
  267. font-size: 16px;
  268. line-height: 140%;
  269. }
  270. }
  271. :deep(.form) {
  272. padding: 24px;
  273. .action {
  274. display: flex;
  275. flex-flow: row;
  276. justify-content: flex-end;
  277. margin-top: 32px;
  278. }
  279. }
  280. }
  281. }
  282. </style>