Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wellheor1 committed Sep 15, 2023
1 parent 4f6224b commit 42072ec
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 134 deletions.
4 changes: 2 additions & 2 deletions api/education/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def get_columns(request):
{"field": 'achievementPoint', "key": 'achievementPoint', "title": 'ИД'},
{"field": 'achievementСhecked', "key": 'achievementСhecked', "title": 'ИД+'},
{"field": 'totalPoints', "key": 'totalPoint', "title": 'Сумм'},
{"field": 'is_original', "key": 'is_original', "title": 'Оригинал'},
{"field": 'isOriginal', "key": 'isOriginal', "title": 'Оригинал'},
{"field": 'researchContractId', "key": 'researchContractId', "title": 'Договор'},
{"field": 'status', "key": 'status', "title": 'Статус'},
{"field": 'create_date', "key": 'create_date', "title": 'Создано'},
{"field": 'createDate', "key": 'create_date', "title": 'Создано'},
]
for i in entrance_exam_data:
columns.insert(4, {"field": i.synonym, "key": i.synonym, "title": i.short_title})
Expand Down
12 changes: 6 additions & 6 deletions education/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def get_all_enrollees(request):
"applicationPersonNumber": "",
"achievementPoint": 0,
"totalPoints": 0,
"is_original": "",
"isOriginal": "",
"status": "",
"create_date": "",
"createDate": "",
"researchContractId": None,
}
for synonym in entrance_exam_synonym:
Expand All @@ -208,12 +208,12 @@ def get_all_enrollees(request):
temp_result["fio"] = f"{i.ind_family} {i.ind_name} {i.ind_patronymic}"
temp_result["applicationSpeciality"] = i.special_title
temp_result["applicationPersonNumber"] = i.personal_number
temp_result["is_original"] = i.original
temp_result["is_enrolled"] = i.is_enrolled
temp_result["isOriginal"] = i.original
temp_result["isEnrolled"] = i.is_enrolled
if i.is_enrolled and research_contract_ids:
temp_result["researchContractId"] = i.direction_id
temp_result["is_expelled"] = i.is_expelled
temp_result["create_date"] = date
temp_result["isExpelled"] = i.is_expelled
temp_result["createDate"] = date
if i.subj_synonym in entrance_exam_synonym:
temp_result[i.subj_synonym] = i.grade if i.grade else 0
last_app_id = i.app_id
Expand Down
9 changes: 0 additions & 9 deletions l2-frontend/src/modals/EnrolleesApplication.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,6 @@ onMounted(() => {
</script>

<style lang="scss" scoped>
.three-col-div {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
margin-bottom: 5px;
}
.application-div {
margin: 5px;
padding: 0 5px;
}
.empty-list {
width: 85px;
margin: 20px auto;
Expand Down
273 changes: 156 additions & 117 deletions l2-frontend/src/pages/Education/EnrolleesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,147 +29,186 @@
</div>
</template>

<script>
<script setup lang="ts">
import {
VeLocale,
VePagination,
VeTable,
} from 'vue-easytable';
computed, defineProps, onMounted, ref,
} from 'vue';
import { VeLocale, VePagination, VeTable } from 'vue-easytable';
import 'vue-easytable/libs/theme-default/index.css';
import ruRu from '@/locales/ve';
import EnrolleesApplication from '@/modals/EnrolleesApplication.vue';
import api from '@/api';
VeLocale.use(ruRu);
export default {
name: 'EnrolleesTable',
components: { EnrolleesApplication, VeTable, VePagination },
props: ['enrollees'],
data() {
return {
columns: [],
showInfoModal: false,
selectedCardPk: -1,
selectedFio: '',
pageSize: 100,
page: 1,
pageSizeOption: [100, 300, 500],
basePk: -1,
};
const props = defineProps({
enrollees: {
type: Array,
required: true,
},
computed: {
enrolleesPagination() {
const { page, pageSize } = this;
return this.enrollees.slice((page - 1) * pageSize, page * pageSize);
},
},
mounted() {
this.getInternalBase();
this.getColumns();
},
methods: {
pageNumberChange(number) {
this.page = number;
},
pageSizeChange(size) {
this.pageSize = size;
},
async getInternalBase() {
const baseData = await this.$api('/bases');
this.basePk = baseData.bases[0].pk;
},
async getColumns() {
const data = await this.$api('/education/get-columns');
const { result } = data;
result[result.length - 4].renderBodyCell = ({ row, column }) => {
const text = row[column.field];
return text ? <i class="fa fa-check-square" aria-hidden="true" style="color: #37BC9B;" />
: <i class="fa fa-square-o" aria-hidden="true" />;
});
const columns = ref([]);
const showInfoModal = ref(false);
const selectedCardPk = ref(-1);
const selectedFio = ref('');
const pageSize = ref(50);
const page = ref(1);
const pageSizeOption = ref([50, 100, 300, 500]);
const basePk = ref(-1);
const enrolleesPagination = computed(() => props.enrollees.slice((page.value - 1) * pageSize.value, page.value
* pageSize.value));
const pageNumberChange = (number) => {
page.value = number;
};
const pageSizeChange = (size) => {
pageSize.value = size;
};
const getInternalBase = async () => {
const baseData = await api('/bases');
basePk.value = baseData.bases[0].pk;
};
const openCard = (cardPk) => {
window.open(`/ui/directions?card_pk=${cardPk}&base_pk=${this.basePk}`);
};
const openInfo = (cardPk, fio) => {
this.showInfoModal = true;
this.selectedCardPk = cardPk;
this.selectedFio = fio;
};
const openContract = (contractPk) => {
window.open(`/ui/results/descriptive#{"pk":${contractPk}}`);
};
const getColumns = async () => {
const data = await api('/education/get-columns');
const { result } = data;
columns.value = result.map((cell) => {
if (cell.key === 'isOriginal') {
return {
key: 'isOriginal',
fields: 'isOriginal',
title: 'Оригинал',
renderBodyCell: ({ row }, h) => h('i', row.isOriginal ? {
class: 'fa fa-check-square',
'aria-hidden': 'true',
style: 'color: #37BC9B;',
} : { class: 'fa fa-square-o', 'aria-hidden': 'true' }),
};
result[result.length - 3].renderBodyCell = ({ row, column }) => {
const contract = row[column.field];
return contract ? <button
class="btn btn-blue-nb button-icon"
title="Договор"
v-tippy
on-click={() => this.openContract(contract)}
>
<i
class="fa-solid fa-folder"
/>
</button> : '';
} if (cell.key === 'researchContractId') {
return {
key: 'researchContractId',
fields: 'researchContractId',
title: 'Договор',
renderBodyCell: ({ row }, h) => (row.researchContractId ? h('button', {
class: 'btn btn-blue-nb transparent-button',
title: 'Договор',
on: {
click: () => {
openContract(row.researchContractId);
},
},
}, [h('i', { class: 'fa-solid fa-folder' })]) : ''),
};
result[result.length - 2].renderBodyCell = ({ row }) => {
const enrolled = row.is_enrolled;
const expelled = row.is_expelled;
if (expelled) { return <p style="color: red">Отчислен</p>; }
if (enrolled) { return <p style="color: #37BC9B;">Зачислен</p>; }
return '';
} if (cell.key === 'status') {
return {
key: 'status',
fields: 'status',
title: 'Статус1',
align: 'center',
renderBodyCell: '',
};
result.push({
field: 'actions',
key: 'actions',
title: 'Действия',
width: 100,
renderBodyCell: ({ row }) => (
<div style="display: flex; justify-content: space-evenly">
<button
class="btn btn-blue-nb button-icon"
title="Карта"
v-tippy
on-click={() => this.openCard(row.card)}
>
<i
class="fa-solid fa-user-graduate"
aria-hidden="true"
/>
</button>
<button
v-tippy
title="Информация"
class="btn btn-blue-nb button-icon"
on-click={() => this.openInfo(row.card, row.fio)}
>
<i
class="fa fa-info-circle"
aria-hidden="true"
/>
</button>
</div>),
});
this.columns = result;
},
openCard(cardPk) {
window.open(`/ui/directions?card_pk=${cardPk}&base_pk=${this.basePk}`);
},
openInfo(cardPk, fio) {
this.showInfoModal = true;
this.selectedCardPk = cardPk;
this.selectedFio = fio;
},
openContract(contractPk) {
window.open(`/ui/results/descriptive#{"pk":${contractPk}}`);
},
},
}
return cell;
});
columns.value.push({
field: 'actions',
key: 'actions',
title: 'Действия',
width: 100,
renderBodyCell: '',
});
};
onMounted(() => {
getInternalBase();
getColumns();
});
// const async getColumns() {
// const data = await this.$api('/education/get-columns');
// const { result } = data;
// result[result.length - 4].renderBodyCell = ({ row, column }) => {
// const text = row[column.field];
// return text ? <i class="fa fa-check-square" aria-hidden="true" style="color: #37BC9B;" />
// : <i class="fa fa-square-o" aria-hidden="true" />;
// };
// result[result.length - 3].renderBodyCell = ({ row, column }) => {
// const contract = row[column.field];
// return contract ? <button
// class="btn btn-blue-nb button-icon"
// title="Договор"
// v-tippy
// on-click={() => this.openContract(contract)}
// >
// <i
// class="fa-solid fa-folder"
// />
// </button> : '';
// };
// result[result.length - 2].renderBodyCell = ({ row }) => {
// const enrolled = row.is_enrolled;
// const expelled = row.is_expelled;
// if (expelled) { return <p style="color: red">Отчислен</p>; }
// if (enrolled) { return <p style="color: #37BC9B;">Зачислен</p>; }
// return '';
// };
// result.push({
// field: 'actions',
// key: 'actions',
// title: 'Действия',
// width: 100,
// renderBodyCell: ({ row }) => (
// <div style="display: flex; justify-content: space-evenly">
// <button
// class="btn btn-blue-nb button-icon"
// title="Карта"
// v-tippy
// on-click={() => this.openCard(row.card)}
// >
// <i
// class="fa-solid fa-user-graduate"
// aria-hidden="true"
// />
// </button>
// <button
// v-tippy
// title="Информация"
// class="btn btn-blue-nb button-icon"
// on-click={() => this.openInfo(row.card, row.fio)}
// >
// <i
// class="fa fa-info-circle"
// aria-hidden="true"
// />
// </button>
// </div>),
// });
// this.columns = result;
// },
</script>

<style scoped lang="scss">
<style lang="scss">
.empty-list {
width: 85px;
margin: 20px auto;
}
.button-icon {
.transparent-button1 {
background-color: transparent !important;
color: grey;
color: #434A54;
border: none !important;
font-size: 12px;
}
.button-icon:hover {
.transparent-button1:hover {
background-color: #434a54 !important;
color: #FFFFFF
}
.button-icon:active {
.transparent-button1:active {
background-color: #37BC9B !important;
}
</style>

0 comments on commit 42072ec

Please sign in to comment.