AdminContentCreate.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="AdminContentCreate"
  3. :style="localOptions.style">
  4. <entity-create v-if="mounted"
  5. ref="entityCreate"
  6. v-model:value="inputs"
  7. title="ایجاد محتوا"
  8. :api="api"
  9. :entity-id-key="entityIdKey"
  10. :entity-param-key="entityParamKey"
  11. :show-route-name="showRouteName"
  12. :show-close-button="false"
  13. :show-edit-button="false"
  14. :show-expand-button="false"
  15. :show-save-button="false"
  16. :show-reload-button="false" />
  17. </div>
  18. </template>
  19. <script>
  20. import { shallowRef } from 'vue'
  21. import { EntityCreate } from 'quasar-crud'
  22. import { mixinWidget } from 'src/mixin/Mixins.js'
  23. import { APIGateway } from 'src/api/APIGateway.js'
  24. import BtnControl from 'src/components/Control/btn.vue'
  25. import ContentMedias from 'src/components/FormBuilderCustumComponents/ContentMedias/ContentMedias.vue'
  26. import ContentCategorySelector from 'src/components/FormBuilderCustumComponents/ContentCategorySelector.vue'
  27. const BtnControlComp = shallowRef(BtnControl)
  28. const ContentMediasComp = shallowRef(ContentMedias)
  29. const ContentCategorySelectorComp = shallowRef(ContentCategorySelector)
  30. export default {
  31. name: 'AdminContentCreate',
  32. components: { EntityCreate },
  33. mixins: [mixinWidget],
  34. data: () => {
  35. return {
  36. mounted: false,
  37. entityLoading: false,
  38. api: APIGateway.content.APIAdresses.base,
  39. entityIdKey: 'id',
  40. entityParamKey: 'id',
  41. showRouteName: 'Admin.Content.Show',
  42. inputs: [
  43. { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان', placeholder: ' ', col: 'col-md-6 col-12' },
  44. // { type: 'file', name: 'thumbnail', responseKey: 'thumbnail', label: 'عکس', placeholder: ' ', col: 'col-md-6 col-12' },
  45. { type: ContentCategorySelectorComp, name: 'category', responseKey: 'category', col: 'col-12' },
  46. { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات', col: 'col-12' },
  47. { type: ContentMediasComp, name: 'medias', responseKey: 'medias_info', col: 'col-12' },
  48. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ایجاد محتوا', placeholder: ' ', atClick: () => {}, col: 'col-md-6' }
  49. ]
  50. }
  51. },
  52. mounted() {
  53. this.setActionBtn()
  54. this.mounted = true
  55. },
  56. methods: {
  57. setActionBtn () {
  58. this.inputs.forEach((item, index) => {
  59. if (item.name === 'btn') {
  60. this.inputs[index].atClick = this.onSubmit
  61. }
  62. })
  63. },
  64. onSubmit () {
  65. this.create()
  66. },
  67. create() {
  68. this.entityLoading = true
  69. this.$refs.entityCreate.createEntity()
  70. .then(() => {
  71. this.entityLoading = false
  72. })
  73. .catch(() => {
  74. this.entityLoading = false
  75. })
  76. }
  77. }
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. .AdminContentCreate {
  82. .title {
  83. font-style: normal;
  84. font-weight: 700;
  85. font-size: 24px;
  86. line-height: 140%;
  87. color: #424242;
  88. margin-bottom: 27px;
  89. position: relative;
  90. .back-action {
  91. position: absolute;
  92. right: 0;
  93. top: 0;
  94. }
  95. }
  96. :deep(.form) {
  97. padding: 24px;
  98. }
  99. }
  100. </style>