AdminContentTopicCreate.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class="AdminContentTopicCreate"
  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 { FormBuilderAssist } from 'quasar-form-builder'
  26. import HashtagSelector from 'src/components/FormBuilderCustumComponents/Hashtags/HashtagSelector.vue'
  27. import ContentCategorySelector from 'src/components/FormBuilderCustumComponents/ContentCategorySelector.vue'
  28. const BtnControlComp = shallowRef(BtnControl)
  29. const HashtagSelectorComp = shallowRef(HashtagSelector)
  30. const ContentCategorySelectorComp = shallowRef(ContentCategorySelector)
  31. export default {
  32. name: 'AdminContentCreate',
  33. components: { EntityCreate },
  34. mixins: [mixinWidget],
  35. props: {
  36. content: {
  37. type: Number,
  38. default: null
  39. },
  40. redirect: {
  41. type: Boolean,
  42. default: true
  43. }
  44. },
  45. emits: ['created'],
  46. data () {
  47. return {
  48. mounted: false,
  49. entityLoading: false,
  50. api: APIGateway.contentTopic.APIAdresses.base,
  51. entityIdKey: 'id',
  52. entityParamKey: 'id',
  53. showRouteName: 'Admin.ContentTopicCategory.Show',
  54. inputs: [
  55. { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان فیش', placeholder: ' ', col: 'col-md-6 col-12' },
  56. { type: 'file', name: 'thumbnail', responseKey: 'thumbnail', label: 'عکس', value: null, placeholder: ' ', col: 'col-md-6 col-12' },
  57. { type: ContentCategorySelectorComp, name: 'category', responseKey: 'category_info', categoryType: 'contentTopic', col: 'col-12' },
  58. { type: HashtagSelectorComp, name: 'hashtags', responseKey: 'hashtags_info', col: 'col-12' },
  59. { type: 'inputEditor', name: 'text', responseKey: 'text', label: 'متن', placeholder: ' ', col: 'col-md-12 col-12' },
  60. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ایجاد فیش', placeholder: ' ', atClick: this.create, col: 'col-md-6' },
  61. { type: 'hidden', name: 'content', responseKey: 'content' }
  62. ]
  63. }
  64. },
  65. created() {
  66. FormBuilderAssist.setAttributeByName(this.inputs, 'content', 'value', this.content)
  67. },
  68. mounted() {
  69. this.mounted = true
  70. },
  71. methods: {
  72. create() {
  73. this.entityLoading = true
  74. this.$refs.entityCreate.createEntity(this.redirect)
  75. .then(() => {
  76. this.$emit('created')
  77. this.entityLoading = false
  78. })
  79. .catch(() => {
  80. this.entityLoading = false
  81. })
  82. }
  83. }
  84. }
  85. </script>
  86. <style scoped lang="scss">
  87. .AdminContentTopicCreate {
  88. .title {
  89. font-style: normal;
  90. font-weight: 700;
  91. font-size: 24px;
  92. line-height: 140%;
  93. color: #424242;
  94. margin-bottom: 27px;
  95. position: relative;
  96. .back-action {
  97. position: absolute;
  98. right: 0;
  99. top: 0;
  100. }
  101. }
  102. :deep(.form) {
  103. padding: 24px;
  104. }
  105. }
  106. </style>