AdminInvoiceList.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 #entity-index-table-cell="{inputData}">
  16. <template v-if="inputData.col.name === 'number'">
  17. {{ inputData.rowNumber }}
  18. </template>
  19. <template v-else-if="inputData.col.name === 'action'">
  20. <q-btn color="primary"
  21. :to="{name: 'Admin.Invoice.Show', params: {id: inputData.props.row.id}}">
  22. جزییات
  23. </q-btn>
  24. </template>
  25. <template v-else>
  26. {{ inputData.col.value }}
  27. </template>
  28. </template>
  29. </entity-index>
  30. </div>
  31. </template>
  32. <script>
  33. import { shallowRef } from 'vue'
  34. import Assist from 'assets/js/Assist.js'
  35. import { EntityIndex } from 'quasar-crud'
  36. import { Invoice } from 'src/models/Invoice.js'
  37. import { mixinWidget } from 'src/mixin/Mixins.js'
  38. import { APIGateway } from 'src/api/APIGateway.js'
  39. import BtnControl from 'src/components/Control/btn.vue'
  40. const BtnControlComp = shallowRef(BtnControl)
  41. export default {
  42. name: 'AdminInvoiceList',
  43. components: { EntityIndex },
  44. mixins: [mixinWidget],
  45. data () {
  46. return {
  47. api: APIGateway.invoice.APIAdresses.base,
  48. tableKeys: {
  49. data: 'results',
  50. total: 'count',
  51. currentPage: 'current',
  52. perPage: 'per_page',
  53. pageKey: 'page'
  54. },
  55. inputs: [
  56. {
  57. type: 'dateTime',
  58. name: 'creation_time__gte',
  59. outsideLabel: 'از تاریخ',
  60. col: 'col-md-3 col-12'
  61. },
  62. {
  63. type: 'dateTime',
  64. name: 'creation_time__lt',
  65. outsideLabel: 'تا تاریخ',
  66. col: 'col-md-3 col-12'
  67. },
  68. { type: 'select', name: 'status', options: (new Invoice()).statusEnums, label: 'وضعیت', placeholder: ' ', col: 'col-md-3 col-12' },
  69. { type: 'select', name: 'type', options: (new Invoice()).typeEnums, label: 'نوع', placeholder: ' ', col: 'col-md-3 col-12' },
  70. { type: 'input', name: 'owner__firstname', label: 'نام سفارش دهنده', placeholder: ' ', col: 'col-md-3 col-12' },
  71. { type: 'input', name: 'owner__lastname', label: 'نام خانوادگی سفارش دهنده', placeholder: ' ', col: 'col-md-3 col-12' },
  72. { type: 'input', name: 'owner__national_code', label: 'کدملی سفارش دهنده', placeholder: ' ', col: 'col-md-3 col-12' },
  73. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-3 col-12' }
  74. ],
  75. table: {
  76. columns: [
  77. {
  78. name: 'number',
  79. required: true,
  80. label: 'شماره',
  81. align: 'left',
  82. field: () => ''
  83. },
  84. {
  85. name: 'id',
  86. required: true,
  87. label: 'شناسه',
  88. align: 'left',
  89. field: row => row.id
  90. },
  91. {
  92. name: 'id',
  93. required: true,
  94. label: 'سفارش دهنده',
  95. align: 'left',
  96. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  97. },
  98. {
  99. name: 'id',
  100. required: true,
  101. label: 'کدملی سفارش دهنده',
  102. align: 'left',
  103. field: row => row.owner_info.national_code
  104. },
  105. {
  106. name: 'id',
  107. required: true,
  108. label: 'عنوان',
  109. align: 'left',
  110. field: row => this.getInvoiceTitle(row)
  111. },
  112. {
  113. name: 'id',
  114. required: true,
  115. label: 'نوع صورتحساب',
  116. align: 'left',
  117. field: row => (new Invoice(row)).type_info.label
  118. },
  119. {
  120. name: 'amount',
  121. required: true,
  122. label: 'مبلغ تراکنش(ریال)',
  123. align: 'left',
  124. field: row => row.amount.toLocaleString('fa')
  125. },
  126. {
  127. name: 'id',
  128. required: true,
  129. label: 'وضعیت تراکنش',
  130. align: 'left',
  131. field: row => (new Invoice(row)).status_info.label
  132. },
  133. {
  134. name: 'creation_time',
  135. required: true,
  136. label: 'زمان ثبت',
  137. align: 'left',
  138. field: row => Assist.miladiToShamsi(row.creation_time)
  139. },
  140. {
  141. name: 'last_modification_time',
  142. required: true,
  143. label: 'زمان آخرین بروز رسانی',
  144. align: 'left',
  145. field: row => Assist.miladiToShamsi(row.last_modification_time)
  146. },
  147. {
  148. name: 'action',
  149. required: true,
  150. label: 'جزییات',
  151. align: 'left',
  152. field: row => ''
  153. }
  154. ]
  155. },
  156. mounted: false,
  157. createRouteName: ''
  158. }
  159. },
  160. mounted() {
  161. this.setActionBtn()
  162. this.mounted = true
  163. },
  164. methods: {
  165. getInvoiceTitle (invoice) {
  166. if (invoice.item_info.item_type === 'CLASSROOM') {
  167. return invoice.item_info.title
  168. } else {
  169. return invoice.item_info.title || '-'
  170. }
  171. },
  172. setActionBtn () {
  173. this.inputs.forEach((item, index) => {
  174. if (item.name === 'btn') {
  175. this.inputs[index].atClick = this.search
  176. }
  177. })
  178. },
  179. search () {
  180. this.$refs.entityIndex.search()
  181. }
  182. }
  183. }
  184. </script>
  185. <style scoped lang="scss">
  186. .AdminInvoiceList {
  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>