AdminPostShow.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div class="AdminPostShow"
  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. <entity-edit v-if="mounted"
  13. ref="entityEdit"
  14. v-model:value="inputs"
  15. title="اطلاعات محتوا"
  16. :api="api"
  17. :entity-id-key="entityIdKey"
  18. :entity-param-key="entityParamKey"
  19. :show-route-name="showRouteName"
  20. :show-close-button="false"
  21. :show-edit-button="false"
  22. :show-expand-button="false"
  23. :show-save-button="false"
  24. :show-reload-button="false"
  25. :redirect-after-edit="false"
  26. :after-load-input-data="afterLoadInputData" />
  27. </div>
  28. </template>
  29. <script>
  30. import { shallowRef } from 'vue'
  31. import { EntityEdit } from 'quasar-crud'
  32. import { mixinWidget } from 'src/mixin/Mixins.js'
  33. import { APIGateway } from 'src/api/APIGateway.js'
  34. import BtnControl from 'src/components/Control/btn.vue'
  35. import PostMixin from 'src/components/Widgets/Post/PostMixin.js'
  36. import PostCategorySelector from 'src/components/FormBuilderCustumComponents/PostCategorySelector.vue'
  37. import FormBuilderTiptapEditor from 'src/components/FormBuilderCustumComponents/FormBuilderTiptapEditor.vue'
  38. const BtnControlComp = shallowRef(BtnControl)
  39. const PostCategorySelectorComp = shallowRef(PostCategorySelector)
  40. const FormBuilderTiptapEditorComp = shallowRef(FormBuilderTiptapEditor)
  41. export default {
  42. name: 'AdminPostShow',
  43. components: {
  44. EntityEdit
  45. },
  46. mixins: [mixinWidget, PostMixin],
  47. data () {
  48. const postId = this.$route.params.id
  49. const authorization = 'Bearer ' + this.$store.getters['Auth/accessToken']
  50. const uploadVideo = this.uploadVideo
  51. const uploadAudio = this.uploadAudio
  52. return {
  53. mounted: false,
  54. entityLoading: true,
  55. api: APIGateway.post.APIAdresses.byId(postId),
  56. entityIdKey: 'id',
  57. entityParamKey: 'id',
  58. showRouteName: 'Admin.Post.Show',
  59. indexRouteName: 'Admin.Post.List',
  60. inputs: [
  61. { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان', placeholder: ' ', col: 'col-12' },
  62. { type: 'input', name: 'order', responseKey: 'order', label: 'ترتیب', placeholder: ' ', col: 'col-md-6 col-12' },
  63. { type: 'file', name: 'thumbnail', responseKey: 'thumbnail', label: 'عکس', placeholder: ' ', col: 'col-md-6 col-12' },
  64. { type: PostCategorySelectorComp, name: 'category', responseKey: 'category_info', col: 'col-md-12 col-12' },
  65. {
  66. // type: 'tiptap-editor',
  67. type: FormBuilderTiptapEditorComp,
  68. name: 'summary',
  69. responseKey: 'summary',
  70. label: 'خلاصه',
  71. options: {
  72. bubbleMenu: false,
  73. floatingMenu: false,
  74. poem: false,
  75. reading: false,
  76. loadBareHtml: true,
  77. persianKeyboard: true,
  78. mathliveOptions: { smartFence: false },
  79. uploadServer: {
  80. url: '/api' + APIGateway.media.APIAdresses.base,
  81. instantUpload: true,
  82. responseKey: 'file',
  83. headers: { Authorization: authorization }
  84. },
  85. uploadVideo,
  86. uploadAudio
  87. },
  88. col: 'col-md-12 col-12'
  89. },
  90. {
  91. // type: 'tiptap-editor',
  92. type: FormBuilderTiptapEditorComp,
  93. name: 'text',
  94. responseKey: 'text',
  95. label: 'متن',
  96. options: {
  97. bubbleMenu: false,
  98. floatingMenu: false,
  99. poem: false,
  100. reading: false,
  101. loadBareHtml: true,
  102. persianKeyboard: true,
  103. mathliveOptions: { smartFence: false },
  104. uploadServer: {
  105. url: '/api' + APIGateway.media.APIAdresses.base,
  106. instantUpload: true,
  107. responseKey: 'file',
  108. headers: { Authorization: authorization }
  109. },
  110. uploadVideo,
  111. uploadAudio
  112. },
  113. col: 'col-md-12 col-12'
  114. },
  115. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ویرایش پست', placeholder: ' ', ignoreValue: true, atClick: () => {}, col: 'col-md-6' }
  116. ]
  117. }
  118. },
  119. mounted() {
  120. this.setActionBtn()
  121. this.mounted = true
  122. },
  123. methods: {
  124. setActionBtn () {
  125. this.inputs.forEach((item, index) => {
  126. if (item.name === 'btn') {
  127. this.inputs[index].atClick = this.edit
  128. }
  129. })
  130. },
  131. afterLoadInputData () {
  132. this.entityLoading = false
  133. },
  134. edit() {
  135. this.entityLoading = true
  136. this.$refs.entityEdit.editEntity(false)
  137. .then(() => {
  138. this.$refs.entityEdit.getData()
  139. this.entityLoading = false
  140. })
  141. .catch(() => {
  142. this.$refs.entityEdit.getData()
  143. this.entityLoading = false
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style scoped lang="scss">
  150. .AdminPostShow {
  151. .title {
  152. font-style: normal;
  153. font-weight: 700;
  154. font-size: 24px;
  155. line-height: 140%;
  156. color: #424242;
  157. margin-bottom: 27px;
  158. display: flex;
  159. flex-flow: row;
  160. position: relative;
  161. .static-title {
  162. }
  163. .dynamic-title {
  164. }
  165. .back-action {
  166. position: absolute;
  167. right: 0;
  168. top: 0;
  169. }
  170. }
  171. :deep(.form) {
  172. padding: 24px;
  173. }
  174. }
  175. </style>