AdminPaymentList.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="AdminPaymentList"
  3. :style="localOptions.style">
  4. <entity-index v-if="mounted"
  5. ref="entityIndex"
  6. v-model:value="inputs"
  7. title="لیست ۲پرداخت ها"
  8. :api="api"
  9. :table="table"
  10. :table-keys="tableKeys"
  11. :create-route-name="createRouteName"
  12. :table-grid-size="$q.screen.lt.sm"
  13. :show-search-button="false"
  14. :show-expand-button="false"
  15. :show-reload-button="false">
  16. <template #toolbar>
  17. <q-btn color="primary"
  18. :loading="exportReportLoading"
  19. @click="getPaymentsListExcel">
  20. دریافت
  21. </q-btn>
  22. </template>
  23. <template #entity-index-table-cell="{inputData}">
  24. <template v-if="inputData.col.name === 'number'">
  25. {{ inputData.rowNumber }}
  26. </template>
  27. <template v-else-if="inputData.col.name === 'action'">
  28. <q-btn color="primary"
  29. :to="{name: 'Admin.Payment.Show', params: {id: inputData.props.row.id}}">
  30. مشاهده جزییات
  31. </q-btn>
  32. </template>
  33. <template v-else>
  34. {{ inputData.col.value }}
  35. </template>
  36. </template>
  37. <template #entity-index-table-item-cell="{inputData}">
  38. <entity-index-grid-item :input-data="inputData">
  39. <template #col="{col, row}">
  40. <template v-if="col.name === 'number'">
  41. {{ inputData.rowNumber }}
  42. </template>
  43. <template v-else-if="col.name === 'action'">
  44. <q-btn color="primary"
  45. :to="{name: 'Admin.Payment.Show', params: {id: row.id}}">
  46. مشاهده جزییات
  47. </q-btn>
  48. </template>
  49. </template>
  50. </entity-index-grid-item>
  51. </template>
  52. </entity-index>
  53. </div>
  54. </template>
  55. <script>
  56. import { shallowRef } from 'vue'
  57. import Assist from 'assets/js/Assist.js'
  58. import { EntityIndex } from 'quasar-crud'
  59. import { Payment } from 'src/models/Payment.js'
  60. import { mixinWidget } from 'src/mixin/Mixins.js'
  61. import { APIGateway } from 'src/api/APIGateway.js'
  62. import { FormBuilderAssist } from 'quasar-form-builder'
  63. import BtnControl from 'src/components/Control/btn.vue'
  64. import EntityIndexGridItem from 'src/components/EntityIndexGridItem.vue'
  65. import FormBuilderDateTime from 'src/components/FormBuilderCustumComponents/FormBuilderDateTime.vue'
  66. const BtnControlComp = shallowRef(BtnControl)
  67. const FormBuilderDateTimeComp = shallowRef(FormBuilderDateTime)
  68. export default {
  69. name: 'AdminPaymentList',
  70. components: { EntityIndex, EntityIndexGridItem },
  71. mixins: [mixinWidget],
  72. data: () => {
  73. return {
  74. api: APIGateway.payment.APIAdresses.base,
  75. tableKeys: {
  76. data: 'results',
  77. total: 'count',
  78. currentPage: 'current',
  79. perPage: 'per_page',
  80. pageKey: 'page'
  81. },
  82. inputs: [
  83. {
  84. type: FormBuilderDateTimeComp,
  85. name: 'creation_time__gte',
  86. outsideLabel: 'از تاریخ',
  87. col: 'col-md-3 col-12'
  88. },
  89. {
  90. type: FormBuilderDateTimeComp,
  91. name: 'creation_time__lt',
  92. outsideLabel: 'تا تاریخ',
  93. col: 'col-md-3 col-12'
  94. },
  95. { type: 'select', name: 'type', options: (new Payment()).typeEnums, label: 'نوع۲ تراکنش', placeholder: ' ', col: 'col-md-3 col-12' },
  96. { type: 'input', name: 'search', value: null, col: 'col-md-3 col-12', label: 'جست و جو', placeholder: ' ' },
  97. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  98. ],
  99. table: {
  100. columns: [
  101. {
  102. name: 'number',
  103. required: true,
  104. label: 'شماره',
  105. align: 'left',
  106. field: () => ''
  107. },
  108. {
  109. name: 'id',
  110. required: true,
  111. label: 'شناسه',
  112. align: 'left',
  113. field: row => row.id
  114. },
  115. {
  116. name: 'invoice_info.title',
  117. required: true,
  118. label: 'نام صاحب حساب',
  119. align: 'left',
  120. field: row => row.wallet_info?.owner_info?.firstname + ' ' + row.wallet_info?.owner_info?.lastname
  121. },
  122. {
  123. name: 'type',
  124. required: true,
  125. label: 'عنوان',
  126. align: 'left',
  127. field: row => row.title
  128. },
  129. {
  130. name: 'amount',
  131. required: true,
  132. label: 'مبلغ تراکنش (ریال)',
  133. align: 'left',
  134. field: row => row.amount.toLocaleString('fa')
  135. },
  136. {
  137. name: 'creation_time',
  138. required: true,
  139. label: 'زمان',
  140. align: 'left',
  141. field: row => Assist.miladiToShamsi(row.creation_time)
  142. },
  143. {
  144. name: 'action',
  145. required: true,
  146. label: 'جزییات',
  147. align: 'left',
  148. field: row => ''
  149. }
  150. ]
  151. },
  152. mounted: false,
  153. exportReportLoading: false,
  154. createRouteName: ''
  155. }
  156. },
  157. mounted() {
  158. this.setActionBtn()
  159. this.mounted = true
  160. },
  161. methods: {
  162. setActionBtn () {
  163. FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.search)
  164. },
  165. search () {
  166. this.$refs.entityIndex.search()
  167. },
  168. getPaymentsListExcel () {
  169. this.exportReportLoading = true
  170. const filter = this.$refs.entityIndex.createParams()
  171. filter.report_type = 'payments_list'
  172. APIGateway.payment.exportPaymentReport(filter)
  173. .then((xlsxData) => {
  174. // Assist.saveXlsx(xlsxData, this.classroomId)
  175. Assist.saveXlsx(xlsxData, 'پرداخت ها')
  176. this.exportReportLoading = false
  177. })
  178. .catch((e) => {
  179. this.exportReportLoading = false
  180. })
  181. }
  182. }
  183. }
  184. </script>
  185. <style scoped lang="scss">
  186. .AdminPaymentList {
  187. .title {
  188. font-style: normal;
  189. font-weight: 700;
  190. font-size: 24px;
  191. line-height: 140%;
  192. color: #424242;
  193. margin-bottom: 27px;
  194. }
  195. :deep(.list) {
  196. .quasar-crud-index-table {
  197. padding: 0;
  198. .q-table__container {
  199. background-color: transparent;
  200. box-shadow: none;
  201. border: none;
  202. .q-table__top {
  203. display: none;
  204. }
  205. }
  206. }
  207. }
  208. }
  209. </style>