AdminContentShow.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="AdminContentShow"
  3. :style="localOptions.style">
  4. <div class="flex justify-end">
  5. <q-btn flat
  6. color="grey"
  7. @click="$router.go(-1)">
  8. بازگشت
  9. >
  10. </q-btn>
  11. </div>
  12. <q-card flat>
  13. <q-tabs v-model="tab"
  14. align="left">
  15. <q-tab name="content"
  16. label="جزییات محتوا" />
  17. <q-tab name="contentTag"
  18. label="فیش برداری" />
  19. </q-tabs>
  20. </q-card>
  21. <q-tab-panels v-if="mounted"
  22. v-model="tab">
  23. <q-tab-panel name="content"
  24. class="q-pa-none">
  25. <entity-edit ref="entityEdit"
  26. v-model:value="inputs"
  27. title="اطلاعات محتوا"
  28. :api="api"
  29. :entity-id-key="entityIdKey"
  30. :entity-param-key="entityParamKey"
  31. :show-route-name="showRouteName"
  32. :show-close-button="false"
  33. :show-edit-button="false"
  34. :show-expand-button="false"
  35. :show-save-button="false"
  36. :show-reload-button="false"
  37. :redirect-after-edit="false"
  38. :after-load-input-data="afterLoadInputData" />
  39. </q-tab-panel>
  40. <q-tab-panel name="contentTag"
  41. class="q-pa-none">
  42. <admin-content-topic-create :content="contentId"
  43. :redirect="false"
  44. @created="onTopicCreated" />
  45. <q-separator class="q-my-md" />
  46. <admin-content-topic-list :key="topicListKey"
  47. :content-id="contentId" />
  48. </q-tab-panel>
  49. </q-tab-panels>
  50. </div>
  51. </template>
  52. <script>
  53. import { shallowRef } from 'vue'
  54. import { EntityEdit } from 'quasar-crud'
  55. import { mixinWidget } from 'src/mixin/Mixins.js'
  56. import { APIGateway } from 'src/api/APIGateway.js'
  57. import BtnControl from 'src/components/Control/btn.vue'
  58. import ContentMedias from 'src/components/FormBuilderCustumComponents/ContentMedias/ContentMedias.vue'
  59. import ContentCategorySelector from 'src/components/FormBuilderCustumComponents/ContentCategorySelector.vue'
  60. import AdminContentTopicList from 'src/components/Widgets/Content/AdminContentTopicList/AdminContentTopicList.vue'
  61. import AdminContentTopicCreate from 'src/components/Widgets/Content/AdminContentTopicCreate/AdminContentTopicCreate.vue'
  62. const BtnControlComp = shallowRef(BtnControl)
  63. const ContentMediasComp = shallowRef(ContentMedias)
  64. const ContentCategorySelectorComp = shallowRef(ContentCategorySelector)
  65. export default {
  66. name: 'AdminContentShow',
  67. components: {
  68. EntityEdit,
  69. AdminContentTopicList,
  70. AdminContentTopicCreate
  71. },
  72. mixins: [mixinWidget],
  73. data () {
  74. return {
  75. mounted: false,
  76. entityLoading: true,
  77. topicListKey: Date.now(),
  78. api: APIGateway.content.APIAdresses.byId(this.$route.params.id),
  79. tab: 'content',
  80. entityIdKey: 'id',
  81. entityParamKey: 'id',
  82. showRouteName: 'Admin.Content.Show',
  83. indexRouteName: 'Admin.Content.List',
  84. inputs: [
  85. { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان', placeholder: ' ', col: 'col-md-6 col-12' },
  86. { type: 'file', name: 'thumbnail', responseKey: 'thumbnail', label: 'عکس', placeholder: ' ', col: 'col-md-6 col-12' },
  87. { type: ContentCategorySelectorComp, name: 'category', responseKey: 'category_info', col: 'col-md-12 col-12' },
  88. { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات', col: 'col-md-12 col-12' },
  89. { type: ContentMediasComp, name: 'medias', responseKey: 'medias_info', col: 'col-md-12 col-12' },
  90. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ویرایش محتوا', placeholder: ' ', ignoreValue: true, atClick: this.edit, col: 'col-md-6' }
  91. ]
  92. }
  93. },
  94. computed: {
  95. contentId () {
  96. return parseInt(this.$route.params.id)
  97. }
  98. },
  99. mounted() {
  100. this.mounted = true
  101. },
  102. methods: {
  103. afterLoadInputData () {
  104. this.entityLoading = false
  105. },
  106. edit() {
  107. this.entityLoading = true
  108. this.$refs.entityEdit.editEntity(false)
  109. .then(() => {
  110. this.$refs.entityEdit.getData()
  111. this.entityLoading = false
  112. })
  113. .catch(() => {
  114. this.$refs.entityEdit.getData()
  115. this.entityLoading = false
  116. })
  117. },
  118. onTopicCreated () {
  119. this.topicListKey = Date.now()
  120. }
  121. }
  122. }
  123. </script>
  124. <style scoped lang="scss">
  125. .AdminContentShow {
  126. .more-action {
  127. display: flex;
  128. flex-flow: row;
  129. justify-content: flex-start;
  130. margin-bottom: 10px;
  131. }
  132. .title {
  133. font-style: normal;
  134. font-weight: 700;
  135. font-size: 24px;
  136. line-height: 140%;
  137. color: #424242;
  138. margin-bottom: 27px;
  139. display: flex;
  140. flex-flow: row;
  141. position: relative;
  142. .static-title {
  143. }
  144. .dynamic-title {
  145. }
  146. .back-action {
  147. position: absolute;
  148. right: 0;
  149. top: 0;
  150. }
  151. }
  152. :deep(.form) {
  153. padding: 24px;
  154. }
  155. }
  156. </style>