AdminContentList.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="AdminContentList"
  3. :style="localOptions.style">
  4. <div class="more-action">
  5. <q-btn label="محتوای جدید"
  6. color="primary"
  7. :to="{name: 'Admin.Content.Create'}" />
  8. </div>
  9. <entity-index v-if="mounted"
  10. v-model:value="inputs"
  11. title="لیست محتواها"
  12. :api="api"
  13. :table="table"
  14. :table-keys="tableKeys"
  15. :create-route-name="createRouteName"
  16. :show-search-button="false"
  17. :show-expand-button="false"
  18. :show-reload-button="false">
  19. <template #entity-index-table-cell="{inputData}">
  20. <template v-if="inputData.col.name === 'number'">
  21. {{ inputData.rowNumber }}
  22. </template>
  23. <template v-else-if="inputData.col.name === 'thumbnail'">
  24. <q-img :src="inputData.col.value"
  25. width="100px" />
  26. </template>
  27. <template v-else-if="inputData.col.name === 'action'">
  28. <q-btn color="primary"
  29. :to="{name: 'Admin.Content.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. </entity-index>
  38. </div>
  39. </template>
  40. <script>
  41. import { EntityIndex } from 'quasar-crud'
  42. import { mixinWidget } from 'src/mixin/Mixins.js'
  43. import { APIGateway } from 'src/api/APIGateway.js'
  44. export default {
  45. name: 'AdminContentList',
  46. components: { EntityIndex },
  47. mixins: [mixinWidget],
  48. data: () => {
  49. return {
  50. api: APIGateway.content.APIAdresses.base,
  51. tableKeys: {
  52. data: 'results',
  53. total: 'count',
  54. currentPage: 'current',
  55. perPage: 'per_page',
  56. pageKey: 'page'
  57. },
  58. inputs: [],
  59. table: {
  60. columns: [
  61. {
  62. name: 'number',
  63. required: true,
  64. label: 'شماره',
  65. align: 'left',
  66. field: () => ''
  67. },
  68. {
  69. name: 'thumbnail',
  70. required: true,
  71. label: 'تصویر',
  72. align: 'left',
  73. field: row => row.thumbnail
  74. },
  75. {
  76. name: 'title',
  77. required: true,
  78. label: 'عنوان',
  79. align: 'left',
  80. field: row => row.title
  81. },
  82. {
  83. name: 'category_info',
  84. required: true,
  85. label: 'دسته',
  86. align: 'left',
  87. field: row => row.category_info?.title
  88. },
  89. {
  90. name: 'action',
  91. required: true,
  92. label: 'جزییات',
  93. align: 'left',
  94. field: row => ''
  95. }
  96. ]
  97. },
  98. mounted: false,
  99. createRouteName: ''
  100. }
  101. },
  102. mounted() {
  103. this.mounted = true
  104. }
  105. }
  106. </script>
  107. <style scoped lang="scss">
  108. .AdminContentList {
  109. .more-action {
  110. display: flex;
  111. flex-flow: row;
  112. justify-content: flex-end;
  113. margin-bottom: 10px;
  114. }
  115. }
  116. </style>