Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

Aspects.vue 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template lang="pug">
  2. p {{ aspectQuestions }}
  3. //- form.questionnaire(@submit.prevent='this.$emit("handle-submit")')
  4. //- p(v-for='question in aspectQuestions')
  5. //- QuestionResponse(
  6. //- :question='question'
  7. //- @updated='updateRadio'
  8. //- @updateIsAnswered='updateIsAnswered'
  9. //- @update-all='updateAll'
  10. //- v-if='question.isBeingAnswered'
  11. //- )
  12. </template>
  13. <script>
  14. import QuestionResponse from './QuestionResponse.vue'
  15. import { aspectsArr } from '../../utils/lang.js'
  16. export default {
  17. name: 'Aspects',
  18. components: {
  19. QuestionResponse,
  20. },
  21. props: {
  22. aspectQuestions: {
  23. required: true,
  24. type: Array,
  25. },
  26. },
  27. emits: ['handle-submit', 'update-answers'],
  28. data: () => ({
  29. answered: [],
  30. }),
  31. async created() {
  32. this.aspectQuestions.forEach((q, i) => {
  33. console.log(`Aspect #${i}: ${JSON.stringify(q)}`)
  34. q.isBeingAnswered = i === 0 ? true : false
  35. })
  36. aspectsArr.forEach(() => {
  37. this.answered.push(null)
  38. })
  39. },
  40. methods: {
  41. updateAll() {
  42. this.$emit('handle-submit')
  43. },
  44. updateRadio(onRadioSelect) {
  45. this.answered[onRadioSelect.id - 1] = onRadioSelect.answer
  46. this.$emit('update-answers', {
  47. key: 'Aspects',
  48. question: {
  49. survey_stage: 'aspects',
  50. },
  51. input: this.answered,
  52. })
  53. },
  54. updateIsAnswered(id) {
  55. this.aspectQuestions.forEach((q, i) => {
  56. if (i === id - 1) {
  57. const nextQ = this.aspectQuestions[id]
  58. q.isBeingAnswered = false
  59. nextQ.isBeingAnswered = true
  60. }
  61. })
  62. },
  63. },
  64. }
  65. </script>