AdminTestSetCreate.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="AdminTestCreate"
  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-create v-if="mounted"
  13. ref="entityCreate"
  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. </div>
  26. </template>
  27. <script>
  28. import { shallowRef } from 'vue'
  29. import { EntityCreate } from 'quasar-crud'
  30. import { mixinWidget } from 'src/mixin/Mixins.js'
  31. import { APIGateway } from 'src/api/APIGateway.js'
  32. import { FormBuilderAssist } from 'quasar-form-builder'
  33. import BtnControl from 'src/components/Control/btn.vue'
  34. import QuestionsSelector from 'src/components/FormBuilderCustumComponents/QuestionsSelector/QuestionsSelector.vue'
  35. const BtnControlComp = shallowRef(BtnControl)
  36. const QuestionsSelectorComp = shallowRef(QuestionsSelector)
  37. export default {
  38. name: 'AdminTestCreate',
  39. components: { EntityCreate },
  40. mixins: [mixinWidget],
  41. data () {
  42. const unitId = this.$route.params.unit_id
  43. return {
  44. mounted: false,
  45. entityLoading: false,
  46. api: APIGateway.testSet.APIAdresses.base,
  47. entityIdKey: 'id',
  48. entityParamKey: 'id',
  49. showRouteName: 'Admin.Unit.TestSet.Show',
  50. inputs: [
  51. { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان آزمون', placeholder: ' ', col: 'col-md-6 col-12' },
  52. { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات آزمون', col: 'col-md-12 col-12' },
  53. { type: 'hidden', name: 'unit', responseKey: 'unit', value: unitId },
  54. { type: QuestionsSelectorComp, name: 'test_questions', responseKey: 'test_questions', unitId, col: 'col-md-12 col-12' },
  55. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تایید نهایی', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
  56. ]
  57. }
  58. },
  59. mounted() {
  60. this.setActionBtn()
  61. this.mounted = true
  62. },
  63. methods: {
  64. setActionBtn () {
  65. FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.create)
  66. },
  67. create() {
  68. this.entityLoading = true
  69. this.$refs.entityCreate.createEntity()
  70. .then((response) => {
  71. this.$router.push({ name: 'Admin.Unit.TestSet.Show', params: { unit_id: this.$route.params.unit_id, id: response.data.id } })
  72. this.entityLoading = false
  73. })
  74. .catch(() => {
  75. this.entityLoading = false
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped lang="scss">
  82. .AdminTestCreate {
  83. .title {
  84. font-style: normal;
  85. font-weight: 700;
  86. font-size: 24px;
  87. line-height: 140%;
  88. color: #424242;
  89. margin-bottom: 27px;
  90. position: relative;
  91. .back-action {
  92. position: absolute;
  93. right: 0;
  94. top: 0;
  95. }
  96. }
  97. :deep(.form) {
  98. padding: 24px;
  99. }
  100. }
  101. </style>