DonationShow.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="DonationShow"
  3. :style="localOptions.style">
  4. <div class="more-action">
  5. <breadcrumbs />
  6. </div>
  7. <div class="main-section">
  8. <div v-if="donationCategory.id"
  9. class="show-donation-category-section">
  10. <div class="donation-category-content">
  11. <q-banner class="donation-category-title">
  12. {{donationCategory.title}}
  13. </q-banner>
  14. <div class="donation-category-description"
  15. v-html="donationCategory.description" />
  16. </div>
  17. <div class="donation-category-thumbnail">
  18. <q-img :src="donationCategory.thumbnail" />
  19. </div>
  20. </div>
  21. <div class="show-donation-selector">
  22. <q-banner class="donation-category-title">
  23. پرداخت
  24. صدقه
  25. آنلاین
  26. </q-banner>
  27. <div class="donation-selector-form">
  28. <entity-create v-if="mounted"
  29. ref="entityCreate"
  30. v-model:value="donationSelectorInputs"
  31. :api="donationSelectorApi"
  32. :entity-id-key="donationSelectorEntityIdKey"
  33. :entity-param-key="donationSelectorEntityParamKey"
  34. :show-route-name="donationSelectorShowRouteName"
  35. :default-layout="false"
  36. :show-close-button="false"
  37. :show-edit-button="false"
  38. :show-expand-button="false"
  39. :show-save-button="false"
  40. :show-reload-button="false" />
  41. </div>
  42. </div>
  43. <div v-if="selectedDonation?.id"
  44. class="show-donation-section">
  45. <div class="show-donation-payment-section">
  46. <q-banner class="donation-category-title">
  47. شرح مورد استفاده
  48. <!-- {{selectedDonation.title}}-->
  49. </q-banner>
  50. </div>
  51. <div class="show-donation-info-section">
  52. <div class="donation-content">
  53. <div class="donation-description"
  54. v-html="selectedDonation.description" />
  55. </div>
  56. <div class="donation-thumbnail">
  57. <q-img :src="selectedDonation.thumbnail" />
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import { shallowRef } from 'vue'
  66. import { EntityCreate } from 'quasar-crud'
  67. import { mixinWidget } from 'src/mixin/Mixins.js'
  68. import { APIGateway } from 'src/api/APIGateway.js'
  69. import { DonationList } from 'src/models/Donation.js'
  70. import BtnControl from 'src/components/Control/btn.vue'
  71. import { DonationCategory } from 'src/models/DonationCategory.js'
  72. import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
  73. import { FormBuilderAssist } from 'quasar-form-builder'
  74. const BtnControlComp = shallowRef(BtnControl)
  75. export default {
  76. name: 'DonationList',
  77. components: { Breadcrumbs, EntityCreate },
  78. mixins: [mixinWidget],
  79. data () {
  80. return {
  81. api: APIGateway.donation.APIAdresses.base,
  82. tableKeys: {
  83. data: 'results',
  84. total: 'count',
  85. currentPage: 'current',
  86. perPage: 'per_page',
  87. pageKey: 'page'
  88. },
  89. inputs: [],
  90. table: {
  91. columns: []
  92. },
  93. donations: new DonationList(),
  94. donationCategory: new DonationCategory(),
  95. mounted: false,
  96. createRouteName: '',
  97. donationSelectorApi: 'id',
  98. donationSelectorInputs: [
  99. { type: 'select', name: 'donation', responseKey: 'donation', label: 'مورد استفاده', placeholder: ' ', optionValue: 'id', optionLabel: 'title', col: 'col-md-8 col-12' },
  100. { type: 'input', name: 'amount', responseKey: 'amount', label: 'مبلغ', placeholder: ' ', col: 'col-md-4 col-12' },
  101. { type: 'input', name: 'fullName', responseKey: 'fullName', label: 'نام و نام خانوادگی', placeholder: ' ', col: 'col-md-4 col-12' },
  102. { type: 'input', name: 'mobile', responseKey: 'mobile', label: 'موبایل(جهت اصلاع رسانی)', placeholder: ' ', col: 'col-md-4 col-12' },
  103. { type: 'checkbox', name: 'private', responseKey: 'private', label: 'ناشناس بمانم', placeholder: ' ', value: false, class: 'flex justify-end items-end full-height', col: 'col-md-2 col-12' },
  104. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'پرداخت', placeholder: ' ', atClick: () => {}, class: 'flex justify-end items-end full-height', col: 'col-md-2 col-12' }
  105. ],
  106. donationSelectorEntityIdKey: 'id',
  107. donationSelectorEntityParamKey: 'id',
  108. donationSelectorShowRouteName: 'Admin.Donation.Show'
  109. }
  110. },
  111. computed: {
  112. selectedDonation () {
  113. const donationId = FormBuilderAssist.getInputsByName(this.donationSelectorInputs, 'donation')?.value
  114. if (!donationId) {
  115. return null
  116. }
  117. return this.donations.list.find(item => item.id === donationId)
  118. }
  119. },
  120. mounted() {
  121. this.getDonations()
  122. },
  123. methods: {
  124. getDonations () {
  125. this.donations.loading = true
  126. APIGateway.donation.index({
  127. category: this.$route.params.donation_category_id
  128. })
  129. .then(({ list }) => {
  130. this.donations = new DonationList(list)
  131. FormBuilderAssist.setAttributeByName(this.donationSelectorInputs, 'donation', 'options', this.donations.list)
  132. this.getDonationCategory()
  133. })
  134. },
  135. getDonationCategory () {
  136. this.donationCategory.loading = true
  137. APIGateway.donationCategory.get(this.$route.params.donation_category_id)
  138. .then((donationCategory) => {
  139. this.donationCategory = new DonationCategory(donationCategory)
  140. this.updateBreadcrumbs(this.donationCategory, this.donation)
  141. })
  142. },
  143. updateBreadcrumbs (donationCategory, donation) {
  144. this.$store.commit('AppLayout/updateBreadcrumbs', {
  145. visible: true,
  146. loading: false,
  147. path: [
  148. {
  149. label: 'خانه',
  150. to: { name: 'Public.Home' }
  151. },
  152. {
  153. label: 'پرداخت کمک مالی',
  154. to: { name: 'Public.DonationCategory.List' }
  155. },
  156. {
  157. label: donationCategory.title,
  158. to: { name: 'Public.DonationCategory.Show', params: { donation_category_id: donationCategory.id } }
  159. }
  160. ]
  161. })
  162. this.mounted = true
  163. }
  164. }
  165. }
  166. </script>
  167. <style scoped lang="scss">
  168. .DonationShow {
  169. .more-action {
  170. display: flex;
  171. flex-flow: row;
  172. justify-content: flex-start;
  173. margin-bottom: 24px;
  174. }
  175. .main-section {
  176. .show-donation-category-section {
  177. display: flex;
  178. justify-content: flex-start;
  179. gap: 16px;
  180. .donation-category-thumbnail {
  181. width: 30%;
  182. }
  183. .donation-category-content {
  184. width: 70%;
  185. .donation-category-title {
  186. margin-bottom: 16px;
  187. }
  188. .donation-category-description {}
  189. }
  190. }
  191. .show-donation-selector {
  192. .donation-category-title {
  193. margin-bottom: 34px;
  194. }
  195. .donation-selector-form {
  196. background: #F5F5F5;
  197. padding: 44px 24px 24px 24px;
  198. margin-bottom: 60px;
  199. :deep(.entity-crud-formBuilder) {
  200. .form-builder-checkbox {
  201. .q-checkbox {
  202. height: 48px !important;
  203. }
  204. }
  205. }
  206. }
  207. }
  208. .show-donation-section {
  209. .show-donation-payment-section {
  210. margin-bottom: 16px;
  211. }
  212. .show-donation-info-section {
  213. display: flex;
  214. justify-content: flex-start;
  215. gap: 16px;
  216. .donation-thumbnail {
  217. width: 30%;
  218. }
  219. .donation-content {
  220. width: 70%;
  221. .donation-title {
  222. margin-bottom: 16px;
  223. }
  224. .donation-description {}
  225. }
  226. }
  227. }
  228. }
  229. }
  230. </style>