AdminContentList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="AdminContentList"
  3. :style="localOptions.style">
  4. <q-linear-progress v-if="loading"
  5. indeterminate />
  6. <div class="more-action">
  7. <q-btn label="محتوای جدید"
  8. color="primary"
  9. :to="{name: 'Admin.Content.Create'}" />
  10. </div>
  11. <entity-index v-if="mounted"
  12. ref="entityIndex"
  13. v-model:value="inputs"
  14. title="لیست محتواها"
  15. :api="api"
  16. :table="table"
  17. :table-keys="tableKeys"
  18. :create-route-name="createRouteName"
  19. :show-search-button="false"
  20. :show-expand-button="false"
  21. :show-reload-button="false">
  22. <template #entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
  23. <template v-if="inputData.col.name === 'number'">
  24. {{ inputData.rowNumber }}
  25. </template>
  26. <template v-else-if="inputData.col.name === 'thumbnail'">
  27. <q-img :src="inputData.col.value"
  28. width="100px" />
  29. </template>
  30. <template v-else-if="inputData.col.name === 'action'">
  31. <div class="action-column-entity-index">
  32. <q-btn color="primary"
  33. :to="{name: 'Admin.Content.Show', params: {id: inputData.props.row.id}}">
  34. مشاهده جزییات
  35. </q-btn>
  36. <delete-btn @click="showConfirmRemoveDialog(inputData.props.row, 'id', getRemoveMessage(inputData.props.row))" />
  37. </div>
  38. </template>
  39. <template v-else>
  40. {{ inputData.col.value }}
  41. </template>
  42. </template>
  43. </entity-index>
  44. </div>
  45. </template>
  46. <script>
  47. import { shallowRef } from 'vue'
  48. import { EntityIndex } from 'quasar-crud'
  49. import { mixinWidget } from 'src/mixin/Mixins.js'
  50. import { APIGateway } from 'src/api/APIGateway.js'
  51. import BtnControl from 'src/components/Control/btn.vue'
  52. import DeleteBtn from 'src/components/Control/DeleteBtn.vue'
  53. import ContentCategorySelector from 'src/components/FormBuilderCustumComponents/ContentCategorySelector.vue'
  54. const BtnControlComp = shallowRef(BtnControl)
  55. const ContentCategorySelectorComp = shallowRef(ContentCategorySelector)
  56. export default {
  57. name: 'AdminContentList',
  58. components: { DeleteBtn, EntityIndex },
  59. mixins: [mixinWidget],
  60. data () {
  61. return {
  62. loading: false,
  63. api: APIGateway.content.APIAdresses.base,
  64. tableKeys: {
  65. data: 'results',
  66. total: 'count',
  67. currentPage: 'current',
  68. perPage: 'per_page',
  69. pageKey: 'page'
  70. },
  71. inputs: [
  72. { type: ContentCategorySelectorComp, name: 'category', responseKey: 'category', col: 'col-12' },
  73. { type: 'input', name: 'search', value: null, col: 'col-md-3 col-12', label: 'جست و جو', placeholder: ' ' },
  74. { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: this.search, col: 'col-md-2 col-12' }
  75. ],
  76. table: {
  77. columns: [
  78. {
  79. name: 'number',
  80. required: true,
  81. label: 'شماره',
  82. align: 'left',
  83. field: () => ''
  84. },
  85. {
  86. name: 'thumbnail',
  87. required: true,
  88. label: 'تصویر',
  89. align: 'left',
  90. field: row => row.thumbnail
  91. },
  92. {
  93. name: 'title',
  94. required: true,
  95. label: 'عنوان',
  96. align: 'left',
  97. field: row => row.title
  98. },
  99. {
  100. name: 'category_info',
  101. required: true,
  102. label: 'دسته',
  103. align: 'left',
  104. field: row => row.category_info?.title
  105. },
  106. {
  107. name: 'action',
  108. required: true,
  109. label: 'جزییات',
  110. align: 'left',
  111. field: row => ''
  112. }
  113. ]
  114. },
  115. mounted: false,
  116. createRouteName: ''
  117. }
  118. },
  119. mounted() {
  120. this.mounted = true
  121. },
  122. methods: {
  123. search () {
  124. this.$refs.entityIndex.search()
  125. },
  126. getRemoveMessage (row) {
  127. return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
  128. }
  129. }
  130. }
  131. </script>
  132. <style scoped lang="scss">
  133. .AdminContentList {
  134. .more-action {
  135. display: flex;
  136. flex-flow: row;
  137. justify-content: flex-end;
  138. margin-bottom: 10px;
  139. }
  140. .action-column-entity-index {
  141. display: flex;
  142. align-items: center;
  143. justify-content: flex-start;
  144. }
  145. }
  146. </style>