Include complete API and frontend sources for unified deployment
This commit is contained in:
1 parent
627b0ae60e
commit
d8fcae32b0
93 files changed
+53270
-3
No files matched your search
@@ -0,0 +1,369 @@
|
||||
<template>
|
||||
<div>
|
||||
<NuxtLink to="/admin" class="back-link"><AppIcon name="back" :size="15" /> Кейсы</NuxtLink>
|
||||
<div class="page-heading">
|
||||
<div class="case-title">
|
||||
<CaseIcon :src="task.icon" />
|
||||
<h1>{{ task.name }}</h1>
|
||||
</div>
|
||||
<button class="button" type="button" @click="editCase">Изменить</button>
|
||||
</div>
|
||||
<p v-if="task.description" class="plain-description">{{ task.description }}</p>
|
||||
<div class="section-heading">
|
||||
<h2>Команды</h2>
|
||||
<button class="button button-primary" type="button" @click="editTeam()">
|
||||
<AppIcon name="plus" :size="16" /> Добавить команду
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="scoreError" class="form-error" role="alert">{{ scoreError }}</div>
|
||||
<div class="panel">
|
||||
<div class="table-scroll">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<SortHeader
|
||||
v-for="column in teamColumns"
|
||||
:key="column.key"
|
||||
:active="teamSortKey === column.key"
|
||||
:direction="teamSortDirection"
|
||||
@sort="sortTeamsBy(column.key)"
|
||||
>{{ column.name }}</SortHeader
|
||||
>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="team in sortedTeams" :key="team.id">
|
||||
<td>
|
||||
<strong>{{ team.name }}</strong>
|
||||
<p v-if="team.description" class="table-description">{{ team.description }}</p>
|
||||
<p
|
||||
v-if="team.TeamInCase && team.TeamInCase.technicalComment"
|
||||
class="table-description technical-comment-text"
|
||||
>
|
||||
Комментарий тех. эксперта: {{ team.TeamInCase.technicalComment }}
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
class="score-input"
|
||||
type="number"
|
||||
min="0"
|
||||
max="5"
|
||||
step="1"
|
||||
:value="implementation[team.id]"
|
||||
:aria-label="'Качество реализации — ' + team.name"
|
||||
:disabled="savingScores"
|
||||
@input="setScore(implementation, team.id, $event)"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
class="score-input"
|
||||
type="number"
|
||||
min="0"
|
||||
max="5"
|
||||
step="1"
|
||||
:value="work[team.id]"
|
||||
:aria-label="'Работа на хакатоне — ' + team.name"
|
||||
:disabled="savingScores"
|
||||
@input="setScore(work, team.id, $event)"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:aria-label="'Изменить команду ' + team.name"
|
||||
@click="editTeam(team)"
|
||||
>
|
||||
Изменить
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!task.teams.length">
|
||||
<td colspan="4" class="table-empty">Команд пока нет.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="task.teams.length" class="save-row">
|
||||
<span class="muted">{{
|
||||
task.users.length ? 'Оценки тех. экспертов · 0–5' : 'Сначала назначьте экспертов в разделе «Эксперты».'
|
||||
}}</span
|
||||
><button
|
||||
class="button button-primary"
|
||||
type="button"
|
||||
:disabled="savingScores || !task.users.length"
|
||||
@click="saveScores"
|
||||
>
|
||||
{{ savingScores ? 'Сохраняем…' : 'Сохранить оценки' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="section-heading" style="margin-top: 32px">
|
||||
<h2>Эксперты</h2>
|
||||
<div ref="assignmentPicker" class="assignment-picker" @keydown.esc.prevent.stop="closeAssignments">
|
||||
<button
|
||||
ref="assignmentButton"
|
||||
type="button"
|
||||
class="button button-sm"
|
||||
:aria-expanded="String(assignmentOpen)"
|
||||
aria-controls="case-expert-picker"
|
||||
:disabled="savingAssignments"
|
||||
@click="toggleAssignments"
|
||||
>
|
||||
Назначить
|
||||
</button>
|
||||
<div v-if="assignmentOpen" id="case-expert-picker" class="assignment-dropdown">
|
||||
<input
|
||||
v-model="expertSearch"
|
||||
class="text-input"
|
||||
type="search"
|
||||
aria-label="Найти эксперта"
|
||||
placeholder="Найти эксперта"
|
||||
/>
|
||||
<p v-if="loadingAssignments" class="muted">Загрузка…</p>
|
||||
<div v-else class="assignment-options">
|
||||
<label v-for="user in filteredAssignmentUsers" :key="user.id" class="checkbox-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="isAssigned(user)"
|
||||
:disabled="savingAssignments"
|
||||
@change="setAssignment(user, $event)"
|
||||
/>
|
||||
<span
|
||||
>{{ [user.lastName, user.firstName, user.middleName].filter(Boolean).join(' ')
|
||||
}}{{ user.role === 'technical' ? ' · Технический эксперт' : '' }}</span
|
||||
>
|
||||
</label>
|
||||
<p v-if="!filteredAssignmentUsers.length" class="muted">Эксперты не найдены.</p>
|
||||
</div>
|
||||
<div v-if="assignmentError" class="form-error" role="alert">{{ assignmentError }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div v-for="user in task.users" :key="user.id" class="simple-row">
|
||||
<span>{{ [user.lastName, user.firstName, user.middleName].filter(Boolean).join(' ') }}</span>
|
||||
<span v-if="user.role === 'technical'" class="badge">Технический эксперт</span>
|
||||
</div>
|
||||
<div v-if="!task.users.length" class="table-empty">Эксперты не назначены.</div>
|
||||
</div>
|
||||
<FormDialog
|
||||
v-if="editor"
|
||||
:title="editor === 'case' ? 'Изменить кейс' : teamId ? 'Изменить команду' : 'Новая команда'"
|
||||
:busy="saving"
|
||||
@close="editor = null"
|
||||
@save="save"
|
||||
><label class="field" for="entityName"
|
||||
><span>Название</span
|
||||
><input id="entityName" v-model.trim="name" class="text-input" maxlength="255" required /></label
|
||||
><label class="field" for="entityDescription"
|
||||
><span>Описание</span
|
||||
><textarea id="entityDescription" v-model.trim="description" class="text-input" maxlength="10000" rows="3" />
|
||||
</label>
|
||||
<CaseIconUpload v-if="editor === 'case'" v-model="icon" :disabled="saving" />
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div></FormDialog
|
||||
>
|
||||
<div v-if="message" class="toast" role="status">{{ message }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'CaseDetails',
|
||||
async asyncData({ $axios, params, error }) {
|
||||
const [{ cases }, { marks }] = await Promise.all([$axios.$get('/admin/cases'), $axios.$get('/admin')])
|
||||
const task = cases.find(c => c.id === params.id)
|
||||
if (!task) {
|
||||
error({ statusCode: 404, message: 'Кейс не найден' })
|
||||
return {}
|
||||
}
|
||||
return { task, implementation: marks.implementation, work: marks.work }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
task: { name: '', teams: [], users: [] },
|
||||
implementation: {},
|
||||
work: {},
|
||||
editor: null,
|
||||
teamId: null,
|
||||
name: '',
|
||||
description: '',
|
||||
icon: null,
|
||||
saving: false,
|
||||
error: '',
|
||||
savingScores: false,
|
||||
scoreError: '',
|
||||
message: '',
|
||||
timer: null,
|
||||
assignmentOpen: false,
|
||||
assignmentUsers: [],
|
||||
expertSearch: '',
|
||||
loadingAssignments: false,
|
||||
savingAssignments: false,
|
||||
assignmentError: '',
|
||||
teamSortKey: 'name',
|
||||
teamSortDirection: 'asc',
|
||||
teamColumns: [
|
||||
{ key: 'name', name: 'Команда' },
|
||||
{ key: 'implementation', name: 'Качество реализации (тех.)' },
|
||||
{ key: 'work', name: 'Работа на хакатоне (тех.)' },
|
||||
],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
sortedTeams() {
|
||||
const direction = this.teamSortDirection === 'asc' ? 1 : -1
|
||||
return [...this.task.teams].sort((a, b) => {
|
||||
const nameOrder = a.name.localeCompare(b.name, 'ru', { numeric: true, sensitivity: 'base' })
|
||||
if (this.teamSortKey === 'name') return direction * nameOrder
|
||||
const left = this[this.teamSortKey][a.id]
|
||||
const right = this[this.teamSortKey][b.id]
|
||||
const leftMissing = left === null || left === undefined || left === ''
|
||||
const rightMissing = right === null || right === undefined || right === ''
|
||||
if (leftMissing || rightMissing) return leftMissing === rightMissing ? nameOrder : leftMissing ? 1 : -1
|
||||
return direction * (Number(left) - Number(right)) || nameOrder
|
||||
})
|
||||
},
|
||||
filteredAssignmentUsers() {
|
||||
const search = this.expertSearch.trim().toLowerCase()
|
||||
return this.assignmentUsers.filter(user =>
|
||||
[user.lastName, user.firstName, user.middleName].filter(Boolean).join(' ').toLowerCase().includes(search)
|
||||
)
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
document.addEventListener('click', this.assignmentOutsideClick)
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearTimeout(this.timer)
|
||||
document.removeEventListener('click', this.assignmentOutsideClick)
|
||||
},
|
||||
methods: {
|
||||
sortTeamsBy(key) {
|
||||
this.teamSortDirection = this.teamSortKey === key && this.teamSortDirection === 'asc' ? 'desc' : 'asc'
|
||||
this.teamSortKey = key
|
||||
},
|
||||
isAssigned(user) {
|
||||
return user.cases.some(task => task.id === this.task.id)
|
||||
},
|
||||
closeAssignments() {
|
||||
if (this.savingAssignments) return
|
||||
this.assignmentOpen = false
|
||||
this.$refs.assignmentButton?.focus()
|
||||
},
|
||||
assignmentOutsideClick(event) {
|
||||
if (!this.savingAssignments && !this.$refs.assignmentPicker?.contains(event.target)) this.assignmentOpen = false
|
||||
},
|
||||
async toggleAssignments() {
|
||||
this.assignmentOpen = !this.assignmentOpen
|
||||
if (!this.assignmentOpen) return
|
||||
this.expertSearch = ''
|
||||
this.assignmentError = ''
|
||||
this.loadingAssignments = true
|
||||
try {
|
||||
const { users } = await this.$axios.$get('/admin/users')
|
||||
this.assignmentUsers = users.filter(user => !user.deletedAt)
|
||||
} catch (e) {
|
||||
this.assignmentUsers = []
|
||||
this.assignmentError = 'Не удалось загрузить экспертов.'
|
||||
} finally {
|
||||
this.loadingAssignments = false
|
||||
}
|
||||
},
|
||||
async setAssignment(user, event) {
|
||||
if (this.savingAssignments) return
|
||||
const checked = event.target.checked
|
||||
const caseIds = user.cases.filter(task => task.id !== this.task.id).map(task => task.id)
|
||||
if (checked) caseIds.push(this.task.id)
|
||||
this.savingAssignments = true
|
||||
this.assignmentError = ''
|
||||
try {
|
||||
await this.$axios.$put('/admin/users/' + user.id + '/cases', { caseIds })
|
||||
user.cases = user.cases.filter(task => task.id !== this.task.id)
|
||||
this.task.users = this.task.users.filter(expert => expert.id !== user.id)
|
||||
if (checked) {
|
||||
user.cases.push({ id: this.task.id, name: this.task.name })
|
||||
const { id, firstName, lastName, middleName, login, role } = user
|
||||
this.task.users.push({ id, firstName, lastName, middleName, login, role })
|
||||
}
|
||||
} catch (e) {
|
||||
event.target.checked = this.isAssigned(user)
|
||||
this.assignmentError = e.response?.data?.message || 'Не удалось сохранить назначение. Попробуйте ещё раз.'
|
||||
} finally {
|
||||
this.savingAssignments = false
|
||||
}
|
||||
},
|
||||
async reload() {
|
||||
const { cases } = await this.$axios.$get('/admin/cases')
|
||||
this.task = cases.find(c => c.id === this.$route.params.id)
|
||||
},
|
||||
editCase() {
|
||||
this.editor = 'case'
|
||||
this.name = this.task.name
|
||||
this.description = this.task.description
|
||||
this.icon = this.task.icon || null
|
||||
this.error = ''
|
||||
},
|
||||
editTeam(team) {
|
||||
this.editor = 'team'
|
||||
this.teamId = team?.id || null
|
||||
this.name = team?.name || ''
|
||||
this.description = team?.description || ''
|
||||
this.error = ''
|
||||
},
|
||||
async save() {
|
||||
if (this.saving || !this.name) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
const body = { name: this.name, description: this.description || '' }
|
||||
const base = '/admin/cases/' + this.task.id
|
||||
if (this.editor === 'case') await this.$axios.$put(base, { ...body, icon: this.icon })
|
||||
else if (this.teamId) await this.$axios.$put(base + '/teams/' + this.teamId, body)
|
||||
else await this.$axios.$post(base + '/teams', body)
|
||||
await this.reload()
|
||||
this.editor = null
|
||||
} catch (e) {
|
||||
this.error = 'Не удалось сохранить изменения.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
setScore(target, id, event) {
|
||||
const value =
|
||||
event.target.value === '' ? '' : Math.min(5, Math.max(0, Math.round(Number(event.target.value) || 0)))
|
||||
this.$set(target, id, value)
|
||||
event.target.value = value
|
||||
},
|
||||
async saveScores() {
|
||||
if (this.savingScores) return
|
||||
this.scoreError = ''
|
||||
const values = this.task.teams.map(team => ({
|
||||
id: team.id,
|
||||
implementation: this.implementation[team.id],
|
||||
work: this.work[team.id],
|
||||
}))
|
||||
const filled = value => value !== '' && value !== undefined && value !== null
|
||||
if (values.some(m => filled(m.implementation) !== filled(m.work))) {
|
||||
this.scoreError = 'Заполните оба критерия для команды.'
|
||||
return
|
||||
}
|
||||
this.savingScores = true
|
||||
try {
|
||||
await this.$axios.$post('/admin', { marks: values.filter(m => filled(m.implementation) && filled(m.work)) })
|
||||
this.message = 'Оценки сохранены'
|
||||
clearTimeout(this.timer)
|
||||
this.timer = setTimeout(() => {
|
||||
this.message = ''
|
||||
}, 3500)
|
||||
} catch (e) {
|
||||
this.scoreError = 'Не удалось сохранить оценки.'
|
||||
} finally {
|
||||
this.savingScores = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="page-heading">
|
||||
<h1>Кейсы</h1>
|
||||
<button class="button button-primary" type="button" @click="editing = true">
|
||||
<AppIcon name="plus" :size="16" /> Добавить кейс
|
||||
</button>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<NuxtLink v-for="task in cases" :key="task.id" :to="'/admin/cases/' + task.id" class="simple-row"
|
||||
><div class="case-row-label">
|
||||
<CaseIcon :src="task.icon" />
|
||||
<div>
|
||||
<strong>{{ task.name }}</strong>
|
||||
<p>{{ task.teams.length }} команд · {{ task.users.length }} экспертов</p>
|
||||
</div>
|
||||
</div>
|
||||
<AppIcon name="arrow" :size="18"
|
||||
/></NuxtLink>
|
||||
<div v-if="!cases.length" class="table-empty">Кейсов пока нет.</div>
|
||||
</div>
|
||||
<FormDialog
|
||||
v-if="editing"
|
||||
title="Новый кейс"
|
||||
:busy="saving"
|
||||
submit-label="Добавить"
|
||||
@close="
|
||||
editing = false
|
||||
error = ''
|
||||
"
|
||||
@save="save"
|
||||
><label class="field" for="caseName"
|
||||
><span>Название</span
|
||||
><input id="caseName" v-model.trim="name" class="text-input" maxlength="255" required /></label
|
||||
><label class="field" for="caseDescription"
|
||||
><span>Описание</span
|
||||
><textarea id="caseDescription" v-model.trim="description" class="text-input" maxlength="10000" rows="3" />
|
||||
</label>
|
||||
<CaseIconUpload v-model="icon" :disabled="saving" />
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div></FormDialog
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'AdminCases',
|
||||
async asyncData({ $axios }) {
|
||||
return await $axios.$get('/admin/cases')
|
||||
},
|
||||
data() {
|
||||
return { cases: [], editing: false, name: '', description: '', icon: null, saving: false, error: '' }
|
||||
},
|
||||
methods: {
|
||||
async save() {
|
||||
if (this.saving || !this.name) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
const { case: task } = await this.$axios.$post('/admin/cases', {
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
icon: this.icon,
|
||||
})
|
||||
await this.$router.push('/admin/cases/' + task.id)
|
||||
} catch (e) {
|
||||
this.error = 'Не удалось добавить кейс.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,317 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="page-heading">
|
||||
<h1>Результаты</h1>
|
||||
<button class="button" type="button" :disabled="refreshing" @click="refresh">
|
||||
{{ refreshing ? 'Обновляем…' : 'Обновить' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<div class="tabs report-tabs" role="group" aria-label="Отчёт">
|
||||
<button
|
||||
v-for="item in tabs"
|
||||
:key="item.id"
|
||||
class="tab"
|
||||
:class="{ active: tab === item.id }"
|
||||
:aria-pressed="String(tab === item.id)"
|
||||
type="button"
|
||||
@click="tab = item.id"
|
||||
>
|
||||
{{ item.name }}
|
||||
</button>
|
||||
</div>
|
||||
<select v-model="selectedCase" class="filter-select" aria-label="Кейс">
|
||||
<option value="">Все кейсы</option>
|
||||
<option v-for="(name, id) in cases" :key="id" :value="id">{{ name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div>
|
||||
<template v-if="tab === 'ranking'"
|
||||
><section v-for="(ranking, id) in filteredPositions" :key="id" class="panel report-section">
|
||||
<div class="panel-header">
|
||||
<h2>{{ cases[id] }}</h2>
|
||||
</div>
|
||||
<div class="table-scroll">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<SortHeader
|
||||
v-for="column in rankingColumns"
|
||||
:key="column.key"
|
||||
:active="sorting.key === column.key"
|
||||
:direction="sorting.direction"
|
||||
@sort="sortBy(column.key)"
|
||||
>{{ column.name }}</SortHeader
|
||||
>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="[teamId, place] in sortedRanking(ranking)" :key="teamId">
|
||||
<td style="width: 80px">{{ place }}</td>
|
||||
<td>{{ teams[teamId] }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
<div v-if="!Object.keys(filteredPositions).length" class="panel table-empty">Оценок пока нет.</div></template
|
||||
>
|
||||
<template v-else-if="tab === 'details'">
|
||||
<section v-for="task in filteredDetails" :key="task.id" class="panel report-section">
|
||||
<div class="panel-header">
|
||||
<h2>{{ task.name }}</h2>
|
||||
</div>
|
||||
<div class="table-scroll">
|
||||
<table class="data-table all-marks-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<SortHeader
|
||||
v-for="column in detailColumns"
|
||||
:key="column.key"
|
||||
:active="sorting.key === column.key"
|
||||
:direction="sorting.direction"
|
||||
@sort="sortBy(column.key)"
|
||||
>{{ column.name }}</SortHeader
|
||||
>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in sortedDetails(task.rows)" :key="row.teamId + row.userId">
|
||||
<td>{{ row.team }}</td>
|
||||
<td>{{ row.expert }}<span v-if="row.role === 'technical'" class="badge">Технический эксперт</span></td>
|
||||
<td v-for="(_, type) in criteria" :key="type">
|
||||
{{ row.marks[type] === null ? '—' : row.marks[type] }}
|
||||
</td>
|
||||
<td>{{ row.total === null ? '—' : row.total }}</td>
|
||||
</tr>
|
||||
<tr v-if="!task.rows.length">
|
||||
<td :colspan="Object.keys(criteria).length + 3" class="table-empty">
|
||||
Нет назначенных экспертов или команд.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
<div v-if="!filteredDetails.length" class="panel table-empty">Кейсов пока нет.</div>
|
||||
</template>
|
||||
<section v-else class="panel">
|
||||
<div class="table-scroll">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<SortHeader
|
||||
v-for="column in reportColumns"
|
||||
:key="column.key"
|
||||
:active="sorting.key === column.key"
|
||||
:direction="sorting.direction"
|
||||
@sort="sortBy(column.key)"
|
||||
>{{ column.name }}</SortHeader
|
||||
>
|
||||
</tr>
|
||||
</thead>
|
||||
<template v-if="tab === 'zero'">
|
||||
<tbody v-for="group in zeroGroups" :key="group.id">
|
||||
<tr v-for="(row, index) in group.rows" :key="index">
|
||||
<td v-if="index === 0" :rowspan="group.rows.length">{{ group.user }}</td>
|
||||
<td>{{ row.task }}</td>
|
||||
<td class="assignment-cell">{{ row.teams[0] }}</td>
|
||||
<td class="assignment-cell">{{ row.criterion }}</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</template>
|
||||
<tbody v-if="tab !== 'zero' || !reportRows.length">
|
||||
<tr v-for="(row, index) in reportRows" :key="index">
|
||||
<td>{{ row.user }}</td>
|
||||
<td>{{ row.task }}</td>
|
||||
<td class="assignment-cell">{{ row.teams.join(', ') }}</td>
|
||||
<td v-if="tab === 'zero'">{{ row.criterion }}</td>
|
||||
<td v-if="tab === 'zero'">0</td>
|
||||
</tr>
|
||||
<tr v-if="!reportRows.length">
|
||||
<td :colspan="reportColumns.length" class="table-empty">
|
||||
{{ tab === 'missing' ? 'Все оценки заполнены.' : 'Нулевых оценок нет.' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'Results',
|
||||
async asyncData({ $axios }) {
|
||||
const [missing, ranking, detail] = await Promise.all([
|
||||
$axios.$get('/admin/marks'),
|
||||
$axios.$get('/admin/positions'),
|
||||
$axios.$get('/admin/marks/details'),
|
||||
])
|
||||
return { ...missing, ...ranking, ...detail }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
noMarks: {},
|
||||
zeroMarks: {},
|
||||
positions: {},
|
||||
details: [],
|
||||
criteria: {},
|
||||
cases: {},
|
||||
teams: {},
|
||||
selectedCase: '',
|
||||
tab: 'ranking',
|
||||
sorts: {
|
||||
ranking: { key: 'place', direction: 'asc' },
|
||||
details: { key: '', direction: 'asc' },
|
||||
missing: { key: '', direction: 'asc' },
|
||||
zero: { key: '', direction: 'asc' },
|
||||
},
|
||||
rankingColumns: [
|
||||
{ key: 'place', name: 'Место' },
|
||||
{ key: 'team', name: 'Команда' },
|
||||
],
|
||||
missingColumns: [
|
||||
{ key: 'user', name: 'Эксперт' },
|
||||
{ key: 'task', name: 'Кейс' },
|
||||
{ key: 'teams', name: 'Команды' },
|
||||
],
|
||||
refreshing: false,
|
||||
error: '',
|
||||
tabs: [
|
||||
{ id: 'ranking', name: 'Рейтинг' },
|
||||
{ id: 'details', name: 'Все оценки' },
|
||||
{ id: 'missing', name: 'Без оценок' },
|
||||
{ id: 'zero', name: 'Нулевые оценки' },
|
||||
],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
zeroGroups() {
|
||||
if (this.tab !== 'zero') return []
|
||||
const groups = new Map()
|
||||
for (const row of this.reportRows) {
|
||||
if (!groups.has(row.userId)) groups.set(row.userId, { id: row.userId, user: row.user, rows: [] })
|
||||
groups.get(row.userId).rows.push(row)
|
||||
}
|
||||
const direction = this.sorting.key === 'user' && this.sorting.direction === 'desc' ? -1 : 1
|
||||
return [...groups.values()].sort(
|
||||
(a, b) => direction * a.user.localeCompare(b.user, 'ru', { sensitivity: 'base', numeric: true })
|
||||
)
|
||||
},
|
||||
reportColumns() {
|
||||
if (this.tab !== 'zero') return this.missingColumns
|
||||
return [
|
||||
{ key: 'user', name: 'Эксперт' },
|
||||
{ key: 'task', name: 'Кейс' },
|
||||
{ key: 'teams', name: 'Команда' },
|
||||
{ key: 'criterion', name: 'Критерий' },
|
||||
{ key: 'value', name: 'Оценка' },
|
||||
]
|
||||
},
|
||||
sorting() {
|
||||
return this.sorts[this.tab]
|
||||
},
|
||||
detailColumns() {
|
||||
return [
|
||||
{ key: 'team', name: 'Команда' },
|
||||
{ key: 'expert', name: 'Эксперт' },
|
||||
...Object.entries(this.criteria).map(([type, name]) => ({
|
||||
key: 'mark:' + type,
|
||||
name: name + ([20, 30].includes(+type) ? ' (тех.)' : ''),
|
||||
})),
|
||||
{ key: 'total', name: 'Сумма' },
|
||||
]
|
||||
},
|
||||
filteredDetails() {
|
||||
return this.details.filter(task => !this.selectedCase || task.id === this.selectedCase)
|
||||
},
|
||||
filteredPositions() {
|
||||
return this.selectedCase
|
||||
? this.positions[this.selectedCase]
|
||||
? { [this.selectedCase]: this.positions[this.selectedCase] }
|
||||
: {}
|
||||
: this.positions
|
||||
},
|
||||
reportRows() {
|
||||
if (this.tab === 'zero') {
|
||||
const rows = this.filteredDetails.flatMap(task =>
|
||||
task.rows.flatMap(row => {
|
||||
const types = Object.entries(row.marks)
|
||||
.filter(([, value]) => value === 0)
|
||||
.map(([type]) => type)
|
||||
return types.length
|
||||
? [
|
||||
{
|
||||
userId: row.userId,
|
||||
user: row.expert + (row.role === 'technical' ? ' (тех.)' : ''),
|
||||
task: task.name,
|
||||
teams: [row.team],
|
||||
criterion: types
|
||||
.map(type => this.criteria[type] + ([20, 30].includes(+type) ? ' (тех.)' : ''))
|
||||
.join(', '),
|
||||
value: 0,
|
||||
},
|
||||
]
|
||||
: []
|
||||
})
|
||||
)
|
||||
return this.sortRows(rows, (row, key) => (key === 'teams' ? row.teams[0] : row[key]))
|
||||
}
|
||||
const data = this.noMarks
|
||||
const rows = Object.entries(data).flatMap(([user, tasks]) =>
|
||||
Object.entries(tasks)
|
||||
.filter(([name]) => !this.selectedCase || name === this.cases[this.selectedCase])
|
||||
.map(([task, teams]) => ({ user, task, teams }))
|
||||
)
|
||||
return this.sortRows(rows, (row, key) => (key === 'teams' ? row.teams.join(', ') : row[key]))
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
sortBy(key) {
|
||||
this.$set(this.sorts, this.tab, {
|
||||
key,
|
||||
direction: this.sorting.key === key && this.sorting.direction === 'asc' ? 'desc' : 'asc',
|
||||
})
|
||||
},
|
||||
sortRows(rows, value) {
|
||||
const { key, direction } = this.sorting
|
||||
if (!key) return rows
|
||||
return [...rows].sort((a, b) => {
|
||||
const left = value(a, key)
|
||||
const right = value(b, key)
|
||||
if (left == null) return right == null ? 0 : 1
|
||||
if (right == null) return -1
|
||||
const result =
|
||||
typeof left === 'number' && typeof right === 'number'
|
||||
? left - right
|
||||
: String(left).localeCompare(String(right), 'ru', { numeric: true, sensitivity: 'base' })
|
||||
return direction === 'asc' ? result : -result
|
||||
})
|
||||
},
|
||||
sortedDetails(rows) {
|
||||
return this.sortRows(rows, (row, key) => (key.startsWith('mark:') ? row.marks[key.slice(5)] : row[key]))
|
||||
},
|
||||
sortedRanking(ranking) {
|
||||
return this.sortRows(Object.entries(ranking), (row, key) => (key === 'place' ? row[1] : this.teams[row[0]]))
|
||||
},
|
||||
async refresh() {
|
||||
this.refreshing = true
|
||||
this.error = ''
|
||||
try {
|
||||
const [missing, ranking, detail] = await Promise.all([
|
||||
this.$axios.$get('/admin/marks'),
|
||||
this.$axios.$get('/admin/positions'),
|
||||
this.$axios.$get('/admin/marks/details'),
|
||||
])
|
||||
Object.assign(this, missing, ranking, detail)
|
||||
} catch (e) {
|
||||
this.error = 'Не удалось обновить результаты.'
|
||||
} finally {
|
||||
this.refreshing = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,452 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="page-heading expert-heading">
|
||||
<h1>Эксперты</h1>
|
||||
<div class="expert-header-actions">
|
||||
<button class="button" type="button" :disabled="!activeCount" @click="openExport">QR-коды PDF</button
|
||||
><button class="button button-primary" type="button" @click="openNew">
|
||||
<AppIcon name="plus" :size="16" /> Добавить эксперта
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<div class="tabs" role="group" aria-label="Статус эксперта">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.id"
|
||||
class="tab"
|
||||
:class="{ active: filter === tab.id }"
|
||||
:aria-pressed="String(filter === tab.id)"
|
||||
type="button"
|
||||
@click="filter = tab.id"
|
||||
>
|
||||
{{ tab.name }}
|
||||
</button>
|
||||
</div>
|
||||
<label class="search-box"
|
||||
><AppIcon name="search" :size="16" /><input
|
||||
v-model="search"
|
||||
type="search"
|
||||
aria-label="Найти эксперта"
|
||||
placeholder="Найти эксперта"
|
||||
/></label>
|
||||
</div>
|
||||
<div v-if="pageError" class="form-error" role="alert">{{ pageError }}</div>
|
||||
<div class="panel">
|
||||
<div class="table-scroll">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Эксперт</th>
|
||||
<th scope="col">Роль</th>
|
||||
<th scope="col">Логин / пароль</th>
|
||||
<th scope="col">Кейсы</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="user in filteredUsers" :key="user.id">
|
||||
<td>{{ fullName(user) }}</td>
|
||||
<td>{{ user.role === 'technical' ? 'Технический эксперт' : 'Эксперт' }}</td>
|
||||
<td>
|
||||
<span class="mono">{{ user.login }}</span>
|
||||
<div class="password-cell">
|
||||
<span class="mono">{{ revealed[user.id] ? user.passwordForAdmin || '—' : '••••••••' }}</span
|
||||
><button
|
||||
v-if="user.passwordForAdmin"
|
||||
class="icon-button"
|
||||
type="button"
|
||||
:aria-label="(revealed[user.id] ? 'Скрыть пароль: ' : 'Показать пароль: ') + user.login"
|
||||
:aria-pressed="String(!!revealed[user.id])"
|
||||
@click="$set(revealed, user.id, !revealed[user.id])"
|
||||
>
|
||||
<AppIcon name="eye" :size="15" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="assignment-cell">{{ user.cases.map(c => c.name).join(', ') || 'Не назначены' }}</td>
|
||||
<td>
|
||||
<div class="expert-actions">
|
||||
<template v-if="!user.deletedAt"
|
||||
><button
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:aria-label="'Назначить кейсы: ' + user.login"
|
||||
:disabled="saving"
|
||||
@click="assign(user)"
|
||||
>
|
||||
Кейсы</button
|
||||
><button
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:aria-label="'Изменить эксперта: ' + user.login"
|
||||
:disabled="saving"
|
||||
@click="openEdit(user)"
|
||||
>
|
||||
Изменить</button
|
||||
><button
|
||||
class="button button-sm danger-text"
|
||||
type="button"
|
||||
:aria-label="'Удалить эксперта: ' + user.login"
|
||||
:disabled="saving"
|
||||
@click="openDelete(user)"
|
||||
>
|
||||
Удалить
|
||||
</button></template
|
||||
><button
|
||||
v-else
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
:aria-label="'Восстановить эксперта: ' + user.login"
|
||||
@click="restore(user)"
|
||||
>
|
||||
Восстановить
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!filteredUsers.length">
|
||||
<td colspan="5" class="table-empty">Эксперты не найдены.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<FormDialog
|
||||
v-if="editor === 'new' || editor === 'edit'"
|
||||
:title="editor === 'new' ? 'Новый эксперт' : 'Изменить эксперта'"
|
||||
:busy="saving"
|
||||
:submit-label="editor === 'new' ? 'Добавить' : 'Сохранить'"
|
||||
@close="editor = null"
|
||||
@save="saveUser"
|
||||
><label class="field" for="lastName"
|
||||
><span>Фамилия</span
|
||||
><input
|
||||
id="lastName"
|
||||
v-model.trim="draft.lastName"
|
||||
class="text-input"
|
||||
maxlength="50"
|
||||
autocomplete="family-name"
|
||||
required /></label
|
||||
><label class="field" for="firstName"
|
||||
><span>Имя</span
|
||||
><input
|
||||
id="firstName"
|
||||
v-model.trim="draft.firstName"
|
||||
class="text-input"
|
||||
maxlength="50"
|
||||
autocomplete="given-name"
|
||||
required /></label
|
||||
><label class="field" for="middleName"
|
||||
><span>Отчество</span
|
||||
><input
|
||||
id="middleName"
|
||||
v-model.trim="draft.middleName"
|
||||
class="text-input"
|
||||
maxlength="50"
|
||||
autocomplete="additional-name" /></label
|
||||
><template v-if="editor === 'edit'"
|
||||
><label class="field" for="expertLogin"
|
||||
><span>Логин</span
|
||||
><input
|
||||
id="expertLogin"
|
||||
v-model.trim="draft.login"
|
||||
class="text-input"
|
||||
minlength="2"
|
||||
maxlength="100"
|
||||
pattern="[a-zA-Z0-9_.@\-]+"
|
||||
autocomplete="off"
|
||||
required /></label
|
||||
><label class="field" for="expertPassword"
|
||||
><span>Новый пароль</span
|
||||
><input
|
||||
id="expertPassword"
|
||||
v-model="draft.password"
|
||||
class="text-input"
|
||||
type="password"
|
||||
placeholder="Не менять"
|
||||
minlength="6"
|
||||
maxlength="72"
|
||||
autocomplete="new-password" /></label
|
||||
></template>
|
||||
<label class="field" for="expertRole">
|
||||
<span>Роль</span>
|
||||
<select id="expertRole" v-model="draft.role" class="text-input" aria-label="Роль" :disabled="saving">
|
||||
<option value="expert">Эксперт</option>
|
||||
<option value="technical">Технический эксперт</option>
|
||||
</select>
|
||||
</label>
|
||||
<div v-if="editor === 'new'" class="field">
|
||||
<span>Кейсы</span>
|
||||
<div class="checkbox-list">
|
||||
<label v-for="task in cases" :key="task.id" class="checkbox-row">
|
||||
<input v-model="selectedCaseIds" type="checkbox" :value="task.id" :disabled="saving" />
|
||||
<span>{{ task.name }}</span>
|
||||
</label>
|
||||
<p v-if="!cases.length" class="muted">Сначала добавьте кейсы.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div></FormDialog
|
||||
>
|
||||
<FormDialog
|
||||
v-if="editor === 'cases'"
|
||||
:title="fullName(selectedUser)"
|
||||
:busy="saving"
|
||||
@close="editor = null"
|
||||
@save="saveAssignments"
|
||||
><div class="checkbox-list">
|
||||
<label v-for="task in cases" :key="task.id" class="checkbox-row"
|
||||
><input v-model="selectedCaseIds" type="checkbox" :value="task.id" :disabled="saving" /><span>{{
|
||||
task.name
|
||||
}}</span></label
|
||||
>
|
||||
<p v-if="!cases.length" class="muted">Сначала добавьте кейсы.</p>
|
||||
</div>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div></FormDialog
|
||||
>
|
||||
<FormDialog
|
||||
v-if="editor === 'delete'"
|
||||
title="Удалить эксперта?"
|
||||
:busy="saving"
|
||||
submit-label="Удалить"
|
||||
danger
|
||||
@close="editor = null"
|
||||
@save="deleteUser"
|
||||
><p>{{ fullName(selectedUser) }}</p>
|
||||
<p class="muted" style="margin-top: 12px">Доступ будет закрыт. Оценки сохранятся.</p>
|
||||
<div v-if="error" class="form-error" role="alert" style="margin-top: 16px">{{ error }}</div></FormDialog
|
||||
>
|
||||
<FormDialog
|
||||
v-if="editor === 'export'"
|
||||
title="QR-коды экспертов"
|
||||
:busy="exporting"
|
||||
submit-label="Скачать PDF"
|
||||
@close="editor = null"
|
||||
@save="downloadQr"
|
||||
><label class="field" for="baseUrl"
|
||||
><span>Адрес приложения</span
|
||||
><input
|
||||
id="baseUrl"
|
||||
v-model.trim="baseUrl"
|
||||
class="text-input"
|
||||
type="url"
|
||||
maxlength="300"
|
||||
placeholder="https://grading.example.ru/"
|
||||
required
|
||||
/></label>
|
||||
<p class="muted">Все активные эксперты · A4 · 3 × 4 карточки</p>
|
||||
<p v-if="localAddress" class="muted" style="margin-top: 10px">
|
||||
Для входа с телефона укажите адрес, доступный экспертам.
|
||||
</p>
|
||||
<div v-if="error" class="form-error" role="alert" style="margin-top: 16px">{{ error }}</div></FormDialog
|
||||
>
|
||||
<div v-if="message" class="toast" role="status">{{ message }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'Experts',
|
||||
async asyncData({ $axios }) {
|
||||
const [{ users }, { cases }] = await Promise.all([$axios.$get('/admin/users'), $axios.$get('/admin/cases')])
|
||||
return { users, cases }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
users: [],
|
||||
cases: [],
|
||||
search: '',
|
||||
filter: 'active',
|
||||
tabs: [
|
||||
{ id: 'active', name: 'Активные' },
|
||||
{ id: 'deleted', name: 'Удалённые' },
|
||||
],
|
||||
revealed: {},
|
||||
editor: null,
|
||||
selectedUser: null,
|
||||
selectedCaseIds: [],
|
||||
draft: { firstName: '', lastName: '', middleName: '', login: '', password: '', role: 'expert' },
|
||||
error: '',
|
||||
pageError: '',
|
||||
saving: false,
|
||||
exporting: false,
|
||||
baseUrl: '',
|
||||
message: '',
|
||||
timer: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
activeCount() {
|
||||
return this.users.filter(u => !u.deletedAt).length
|
||||
},
|
||||
filteredUsers() {
|
||||
const query = this.search.toLowerCase()
|
||||
return this.users.filter(
|
||||
u =>
|
||||
(this.filter === 'deleted' ? !!u.deletedAt : !u.deletedAt) &&
|
||||
`${this.fullName(u)} ${u.login}`.toLowerCase().includes(query)
|
||||
)
|
||||
},
|
||||
localAddress() {
|
||||
try {
|
||||
return ['localhost', '127.0.0.1', '[::1]'].includes(new URL(this.baseUrl).hostname)
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearTimeout(this.timer)
|
||||
},
|
||||
methods: {
|
||||
fullName(user) {
|
||||
return [user.lastName, user.firstName, user.middleName].filter(Boolean).join(' ')
|
||||
},
|
||||
async reload() {
|
||||
const { users } = await this.$axios.$get('/admin/users')
|
||||
this.users = users
|
||||
},
|
||||
notify(message) {
|
||||
this.message = message
|
||||
clearTimeout(this.timer)
|
||||
this.timer = setTimeout(() => {
|
||||
this.message = ''
|
||||
}, 3500)
|
||||
},
|
||||
openNew() {
|
||||
this.draft = { firstName: '', lastName: '', middleName: '', login: '', password: '', role: 'expert' }
|
||||
this.selectedCaseIds = []
|
||||
this.error = ''
|
||||
this.editor = 'new'
|
||||
},
|
||||
openEdit(user) {
|
||||
this.selectedUser = user
|
||||
this.draft = {
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
middleName: user.middleName || '',
|
||||
login: user.login,
|
||||
password: '',
|
||||
role: user.role || 'expert',
|
||||
}
|
||||
this.error = ''
|
||||
this.editor = 'edit'
|
||||
},
|
||||
openDelete(user) {
|
||||
this.selectedUser = user
|
||||
this.error = ''
|
||||
this.editor = 'delete'
|
||||
},
|
||||
openExport() {
|
||||
this.baseUrl = 'https://cg.vkhost.ru/'
|
||||
this.error = ''
|
||||
this.editor = 'export'
|
||||
},
|
||||
assign(user) {
|
||||
this.selectedUser = user
|
||||
this.selectedCaseIds = user.cases.map(c => c.id)
|
||||
this.error = ''
|
||||
this.editor = 'cases'
|
||||
},
|
||||
async saveUser() {
|
||||
if (this.saving) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
if (this.editor === 'new')
|
||||
await this.$axios.$post('/admin/users', { ...this.draft, caseIds: this.selectedCaseIds })
|
||||
else await this.$axios.$put('/admin/users/' + this.selectedUser.id, this.draft)
|
||||
await this.reload()
|
||||
this.editor = null
|
||||
this.revealed = {}
|
||||
this.filter = 'active'
|
||||
this.search = ''
|
||||
this.notify('Эксперт сохранён')
|
||||
} catch (e) {
|
||||
this.error =
|
||||
e.response?.status === 409
|
||||
? e.response.data.key === 'SYSTEM_ERROR'
|
||||
? e.response.data.message
|
||||
: 'Эксперт или логин уже существует.'
|
||||
: 'Не удалось сохранить эксперта. Проверьте ФИО, логин и пароль.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
async deleteUser() {
|
||||
if (this.saving) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
await this.$axios.$delete('/admin/users/' + this.selectedUser.id)
|
||||
await this.reload()
|
||||
this.editor = null
|
||||
this.revealed = {}
|
||||
this.notify('Эксперт удалён')
|
||||
} catch (e) {
|
||||
this.error = 'Не удалось удалить эксперта.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
async restore(user) {
|
||||
if (this.saving) return
|
||||
this.saving = true
|
||||
this.pageError = ''
|
||||
try {
|
||||
await this.$axios.$post('/admin/users/' + user.id + '/restore')
|
||||
await this.reload()
|
||||
this.notify('Эксперт восстановлен')
|
||||
} catch (e) {
|
||||
this.pageError = e.response?.data?.message || 'Не удалось восстановить эксперта.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
async saveAssignments() {
|
||||
if (this.saving) return
|
||||
this.saving = true
|
||||
this.error = ''
|
||||
try {
|
||||
await this.$axios.$put('/admin/users/' + this.selectedUser.id + '/cases', { caseIds: this.selectedCaseIds })
|
||||
await this.reload()
|
||||
this.editor = null
|
||||
this.notify('Кейсы назначены')
|
||||
} catch (e) {
|
||||
this.error = e.response?.data?.message || 'Не удалось сохранить назначения.'
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
async downloadQr() {
|
||||
if (this.exporting) return
|
||||
this.exporting = true
|
||||
this.error = ''
|
||||
try {
|
||||
const response = await this.$axios.post(
|
||||
'/admin/users/qr-pdf',
|
||||
{ baseUrl: this.baseUrl },
|
||||
{ responseType: 'blob' }
|
||||
)
|
||||
const url = URL.createObjectURL(response.data)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = 'experts-qr.pdf'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
setTimeout(() => URL.revokeObjectURL(url), 10000)
|
||||
this.editor = null
|
||||
} catch (e) {
|
||||
let message = ''
|
||||
try {
|
||||
message = JSON.parse(await e.response.data.text()).message
|
||||
} catch (ignored) {}
|
||||
this.error = message || 'Не удалось скачать PDF. Попробуйте ещё раз.'
|
||||
} finally {
|
||||
this.exporting = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import ExpertCases from '../index.vue'
|
||||
|
||||
export default { ...ExpertCases, name: 'ExpertCase' }
|
||||
</script>
|
||||
@@ -0,0 +1,375 @@
|
||||
<template>
|
||||
<div>
|
||||
<button v-if="selectedCase" class="back-link" type="button" @click="home">
|
||||
<AppIcon name="back" :size="15" /> Кейсы
|
||||
</button>
|
||||
<div class="page-heading">
|
||||
<div class="case-title">
|
||||
<CaseIcon v-if="selectedCase" :src="currentCase.icon" />
|
||||
<h1>{{ selectedCase ? currentCase.name : 'Кейсы' }}</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<button
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
class="simple-row clickable-row"
|
||||
type="button"
|
||||
:aria-label="(selectedCase ? 'Оценить ' : 'Открыть ') + item.name"
|
||||
@click="selectItem(item.id)"
|
||||
>
|
||||
<span class="case-row-label">
|
||||
<CaseIcon v-if="!selectedCase" :src="item.icon" />
|
||||
<span>
|
||||
<strong>{{ item.name }}</strong>
|
||||
<span v-if="item.description" class="row-description">{{ item.description }}</span>
|
||||
<span v-if="!selectedCase" class="row-description"
|
||||
>{{ item.teams.length }} {{ teamWord(item.teams.length) }}</span
|
||||
>
|
||||
<span v-if="selectedCase && isComplete(item)" class="badge team-status-mobile">Оценено</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="row-actions">
|
||||
<span v-if="selectedCase && isComplete(item)" class="badge team-status-desktop">Оценено</span
|
||||
><span class="button" aria-hidden="true">
|
||||
{{ selectedCase ? 'Оценить' : 'Открыть' }}
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
<div v-if="!items.length" class="table-empty">
|
||||
{{ selectedCase ? 'Команд пока нет.' : 'Кейсы не назначены.' }}
|
||||
</div>
|
||||
</div>
|
||||
<dialog
|
||||
ref="scoreDialog"
|
||||
class="score-dialog team-score-dialog"
|
||||
aria-labelledby="score-title"
|
||||
@cancel="closeScore"
|
||||
@click="backdropClick"
|
||||
>
|
||||
<template v-if="team"
|
||||
><div class="dialog-header">
|
||||
<div>
|
||||
<h2 id="score-title">{{ team.name }}</h2>
|
||||
</div>
|
||||
<button class="icon-button" type="button" aria-label="Закрыть оценки" :disabled="saving" @click="closeScore">
|
||||
<AppIcon name="close" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="dialog-body">
|
||||
<p v-if="loadingScore" class="muted" role="status">Загрузка…</p>
|
||||
<div v-if="loadError" class="form-error" role="alert">
|
||||
Не удалось загрузить оценки и комментарий. Откройте команду ещё раз.
|
||||
</div>
|
||||
<div v-if="saveError" class="form-error" role="alert">
|
||||
Не удалось сохранить изменения. Попробуйте ещё раз.
|
||||
</div>
|
||||
<div v-for="(criterion, index) in editableCriteria" :key="criterion.type" class="score-criterion">
|
||||
<div :id="'criterion-' + criterion.type" class="criterion-heading">
|
||||
<span
|
||||
><span class="criterion-index">0{{ index + 1 }}</span
|
||||
>{{ criterion.name }}</span
|
||||
><span>{{ draft[criterion.type] }} / 5</span>
|
||||
</div>
|
||||
<div class="score-scale" role="group" :aria-labelledby="'criterion-' + criterion.type">
|
||||
<button
|
||||
v-for="value in [0, 1, 2, 3, 4, 5]"
|
||||
:key="value"
|
||||
class="score-option"
|
||||
:class="{ selected: draft[criterion.type] === value }"
|
||||
:aria-pressed="String(draft[criterion.type] === value)"
|
||||
:aria-label="criterion.name + ': ' + value"
|
||||
:disabled="saving || loadingScore || loadError"
|
||||
type="button"
|
||||
@click="$set(draft, criterion.type, value)"
|
||||
>
|
||||
{{ value }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="scale-labels"><span>Не проявлено</span><span>Отлично</span></div>
|
||||
</div>
|
||||
<div v-if="isTechnicalExpert" class="field technical-comment-editor">
|
||||
<label for="technicalComment">Комментарий</label>
|
||||
<textarea
|
||||
id="technicalComment"
|
||||
v-model="draftComment"
|
||||
class="text-input"
|
||||
maxlength="5000"
|
||||
rows="4"
|
||||
:disabled="saving || loadingScore || loadError"
|
||||
@input="commentSaved = false"
|
||||
/>
|
||||
<button
|
||||
class="button button-sm"
|
||||
type="button"
|
||||
:disabled="saving || loadingScore || loadError"
|
||||
@click="save(true)"
|
||||
>
|
||||
Сохранить комментарий
|
||||
</button>
|
||||
<p v-if="commentSaved" class="muted" role="status">Комментарий сохранён</p>
|
||||
</div>
|
||||
<section v-if="!isTechnicalExpert && team.technicalComment" class="technical-comment">
|
||||
<h3>Комментарий тех. эксперта</h3>
|
||||
<p>{{ team.technicalComment }}</p>
|
||||
</section>
|
||||
<div v-if="!isTechnicalExpert" class="admin-criteria">
|
||||
<div class="admin-criteria-title"><AppIcon name="lock" :size="13" /> Оценки тех. экспертов</div>
|
||||
<div v-for="criterion in lockedCriteria" :key="criterion.type" class="locked-score">
|
||||
<span>{{ criterion.name }}</span
|
||||
><strong>{{ savedMark(criterion.type) }} / 5</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
<div class="score-total">
|
||||
Ваша оценка<strong
|
||||
>{{ draftTotal }} <span>/ {{ editableCriteria.length * 5 }}</span></strong
|
||||
>
|
||||
</div>
|
||||
<div class="dialog-footer-actions">
|
||||
<button class="button button-quiet" type="button" :disabled="saving" @click="closeScore">Отмена</button
|
||||
><button
|
||||
class="button button-primary"
|
||||
type="button"
|
||||
:disabled="saving || loadingScore || loadError"
|
||||
@click="save()"
|
||||
>
|
||||
<AppIcon name="check" :size="16" /> {{ saving ? 'Сохраняем…' : 'Сохранить оценки' }}
|
||||
</button>
|
||||
</div>
|
||||
</div></template
|
||||
>
|
||||
</dialog>
|
||||
<Transition name="fade"
|
||||
><div v-if="saved" class="toast" role="status">
|
||||
<AppIcon name="check" :size="17" /> {{ savedMessage }}
|
||||
</div></Transition
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Index',
|
||||
middleware: 'home',
|
||||
async asyncData({ $axios, $auth, params, error }) {
|
||||
try {
|
||||
const [{ cases }, appdata] = await Promise.all([$axios.$get('/cases'), $axios.$get('/system/appdata')])
|
||||
if (params.id && !cases?.some(task => task.id === params.id)) {
|
||||
error({ statusCode: 404, message: 'Кейс не найден' })
|
||||
return {}
|
||||
}
|
||||
return { cases: cases || [], appdata }
|
||||
} catch (e) {
|
||||
await $auth.logout()
|
||||
return { cases: [], appdata: { markType: {}, markTypesNames: {} } }
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
cases: [],
|
||||
appdata: { markType: {}, markTypesNames: {} },
|
||||
selectedTeam: null,
|
||||
showScore: false,
|
||||
saving: false,
|
||||
saveError: false,
|
||||
loadingScore: false,
|
||||
loadError: false,
|
||||
scoreRequest: 0,
|
||||
draftComment: '',
|
||||
commentSaved: false,
|
||||
savedMessage: 'Оценки сохранены',
|
||||
saved: false,
|
||||
draft: {},
|
||||
search: '',
|
||||
filter: 'all',
|
||||
toastTimer: null,
|
||||
tabs: [
|
||||
{ id: 'all', label: 'Все' },
|
||||
{ id: 'pending', label: 'К оценке' },
|
||||
{ id: 'done', label: 'Оценено' },
|
||||
],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isTechnicalExpert() {
|
||||
return this.$auth.user?.role === 'technical'
|
||||
},
|
||||
selectedCase() {
|
||||
return this.$route.params.id || null
|
||||
},
|
||||
currentCase() {
|
||||
return this.cases.find(c => c.id === this.selectedCase)
|
||||
},
|
||||
items() {
|
||||
return this.currentCase?.teams || this.cases
|
||||
},
|
||||
team() {
|
||||
return this.currentCase?.teams.find(t => t.id === this.selectedTeam)
|
||||
},
|
||||
allTeams() {
|
||||
return this.cases.flatMap(c => c.teams)
|
||||
},
|
||||
relevantTeams() {
|
||||
return this.currentCase?.teams || this.allTeams
|
||||
},
|
||||
completedTeams() {
|
||||
return this.relevantTeams.filter(this.teamComplete).length
|
||||
},
|
||||
criteria() {
|
||||
return Object.entries(this.appdata.markTypesNames).map(([type, name]) => ({ type: +type, name }))
|
||||
},
|
||||
editableCriteria() {
|
||||
return this.criteria.filter(c => this.isTechnicalExpert === this.isAdminOnlyMarkType(c.type))
|
||||
},
|
||||
lockedCriteria() {
|
||||
return this.criteria.filter(c => this.isAdminOnlyMarkType(c.type))
|
||||
},
|
||||
draftTotal() {
|
||||
return this.editableCriteria.reduce((total, c) => total + (this.draft[c.type] || 0), 0)
|
||||
},
|
||||
visibleItems() {
|
||||
return this.items.filter(
|
||||
item =>
|
||||
item.name.toLowerCase().includes(this.search.toLowerCase()) &&
|
||||
(this.filter === 'all' || (this.filter === 'done' ? this.isComplete(item) : !this.isComplete(item)))
|
||||
)
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearTimeout(this.toastTimer)
|
||||
this.scoreRequest++
|
||||
},
|
||||
methods: {
|
||||
isAdminOnlyMarkType(type) {
|
||||
return type === this.appdata.markType.WORK || type === this.appdata.markType.IMPLEMENTATION
|
||||
},
|
||||
teamComplete(team) {
|
||||
return (
|
||||
this.editableCriteria.length > 0 &&
|
||||
this.editableCriteria.every(c => team.marks.some(m => m.markType === c.type && m.mark !== null))
|
||||
)
|
||||
},
|
||||
isComplete(item) {
|
||||
return this.selectedCase ? this.teamComplete(item) : item.teams.length > 0 && item.teams.every(this.teamComplete)
|
||||
},
|
||||
itemCompleted(item) {
|
||||
return this.selectedCase
|
||||
? this.editableCriteria.filter(c => item.marks.some(m => m.markType === c.type && m.mark !== null)).length
|
||||
: item.teams.filter(this.teamComplete).length
|
||||
},
|
||||
itemTotal(item) {
|
||||
return this.selectedCase ? this.editableCriteria.length : item.teams.length
|
||||
},
|
||||
teamWord(n) {
|
||||
return n % 10 === 1 && n % 100 !== 11
|
||||
? 'команда'
|
||||
: [2, 3, 4].includes(n % 10) && ![12, 13, 14].includes(n % 100)
|
||||
? 'команды'
|
||||
: 'команд'
|
||||
},
|
||||
savedMark(type) {
|
||||
return this.team?.marks.find(m => m.markType === type)?.mark ?? '—'
|
||||
},
|
||||
home() {
|
||||
this.$router.push('/')
|
||||
},
|
||||
fillDraft() {
|
||||
this.commentSaved = false
|
||||
this.draftComment = this.team.technicalComment || ''
|
||||
this.draft = Object.fromEntries(
|
||||
this.editableCriteria.map(c => [c.type, Math.min(5, Math.max(0, Number(this.savedMark(c.type)) || 0))])
|
||||
)
|
||||
},
|
||||
async selectItem(id) {
|
||||
if (!this.selectedCase) {
|
||||
this.$router.push('/cases/' + id)
|
||||
return
|
||||
}
|
||||
this.selectedTeam = id
|
||||
this.saveError = false
|
||||
this.loadError = false
|
||||
this.loadingScore = true
|
||||
const request = ++this.scoreRequest
|
||||
this.showScore = true
|
||||
this.fillDraft()
|
||||
this.$nextTick(() => this.$refs.scoreDialog.showModal())
|
||||
try {
|
||||
const data = await this.$axios.$get(`/cases/${this.selectedCase}/teams/${id}/marks`)
|
||||
if (request !== this.scoreRequest) return
|
||||
this.$set(this.team, 'marks', data.marks)
|
||||
this.$set(this.team, 'technicalComment', data.technicalComment || '')
|
||||
this.fillDraft()
|
||||
} catch (e) {
|
||||
if (request === this.scoreRequest) this.loadError = true
|
||||
} finally {
|
||||
if (request === this.scoreRequest) this.loadingScore = false
|
||||
}
|
||||
},
|
||||
closeScore(event) {
|
||||
if (this.saving) {
|
||||
event?.preventDefault()
|
||||
return
|
||||
}
|
||||
this.$refs.scoreDialog.close()
|
||||
this.showScore = false
|
||||
this.scoreRequest++
|
||||
this.loadingScore = false
|
||||
},
|
||||
backdropClick(event) {
|
||||
if (event.target !== this.$refs.scoreDialog) return
|
||||
const rect = event.target.getBoundingClientRect()
|
||||
if (
|
||||
event.clientX < rect.left ||
|
||||
event.clientX > rect.right ||
|
||||
event.clientY < rect.top ||
|
||||
event.clientY > rect.bottom
|
||||
)
|
||||
this.closeScore(event)
|
||||
},
|
||||
async save(commentOnly = false) {
|
||||
if (this.saving || this.loadingScore || this.loadError) return
|
||||
const marks = commentOnly
|
||||
? []
|
||||
: this.editableCriteria.map(c => ({
|
||||
markType: c.type,
|
||||
mark: Math.min(5, Math.max(0, Number(this.draft[c.type]) || 0)),
|
||||
}))
|
||||
this.saveError = false
|
||||
this.commentSaved = false
|
||||
this.saving = true
|
||||
try {
|
||||
await this.$axios.put(`/cases/${this.selectedCase}/teams/${this.selectedTeam}/marks`, {
|
||||
marks,
|
||||
...(this.isTechnicalExpert ? { technicalComment: this.draftComment } : {}),
|
||||
})
|
||||
if (this.isTechnicalExpert) {
|
||||
this.draftComment = this.draftComment.trim()
|
||||
this.$set(this.team, 'technicalComment', this.draftComment)
|
||||
}
|
||||
for (const { markType, mark } of marks) {
|
||||
const existing = this.team.marks.find(m => m.markType === markType)
|
||||
if (existing) existing.mark = mark
|
||||
else this.team.marks.push({ markType, mark })
|
||||
}
|
||||
if (!commentOnly) {
|
||||
this.$refs.scoreDialog.close()
|
||||
this.showScore = false
|
||||
}
|
||||
this.savedMessage = commentOnly ? 'Комментарий сохранён' : 'Оценки сохранены'
|
||||
this.commentSaved = commentOnly
|
||||
this.saved = true
|
||||
clearTimeout(this.toastTimer)
|
||||
this.toastTimer = setTimeout(() => {
|
||||
this.saved = false
|
||||
}, 4500)
|
||||
} catch (e) {
|
||||
this.saveError = true
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<main class="login-page">
|
||||
<form class="login-form" aria-label="Вход" @submit.prevent="userLogin">
|
||||
<img class="login-logo" src="/logo2026.png" alt="CyberGarden" width="180" height="170" />
|
||||
<h1 class="login-title">Система оценки команд</h1>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div>
|
||||
<input
|
||||
id="login"
|
||||
v-model.trim="login.login"
|
||||
class="text-input"
|
||||
name="username"
|
||||
autocomplete="username"
|
||||
aria-label="Логин"
|
||||
placeholder="Логин"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
id="password"
|
||||
v-model="login.password"
|
||||
class="text-input"
|
||||
name="password"
|
||||
type="password"
|
||||
autocomplete="current-password"
|
||||
aria-label="Пароль"
|
||||
placeholder="Пароль"
|
||||
required
|
||||
/>
|
||||
<button class="button button-primary" type="submit" :disabled="loading">
|
||||
{{ loading ? 'Входим…' : 'Войти' }}
|
||||
</button>
|
||||
</form>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Login',
|
||||
layout: 'empty',
|
||||
data() {
|
||||
return { login: { login: '', password: '' }, loading: false, error: '' }
|
||||
},
|
||||
mounted() {
|
||||
this.login.login = this.$route.query.l ?? ''
|
||||
this.login.password = this.$route.query.p ?? ''
|
||||
},
|
||||
methods: {
|
||||
async userLogin() {
|
||||
if (this.loading) return
|
||||
this.loading = true
|
||||
this.error = ''
|
||||
try {
|
||||
const { data } = await this.$auth.loginWith('local', { data: this.login })
|
||||
this.$auth.setUser(data.user)
|
||||
localStorage.setItem('user.firstName', data.user.firstName || '')
|
||||
localStorage.setItem('user.lastName', data.user.lastName || '')
|
||||
await this.$router.push(data.user.login === 'admin' ? '/admin' : '/')
|
||||
} catch (e) {
|
||||
this.error =
|
||||
e.response?.status === 403
|
||||
? 'Проверьте логин и пароль и попробуйте ещё раз.'
|
||||
: 'Не удалось войти. Проверьте соединение и попробуйте ещё раз.'
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user