index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div class="AdminClassroomIndex">
  3. <div class="add-new-action-row">
  4. <q-btn color="primary"
  5. :to="{name: 'Admin.Classroom.DiscussionCircles.Create'}">
  6. <svg data-name="Close Square"
  7. xmlns="http://www.w3.org/2000/svg"
  8. width="20"
  9. height="20"
  10. viewBox="0 0 20 20"
  11. class="q-mr-md">
  12. <path id="Combined_Shape"
  13. data-name="Combined Shape"
  14. d="M5.665,20C2.276,20,0,17.623,0,14.084V5.916C0,2.377,2.276,0,5.665,0h8.67C17.723,0,20,2.377,20,5.916v8.168C20,17.623,17.723,20,14.333,20ZM1.5,5.916v8.168c0,2.683,1.634,4.416,4.164,4.416h8.669c2.532,0,4.167-1.733,4.167-4.416V5.916c0-2.682-1.635-4.415-4.166-4.415H5.665C3.135,1.5,1.5,3.234,1.5,5.916Zm7.968,8a.747.747,0,0,1-.22-.53V10.741H6.611a.75.75,0,0,1-.75-.75.749.749,0,0,1,.75-.75H9.249V6.6a.75.75,0,1,1,1.5,0V9.241h2.639a.75.75,0,0,1,0,1.5H10.748v2.642a.75.75,0,0,1-1.28.53Z"
  15. fill="#fff" />
  16. </svg>
  17. ایجاد دوره آموزشی جدید
  18. </q-btn>
  19. </div>
  20. <entity-index v-if="mounted"
  21. ref="entityIndex"
  22. v-model:value="inputs"
  23. title="لیست دسته بندی ها"
  24. :api="api"
  25. :table="table"
  26. :table-keys="tableKeys"
  27. :show-expand-button="false"
  28. :show-reload-button="false"
  29. :show-search-button="false">
  30. <template v-slot:entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
  31. <template v-if="inputData.col.name === 'actions'">
  32. <div class="action-column-entity-index">
  33. <q-btn size="md"
  34. color="primary"
  35. label="جزییات"
  36. :to="{name: 'Admin.Classroom.DiscussionCircles.Show', params: {id: inputData.props.row.id}}"
  37. class="q-mr-md" />
  38. <delete-btn @click="showConfirmRemoveDialog(inputData.props.row, 'id', getRemoveMessage(inputData.props.row))" />
  39. </div>
  40. </template>
  41. <template v-else>
  42. {{ inputData.col.value }}
  43. </template>
  44. </template>
  45. </entity-index>
  46. </div>
  47. </template>
  48. <script>
  49. import { shallowRef } from 'vue'
  50. import { EntityIndex } from 'quasar-crud'
  51. import Enums from 'src/assets/Enums/Enums.js'
  52. import ShamsiDate from 'src/assets/ShamsiDate.js'
  53. import { APIGateway } from 'src/api/APIGateway.js'
  54. import BtnControl from 'src/components/Control/btn.vue'
  55. import DeleteBtn from 'src/components/Control/DeleteBtn.vue'
  56. const BtnControlComp = shallowRef(BtnControl)
  57. export default {
  58. name: 'Admin.Classroom.Index',
  59. components: {
  60. EntityIndex,
  61. DeleteBtn
  62. },
  63. data () {
  64. return {
  65. mounted: false,
  66. inputs: [
  67. { type: 'select', name: 'status', options: Enums.classroomStatuses, value: null, label: 'وضعیت دوره', placeholder: ' ', col: 'col-md-2 col-12' },
  68. { type: 'select', name: 'unit', options: [], value: null, label: 'درس', placeholder: ' ', col: 'col-md-2 col-12' },
  69. { type: 'hidden', name: 'type', value: 'DISCUSSION_CIRCLE' },
  70. { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  71. ],
  72. api: APIGateway.classroom.APIAdresses.base,
  73. table: {
  74. columns: [
  75. {
  76. name: 'id',
  77. required: true,
  78. label: 'شماره',
  79. align: 'left',
  80. field: row => row.id
  81. },
  82. {
  83. name: 'title',
  84. required: true,
  85. label: 'نام دوره',
  86. align: 'left',
  87. field: row => row.title
  88. },
  89. {
  90. name: 'audience_gender_type',
  91. required: true,
  92. label: 'جنسیت',
  93. align: 'left',
  94. field: row => (row.audience_gender_type === 'FEMALE') ? 'خواهران' : (row.audience_gender_type === 'MALE') ? 'برادران' : 'خواهران و برادران'
  95. },
  96. {
  97. name: 'status',
  98. required: true,
  99. label: 'وضعیت',
  100. align: 'left',
  101. field: row => this.getClassroomStatusesTitle(row.status)
  102. },
  103. {
  104. name: 'title',
  105. required: true,
  106. label: 'نوع برگزاری',
  107. align: 'left',
  108. field: row => this.getClassroomHoldingTypeTitle(row.holding_type)
  109. },
  110. {
  111. name: 'title',
  112. required: true,
  113. label: 'هزینه(تومان)',
  114. align: 'left',
  115. field: row => row.price
  116. },
  117. {
  118. name: 'title',
  119. required: true,
  120. label: 'استاد مربوطه',
  121. align: 'left',
  122. field: row => row.professor
  123. },
  124. {
  125. name: 'title',
  126. required: true,
  127. label: 'تاریخ و زمان ثبت نام',
  128. align: 'left',
  129. field: row => ShamsiDate.getDateTime(row.beginning_registration_period)
  130. },
  131. {
  132. name: 'title',
  133. required: true,
  134. label: 'ترم برگزاری',
  135. align: 'left',
  136. field: row => (row.beginning_registration_period) ? ShamsiDate.getTerm(row.beginning_registration_period) : '-'
  137. },
  138. {
  139. name: 'actions',
  140. required: true,
  141. label: 'عملیات',
  142. align: 'left',
  143. field: ''
  144. }
  145. ],
  146. data: []
  147. },
  148. tableKeys: {
  149. data: 'results',
  150. total: 'count',
  151. currentPage: 'current',
  152. perPage: 'per_page',
  153. pageKey: 'page'
  154. }
  155. }
  156. },
  157. mounted () {
  158. this.setActionBtn()
  159. this.mounted = true
  160. this.getUnits()
  161. },
  162. methods: {
  163. setActionBtn () {
  164. this.inputs.forEach((item, index) => {
  165. if (item.name === 'btn') {
  166. this.inputs[index].atClick = this.search
  167. }
  168. })
  169. },
  170. search () {
  171. this.$refs.entityIndex.search()
  172. },
  173. getUnits () {
  174. APIGateway.unit.index({ per_page: 9999 })
  175. .then((units) => {
  176. this.loadSelectOptions('unit', this.getSelectOptions(units.list.list, 'id', 'title'))
  177. })
  178. .catch(() => {
  179. })
  180. },
  181. loadSelectOptions (name, value) {
  182. const inputIndex = this.inputs.findIndex(input => input.name === name)
  183. this.inputs[inputIndex].options = value
  184. },
  185. getSelectOptions (result, value, label) {
  186. return result.map(item => {
  187. return {
  188. value: item[value],
  189. label: item[label]
  190. }
  191. })
  192. },
  193. getRemoveMessage (row) {
  194. return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
  195. },
  196. getClassroomHoldingTypeTitle (type) {
  197. const target = Enums.classroomHoldingTypes.find(item => item.value === type)
  198. if (!target) {
  199. return '-'
  200. }
  201. return target.label
  202. },
  203. getClassroomStatusesTitle (type) {
  204. const target = Enums.classroomStatuses.find(item => item.value === type)
  205. if (!target) {
  206. return '-'
  207. }
  208. return target.label
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. .AdminClassroomIndex {
  215. .add-new-action-row {
  216. display: flex;
  217. flex-flow: row;
  218. align-items: center;
  219. justify-content: flex-end;
  220. margin-bottom: 22px;
  221. }
  222. .action-column-entity-index {
  223. display: flex;
  224. align-items: center;
  225. justify-content: flex-start;
  226. }
  227. }
  228. </style>