feat(desktop): implement phase 2 native capabilities
This commit is contained in:
@@ -132,20 +132,17 @@
|
||||
<el-icon><Document /></el-icon>
|
||||
<span>问题导入模板</span>
|
||||
</el-button>
|
||||
<el-upload
|
||||
<el-button
|
||||
v-if="canCreateIssue"
|
||||
ref="importUploadRef"
|
||||
:auto-upload="false"
|
||||
:show-file-list="false"
|
||||
accept=".xlsx,.csv"
|
||||
:on-change="onImportChange"
|
||||
:disabled="importing"
|
||||
class="toolbar-button toolbar-button-warning"
|
||||
type="warning"
|
||||
plain
|
||||
:loading="importing"
|
||||
@click="selectImportFile"
|
||||
>
|
||||
<el-button class="toolbar-button toolbar-button-warning" type="warning" plain :loading="importing">
|
||||
<el-icon><Upload /></el-icon>
|
||||
<span>导入问题</span>
|
||||
</el-button>
|
||||
</el-upload>
|
||||
<el-icon><Upload /></el-icon>
|
||||
<span>导入问题</span>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="toolbar-icons">
|
||||
<el-button circle title="刷新" @click="loadIssues">
|
||||
@@ -455,7 +452,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from "vue";
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules, type UploadFile, type UploadInstance } from "element-plus";
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from "element-plus";
|
||||
import { CircleCheck, Delete, Document, Download, Location, Plus, Refresh, Search, Upload } from "@element-plus/icons-vue";
|
||||
import {
|
||||
createMonitoringVisitIssue,
|
||||
@@ -469,6 +466,7 @@ import {
|
||||
import { fetchSites } from "../../api/sites";
|
||||
import StateEmpty from "../../components/StateEmpty.vue";
|
||||
import { TEXT } from "../../locales";
|
||||
import { pickFiles, saveFile } from "../../runtime";
|
||||
import { useAuthStore } from "../../store/auth";
|
||||
import { useStudyStore } from "../../store/study";
|
||||
import type { Site } from "../../types/api";
|
||||
@@ -523,7 +521,6 @@ const viewDialogVisible = ref(false);
|
||||
const formMode = ref<"create" | "edit">("create");
|
||||
const editingIssueId = ref("");
|
||||
const createFormRef = ref<FormInstance>();
|
||||
const importUploadRef = ref<UploadInstance>();
|
||||
const allItems = ref<MonitoringIssueRow[]>([]);
|
||||
const viewIssue = ref<MonitoringIssueRow | null>(null);
|
||||
const sitesLoading = ref(false);
|
||||
@@ -981,14 +978,7 @@ const handleExportExcel = async () => {
|
||||
const contentType = response.headers?.["content-type"] || "application/octet-stream";
|
||||
const filename = getFilename(response.headers?.["content-disposition"]) || "监查访视问题.xlsx";
|
||||
const blob = new Blob([response.data], { type: contentType });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
window.URL.revokeObjectURL(url);
|
||||
await saveFile({ suggestedName: filename, mimeType: contentType, data: blob });
|
||||
ElMessage.success("导出成功");
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.detail || TEXT.common.messages.downloadFailed);
|
||||
@@ -997,11 +987,9 @@ const handleExportExcel = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const onImportChange = async (uploadFile: UploadFile) => {
|
||||
const importIssueFile = async (file: File) => {
|
||||
const studyId = study.currentStudy?.id;
|
||||
if (!studyId || !canCreateIssue.value) return;
|
||||
const file = uploadFile.raw;
|
||||
if (!file) return;
|
||||
|
||||
importing.value = true;
|
||||
try {
|
||||
@@ -1018,10 +1006,18 @@ const onImportChange = async (uploadFile: UploadFile) => {
|
||||
ElMessage.error(e?.response?.data?.detail || TEXT.common.messages.uploadFailed);
|
||||
} finally {
|
||||
importing.value = false;
|
||||
importUploadRef.value?.clearFiles();
|
||||
}
|
||||
};
|
||||
|
||||
const selectImportFile = async () => {
|
||||
const [file] = await pickFiles({
|
||||
multiple: false,
|
||||
accept: ["xlsx", "csv"],
|
||||
title: "导入监查访视问题",
|
||||
});
|
||||
if (file) await importIssueFile(file);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => study.currentStudy?.id,
|
||||
(studyId) => {
|
||||
|
||||
Reference in New Issue
Block a user