This commit is contained in:
timur 2026-09-26 22:51:18 +05:00
parent 1924f21659
commit 6eed1f1a95
19 changed files with 701 additions and 175 deletions

View File

@ -1,15 +1,12 @@
:root {
color-scheme: light;
--soft-text: #344767;
--soft-muted: #8392ab;
--soft-bg: #f8f9fa;
--soft-shadow: 0 14px 22px 0 rgb(0 0 0 / 3%);
--soft-shadow-hover: 0 16px 24px 0 rgb(0 0 0 / 6%);
--soft-gradient: linear-gradient(
135deg,
color-mix(in srgb, rgb(var(--v-theme-primary)) 88%, black) 0%,
color-mix(in srgb, rgb(var(--v-theme-primary)) 78%, white) 100%
);
--soft-text: #17233c;
--soft-muted: #75819a;
--soft-bg: #f4f6fa;
--soft-border: #e3e8f1;
--soft-shadow: 0 1px 2px rgb(16 24 40 / 3%);
--soft-shadow-hover: 0 8px 24px rgb(36 87 230 / 9%);
--soft-gradient: linear-gradient(135deg, #1f55e5 0%, #356df4 100%);
}
html { overflow-y: auto; }
@ -17,7 +14,7 @@ html { overflow-y: auto; }
body {
background: var(--soft-bg);
color: var(--soft-text);
font-family: "Open Sans", Inter, Roboto, Arial, sans-serif;
font-family: Inter, "Open Sans", Roboto, Arial, sans-serif;
letter-spacing: -.01em;
}
@ -45,21 +42,18 @@ h1, h2, h3, h4, h5, h6,
.soft-main,
.soft-auth {
background:
radial-gradient(circle at 82% 5%, rgb(33 212 253 / 8%), transparent 27rem),
var(--soft-bg);
background: var(--soft-bg);
}
.soft-sidebar {
margin: 16px 0 16px 16px;
height: calc(100% - 32px) !important;
border: 0 !important;
border-radius: 16px;
box-shadow: var(--soft-shadow);
border-right: 1px solid var(--soft-border) !important;
box-shadow: none;
}
.soft-sidebar .v-navigation-drawer__content { border-radius: 16px; }
.soft-brand-title { font-size: .95rem; letter-spacing: .02em; }
.soft-sidebar .v-navigation-drawer__content { background: #fff; }
.soft-brand-title { color: #17233c; font-size: .93rem; letter-spacing: .045em; }
.engineer-brand-mark { background: #17233c; color: white; font-size: 1rem; font-weight: 800; }
.soft-sidebar.v-navigation-drawer--rail .soft-brand {
padding-inline: 8px !important;
@ -70,9 +64,9 @@ h1, h2, h3, h4, h5, h6,
}
.soft-nav .v-list-item {
min-height: 46px;
margin-bottom: 4px;
border-radius: 10px !important;
min-height: 40px;
margin-bottom: 2px;
border-radius: 7px !important;
color: var(--soft-muted);
font-size: .875rem;
font-weight: 600;
@ -87,9 +81,9 @@ h1, h2, h3, h4, h5, h6,
}
.soft-nav .v-list-item--active {
background: rgb(var(--v-theme-surface)) !important;
box-shadow: 0 8px 18px rgb(0 0 0 / 4%);
color: var(--soft-text) !important;
background: rgb(var(--v-theme-primary) / 9%) !important;
box-shadow: inset 3px 0 0 rgb(var(--v-theme-primary));
color: rgb(var(--v-theme-primary)) !important;
}
.soft-nav .v-list-item--active > .v-list-item__prepend .v-icon {
@ -106,14 +100,11 @@ h1, h2, h3, h4, h5, h6,
}
.soft-app-bar {
margin: 12px 20px 0;
right: 0 !important;
width: auto !important;
border: 0 !important;
border-radius: 14px !important;
background: rgb(var(--v-theme-background) / 78%) !important;
border-bottom: 1px solid var(--soft-border) !important;
background: rgb(var(--v-theme-surface) / 96%) !important;
box-shadow: none !important;
backdrop-filter: blur(12px);
backdrop-filter: blur(16px);
}
.soft-app-bar .v-toolbar-title {
@ -130,7 +121,7 @@ h1, h2, h3, h4, h5, h6,
}
.v-card {
border-color: rgb(52 71 103 / 7%) !important;
border: 1px solid var(--soft-border) !important;
box-shadow: var(--soft-shadow) !important;
transition: transform .2s ease, box-shadow .2s ease;
}
@ -152,7 +143,7 @@ h1, h2, h3, h4, h5, h6,
.workspace-zone {
padding: 20px;
border: 1px solid rgb(52 71 103 / 6%);
border-radius: 16px;
border-radius: 10px;
background: rgb(var(--v-theme-surface) / 38%);
}
@ -240,12 +231,12 @@ h1, h2, h3, h4, h5, h6,
.v-label { color: var(--soft-muted); font-size: .875rem; }
.v-data-table {
border-radius: 16px;
border-radius: 9px;
overflow: hidden;
}
.v-data-table thead th {
height: 52px !important;
height: 44px !important;
color: var(--soft-muted) !important;
font-size: .68rem !important;
font-weight: 700 !important;
@ -254,7 +245,7 @@ h1, h2, h3, h4, h5, h6,
}
.v-data-table tbody td {
height: 58px !important;
height: 50px !important;
color: var(--soft-text);
font-size: .82rem;
border-color: rgb(52 71 103 / 6%) !important;
@ -277,13 +268,7 @@ h1, h2, h3, h4, h5, h6,
.v-divider { opacity: .08; }
@media (max-width: 1279px) {
.soft-sidebar {
margin: 0;
height: 100% !important;
border-radius: 0;
}
}
@media (max-width: 1279px) { .soft-sidebar { height: 100% !important; } }
@media (max-width: 600px) {
.v-dialog > .v-overlay__content {
@ -292,9 +277,71 @@ h1, h2, h3, h4, h5, h6,
max-height: calc(100vh - 24px);
}
.soft-app-bar {
margin: 8px 10px 0;
}
}
/* Engineer workspace theme */
.engineer-content { padding: 28px 32px 48px !important; }
.app-command-search {
display: flex;
align-items: center;
gap: 9px;
width: min(540px, 42vw);
height: 38px;
padding: 0 11px;
border: 1px solid var(--soft-border);
border-radius: 8px;
background: #f8f9fc;
color: var(--soft-muted);
transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.app-command-search.is-focused { border-color: rgb(var(--v-theme-primary) / 55%); background: white; box-shadow: 0 0 0 3px rgb(var(--v-theme-primary) / 8%); }
.app-command-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--soft-text); font: inherit; font-size: .8rem; }
.app-command-search input::placeholder { color: #96a0b5; }
.app-command-search kbd { padding: 2px 6px; border: 1px solid #dce2ec; border-radius: 5px; background: #fff; color: #8791a6; font: 600 .62rem/1.3 Inter, sans-serif; }
.app-create-action { min-width: 104px; }
.app-profile-action .v-btn__content { gap: 9px; }
.engineer-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.engineer-page-header h1 { margin: 2px 0 3px; font-size: clamp(1.75rem, 3vw, 2.25rem); line-height: 1.15; }
.engineer-page-header p, .engineer-section-heading p { margin: 0; color: var(--soft-muted); font-size: .84rem; }
.engineer-eyebrow { color: rgb(var(--v-theme-primary)); font-size: .67rem; font-weight: 800; letter-spacing: .1em; }
.engineer-filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--soft-border); }
.engineer-filter-row .v-btn { min-width: 82px; }
.engineer-section { overflow: hidden; margin-bottom: 22px; border: 1px solid var(--soft-border); border-radius: 10px; background: white; }
.engineer-section-heading { display: flex; align-items: center; justify-content: space-between; padding: 17px 18px; border-bottom: 1px solid var(--soft-border); }
.engineer-section-heading h2 { margin: 0 0 2px; font-size: .98rem; }
.engineer-section-heading > span { color: var(--soft-muted); font-size: .75rem; }
.engineer-queue-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto 20px; align-items: center; gap: 12px; min-height: 67px; padding: 10px 17px; border-bottom: 1px solid #edf0f5; color: var(--soft-text); text-decoration: none; transition: background .16s ease; }
.engineer-queue-row:last-child { border-bottom: 0; }
.engineer-queue-row:hover { background: #f7f9ff; }
.engineer-module-icon { display: inline-grid; width: 36px; height: 36px; place-items: center; border: 1px solid #dce4f9; border-radius: 8px; background: #f1f5ff; color: rgb(var(--v-theme-primary)); }
.engineer-module-copy, .engineer-tool-card > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; }
.engineer-module-copy strong, .engineer-tool-card strong { font-size: .84rem; }
.engineer-module-copy small, .engineer-tool-card small { margin-top: 2px; color: var(--soft-muted); font-size: .71rem; }
.engineer-tools-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--soft-border); }
.engineer-tool-card { display: flex; align-items: center; gap: 10px; min-height: 76px; padding: 13px 15px; background: white; color: var(--soft-text); text-decoration: none; transition: background .16s ease; }
.engineer-tool-card:hover { background: #f7f9ff; }
.engineer-tool-card > .v-icon { color: #9aa4b7; }
.resource-view-select { max-width: 230px; }
.page-shell > .v-breadcrumbs { padding-bottom: 8px !important; }
.page-shell > .v-card, .page-shell > div > .v-card { box-shadow: none !important; }
@media (max-width: 900px) {
.engineer-content { padding: 22px 18px 40px !important; }
.app-command-search { width: min(380px, 48vw); }
.app-command-search kbd { display: none; }
.engineer-tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
.engineer-content { padding: 18px 12px 32px !important; }
.app-command-search { display: none; }
.app-create-action { min-width: 40px; padding-inline: 0 !important; }
.app-create-action .v-btn__content { font-size: 0; }
.engineer-page-header { align-items: flex-start; flex-direction: column; }
.engineer-tools-grid { grid-template-columns: 1fr; }
}
.history-meta-grid,
.history-change-row {

View File

@ -5,8 +5,12 @@ const crmModule = getModule('crm')!
const typesResource = getResource('crm', 'types')!
const categoriesResource = getResource('crm', 'categories')!
const permissions = usePermissions()
const canViewTypes = computed(() => permissions.canView('crm', 'crm', 'types'))
const canViewCategories = computed(() => permissions.canView('crm', 'crm', 'categories'))
const canViewTypes = computed(() => permissions.canView(
'crm', 'crm', typesResource.accessKey || typesResource.key,
))
const canViewCategories = computed(() => permissions.canView(
'crm', 'crm', categoriesResource.accessKey || categoriesResource.key,
))
const activeTab = ref(canViewTypes.value ? 'types' : 'categories')
</script>

View File

@ -118,7 +118,8 @@ onBeforeUnmount(() => { if (searchTimer) clearTimeout(searchTimer) })
:title="employeeName(employee)"
:subtitle="String(employee.username || employee.description || '')">
<template #prepend>
<v-avatar color="primary" variant="tonal"><v-icon icon="mdi-account-outline" /></v-avatar>
<EmployeeAvatar :avatar="employee.avatar as string | number | null"
:name="employeeName(employee)" />
</template>
<template #append>
<v-chip v-if="String(employee.id) === String(managerId)" size="small"

View File

@ -0,0 +1,51 @@
<script setup lang="ts">
const props = withDefaults(defineProps<{
avatar?: string | number | null
name?: string | null
size?: string | number
rounded?: string | boolean
}>(), { avatar: null, name: '', size: 40, rounded: 'circle' })
const { request } = useApi()
const imageUrl = ref('')
const failed = ref(false)
let loadVersion = 0
const initials = computed(() => String(props.name || '').trim().split(/\s+/)
.filter(Boolean).slice(0, 2).map(part => part[0]?.toUpperCase()).join(''))
function releaseImage() {
if (imageUrl.value) URL.revokeObjectURL(imageUrl.value)
imageUrl.value = ''
}
async function loadAvatar() {
const version = ++loadVersion
releaseImage()
failed.value = false
if (props.avatar === null || props.avatar === undefined || props.avatar === '') return
try {
const blob = await request<Blob>(`/main/dsk/files/${props.avatar}/download/`, { responseType: 'blob' })
if (version !== loadVersion) return
imageUrl.value = URL.createObjectURL(blob)
} catch {
if (version === loadVersion) failed.value = true
}
}
watch(() => props.avatar, loadAvatar, { immediate: true })
onBeforeUnmount(() => { loadVersion++; releaseImage() })
</script>
<template>
<v-avatar :size="size" :rounded="rounded" color="primary" variant="tonal" class="employee-avatar">
<v-img v-if="imageUrl && !failed" :src="imageUrl" :alt="name ? `Аватар: ${name}` : 'Аватар сотрудника'" cover />
<span v-else-if="initials" class="employee-avatar__initials">{{ initials }}</span>
<v-icon v-else icon="mdi-account-outline" />
</v-avatar>
</template>
<style scoped>
.employee-avatar { flex: 0 0 auto; }
.employee-avatar__initials { font-size: .72em; font-weight: 800; letter-spacing: -.02em; }
</style>

View File

@ -0,0 +1,104 @@
<script setup lang="ts">
import type { ApiRecord } from '~/types/api'
const props = withDefaults(defineProps<{
avatar?: string | number | null
employeeId?: string | number | null
self?: boolean
name?: string | null
readonly?: boolean
}>(), { avatar: null, employeeId: null, self: false, name: '', readonly: false })
const emit = defineEmits<{
updated: [avatar: string | number | null, employee: ApiRecord]
}>()
const { request } = useApi()
const input = ref<HTMLInputElement | null>(null)
const busy = ref(false)
const error = ref('')
const endpoint = computed(() => props.self
? '/main/sys/employees/me/'
: props.employeeId === null || props.employeeId === undefined
? '' : `/main/sys/employees/${props.employeeId}/`)
function selectFile() { input.value?.click() }
async function upload(event: Event) {
const target = event.target as HTMLInputElement
const file = target.files?.[0]
target.value = ''
if (!file || !endpoint.value) return
if (!file.type.startsWith('image/')) {
error.value = 'Выберите файл изображения'
return
}
if (file.size > 5 * 1024 * 1024) {
error.value = 'Размер изображения не должен превышать 5 МБ'
return
}
busy.value = true
error.value = ''
let uploadedId: string | number | null = null
try {
const body = new FormData()
body.append('file', file)
const uploaded = await request<ApiRecord>('/main/dsk/files/', { method: 'POST', body })
if (uploaded.id === undefined) throw new Error('API не вернул идентификатор файла')
uploadedId = uploaded.id
const employee = await request<ApiRecord>(endpoint.value, {
method: 'PATCH', body: { avatar: uploadedId }, preserveNulls: true,
})
emit('updated', uploadedId, employee)
} catch (reason: any) {
if (uploadedId !== null) {
await request(`/main/dsk/files/${uploadedId}/`, { method: 'DELETE' }).catch(() => undefined)
}
error.value = reason?.message || 'Не удалось обновить аватар'
} finally { busy.value = false }
}
async function removeAvatar() {
if (!endpoint.value || props.avatar === null || props.avatar === undefined) return
busy.value = true
error.value = ''
try {
const employee = await request<ApiRecord>(endpoint.value, {
method: 'PATCH', body: { avatar: null }, preserveNulls: true,
})
emit('updated', null, employee)
} catch (reason: any) {
error.value = reason?.message || 'Не удалось удалить аватар'
} finally { busy.value = false }
}
</script>
<template>
<div class="avatar-manager">
<EmployeeAvatar :avatar="avatar" :name="name" :size="88" />
<div class="avatar-manager__content">
<strong>Аватар сотрудника</strong>
<p>JPG, PNG или WebP, до 5 МБ.</p>
<div v-if="!readonly && endpoint" class="d-flex flex-wrap ga-2">
<input ref="input" class="d-none" type="file" accept="image/jpeg,image/png,image/webp"
@change="upload">
<v-btn type="button" size="small" color="primary" variant="tonal"
prepend-icon="mdi-camera-outline" :loading="busy" @click="selectFile">
{{ avatar ? 'Заменить' : 'Загрузить' }}
</v-btn>
<v-btn v-if="avatar" type="button" size="small" color="error" variant="text"
prepend-icon="mdi-delete-outline" :disabled="busy" @click="removeAvatar">
Удалить
</v-btn>
</div>
<p v-else-if="!readonly" class="text-warning">Сначала сохраните сотрудника.</p>
<v-alert v-if="error" type="error" variant="tonal" density="compact" class="mt-3">{{ error }}</v-alert>
</div>
</div>
</template>
<style scoped>
.avatar-manager { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; padding: 16px; border: 1px solid var(--soft-border); border-radius: 10px; background: rgb(var(--v-theme-surface)); }
.avatar-manager__content { min-width: 0; }
.avatar-manager__content > strong { display: block; font-size: .9rem; }
.avatar-manager__content > p { margin: 3px 0 10px; color: var(--soft-muted); font-size: .75rem; }
</style>

View File

@ -2,7 +2,7 @@
import type { AccessOption, ApiRecord, ModuleDefinition, ResourceDefinition, SysNavigation, SysPermission } from '~/types/api'
import type { JsonSchema } from '~/types/schema'
import { comparisonsFor, normalizeFilterType } from '~/config/filter-comparisons'
import { getThemeColorOptions, normalizeThemeColor, resolveThemeColor } from '~/config/theme-colors'
import { getThemeColorOptions, normalizeThemeColor, serializeThemeColor } from '~/config/theme-colors'
import { formatDateValue } from '~/utils/date'
import { accessOption } from '~/utils/access'
@ -12,8 +12,11 @@ const route = useRoute()
const router = useRouter()
const permissions = usePermissions()
const { t } = useUiText()
const canCreate = computed(() => !props.resource.readOnly && permissions.canCreate(props.module.key, props.module.apiPrefix, props.resource.key))
const canEdit = computed(() => !props.resource.readOnly && permissions.canEdit(props.module.key, props.module.apiPrefix, props.resource.key))
const permissionKey = computed(() => props.resource.accessKey || props.resource.key)
const canCreate = computed(() => !props.resource.readOnly
&& permissions.canCreate(props.module.key, props.module.apiPrefix, permissionKey.value))
const canEdit = computed(() => !props.resource.readOnly
&& permissions.canEdit(props.module.key, props.module.apiPrefix, permissionKey.value))
const canCreateCrmActivity = computed(() => permissions.canCreate('crm', 'crm', 'activities'))
const apiPath = computed(() => `/main/${props.module.apiPrefix}/${props.resource.path}/`)
const items = ref<ApiRecord[]>([])
@ -77,6 +80,10 @@ const houseAddressSearch = ref('')
const systemObjectOptions = ref<{ title: string; value: string | number }[]>([])
const selectedSystemObjectId = ref<string | number | null>(null)
const savedSystemObjectId = ref<string | number | null>(null)
const viewEmployeeOptions = ref<{ title: string; value: string | number }[]>([])
const viewDepartmentOptions = ref<{ title: string; value: string | number }[]>([])
const selectedViewEmployeeIds = ref<(string | number)[]>([])
const selectedViewDepartmentIds = ref<(string | number)[]>([])
const newViewField = reactive<{
field: string | { title: string; value: string; type: string }
compare: string | null
@ -99,6 +106,16 @@ const viewOptions = computed(() => listViews.value
title: String(view.name || view.title || `Представление #${view.id}`),
value: view.id!,
})))
const selectedSystemObjectTitle = computed(() => {
const object = formData.value.sys_object
if (object && typeof object === 'object') {
const record = object as ApiRecord
const title = record.name || record.description || record.title
if (title) return String(title)
}
return systemObjectOptions.value.find(option =>
String(option.value) === String(selectedSystemObjectId.value))?.title || '—'
})
const userCreateSchema: JsonSchema = {
type: 'object',
@ -142,7 +159,7 @@ const isCimTypesResource = computed(() => props.module.apiPrefix === 'cim' && pr
const isCisResource = computed(() => props.module.apiPrefix === 'cim' && props.resource.key === 'cis')
const isClientsResource = computed(() => props.module.apiPrefix === 'crm' && props.resource.key === 'clients')
const isLeadsResource = computed(() => props.module.apiPrefix === 'crm' && props.resource.key === 'leads')
const hasContactRelations = computed(() => ['crm:clients', 'crm:leads']
const hasContactRelations = computed(() => ['crm:clients', 'crm:leads', 'sys:employees']
.includes(businessResourceKey.value))
const addressObjectResources = ['countries', 'regions', 'areas', 'towns', 'streets', 'houses', 'zones']
const isAddressObjectResource = computed(() => props.module.apiPrefix === 'adr'
@ -462,7 +479,7 @@ const formHiddenFields = computed(() => [
: []),
...(businessResourceKey.value === 'sys:employees'
? [
'username', 'department_names', 'departments', 'status', 'permissions', 'navigations',
'username', 'avatar', 'department_names', 'departments', 'status', 'permissions', 'navigations',
...(editingId.value !== null ? ['sys_user'] : []),
]
: []),
@ -532,6 +549,7 @@ const formFieldOptions = computed(() => {
? { ci_type_id: ciTypeOptions.value, ...cisReferenceOptions.value }
: { ...scalarReferenceOptions.value }
if (businessResourceKey.value === 'crm:contracts') options.status = contractStatusOptions.value
if (businessResourceKey.value === 'sys:employees') options.theme_color = themeColorOptions
return Object.keys(options).length ? options : undefined
})
const departmentManagerId = computed<string | number | null>({
@ -577,6 +595,11 @@ const formFieldLabels = computed(() => Object.fromEntries([
.map(([field, definition]) => [field, definition.label]),
]))
const formFieldClasses = computed<Record<string, string> | undefined>(() => {
if (businessResourceKey.value === 'sys:employees') return {
firstname: 'employee-name-field',
secondname: 'employee-name-field',
surname: 'employee-name-field',
}
if (isHolidaysResource.value) return {
date_begin: 'holiday-date',
date_end: 'holiday-date',
@ -669,6 +692,10 @@ const formTabs = computed(() => {
{ title: 'Permission', value: 'permissions', fields: ['permissions', 'navigations'] },
{ title: 'Подразделение', value: 'departments', fields: [] },
]
if (businessResourceKey.value === 'sys:tags') return [
{ title: 'Основное', value: 'main' },
{ title: 'Связанные объекты', value: 'objects', fields: [] },
]
if (isClientsResource.value || isLeadsResource.value) return [
{ title: 'Основные', value: 'main' },
{ title: 'Активности', value: 'activities', fields: [] },
@ -904,9 +931,18 @@ function formPayload(record: ApiRecord): ApiRecord {
? ['username', 'department_name', ...(editingId.value !== null ? ['sys_user'] : [])]
: []),
].includes(name))
.map(([name, value]) => hasContactRelations.value && name === 'con_person'
? [name, relationIds(value)]
: [name, value]))
.map(([name, value]) => {
if (hasContactRelations.value && name === 'con_person') return [name, relationIds(value)]
if (businessResourceKey.value === 'sys:employees' && name === 'theme_color') {
return [name, serializeThemeColor(value, formData.value.theme_is_light !== false)]
}
return [name, value]
}))
}
function normalizeEmployeeThemeColor(record: ApiRecord) {
if (businessResourceKey.value !== 'sys:employees' || record.theme_color === undefined) return record
return { ...record, theme_color: normalizeThemeColor(record.theme_color) }
}
function relationIds(value: unknown): (string | number)[] {
@ -1036,6 +1072,59 @@ async function loadSystemObjects(search = '') {
}))
}
function mergeOptions(
current: { title: string; value: string | number }[],
incoming: { title: string; value: string | number }[],
) {
return [...new Map([...current, ...incoming].map(option => [String(option.value), option])).values()]
}
async function loadViewEmployees(search = '') {
const data = await request<any>('/main/sys/employees/', {
query: { page_size: 100, ...(search.trim() ? { searchstr: search.trim() } : {}) },
})
const options = normalizeList<ApiRecord>(data).items
.map(employeeReferenceOption)
.filter((option): option is { title: string; value: string | number } => Boolean(option))
viewEmployeeOptions.value = mergeOptions(viewEmployeeOptions.value, options)
}
async function loadViewDepartments(search = '') {
const data = await request<any>('/main/sys/departments/', {
query: { page_size: 100, ...(search.trim() ? { searchstr: search.trim() } : {}) },
})
const options = normalizeList<ApiRecord>(data).items
.filter(department => department.id !== undefined)
.map(department => ({
title: String(department.name || `Подразделение #${department.id}`),
value: department.id!,
}))
viewDepartmentOptions.value = mergeOptions(viewDepartmentOptions.value, options)
}
async function loadSelectedViewAudienceOptions() {
const employeeIds = selectedViewEmployeeIds.value.filter(id =>
!viewEmployeeOptions.value.some(option => String(option.value) === String(id)))
const departmentIds = selectedViewDepartmentIds.value.filter(id =>
!viewDepartmentOptions.value.some(option => String(option.value) === String(id)))
const [employees, departments] = await Promise.all([
Promise.all(employeeIds.map(async id => employeeReferenceOption(
await request<ApiRecord>(`/main/sys/employees/${id}/`),
))),
Promise.all(departmentIds.map(async id => {
const department = await request<ApiRecord>(`/main/sys/departments/${id}/`)
return department.id === undefined ? null : {
title: String(department.name || `Подразделение #${department.id}`),
value: department.id,
}
})),
])
viewEmployeeOptions.value = mergeOptions(viewEmployeeOptions.value,
employees.filter((option): option is { title: string; value: string | number } => Boolean(option)))
viewDepartmentOptions.value = mergeOptions(viewDepartmentOptions.value,
departments.filter((option): option is { title: string; value: string | number } => Boolean(option)))
}
async function loadManufacturers(search = '') {
const data = await request<any>('/main/dev/manufacturers/', {
query: { page_size: search.trim() ? 50 : 1000, ...(search.trim() ? { searchstr: search.trim() } : {}) },
@ -1469,9 +1558,11 @@ async function saveView() {
method: creating ? 'POST' : 'PATCH',
body: {
name: formData.value.name,
sys_object: { id: Number(selectedSystemObjectId.value) },
...(creating ? { sys_object: { id: String(selectedSystemObjectId.value) } } : {}),
is_all: Boolean(formData.value.is_all),
is_main_menu: Boolean(formData.value.is_main_menu),
employees: selectedViewEmployeeIds.value,
departments: selectedViewDepartmentIds.value,
},
})
if (creating) editingId.value = result.id!
@ -1479,6 +1570,8 @@ async function saveView() {
const object = result.sys_object as ApiRecord | undefined
savedSystemObjectId.value = object?.id ?? selectedSystemObjectId.value
selectedSystemObjectId.value = savedSystemObjectId.value
selectedViewEmployeeIds.value = relationIds(result.employees)
selectedViewDepartmentIds.value = relationIds(result.departments)
viewFields.value = Array.isArray(result.sys_view_field)
? result.sys_view_field as ApiRecord[]
: []
@ -1498,10 +1591,20 @@ watch(selectedViewFieldValue, (field, previousField) => {
newViewField.compare = null
newViewField.value = null
})
watch(selectedSystemObjectId, () => {
watch(selectedSystemObjectId, (objectId, previousObjectId) => {
if (String(objectId) === String(previousObjectId)) return
newViewField.field = ''
newViewField.compare = null
newViewField.value = null
if (isViewsResource.value && editingId.value === null) {
viewFields.value = []
viewFieldOptions.value = []
}
})
watch(() => formData.value.is_all, isAll => {
if (!isViewsResource.value || !isAll) return
selectedViewEmployeeIds.value = []
selectedViewDepartmentIds.value = []
})
watch(() => formData.value.department, async (department, previousDepartment) => {
if (businessResourceKey.value !== 'chn:tasks'
@ -1807,10 +1910,14 @@ async function openCreate() {
if (isViewsResource.value) {
selectedSystemObjectId.value = null
savedSystemObjectId.value = null
selectedViewEmployeeIds.value = []
selectedViewDepartmentIds.value = []
viewEmployeeOptions.value = []
viewDepartmentOptions.value = []
viewFields.value = []
viewFieldOptions.value = []
try {
await loadSystemObjects()
await Promise.all([loadSystemObjects(), loadViewEmployees(), loadViewDepartments()])
editor.value = true
} catch (e: any) {
error.value = e.message
@ -1905,7 +2012,9 @@ async function openEdit(item: ApiRecord) {
}
editor.value = true
try {
formData.value = await request<ApiRecord>(`${apiPath.value}${item.id}/`)
formData.value = normalizeEmployeeThemeColor(
await request<ApiRecord>(`${apiPath.value}${item.id}/`),
)
if (isClientsResource.value || isLeadsResource.value) {
const assigned = formData.value.assigned as ApiRecord | undefined
if (assigned?.id !== undefined) {
@ -1995,10 +2104,18 @@ async function openEdit(item: ApiRecord) {
const object = formData.value.sys_object as ApiRecord | undefined
selectedSystemObjectId.value = object?.id ?? null
savedSystemObjectId.value = selectedSystemObjectId.value
selectedViewEmployeeIds.value = relationIds(formData.value.employees)
selectedViewDepartmentIds.value = relationIds(formData.value.departments)
viewEmployeeOptions.value = []
viewDepartmentOptions.value = []
viewFields.value = Array.isArray(formData.value.sys_view_field)
? formData.value.sys_view_field as ApiRecord[]
: []
await Promise.all([loadSystemObjects(), loadViewFieldOptions(), refreshViewFields()])
await Promise.all([
loadSystemObjects(), loadViewEmployees(), loadViewDepartments(),
loadViewFieldOptions(), refreshViewFields(),
])
await loadSelectedViewAudienceOptions()
return
}
if (isObjectsResource.value) await loadObjectFields()
@ -2110,7 +2227,9 @@ async function save() {
])
} else if (creating) closeEditor()
else {
formData.value = await request<ApiRecord>(`${apiPath.value}${editingId.value}/`)
formData.value = normalizeEmployeeThemeColor(
await request<ApiRecord>(`${apiPath.value}${editingId.value}/`),
)
await loadSchema(formData.value)
}
await load()
@ -2208,7 +2327,9 @@ onMounted(async () => {
:page="page" :items-per-page="pageSize" item-value="id" show-select hover
@update:page="page = $event" @update:items-per-page="pageSize = $event" @click:row="openRow">
<template v-for="column in columns" #[itemSlot(column)]="{ item }">
<v-chip v-if="isInactiveValue(item, column)" size="small" color="error" variant="tonal">
<EmployeeAvatar v-if="column === 'avatar'" :avatar="item.avatar"
:name="String(item.name || item.username || '')" size="34" />
<v-chip v-else-if="isInactiveValue(item, column)" size="small" color="error" variant="tonal">
Нет
</v-chip>
<v-chip v-else-if="isColoredClassifier(column) && columnColor(item, column)"
@ -2324,15 +2445,30 @@ onMounted(async () => {
<v-form v-if="isViewsResource" :id="editorFormId" @submit.prevent="saveView">
<v-text-field v-model="formData.name" label="Название представления"
:readonly="editorReadonly" required />
<v-autocomplete v-model="selectedSystemObjectId" :items="systemObjectOptions"
<v-autocomplete v-if="editingId === null"
v-model="selectedSystemObjectId" :items="systemObjectOptions"
label="Объект системы" :readonly="editorReadonly"
@update:search="loadSystemObjects($event || '')"
:rules="[(value: unknown) => value !== null && value !== undefined || 'Выберите объект системы']"
required />
<div v-else class="resource-text-field mb-4">
<div class="text-caption text-medium-emphasis">Объект системы</div>
<div class="text-body-1">{{ selectedSystemObjectTitle }}</div>
</div>
<v-switch v-model="formData.is_all" label="Доступно всем" color="primary"
:readonly="editorReadonly" />
<v-switch v-model="formData.is_main_menu" label="Показывать в главном меню" color="primary"
:readonly="editorReadonly" />
<v-autocomplete v-if="!formData.is_all"
v-model="selectedViewEmployeeIds" :items="viewEmployeeOptions"
label="Сотрудники" multiple chips closable-chips clearable
:readonly="editorReadonly" no-data-text="Сотрудники не найдены"
@update:search="loadViewEmployees($event || '')" />
<v-autocomplete v-if="!formData.is_all"
v-model="selectedViewDepartmentIds" :items="viewDepartmentOptions"
label="Группы (подразделения)" multiple chips closable-chips clearable
:readonly="editorReadonly" no-data-text="Подразделения не найдены"
@update:search="loadViewDepartments($event || '')" />
</v-form>
<v-form v-else-if="isModelsResource" :id="editorFormId" @submit.prevent="save">
<v-text-field v-model="formData.name" label="Название модели"
@ -2372,14 +2508,20 @@ onMounted(async () => {
<ResourceForm v-else v-model="formData" :schema="resourceFormSchema" :loading="saving"
:form-id="editorFormId" hide-actions
:hidden-fields="formHiddenFields"
:readonly-fields="businessResourceKey === 'chn:changes' && editingId !== null
:readonly-fields="editingId !== null && businessResourceKey === 'chn:changes'
? ['change_type', 'title', 'initiator']
: undefined"
:text-fields="businessResourceKey === 'chn:changes' && editingId !== null
: editingId !== null && businessResourceKey === 'chn:tasks'
? ['initiator']
: undefined"
:text-fields="editingId !== null && businessResourceKey === 'chn:changes'
? ['change_type', 'title', 'initiator']
: undefined"
:form-class="isClientsResource
? 'client-form-grid'
: editingId !== null && businessResourceKey === 'chn:tasks'
? ['initiator']
: undefined"
:form-class="businessResourceKey === 'sys:employees'
? 'employee-form-grid'
: isClientsResource
? 'client-form-grid'
: businessResourceKey === 'crm:contracts'
? 'contract-form-grid'
: businessResourceKey === 'srv:services'
@ -2399,6 +2541,12 @@ onMounted(async () => {
:relation-labels="addressRelationLabels"
:readonly="editorReadonly" @relation-search="searchAddressRelation" @submit="save">
<template #prepend>
<EmployeeAvatarManager v-if="businessResourceKey === 'sys:employees'"
:avatar="formData.avatar as string | number | null"
:employee-id="editingId"
:name="String(formData.name || formData.username || '')"
:readonly="editorReadonly"
@updated="(avatar) => formData = { ...formData, avatar }" />
<v-alert v-if="holidayDateRangeError" type="error" variant="tonal" class="mb-4">
{{ holidayDateRangeError }}
</v-alert>
@ -2503,6 +2651,8 @@ onMounted(async () => {
</template>
</template>
<template #tab-content="{ activeTab }">
<TagLinkedObjects v-if="businessResourceKey === 'sys:tags' && activeTab === 'objects'"
:tag-id="editingId ?? undefined" :active="true" />
<TagsTab v-if="dskTargetType && activeTab === 'main'"
:target-type="dskTargetType" :record-id="editingId ?? undefined"
:readonly="editorReadonly" :active="true" />

View File

@ -186,6 +186,20 @@ async function submit() { const result = await form.value?.validate(); if (resul
column-gap: 16px;
}
.employee-form-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
column-gap: 16px;
}
.employee-form-grid > :deep(*) {
grid-column: 1 / -1;
}
.employee-form-grid > .employee-name-field {
grid-column: span 1;
}
.client-form-grid > :deep(*) {
grid-column: 1 / -1;
}
@ -317,6 +331,10 @@ async function submit() { const result = await form.value?.validate(); if (resul
}
@media (max-width: 600px) {
.employee-form-grid > .employee-name-field {
grid-column: 1 / -1;
}
.client-form-grid > .client-half,
.client-form-grid > .client-given-name,
.client-form-grid > .client-surname {

View File

@ -0,0 +1,121 @@
<script setup lang="ts">
import type { ApiRecord } from '~/types/api'
const props = defineProps<{
tagId?: string | number
active?: boolean
}>()
const { request, normalizeList } = useApi()
const items = ref<(ApiRecord & {
target_type: string
target_id: string | number
display_title: string
target_title: string
})[]>([])
const total = ref(0)
const page = ref(1)
const pageSize = ref(50)
const loading = ref(false)
const error = ref('')
let loadSequence = 0
const headers = [
{ title: 'Объект', key: 'display_title', sortable: false },
{ title: 'Тип', key: 'target_title', sortable: false },
{ title: 'ID', key: 'target_id', sortable: false },
]
const targetDefinitions: Record<string, { title: string; path: string }> = {
'adr.country': { title: 'Страна', path: '/main/adr/countries/' },
'adr.region': { title: 'Регион', path: '/main/adr/regions/' },
'adr.area': { title: 'Район', path: '/main/adr/areas/' },
'adr.town': { title: 'Населённый пункт', path: '/main/adr/towns/' },
'adr.street': { title: 'Улица', path: '/main/adr/streets/' },
'adr.house': { title: 'Дом', path: '/main/adr/houses/' },
'adr.zone': { title: 'Зона', path: '/main/adr/zones/' },
'req.request': { title: 'Обращение', path: '/main/req/requests/' },
'inc.incident': { title: 'Инцидент', path: '/main/inc/incidents/' },
'cim.ci': { title: 'CI', path: '/main/cim/cis/' },
'dev.manufacturer': { title: 'Производитель', path: '/main/dev/manufacturers/' },
'dev.model': { title: 'Модель устройства', path: '/main/dev/models/' },
'dev.software-version': { title: 'Версия ПО', path: '/main/dev/software-versions/' },
'dev.hardware-version': { title: 'Версия оборудования', path: '/main/dev/hardware-versions/' },
'srv.service': { title: 'Сервис', path: '/main/srv/services/' },
'crm.client': { title: 'Клиент', path: '/main/crm/clients/' },
'crm.lead': { title: 'Лид', path: '/main/crm/leads/' },
'crm.contract': { title: 'Договор', path: '/main/crm/contracts/' },
'chn.task': { title: 'Задача', path: '/main/chn/tasks/' },
'chn.change': { title: 'Изменение', path: '/main/chn/changes/' },
}
function objectTitle(record: ApiRecord, fallback: string) {
return String(record.title || record.name || record.address || record.number
|| record.request_text || record.fullname || fallback)
}
async function load() {
if (!props.tagId || props.active === false) return
const sequence = ++loadSequence
loading.value = true
error.value = ''
try {
const data = await request<any>(`/main/sys/tags/${props.tagId}/assignments/`, {
query: { page: page.value, page_size: pageSize.value },
})
const normalized = normalizeList<ApiRecord>(data)
const resolved = await Promise.all(normalized.items.map(async assignment => {
const targetType = String(assignment.target_type || '')
const targetId = assignment.target_id as string | number
const definition = targetDefinitions[targetType] || { title: targetType || 'Объект', path: '' }
const fallback = `${definition.title} #${targetId}`
let displayTitle = fallback
if (definition.path) {
try {
const record = await request<ApiRecord>(`${definition.path}${targetId}/`)
displayTitle = objectTitle(record, fallback)
} catch {
// The assignment remains visible even if its target is unavailable.
}
}
return {
...assignment,
target_type: targetType,
target_id: targetId,
target_title: definition.title,
display_title: displayTitle,
}
}))
if (sequence !== loadSequence) return
items.value = resolved
total.value = normalized.total
} catch (caught: any) {
if (sequence !== loadSequence) return
error.value = caught?.message || 'Не удалось загрузить связанные объекты'
items.value = []
total.value = 0
} finally {
if (sequence === loadSequence) loading.value = false
}
}
watch(() => [props.tagId, props.active], () => {
page.value = 1
if (props.active !== false) load()
}, { immediate: true })
watch([page, pageSize], () => load())
</script>
<template>
<v-alert v-if="!tagId" type="info" variant="tonal">
Сохраните тег, чтобы просматривать связанные объекты.
</v-alert>
<template v-else>
<v-alert v-if="error" type="error" variant="tonal" class="mb-4">{{ error }}</v-alert>
<v-data-table-server :headers="headers" :items="items" :items-length="total"
:loading="loading" :page="page" :items-per-page="pageSize"
:items-per-page-options="[25, 50, 100]" item-value="id"
@update:page="page = $event" @update:items-per-page="pageSize = $event">
<template #no-data>К тегу не привязано ни одного объекта.</template>
</v-data-table-server>
</template>
</template>

View File

@ -15,69 +15,14 @@ const error = ref('')
const loadedKey = ref('')
const detailsOpen = ref(false)
const detailsTag = ref<Tag | null>(null)
const detailsLoading = ref(false)
const detailsError = ref('')
const linkedObjects = ref<(ApiRecord & { target_type: string; target_id: string | number; display_title: string })[]>([])
const targetKey = computed(() => props.recordId === undefined || props.recordId === null ? '' : `${props.targetType}:${props.recordId}`)
const options = computed(() => catalog.value.filter(tag => !assigned.value.some(item => String(item.id) === String(tag.id)))
.map(tag => ({ title: tag.name, value: tag.id })))
const canAdd = computed(() => selectedId.value === null && Boolean(enteredName.value.trim()))
let searchTimer: ReturnType<typeof setTimeout> | undefined
const targetDefinitions: Record<string, { title: string; path: string }> = {
'adr.country': { title: 'Страна', path: '/main/adr/countries/' },
'adr.region': { title: 'Регион', path: '/main/adr/regions/' },
'adr.area': { title: 'Район', path: '/main/adr/areas/' },
'adr.town': { title: 'Населённый пункт', path: '/main/adr/towns/' },
'adr.street': { title: 'Улица', path: '/main/adr/streets/' },
'adr.house': { title: 'Дом', path: '/main/adr/houses/' },
'adr.zone': { title: 'Зона', path: '/main/adr/zones/' },
'req.request': { title: 'Обращение', path: '/main/req/requests/' },
'inc.incident': { title: 'Инцидент', path: '/main/inc/incidents/' },
'cim.ci': { title: 'CI', path: '/main/cim/cis/' },
'dev.manufacturer': { title: 'Производитель', path: '/main/dev/manufacturers/' },
'dev.model': { title: 'Модель устройства', path: '/main/dev/models/' },
'dev.software-version': { title: 'Версия ПО', path: '/main/dev/software-versions/' },
'dev.hardware-version': { title: 'Версия оборудования', path: '/main/dev/hardware-versions/' },
'srv.service': { title: 'Сервис', path: '/main/srv/services/' },
'crm.client': { title: 'Клиент', path: '/main/crm/clients/' },
'crm.lead': { title: 'Лид', path: '/main/crm/leads/' },
'crm.contract': { title: 'Договор', path: '/main/crm/contracts/' },
'chn.task': { title: 'Задача', path: '/main/chn/tasks/' },
'chn.change': { title: 'Изменение', path: '/main/chn/changes/' },
}
function objectTitle(record: ApiRecord, definition: { title: string }, id: string | number) {
return String(record.title || record.name || record.address || record.number
|| record.request_text || record.fullname || `${definition.title} #${id}`)
}
async function openTag(tag: Tag) {
detailsTag.value = tag
detailsOpen.value = true
detailsLoading.value = true
detailsError.value = ''
linkedObjects.value = []
try {
const data = await request<any>(`/main/sys/tags/${tag.id}/assignments/`)
const assignments = normalizeList<ApiRecord>(data).items
linkedObjects.value = await Promise.all(assignments.map(async assignment => {
const targetType = String(assignment.target_type || '')
const targetId = assignment.target_id as string | number
const definition = targetDefinitions[targetType] || { title: targetType || 'Объект', path: '' }
if (!definition.path) return { ...assignment, target_type: targetType, target_id: targetId,
display_title: `${definition.title} #${targetId}` }
try {
const record = await request<ApiRecord>(`${definition.path}${targetId}/`)
return { ...assignment, ...record, target_type: targetType, target_id: targetId,
display_title: objectTitle(record, definition, targetId) }
} catch {
return { ...assignment, target_type: targetType, target_id: targetId,
display_title: `${definition.title} #${targetId}` }
}
}))
} catch (caught: any) {
detailsError.value = caught?.message || 'Не удалось загрузить связанные объекты'
} finally { detailsLoading.value = false }
}
async function load(force = false) {
@ -185,16 +130,7 @@ onBeforeUnmount(() => { if (searchTimer) clearTimeout(searchTimer) })
</v-card-title>
<v-card-subtitle>Привязанные объекты</v-card-subtitle>
<v-card-text>
<v-progress-linear v-if="detailsLoading" indeterminate color="primary" class="mb-4" />
<v-alert v-if="detailsError" type="error" variant="tonal">{{ detailsError }}</v-alert>
<v-alert v-else-if="!detailsLoading && !linkedObjects.length" type="info" variant="tonal">
К тегу не привязано ни одного объекта.
</v-alert>
<v-list v-else-if="!detailsLoading" border rounded lines="two">
<v-list-item v-for="item in linkedObjects" :key="`${item.target_type}:${item.target_id}`"
prepend-icon="mdi-link-variant" :title="item.display_title"
:subtitle="`${targetDefinitions[item.target_type]?.title || item.target_type} · ID ${item.target_id}`" />
</v-list>
<TagLinkedObjects :tag-id="detailsTag?.id" :active="detailsOpen" />
</v-card-text>
<v-card-actions class="justify-end">
<v-btn type="button" variant="text" @click="detailsOpen = false">Закрыть</v-btn>

View File

@ -16,9 +16,10 @@ export const modules: ModuleDefinition[] = [
{ key: 'crm', title: 'CRM', icon: 'mdi-account-group', apiPrefix: 'crm', resources: [
resource('clients', 'Клиенты'),
resource('contracts', 'Договора'), resource('leads', 'Лиды'),
resource('categories', 'Категории', false, 'client-categories', 'settings', undefined, true),
resource('types', 'Типы', false, 'client-types', 'settings', undefined, true),
{ ...resource('settings', 'Настройки', false, 'settings', 'settings'), accessKeys: ['categories', 'types'] },
resource('categories', 'Категории клиентов', false, 'client-categories', 'settings', 'client-category'),
resource('types', 'Типы клиентов', false, 'client-types', 'settings', 'client-type'),
{ ...resource('settings', 'Настройки', false, 'settings', 'settings', 'settings', true),
accessKeys: ['settings', 'client-category', 'client-type'] },
] },
{ key: 'service', title: 'Сервисы', icon: 'mdi-room-service', apiPrefix: 'srv', resources: [
resource('services', 'Сервисы'),

View File

@ -64,7 +64,12 @@ export function isThemeColorName(value: unknown): value is ThemeColorName {
}
export function normalizeThemeColor(value: unknown): ThemeColorName {
return isThemeColorName(value) ? value.toLowerCase() as ThemeColorName : 'grey'
if (isThemeColorName(value)) return value.toLowerCase() as ThemeColorName
if (typeof value !== 'string') return 'grey'
const normalized = value.toUpperCase()
if (['#17C1E8', '#21D4FD'].includes(normalized)) return 'base'
return (Object.entries(colorHex).find(([, hex]) => hex === normalized)?.[0]
|| 'grey') as ThemeColorName
}
export function resolveThemeColor(value: unknown, lightTheme = true) {
@ -73,6 +78,10 @@ export function resolveThemeColor(value: unknown, lightTheme = true) {
return colorHex[name]
}
export function serializeThemeColor(value: unknown, lightTheme = true) {
return resolveThemeColor(value, lightTheme)
}
export function getThemeColorOptions(language: 'ru' | 'en' = 'ru') {
return themeColorValues.map(value => ({
title: titles[value][language],

View File

@ -10,6 +10,8 @@ const route = useRoute()
const auth = useAuthStore()
const permissions = usePermissions()
const { t } = useUiText()
const navigationSearch = ref('')
const searchFocused = ref(false)
const visibleModules = computed(() => modules.map(module => ({
...module,
resources: module.resources.filter(resource => !resource.hiddenInMenu
@ -40,11 +42,11 @@ function toggleNavigation() {
<template>
<v-app>
<v-navigation-drawer v-model="drawer" width="280" class="soft-sidebar"
<v-navigation-drawer v-model="drawer" width="252" class="soft-sidebar"
:rail="lgAndUp && rail" :expand-on-hover="lgAndUp && rail">
<div class="soft-brand pa-5 d-flex align-center ga-3">
<v-avatar class="soft-gradient" rounded="lg"><v-icon color="white">mdi-lifebuoy</v-icon></v-avatar>
<div class="soft-brand-text"><div class="font-weight-bold soft-brand-title">WANITIL</div><div class="text-caption text-medium-emphasis">Техническая поддержка</div></div>
<div class="soft-brand px-4 py-4 d-flex align-center ga-3">
<v-avatar class="engineer-brand-mark" rounded="lg" size="34"><span>W</span></v-avatar>
<div class="soft-brand-text"><div class="font-weight-bold soft-brand-title">WANITIL</div><div class="text-caption text-medium-emphasis">Рабочий стол инженера</div></div>
</div>
<v-divider />
<v-list nav density="comfortable" class="soft-nav pa-3">
@ -76,18 +78,31 @@ function toggleNavigation() {
</v-list-group>
</v-list>
</v-navigation-drawer>
<v-app-bar elevation="0" class="soft-app-bar">
<v-app-bar elevation="0" class="soft-app-bar" height="64">
<v-app-bar-nav-icon :aria-label="lgAndUp && rail ? 'Развернуть меню' : 'Свернуть меню'"
@click="toggleNavigation" />
<v-app-bar-title>{{ route.meta.title || 'WANITIL Support' }}</v-app-bar-title>
<div class="app-command-search" :class="{ 'is-focused': searchFocused }">
<v-icon size="19">mdi-magnify</v-icon>
<input v-model="navigationSearch" placeholder="Поиск по заявкам, услугам, пользователям…"
aria-label="Глобальный поиск" @focus="searchFocused = true" @blur="searchFocused = false">
<kbd>Ctrl K</kbd>
</div>
<v-spacer />
<v-btn class="app-create-action mr-2" color="primary" prepend-icon="mdi-plus" to="/requests/requests">Создать</v-btn>
<AppMessagesMenu />
<v-menu>
<template #activator="{ props }"><v-btn v-bind="props" class="persistent-app-action" prepend-icon="mdi-account-circle" :text="auth.user?.name || auth.user?.username || t('profile')" /></template>
<template #activator="{ props }">
<v-btn v-bind="props" class="persistent-app-action app-profile-action">
<EmployeeAvatar :avatar="auth.profile?.avatar"
:name="auth.profile?.name || auth.user?.name || auth.user?.username" size="30" />
<span>{{ auth.profile?.name || auth.user?.name || auth.user?.username || t('profile') }}</span>
<v-icon size="17">mdi-chevron-down</v-icon>
</v-btn>
</template>
<v-list><v-list-item to="/profile" prepend-icon="mdi-account-edit" :title="t('profile')" />
<v-list-item prepend-icon="mdi-logout" :title="t('logout')" @click="auth.logout" /></v-list>
</v-menu>
</v-app-bar>
<v-main class="soft-main"><v-container fluid class="pa-6"><slot /></v-container></v-main>
<v-main class="soft-main"><v-container fluid class="engineer-content"><slot /></v-container></v-main>
</v-app>
</template>

View File

@ -8,11 +8,55 @@ const visibleModules = computed(() => modules.map(module => ({
module.key, module.apiPrefix, resource.accessKey || resource.key,
) && permissions.canNavigate(module.key, module.apiPrefix, resource.accessKey || resource.key)),
})).filter(module => module.resources.length > 0))
const primaryKeys = ['requests', 'incidents', 'tasks', 'service']
const primaryModules = computed(() => primaryKeys
.map(key => visibleModules.value.find(module => module.key === key))
.filter(Boolean))
const secondaryModules = computed(() => visibleModules.value.filter(module => !primaryKeys.includes(module.key)))
</script>
<template><div class="page-shell"><h1 class="text-h4 font-weight-bold mb-2">{{ t('workspace') }}</h1>
<p class="text-medium-emphasis mb-7">{{ t('workspaceHint') }}</p>
<v-row><v-col v-for="module in visibleModules" :key="module.key" cols="12" sm="6" lg="4">
<v-card :to="`/${module.key}`" class="workspace-card pa-5 h-100" hover>
<v-avatar class="soft-gradient mb-4" rounded="lg"><v-icon color="white">{{ module.icon }}</v-icon></v-avatar>
<div class="text-h6">{{ module.title }}</div><div class="text-body-2 text-medium-emphasis">{{ module.resources.length }} {{ t('sections') }}</div>
</v-card></v-col></v-row></div></template>
<template>
<div class="page-shell engineer-home">
<header class="engineer-page-header">
<div>
<div class="engineer-eyebrow">РАБОЧЕЕ ПРОСТРАНСТВО</div>
<h1>Моя очередь</h1>
<p>Разделы, которые требуют вашего внимания</p>
</div>
<v-btn color="primary" prepend-icon="mdi-plus" to="/requests/requests">Создать обращение</v-btn>
</header>
<div class="engineer-filter-row">
<v-btn variant="flat" color="primary">Все</v-btn>
<v-btn variant="outlined">Новые</v-btn>
<v-btn variant="outlined">В работе</v-btn>
<v-btn variant="outlined">Ожидают</v-btn>
<v-btn variant="outlined" prepend-icon="mdi-calendar-blank-outline">Сегодня</v-btn>
</div>
<section class="engineer-section">
<div class="engineer-section-heading">
<div><h2>Основные процессы</h2><p>Быстрый переход к ежедневной работе</p></div>
<span>{{ primaryModules.length }} раздела</span>
</div>
<div class="engineer-queue">
<NuxtLink v-for="module in primaryModules" :key="module!.key" :to="`/${module!.key}`" class="engineer-queue-row">
<span class="engineer-module-icon"><v-icon size="20">{{ module!.icon }}</v-icon></span>
<span class="engineer-module-copy"><strong>{{ module!.title }}</strong><small>{{ module!.resources.length }} доступных разделов</small></span>
<v-chip size="small" variant="tonal" color="primary">Открыть</v-chip>
<v-icon size="18">mdi-chevron-right</v-icon>
</NuxtLink>
</div>
</section>
<section v-if="secondaryModules.length" class="engineer-section engineer-section-secondary">
<div class="engineer-section-heading"><div><h2>Все инструменты</h2><p>Сервисы, справочники и настройки</p></div></div>
<div class="engineer-tools-grid">
<NuxtLink v-for="module in secondaryModules" :key="module.key" :to="`/${module.key}`" class="engineer-tool-card">
<span class="engineer-module-icon"><v-icon size="19">{{ module.icon }}</v-icon></span>
<span><strong>{{ module.title }}</strong><small>{{ module.resources.length }} {{ t('sections') }}</small></span>
<v-icon class="ml-auto" size="17">mdi-arrow-up-right</v-icon>
</NuxtLink>
</div>
</section>
</div>
</template>

View File

@ -66,6 +66,11 @@ async function changePassword() {
}
}
function exitProfile() { return navigateTo('/') }
function avatarUpdated(avatar: string | number | null, employee: Record<string, unknown>) {
if (!auth.profile) return
auth.profile = { ...auth.profile, ...employee, avatar: typeof avatar === 'number' ? avatar : avatar === null ? null : Number(avatar) }
form.avatar = auth.profile.avatar
}
</script>
<template>
@ -76,6 +81,9 @@ function exitProfile() { return navigateTo('/') }
<v-snackbar v-model="saved" color="success">{{ isEnglish ? 'Profile saved' : 'Профиль сохранён' }}</v-snackbar>
<v-row>
<v-col cols="12" md="7"><v-card class="pa-6">
<EmployeeAvatarManager self :avatar="auth.profile?.avatar"
:name="auth.profile?.name || auth.user?.name || auth.user?.username"
@updated="avatarUpdated" />
<h2 class="text-h6 mb-5">{{ isEnglish ? 'Appearance' : 'Оформление' }}</h2>
<v-select v-model="form.lang" :items="languages" :label="isEnglish ? 'Interface language' : 'Язык интерфейса'" />
<v-switch v-model="form.theme_is_light" color="primary" inset
@ -97,7 +105,10 @@ function exitProfile() { return navigateTo('/') }
</v-card></v-col>
<v-col cols="12" md="5"><v-card class="pa-6 mb-4">
<h2 class="text-h6 mb-4">{{ isEnglish ? 'Account' : 'Учётная запись' }}</h2>
<v-list density="compact"><v-list-item prepend-icon="mdi-account" :title="auth.user?.name || auth.user?.username" :subtitle="auth.user?.username" />
<v-list density="compact"><v-list-item :title="auth.user?.name || auth.user?.username" :subtitle="auth.user?.username">
<template #prepend><EmployeeAvatar :avatar="auth.profile?.avatar"
:name="auth.profile?.name || auth.user?.name || auth.user?.username" size="40" /></template>
</v-list-item>
<v-list-item prepend-icon="mdi-email-outline" :title="auth.user?.email || '—'" /></v-list>
<v-btn block class="mt-4" color="primary" variant="tonal" prepend-icon="mdi-lock-reset"
@click="passwordDialog = true">

View File

@ -10,10 +10,10 @@ export default defineNuxtPlugin(nuxtApp => {
wanitilLight: {
dark: false,
colors: {
primary: '#17C1E8', secondary: '#8392AB', accent: '#CB0C9F',
background: '#F8F9FA', surface: '#FFFFFF', error: '#EA0606',
success: '#82D616', warning: '#FBCF33', info: '#17C1E8',
'on-background': '#344767', 'on-surface': '#344767',
primary: '#2457E6', secondary: '#667085', accent: '#84CC16',
background: '#F4F6FA', surface: '#FFFFFF', error: '#E5484D',
success: '#2F9E64', warning: '#F59E0B', info: '#2F6FED',
'on-background': '#17233C', 'on-surface': '#17233C',
},
},
wanitilDark: {
@ -28,12 +28,12 @@ export default defineNuxtPlugin(nuxtApp => {
},
},
defaults: {
VBtn: { rounded: 'lg', elevation: 0 },
VCard: { rounded: 'xl', elevation: 0 },
VTextField: { variant: 'outlined', density: 'comfortable', rounded: 'lg' },
VTextarea: { variant: 'outlined', density: 'comfortable', rounded: 'lg' },
VSelect: { variant: 'outlined', density: 'comfortable', rounded: 'lg' },
VAutocomplete: { variant: 'outlined', density: 'comfortable', rounded: 'lg' },
VBtn: { rounded: 'lg', elevation: 0, density: 'comfortable' },
VCard: { rounded: 'lg', elevation: 0 },
VTextField: { variant: 'outlined', density: 'compact', rounded: 'lg' },
VTextarea: { variant: 'outlined', density: 'compact', rounded: 'lg' },
VSelect: { variant: 'outlined', density: 'compact', rounded: 'lg' },
VAutocomplete: { variant: 'outlined', density: 'compact', rounded: 'lg' },
VList: { rounded: 'lg' },
},
})

View File

@ -1,5 +1,5 @@
import type { CapabilitiesResponse, ManagementObject, PermissionsResponse, SessionUser, UserManagement, UserProfile, UserRole } from '~/types/api'
import { normalizeThemeColor } from '~/config/theme-colors'
import { normalizeThemeColor, serializeThemeColor } from '~/config/theme-colors'
interface LoginResponse { token?: string; expiry?: string }
interface SetupStatusResponse { status: 'waiting' | 'completed' }
@ -97,12 +97,13 @@ export const useAuthStore = defineStore('auth', () => {
const body = {
...changes,
...(changes.theme_color !== undefined
? { theme_color: normalizeThemeColor(changes.theme_color) }
? { theme_color: serializeThemeColor(changes.theme_color, changes.theme_is_light !== false) }
: {}),
}
const result = await request<UserProfile | SessionUser>('/main/sys/employees/me/', {
method: 'PATCH',
body,
preserveNulls: changes.avatar === null,
})
const returnedUser = 'username' in result ? result as SessionUser : null
const returnedProfile = returnedUser?.sys_employee || returnedUser?.sys_user_profile || result as UserProfile

View File

@ -46,12 +46,18 @@ describe('module registry', () => {
expect(getResource('system', 'settings')).toMatchObject({ path: 'settings', menuGroup: 'parameters' })
expect(getResource('system', 'preferences')).toBeUndefined()
expect(getResource('system', 'module-settings')?.path).toBe('module-settings')
expect(getResource('crm', 'categories')?.path).toBe('client-categories')
expect(getResource('crm', 'types')?.path).toBe('client-types')
expect(getResource('crm', 'categories')?.hiddenInMenu).toBe(true)
expect(getResource('crm', 'types')?.hiddenInMenu).toBe(true)
expect(getResource('crm', 'categories')).toMatchObject({
title: 'Категории клиентов', path: 'client-categories', accessKey: 'client-category',
menuGroup: 'settings', hiddenInMenu: false,
})
expect(getResource('crm', 'types')).toMatchObject({
title: 'Типы клиентов', path: 'client-types', accessKey: 'client-type',
menuGroup: 'settings', hiddenInMenu: false,
})
expect(getResource('crm', 'settings')).toMatchObject({
menuGroup: 'settings', accessKeys: ['categories', 'types'],
menuGroup: 'settings', accessKey: 'settings',
accessKeys: ['settings', 'client-category', 'client-type'],
hiddenInMenu: true,
})
expect(getResource('service', 'requests')?.path).toBe('request-types')
expect(getResource('requests', 'sourcetypes')?.path).toBe('source-types')

View File

@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { normalizeThemeColor, resolveThemeColor, themeColorValues } from '../config/theme-colors'
import { normalizeThemeColor, resolveThemeColor, serializeThemeColor, themeColorValues } from '../config/theme-colors'
describe('theme colors', () => {
it('contains every supported API value', () => {
@ -15,6 +15,12 @@ describe('theme colors', () => {
expect(resolveThemeColor('unknown')).toBe('#9E9E9E')
})
it('converts API HEX values without changing selector values', () => {
expect(normalizeThemeColor('#2196F3')).toBe('blue')
expect(normalizeThemeColor('#21d4fd')).toBe('base')
expect(serializeThemeColor('green')).toBe('#4CAF50')
})
it('resolves base for light and dark themes', () => {
expect(resolveThemeColor('base', true)).toBe('#17C1E8')
expect(resolveThemeColor('base', false)).toBe('#21D4FD')

View File

@ -41,6 +41,7 @@ export interface UserProfile {
theme_is_light?: boolean
theme_color?: string
name: string
avatar?: number | null
is_active: boolean
}