Feedback.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <entity-crud v-model:edit-inputs="editInputs"
  3. v-model:index-inputs="indexInputs"
  4. v-model:show-inputs="showInputs"
  5. v-model:create-inputs="createInputs"
  6. v-model:default-inputs="defaultInputs"
  7. v-bind="allProps">
  8. <template v-slot:entity-crud-table-cell="{inputData, showConfirmRemoveDialog}">
  9. <q-td :props="inputData.props">
  10. <template v-if="inputData.props.col.name === 'actions'">
  11. <q-btn round
  12. flat
  13. dense
  14. size="md"
  15. color="info"
  16. icon="info"
  17. :to="{name:'Admin.Feedback.Show', params: {id: inputData.props.row.id}}">
  18. <q-tooltip>
  19. مشاهده
  20. </q-tooltip>
  21. </q-btn>
  22. <q-btn v-if="user.isSuperUser()"
  23. round
  24. flat
  25. dense
  26. size="md"
  27. color="negative"
  28. icon="delete"
  29. class="q-ml-md"
  30. @click="showConfirmRemoveDialog(inputData.props.row, 'id', getRemoveMessage(inputData.props.row))">
  31. <q-tooltip>
  32. حذف
  33. </q-tooltip>
  34. </q-btn>
  35. </template>
  36. <template v-else-if="inputData.props.col.name === 'description'">
  37. <div v-html="inputData.props.value" />
  38. </template>
  39. <template v-else>
  40. {{ inputData.props.value }}
  41. </template>
  42. </q-td>
  43. </template>
  44. </entity-crud>
  45. </template>
  46. <script>
  47. import { shallowRef } from 'vue'
  48. import { EntityCrud } from 'quasar-crud'
  49. import API_ADDRESS from 'src/api/Addresses'
  50. import ShamsiDate from 'src/assets/ShamsiDate'
  51. import FormBuilderDateTime from 'src/components/FormBuilderCustumComponents/FormBuilderDateTime.vue'
  52. const FormBuilderDateTimeComp = shallowRef(FormBuilderDateTime)
  53. export default {
  54. name: 'Feedback',
  55. components: {
  56. EntityCrud
  57. },
  58. data () {
  59. return {
  60. model: null,
  61. tags: [],
  62. expanded: true,
  63. allProps: {
  64. config: {
  65. api: API_ADDRESS.feedback.base,
  66. title: {
  67. show: 'اطلاعات نظر',
  68. edit: 'اطلاعات نظر',
  69. create: 'ثبت نظر جدید',
  70. index: 'لیست نظر'
  71. },
  72. showRouteName: 'Admin.Feedback.Show',
  73. editRouteName: 'Admin.Feedback.Edit',
  74. indexRouteName: 'Admin.Feedback.Index',
  75. createRouteName: 'Admin.Feedback.Create',
  76. tableKeys: {
  77. data: 'results',
  78. total: 'count',
  79. currentPage: 'current',
  80. perPage: 'per_page',
  81. pageKey: 'page'
  82. },
  83. table: {
  84. columns: [
  85. {
  86. name: 'id',
  87. required: true,
  88. label: '#',
  89. align: 'left',
  90. field: row => row.id
  91. },
  92. {
  93. name: 'title',
  94. required: true,
  95. label: 'عنوان',
  96. align: 'left',
  97. field: row => row.title
  98. },
  99. {
  100. name: 'category',
  101. required: true,
  102. label: 'دسته',
  103. align: 'left',
  104. field: row => row.category
  105. },
  106. {
  107. name: 'creation_time',
  108. required: true,
  109. label: 'زمان ایجاد',
  110. align: 'left',
  111. field: row => ShamsiDate.getDateTime(row.creation_time)
  112. },
  113. {
  114. name: 'creator_info.nickname',
  115. required: true,
  116. label: 'نویسنده',
  117. align: 'left',
  118. field: row => row.summary
  119. },
  120. {
  121. name: 'actions',
  122. required: true,
  123. label: 'عملیات',
  124. align: 'left',
  125. field: ''
  126. }
  127. ],
  128. data: []
  129. }
  130. }
  131. },
  132. defaultInputs: [
  133. { type: 'input', name: 'id', responseKey: 'id', label: 'شناسه', col: 'col-md-3', disable: true },
  134. { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان', col: 'col-md-3' },
  135. { type: 'select', name: 'category', responseKey: 'category', options: [{ label: 'انتقاد', value: 'انتقاد' }, { label: 'پیشنهاد', value: 'پیشنهاد' }], value: null, label: 'دسته', col: 'col-md-3' },
  136. { type: FormBuilderDateTimeComp, name: 'creation_time', responseKey: 'creation_time', outsideLabel: 'تاریخ ایجاد', col: 'col-md-3', disable: true },
  137. {
  138. type: 'tiptap-editor',
  139. name: 'description',
  140. responseKey: 'description',
  141. label: 'متن',
  142. options: {
  143. bubbleMenu: false,
  144. floatingMenu: false,
  145. poem: false,
  146. reading: false,
  147. persianKeyboard: true,
  148. mathliveOptions: { smartFence: false },
  149. uploadServer: {
  150. url: API_ADDRESS.media.upload,
  151. instantUpload: true,
  152. responseKey: 'file',
  153. headers: { Authorization: 'Bearer ' + this.$store.getters['Auth/accessToken'] }
  154. }
  155. },
  156. col: 'col-md-12'
  157. }
  158. ],
  159. createInputs: [],
  160. editInputs: [],
  161. showInputs: [],
  162. indexInputs: [
  163. { type: 'input', name: 'id', label: 'شناسه', col: 'col-md-12' }
  164. ]
  165. }
  166. },
  167. computed: {
  168. user () {
  169. return this.$store.getters['Auth/user']
  170. }
  171. },
  172. methods: {
  173. // for index.vue
  174. getRemoveMessage (row) {
  175. return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
  176. }
  177. }
  178. }
  179. </script>
  180. <style scoped>
  181. </style>