AdminInvoiceList.vue 6.9 KB

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