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,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>
|
||||
Reference in new issue
Block a user