| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- <template>
- <div class="AdminTeamShow"
- :style="localOptions.style">
- <div class="flex justify-end">
- <q-btn flat
- color="grey"
- @click="$router.go(-1)">
- بازگشت
- >
- </q-btn>
- </div>
- <entity-edit v-if="mounted"
- ref="entityEdit"
- v-model:value="inputs"
- title="اطلاعات گروه"
- :api="api"
- :entity-id-key="entityIdKey"
- :entity-param-key="entityParamKey"
- :show-close-button="false"
- :show-edit-button="false"
- :show-expand-button="false"
- :show-save-button="false"
- :show-reload-button="false"
- :redirect-after-edit="false"
- :after-load-input-data="afterLoadInputData" />
- <q-separator class="q-my-lg" />
- <entity-index v-if="mounted"
- ref="teamRegistrationList"
- v-model:value="teamRegistrationListInputs"
- title="لیست اعضای گروه"
- :api="teamRegistrationListApi"
- :table="teamRegistrationListTable"
- :table-keys="teamRegistrationListTableKeys"
- :show-search-button="false"
- :show-reload-button="false"
- :show-expand-button="false">
- <template #toolbar>
- <form-builder ref="formBuilder"
- :key="addTeamRegistrationKey"
- v-model:value="addTeamRegistrationInputs"
- :loading="addNewTeamRegistrationLoading" />
- </template>
- <template v-slot:entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
- <template v-if="inputData.col.name === 'number'">
- {{ inputData.rowNumber }}
- </template>
- <template v-else-if="inputData.col.name === 'actions'">
- <div class="action-column-entity-index">
- <delete-btn @click="showConfirmRemoveDialog(inputData.props.row, 'id', getRemoveMessage(inputData.props.row))" />
- </div>
- </template>
- <template v-else>
- {{ inputData.col.value }}
- </template>
- </template>
- </entity-index>
- </div>
- </template>
- <script>
- import { shallowRef } from 'vue'
- import { Team } from 'src/models/Team.js'
- import { mixinWidget } from 'src/mixin/Mixins.js'
- import { APIGateway } from 'src/api/APIGateway.js'
- import { EntityEdit, EntityIndex } from 'quasar-crud'
- import BtnControl from 'src/components/Control/btn.vue'
- import DeleteBtn from 'src/components/Control/DeleteBtn.vue'
- import { FormBuilder, inputMixin, FormBuilderAssist } from 'quasar-form-builder'
- import EntityInput from 'quasar-crud/src/components/Entity/Attachment/EntityInput.vue'
- import FormBuilderInputEditor from 'src/components/FormBuilderCustumComponents/FormBuilderInputEditor.vue'
- const BtnControlComp = shallowRef(BtnControl)
- const EntityInputComp = shallowRef(EntityInput)
- const FormBuilderInputEditorComp = shallowRef(FormBuilderInputEditor)
- export default {
- name: 'AdminTeamShow',
- components: {
- DeleteBtn,
- EntityEdit,
- EntityIndex,
- FormBuilder
- },
- mixins: [mixinWidget, inputMixin],
- data () {
- const teamId = this.$route.params.team_id
- const classroomId = this.$route.params.classroom_id
- return {
- mounted: false,
- team: new Team(),
- entityLoading: true,
- api: APIGateway.team.APIAdresses.byId(teamId),
- entityIdKey: 'id',
- entityParamKey: 'id',
- inputs: [
- { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان گروه', placeholder: ' ', col: 'col-md-3 col-12' },
- { type: 'input', name: 'capacity', responseKey: 'capacity', label: 'ظرفیت', placeholder: ' ', col: 'col-md-3 col-12' },
- { type: 'checkbox', name: 'is_joinable', responseKey: 'is_joinable', label: 'قابل پیوستن', placeholder: ' ', value: false, col: 'col-md-3 col-12' },
- { type: 'separator', name: 'space', label: 'مشخصات سرگروه', className: 'custom-separator', col: 'col-12' },
- { type: 'input', name: 'leader_info.firstname', responseKey: 'leader_info.firstname', label: 'نام سرگروه', placeholder: ' ', readonly: true, ignoreValue: true, col: 'col-md-3 col-12' },
- { type: 'input', name: 'leader_info.lastname', responseKey: 'leader_info.lastname', label: 'نام خانوادگی سرگروه', placeholder: ' ', readonly: true, ignoreValue: true, col: 'col-md-3 col-12' },
- { type: 'separator', name: 'space', size: '0', col: 'col-12' },
- {
- type: 'entity',
- name: 'leader',
- responseKey: 'leader_info',
- selectionMode: 'single',
- popUpButtonConfig: {
- label: 'انتخاب سرگروه',
- outline: true,
- buttonColor: 'deep-purple',
- buttonTextColor: 'white',
- buttonBadgeColor: 'pink'
- },
- dialogConfirmButtonConfig: {
- label: 'تایید',
- buttonColor: 'deep-purple',
- buttonTextColor: 'white',
- buttonBadgeColor: 'pink'
- },
- apiAddress: APIGateway.classroomLeaders.APIAdresses.base,
- tableTitle: 'لیست کل سرگروه ها',
- showTableItemsRouteName: 'Admin.BlockManagement.Show',
- tableKeys: {
- data: 'results',
- total: 'count',
- currentPage: 'current',
- perPage: 'per_page',
- pageKey: 'page'
- },
- table: {
- columns: [
- {
- name: 'leader',
- required: true,
- label: 'شناسه',
- align: 'left',
- field: row => row.leader
- },
- {
- name: 'leader_info.gender',
- required: true,
- label: 'جنسیت',
- align: 'left',
- field: row => (row.leader_info.gender === 1) ? 'مذکر' : ((row.leader_info.gender === 2) ? 'مونث' : '-')
- },
- {
- name: 'leader_info.full_name',
- required: true,
- label: 'نام و نام خانوادگی',
- align: 'left',
- field: row => row.leader_info.firstname + ' ' + row.leader_info.lastname
- },
- {
- name: 'leader_info.national_code',
- required: true,
- label: 'کدملی',
- align: 'left',
- field: row => row.leader_info.national_code
- },
- {
- name: 'leader_info.mobile_number',
- required: true,
- label: 'شماره تلفن',
- align: 'left',
- field: row => row.leader_info.mobile_number
- },
- {
- name: 'leader_info.last_academy_name',
- required: true,
- label: 'دانشگاه',
- align: 'left',
- field: row => row.leader_info.last_academy_name
- },
- {
- name: 'leader_info.living_city',
- required: true,
- label: 'شهر',
- align: 'left',
- field: row => row.leader_info.living_city
- }
- ]
- },
- inputs: [
- { type: 'hidden', name: 'classroom', value: classroomId }
- ],
- // itemIndicatorKey: row => row.firstname + ' ' + row.lastname,
- itemIndicatorKey: 'leader_info.id',
- // itemIndicatorKey: 'firstname',
- itemIdentifyKey: 'leader_info.id',
- itemIdentifyKeyOfIndexTable: 'leader',
- indexConfig: {
- itemIndicatorKey: row => row.leader_info.firstname + ' ' + row.leader_info.lastname,
- itemIdentifyKey: 'leader'
- // itemIdentifyKey: 'id'
- },
- value: null,
- selected: null,
- col: 'col-md-3 col-12'
- },
- { type: FormBuilderInputEditorComp, name: 'description', responseKey: 'description', label: 'توضیحات', col: 'col-12' },
- { type: 'hidden', name: 'classroom', value: classroomId },
- { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ویرایش گروه', placeholder: ' ', atClick: () => {}, col: 'col-md-6' }
- ],
- addNewTeamRegistrationLoading: false,
- addTeamRegistrationKey: Date.now(),
- addTeamRegistrationInputs: [
- {
- type: EntityInputComp,
- name: 'leaders',
- selectionMode: 'multiple',
- popUpButtonConfig: {
- label: 'اختصاص عضو جدید',
- outline: true,
- buttonColor: 'deep-purple',
- buttonTextColor: 'white',
- buttonBadgeColor: 'pink'
- },
- dialogConfirmButtonConfig: {
- label: 'تایید',
- buttonColor: 'deep-purple',
- buttonTextColor: 'white',
- buttonBadgeColor: 'pink'
- },
- apiAddress: APIGateway.registration.APIAdresses.base,
- tableTitle: 'لیست کاربران',
- showTableItemsRouteName: 'Admin.BlockManagement.Show',
- tableKeys: {
- data: 'results',
- total: 'count',
- currentPage: 'current',
- perPage: 'per_page',
- pageKey: 'page'
- },
- table: {
- columns: [
- {
- name: 'id',
- required: true,
- label: 'شناسه',
- align: 'left',
- field: row => row.owner_info.id
- },
- {
- name: 'fullname',
- required: true,
- label: 'نام و نام خانوادگی',
- align: 'left',
- field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
- },
- {
- name: 'national_code',
- required: true,
- label: 'کد ملی',
- align: 'left',
- field: row => row.owner_info.national_code
- },
- {
- name: 'mobile_number',
- required: true,
- label: 'شماره همراه',
- align: 'left',
- field: row => row.owner_info.mobile_number
- }
- ]
- },
- inputs: [
- { type: 'hidden', name: 'teams__isnull', value: true },
- { type: 'hidden', name: 'classroom', value: classroomId }
- ],
- itemIndicatorKey: row => row.owner_info.firstname + ' ' + row.owner_info.lastname,
- // itemIndicatorKey: 'firstname',
- itemIdentifyKey: 'id',
- onConfirmed: this.onConfirmedSelectedRegistrations,
- value: [],
- selected: [],
- col: 'col-md-12 col-12'
- }
- ],
- teamRegistrationListInputs: [
- { type: 'hidden', name: 'team', value: teamId }
- ],
- teamRegistrationListApi: APIGateway.teamRegistrations.APIAdresses.base,
- teamRegistrationListTable: {
- columns: [
- {
- name: 'number',
- required: true,
- label: 'شماره',
- align: 'left',
- field: () => ''
- },
- {
- name: 'id',
- required: true,
- label: 'شناسه',
- align: 'left',
- field: row => row.registration_info.owner_info.id
- },
- {
- name: 'title',
- required: true,
- label: 'جنسیت',
- align: 'left',
- field: row => (row.registration_info.owner_info.gender === 1) ? 'مذکر' : ((row.registration_info.owner_info.gender === 2) ? 'مونث' : '-')
- },
- {
- name: 'creation_time',
- required: true,
- label: 'نام و نام خانوادگی',
- align: 'left',
- field: row => row.registration_info.owner_info.firstname + ' ' + row.registration_info.owner_info.lastname
- },
- {
- name: 'creation_time',
- required: true,
- label: 'کدملی',
- align: 'left',
- field: row => row.registration_info.owner_info.national_code
- },
- {
- name: 'creation_time',
- required: true,
- label: 'شماره تلفن',
- align: 'left',
- field: row => row.registration_info.owner_info.mobile_number
- },
- {
- name: 'creation_time',
- required: true,
- label: 'دانشگاه',
- align: 'left',
- field: row => row.registration_info.owner_info.last_academy_name
- },
- {
- name: 'creation_time',
- required: true,
- label: 'شهر',
- align: 'left',
- field: row => row.registration_info.owner_info.living_city
- },
- {
- name: 'actions',
- required: true,
- label: 'عملیات',
- align: 'left',
- field: ''
- }
- ]
- },
- teamRegistrationListTableKeys: {
- data: 'results',
- total: 'count',
- currentPage: 'current',
- perPage: 'per_page',
- pageKey: 'page'
- }
- }
- },
- mounted() {
- this.setActionBtn()
- this.mounted = true
- },
- methods: {
- onConfirmedSelectedRegistrations (data) {
- const registrations = data.map(item => item.id)
- this.addNewLeaderLoading = true
- APIGateway.team.appendRegistrations({ teamId: this.$route.params.team_id, registrations })
- .then(() => {
- this.$refs.teamRegistrationList.search()
- this.addTeamRegistrationInputs[0].value = []
- this.addTeamRegistrationInputs[0].selected = []
- this.addTeamRegistrationKey = Date.now()
- this.addNewLeaderLoading = false
- })
- .catch(() => {
- this.addTeamRegistrationInputs[0].value = []
- this.addTeamRegistrationInputs[0].selected = []
- this.addTeamRegistrationKey = Date.now()
- this.addNewLeaderLoading = false
- })
- },
- setActionBtn () {
- FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.edit)
- },
- afterLoadInputData (responseData) {
- this.team = new Team(responseData)
- this.entityLoading = false
- FormBuilderAssist.setAttributeByName(this.inputs, 'leader', 'value', this.team.leader)
- FormBuilderAssist.setAttributeByName(this.inputs, 'leader', 'selected', this.team.leader_info)
- },
- edit() {
- this.entityLoading = true
- this.$refs.entityEdit.editEntity(false)
- .then(() => {
- this.$refs.entityEdit.getData()
- this.entityLoading = false
- })
- .catch(() => {
- this.$refs.entityEdit.getData()
- this.entityLoading = false
- })
- },
- getRemoveMessage (row) {
- return 'آیا از حذف ' + row.registration_info.owner_info.firstname + ' ' + row.registration_info.owner_info.lastname + ' اطمینان دارید؟'
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .AdminTeamShow {
- .title {
- font-style: normal;
- font-weight: 700;
- font-size: 24px;
- line-height: 140%;
- color: #424242;
- margin-bottom: 27px;
- display: flex;
- flex-flow: row;
- position: relative;
- .static-title {
- }
- .dynamic-title {
- }
- .back-action {
- position: absolute;
- right: 0;
- top: 0;
- }
- }
- :deep(.form) {
- padding: 24px;
- }
- }
- </style>
|