AdminSessionTemplateQuestionShow.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="AdminSessionTemplateQuestionShow"
  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 { Question } from 'src/models/Question.js'
  34. import { APIGateway } from 'src/api/APIGateway.js'
  35. import BtnControl from 'src/components/Control/btn.vue'
  36. import { FormBuilderAssist } from 'quasar-form-builder'
  37. const BtnControlComp = shallowRef(BtnControl)
  38. export default {
  39. name: 'AdminSessionTemplateQuestionShow',
  40. components: {
  41. EntityEdit
  42. },
  43. mixins: [mixinWidget],
  44. data () {
  45. return {
  46. mounted: false,
  47. entityLoading: true,
  48. api: APIGateway.question.APIAdresses.byId(this.$route.params.id),
  49. entityIdKey: 'id',
  50. entityParamKey: 'id',
  51. showRouteName: 'Admin.Unit.Questions.Show',
  52. inputs: [
  53. { type: 'input', name: 'text', responseKey: 'text', label: 'سوال', placeholder: ' ', col: 'col-12' },
  54. { type: 'inputEditor', name: 'correct_answer', responseKey: 'correct_answer', label: 'پاسخ', placeholder: ' ', col: 'col-12' },
  55. { type: 'input', name: 'mark', responseKey: 'mark', label: 'بارم پیشنهادی سوال', placeholder: ' ', col: 'col-md-3 col-12' },
  56. { type: 'select', name: 'level', responseKey: 'level', label: 'سطح سوال', placeholder: ' ', options: (new Question()).levelEnums, col: 'col-md-3 col-12' },
  57. { type: BtnControlComp, name: 'btn', label: 'ویرایش سوال', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' },
  58. { type: 'hidden', name: 'type', responseKey: 'type', value: 'QUESTION_BANK' }
  59. ]
  60. }
  61. },
  62. mounted() {
  63. this.setActionBtn()
  64. this.mounted = true
  65. },
  66. methods: {
  67. setActionBtn () {
  68. FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.edit)
  69. },
  70. afterLoadInputData () {
  71. this.entityLoading = false
  72. },
  73. edit() {
  74. this.entityLoading = true
  75. this.$refs.entityEdit.editEntity(false)
  76. .then(() => {
  77. this.$refs.entityEdit.getData()
  78. this.entityLoading = false
  79. })
  80. .catch(() => {
  81. this.$refs.entityEdit.getData()
  82. this.entityLoading = false
  83. })
  84. }
  85. }
  86. }
  87. </script>
  88. <style scoped lang="scss">
  89. .AdminSessionTemplateQuestionShow {
  90. .title {
  91. font-style: normal;
  92. font-weight: 700;
  93. font-size: 24px;
  94. line-height: 140%;
  95. color: #424242;
  96. margin-bottom: 27px;
  97. display: flex;
  98. flex-flow: row;
  99. position: relative;
  100. .static-title {
  101. }
  102. .dynamic-title {
  103. }
  104. .back-action {
  105. position: absolute;
  106. right: 0;
  107. top: 0;
  108. }
  109. }
  110. :deep(.form) {
  111. padding: 24px;
  112. }
  113. }
  114. </style>