fix
This commit is contained in:
@@ -16,25 +16,25 @@ impl AppModule for ContractappModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init(&self, ctx: &mut ModuleContext) {
|
fn init(&self, ctx: &mut ModuleContext) {
|
||||||
ctx.mapped_remote_resource::<models::Contract>(
|
ctx.cached_mapped_remote_resource::<models::Contract>(
|
||||||
"contract",
|
"contract",
|
||||||
"/api/contract/",
|
"/api/contract/",
|
||||||
serializers::contractapp_serializer(),
|
serializers::contractapp_serializer(),
|
||||||
filters::contractapp_filterset(),
|
filters::contractapp_filterset(),
|
||||||
);
|
);
|
||||||
ctx.mapped_remote_resource::<models::ContractCategory>(
|
ctx.cached_mapped_remote_resource::<models::ContractCategory>(
|
||||||
"contract_category",
|
"contract_category",
|
||||||
"/api/cont/category/",
|
"/api/cont/category/",
|
||||||
serializers::contract_category_serializer(),
|
serializers::contract_category_serializer(),
|
||||||
filters::contract_category_filterset(),
|
filters::contract_category_filterset(),
|
||||||
);
|
);
|
||||||
ctx.mapped_remote_resource::<models::Counterparty>(
|
ctx.cached_mapped_remote_resource::<models::Counterparty>(
|
||||||
"counterparty",
|
"counterparty",
|
||||||
"/api/catalog/company/",
|
"/api/catalog/company/",
|
||||||
serializers::counterparty_serializer(),
|
serializers::counterparty_serializer(),
|
||||||
filters::counterparty_filterset(),
|
filters::counterparty_filterset(),
|
||||||
);
|
);
|
||||||
ctx.mapped_remote_resource::<models::ContractApplicationFile>(
|
ctx.cached_mapped_remote_resource::<models::ContractApplicationFile>(
|
||||||
"contract_application_file",
|
"contract_application_file",
|
||||||
"/api/cont/appfile/",
|
"/api/cont/appfile/",
|
||||||
serializers::contract_application_file_serializer(),
|
serializers::contract_application_file_serializer(),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl AppModule for FrcModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init(&self, ctx: &mut ModuleContext) {
|
fn init(&self, ctx: &mut ModuleContext) {
|
||||||
ctx.mapped_remote_resource::<models::Frc>(
|
ctx.cached_mapped_remote_resource::<models::Frc>(
|
||||||
"frc",
|
"frc",
|
||||||
"/api/frc/frc/",
|
"/api/frc/frc/",
|
||||||
serializers::frc_serializer(),
|
serializers::frc_serializer(),
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ static EMPLOYEE_FILTERS: &[Filter] = &[
|
|||||||
static TASK_FILTERS: &[Filter] = &[
|
static TASK_FILTERS: &[Filter] = &[
|
||||||
Filter::exact("id"),
|
Filter::exact("id"),
|
||||||
Filter::contains("text"),
|
Filter::contains("text"),
|
||||||
|
Filter::remote_only("contract"),
|
||||||
Filter::remote_only("doer"),
|
Filter::remote_only("doer"),
|
||||||
Filter::remote_only("author"),
|
Filter::remote_only("author"),
|
||||||
Filter::exact("archive"),
|
Filter::exact("archive"),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl AppModule for TaskModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init(&self, ctx: &mut ModuleContext) {
|
fn init(&self, ctx: &mut ModuleContext) {
|
||||||
ctx.mapped_remote_resource::<models::Employee>(
|
ctx.cached_mapped_remote_resource::<models::Employee>(
|
||||||
"employee",
|
"employee",
|
||||||
"/api/persone/employee/",
|
"/api/persone/employee/",
|
||||||
serializers::employee_serializer(),
|
serializers::employee_serializer(),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl AppModule for ProjectModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn init(&self, ctx: &mut ModuleContext) {
|
fn init(&self, ctx: &mut ModuleContext) {
|
||||||
ctx.mapped_remote_resource::<models::Project>(
|
ctx.cached_mapped_remote_resource::<models::Project>(
|
||||||
"project",
|
"project",
|
||||||
"/api/project/",
|
"/api/project/",
|
||||||
serializers::project_serializer(),
|
serializers::project_serializer(),
|
||||||
|
|||||||
@@ -0,0 +1,459 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
|
import { taskApi } from "../../../generated/api";
|
||||||
|
import type { Task, TaskListParams } from "../../../generated/models";
|
||||||
|
import { useModelApi } from "../../../shared/composables/useModelApi";
|
||||||
|
import RemoteImage from "../../../shared/components/RemoteImage.vue";
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
contractId: number;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const {
|
||||||
|
items: tasks,
|
||||||
|
loading,
|
||||||
|
error,
|
||||||
|
load,
|
||||||
|
} = useModelApi(taskApi, {
|
||||||
|
loadErrorMessage: "Не удалось загрузить поручения",
|
||||||
|
autoLoad: false,
|
||||||
|
autoLoadOnFilterChange: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const expandedTasks = ref<Record<number, boolean>>({});
|
||||||
|
|
||||||
|
const hasTasks = computed(() => tasks.value.length > 0);
|
||||||
|
|
||||||
|
function taskTitle(task: Task) {
|
||||||
|
return task.text?.trim() || task.result?.trim() || `Задача #${task.id}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function personName(
|
||||||
|
person: { short_name?: string | null; name?: string | null } | null,
|
||||||
|
) {
|
||||||
|
if (!person) {
|
||||||
|
return "не указан";
|
||||||
|
}
|
||||||
|
|
||||||
|
return person.short_name ?? person.name ?? "не указан";
|
||||||
|
}
|
||||||
|
|
||||||
|
function personAvatar(person: { avatar_small?: string | null } | null) {
|
||||||
|
return person?.avatar_small ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function isHistoryExpanded(taskId: number) {
|
||||||
|
return expandedTasks.value[taskId] ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleHistory(taskId: number) {
|
||||||
|
expandedTasks.value = {
|
||||||
|
...expandedTasks.value,
|
||||||
|
[taskId]: !isHistoryExpanded(taskId),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function visibleMessages(task: Task) {
|
||||||
|
const messages = task.message_set ?? [];
|
||||||
|
|
||||||
|
if (isHistoryExpanded(task.id)) {
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages.length > 0 ? [messages[messages.length - 1]] : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusType(statusClass: string) {
|
||||||
|
if (/success|done|complete|green/i.test(statusClass)) {
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/warning|pending|wait|yellow|orange/i.test(statusClass)) {
|
||||||
|
return "warning";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/danger|error|red|fail/i.test(statusClass)) {
|
||||||
|
return "danger";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "primary";
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusTone(statusClass: string) {
|
||||||
|
if (/success|done|complete|green/i.test(statusClass)) {
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/warning|pending|wait|yellow|orange/i.test(statusClass)) {
|
||||||
|
return "warning";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/danger|error|red|fail/i.test(statusClass)) {
|
||||||
|
return "danger";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "primary";
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadTasks() {
|
||||||
|
const params = {
|
||||||
|
contract: props.contractId,
|
||||||
|
ordering: "-id",
|
||||||
|
} as TaskListParams;
|
||||||
|
|
||||||
|
return load(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.contractId,
|
||||||
|
() => {
|
||||||
|
void loadTasks();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void loadTasks();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section class="approval-tasks">
|
||||||
|
<van-notice-bar
|
||||||
|
v-if="error"
|
||||||
|
class="approval-tasks__error"
|
||||||
|
color="#991b1b"
|
||||||
|
background="#fee2e2"
|
||||||
|
left-icon="warning-o"
|
||||||
|
wrapable
|
||||||
|
:scrollable="false"
|
||||||
|
:text="error"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<van-loading v-if="loading" class="approval-tasks__state" type="spinner">
|
||||||
|
Загрузка поручений...
|
||||||
|
</van-loading>
|
||||||
|
|
||||||
|
<van-empty v-else-if="!hasTasks" description="Поручений пока нет" />
|
||||||
|
|
||||||
|
<div v-else class="approval-task-list">
|
||||||
|
<article
|
||||||
|
v-for="task in tasks"
|
||||||
|
:key="task.id"
|
||||||
|
:class="[
|
||||||
|
'approval-task-card',
|
||||||
|
`approval-task-card--${statusTone(task.get_status_class)}`,
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<div class="approval-task-head">
|
||||||
|
<div class="approval-task-head__main">
|
||||||
|
<div class="approval-task-title">{{ taskTitle(task) }}</div>
|
||||||
|
<div class="approval-task-meta">
|
||||||
|
ID {{ task.id }} · {{ task.deadline }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<van-tag plain :type="statusType(task.get_status_class)">
|
||||||
|
{{ task.get_status }}
|
||||||
|
</van-tag>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<van-cell-group inset>
|
||||||
|
<div class="approval-person-list">
|
||||||
|
<div class="approval-person-item">
|
||||||
|
<RemoteImage
|
||||||
|
class="approval-person-avatar"
|
||||||
|
round
|
||||||
|
width="32"
|
||||||
|
height="32"
|
||||||
|
:src="personAvatar(task.doer)"
|
||||||
|
/>
|
||||||
|
<div class="approval-person-body">
|
||||||
|
<div class="approval-person-role">Исполнитель</div>
|
||||||
|
<div class="approval-person-name">
|
||||||
|
{{ personName(task.doer) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="approval-person-item">
|
||||||
|
<RemoteImage
|
||||||
|
class="approval-person-avatar"
|
||||||
|
round
|
||||||
|
width="32"
|
||||||
|
height="32"
|
||||||
|
:src="personAvatar(task.author)"
|
||||||
|
/>
|
||||||
|
<div class="approval-person-body">
|
||||||
|
<div class="approval-person-role">Автор</div>
|
||||||
|
<div class="approval-person-name">
|
||||||
|
{{ personName(task.author) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="approval-person-item">
|
||||||
|
<RemoteImage
|
||||||
|
class="approval-person-avatar"
|
||||||
|
round
|
||||||
|
width="32"
|
||||||
|
height="32"
|
||||||
|
:src="personAvatar(task.responsible)"
|
||||||
|
/>
|
||||||
|
<div class="approval-person-body">
|
||||||
|
<div class="approval-person-role">Ответственный</div>
|
||||||
|
<div class="approval-person-name">
|
||||||
|
{{ personName(task.responsible) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</van-cell-group>
|
||||||
|
|
||||||
|
<div class="approval-task-messages">
|
||||||
|
<div class="approval-task-messages__title">Сообщения</div>
|
||||||
|
|
||||||
|
<van-empty
|
||||||
|
v-if="!task.message_set?.length"
|
||||||
|
description="Сообщений пока нет"
|
||||||
|
image-size="64"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div v-else class="approval-message-list">
|
||||||
|
<article
|
||||||
|
v-for="message in visibleMessages(task)"
|
||||||
|
:key="message.id"
|
||||||
|
:class="[
|
||||||
|
'approval-message-item',
|
||||||
|
!isHistoryExpanded(task.id) &&
|
||||||
|
message.id ===
|
||||||
|
task.message_set?.[task.message_set.length - 1]?.id
|
||||||
|
? 'approval-message-item--latest'
|
||||||
|
: '',
|
||||||
|
]"
|
||||||
|
@click="
|
||||||
|
message.id ===
|
||||||
|
task.message_set?.[task.message_set.length - 1]?.id &&
|
||||||
|
!isHistoryExpanded(task.id)
|
||||||
|
? toggleHistory(task.id)
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<RemoteImage
|
||||||
|
class="approval-message-avatar"
|
||||||
|
round
|
||||||
|
width="36"
|
||||||
|
height="36"
|
||||||
|
:src="message.author.avatar_small"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="approval-message-body">
|
||||||
|
<div class="approval-message-head">
|
||||||
|
<div class="approval-message-author">
|
||||||
|
{{ personName(message.author) }}
|
||||||
|
</div>
|
||||||
|
<div class="approval-message-meta">
|
||||||
|
{{ message.date }} · {{ message.status }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="approval-message-text">{{ message.text }}</div>
|
||||||
|
<div class="approval-message-recipient">
|
||||||
|
Кому: {{ personName(message.recipient) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
<van-button
|
||||||
|
v-if="(task.message_set?.length ?? 0) > 1"
|
||||||
|
class="approval-message-toggle"
|
||||||
|
size="small"
|
||||||
|
round
|
||||||
|
plain
|
||||||
|
type="primary"
|
||||||
|
@click.stop="toggleHistory(task.id)"
|
||||||
|
>
|
||||||
|
<van-icon
|
||||||
|
:name="isHistoryExpanded(task.id) ? 'arrow-up' : 'arrow-down'"
|
||||||
|
/>
|
||||||
|
</van-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.approval-tasks {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 8px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-tasks__state {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 24px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-card {
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 16px;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 8px 24px rgba(36, 42, 56, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-card--success {
|
||||||
|
background: #f0fdf4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-card--warning {
|
||||||
|
background: #fffbeb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-card--danger {
|
||||||
|
background: #fef2f2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-card--primary {
|
||||||
|
background: #eff6ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 14px 16px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-head__main {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-title {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.35;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-meta {
|
||||||
|
margin-top: 4px;
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-messages {
|
||||||
|
padding: 12px 16px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-person-list {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 6px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-person-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-person-avatar {
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-person-body {
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-person-role {
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 10px;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-person-name {
|
||||||
|
margin-top: 1px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.35;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-task-messages__title {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: #374151;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-item {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-item--latest {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-avatar {
|
||||||
|
flex: none;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-body {
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-head {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-author {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-meta,
|
||||||
|
.approval-message-recipient {
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-toggle {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
margin-top: 8px;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.approval-message-text {
|
||||||
|
margin-top: 4px;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-word;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.45;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -4,7 +4,10 @@ import { openUrl } from "@tauri-apps/plugin-opener";
|
|||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { showToast } from "vant";
|
import { showToast } from "vant";
|
||||||
import { contractApi, contractApplicationFileApi } from "../../../generated/api";
|
import {
|
||||||
|
contractApi,
|
||||||
|
contractApplicationFileApi,
|
||||||
|
} from "../../../generated/api";
|
||||||
import type {
|
import type {
|
||||||
Contract,
|
Contract,
|
||||||
ContractApplicationFile,
|
ContractApplicationFile,
|
||||||
@@ -12,6 +15,7 @@ import type {
|
|||||||
} from "../../../generated/models";
|
} from "../../../generated/models";
|
||||||
import { useModelApi } from "../../../shared/composables/useModelApi";
|
import { useModelApi } from "../../../shared/composables/useModelApi";
|
||||||
import PdfPreview from "../components/PdfPreview.vue";
|
import PdfPreview from "../components/PdfPreview.vue";
|
||||||
|
import ContractApprovalTasks from "../components/ContractApprovalTasks.vue";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -107,12 +111,6 @@ const approvalFields = computed(() => {
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
{ title: "Статус", value: item.status_name },
|
{ title: "Статус", value: item.status_name },
|
||||||
{ title: "Код статуса", value: item.status },
|
|
||||||
{
|
|
||||||
title: "Сотрудник",
|
|
||||||
value: item.employee?.short_name ?? item.employee?.name,
|
|
||||||
},
|
|
||||||
{ title: "Сотрудник ID", value: item.employee_id },
|
|
||||||
{ title: "Комментарий", value: item.comment },
|
{ title: "Комментарий", value: item.comment },
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
@@ -411,6 +409,8 @@ onMounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
</van-cell>
|
</van-cell>
|
||||||
</van-cell-group>
|
</van-cell-group>
|
||||||
|
|
||||||
|
<ContractApprovalTasks v-if="contract" :contract-id="contract.id" />
|
||||||
</div>
|
</div>
|
||||||
</van-tab>
|
</van-tab>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
|
||||||
import { computed, ref, watch } from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { showToast } from "vant";
|
import { showToast } from "vant";
|
||||||
@@ -113,13 +112,6 @@ const currentPage = computed({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface SyncContractsResult {
|
|
||||||
synced: number;
|
|
||||||
pages: number;
|
|
||||||
applications: number;
|
|
||||||
files_downloaded: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const syncing = ref(false);
|
const syncing = ref(false);
|
||||||
const showFilters = ref(false);
|
const showFilters = ref(false);
|
||||||
|
|
||||||
@@ -155,15 +147,13 @@ async function syncContracts() {
|
|||||||
syncing.value = true;
|
syncing.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await invoke<SyncContractsResult>("sync_contracts");
|
await loadContracts({
|
||||||
showToast(
|
...filters,
|
||||||
`Синхронизировано: ${result.synced}; приложений: ${result.applications}; файлов: ${result.files_downloaded}`,
|
limit: PAGE_SIZE,
|
||||||
);
|
offset: filters.offset ?? 0,
|
||||||
if (filters.offset) {
|
force_remote: true,
|
||||||
filters.offset = 0;
|
} as ContractListParams);
|
||||||
} else {
|
showToast("Данные обновлены с сервера");
|
||||||
await loadContracts();
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showToast(errorMessage(err, "Не удалось синхронизировать договоры"));
|
showToast(errorMessage(err, "Не удалось синхронизировать договоры"));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -228,7 +218,7 @@ watch(
|
|||||||
Обновить
|
Обновить
|
||||||
</van-button>
|
</van-button>
|
||||||
<van-button size="small" type="primary" :loading="syncing" @click="syncContracts">
|
<van-button size="small" type="primary" :loading="syncing" @click="syncContracts">
|
||||||
Синхронизация
|
Обновить с сервера
|
||||||
</van-button>
|
</van-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user