OptionPanel.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <option-panel-tabs v-model:options="localOptions">
  3. <template #main-tab>
  4. <q-expansion-item v-for="(topic, topicIndex) in localOptions.topics"
  5. :key="topicIndex"
  6. expand-separator>
  7. <template #header>
  8. <div class="full-width">
  9. <q-btn icon="remove"
  10. flat
  11. @click="removeTopic(topicIndex)">
  12. حذف موضوع
  13. </q-btn>
  14. (
  15. <q-icon :name="localOptions.topics[topicIndex].icon"
  16. size="30px" />
  17. {{ topic.title }}
  18. )
  19. </div>
  20. </template>
  21. <q-card class="bg-grey-3">
  22. <q-card-section>
  23. <div>
  24. عنوان موضوع
  25. </div>
  26. <q-input v-model="localOptions.topics[topicIndex].title" />
  27. <div>
  28. آیکون موضوع
  29. </div>
  30. <div>
  31. <icon-sax v-model:icon="localOptions.topics[topicIndex].icon"
  32. :select-type="'emit'" />
  33. </div>
  34. <q-separator />
  35. <div v-for="(subTopic, subTopicIndex) in topic.subTopics"
  36. :key="subTopicIndex"
  37. class="q-mt-md bg-green-1 q-pa-md">
  38. <div>
  39. سوال
  40. </div>
  41. <q-input v-model="localOptions.topics[topicIndex].subTopics[subTopicIndex].question" />
  42. <div class="q-mt-sm">
  43. پاسخ
  44. </div>
  45. <q-input v-model="localOptions.topics[topicIndex].subTopics[subTopicIndex].answer" />
  46. <q-btn class="full-width"
  47. @click="removeSubTopic(localOptions.topics[topicIndex].subTopics, subTopicIndex)">
  48. حذف سوال و جواب
  49. </q-btn>
  50. </div>
  51. <q-btn class="q-mt-md full-width"
  52. icon="add"
  53. @click="addSubTopic(localOptions.topics[topicIndex].subTopics)">
  54. افزودن سوال و جواب
  55. </q-btn>
  56. </q-card-section>
  57. </q-card>
  58. </q-expansion-item>
  59. <q-btn class="q-mt-md full-width"
  60. icon="add"
  61. @click="addTopic">
  62. افزودن موضوع
  63. </q-btn>
  64. </template>
  65. </option-panel-tabs>
  66. </template>
  67. <script>
  68. import { defineComponent } from 'vue'
  69. import { mixinOptionPanel } from 'quasar-ui-q-page-builder'
  70. import IconSax from 'src/pages/Document/IconSax.vue'
  71. import OptionPanelTabs from 'quasar-ui-q-page-builder/src/components/OptionPanelComponents/OptionPanelTabs.vue'
  72. export default defineComponent({
  73. name: 'OptionPanel',
  74. components: { OptionPanelTabs, IconSax },
  75. mixins: [mixinOptionPanel],
  76. data() {
  77. return {
  78. defaultOptions: {
  79. topics: []
  80. }
  81. }
  82. },
  83. methods: {
  84. addTopic () {
  85. this.localOptions.topics.push({
  86. title: '',
  87. icon: '',
  88. subTopics: []
  89. })
  90. },
  91. removeTopic (index) {
  92. this.localOptions.topics.splice(index, 1)
  93. },
  94. addSubTopic (subTopics) {
  95. subTopics.push({
  96. question: '',
  97. answer: ''
  98. })
  99. },
  100. removeSubTopic (subTopics, index) {
  101. subTopics.splice(index, 1)
  102. }
  103. }
  104. })
  105. </script>