提交修改
This commit is contained in:
1 parent
bc70052bf8
commit
82ecb8621d
3 files changed
+190
-25
No files matched your search
@@ -562,13 +562,15 @@
|
||||
<div class="upload-file-card">
|
||||
<!-- 缩略图区域 -->
|
||||
<div class="upload-file-thumb">
|
||||
<el-image
|
||||
<!-- {{ file.url }} -->
|
||||
<image-preview v-if="isImageFile(file) && file.url" :src="file.url" class="upload-thumb-image" :isOssId="true" />
|
||||
<!-- <el-image
|
||||
v-if="isImageFile(file) && file.url"
|
||||
:src="file.url"
|
||||
fit="cover"
|
||||
:preview-src-list="[file.url]"
|
||||
class="upload-thumb-image"
|
||||
/>
|
||||
/> -->
|
||||
<div v-else class="upload-file-placeholder">
|
||||
<el-icon><Document /></el-icon>
|
||||
<span class="file-ext">{{ getFileExt(file.name) }}</span>
|
||||
@@ -822,14 +824,15 @@
|
||||
<div v-for="attachment in currentAttachments" :key="attachment.id" class="attachment-card">
|
||||
<!-- 附件缩略图 -->
|
||||
<div class="attachment-thumbnail-wrapper">
|
||||
<el-image
|
||||
<!-- <el-image
|
||||
v-if="attachment.fileType === 'image'"
|
||||
:src="attachment.filePath"
|
||||
:preview-src-list="getImagePreviewList()"
|
||||
fit="cover"
|
||||
class="attachment-image"
|
||||
lazy
|
||||
/>
|
||||
/> -->
|
||||
<image-preview v-if="attachment.fileType === 'image'" :src="attachment.filePath" class="attachment-image" :isOssId="true" />
|
||||
<div v-else class="attachment-file-icon">
|
||||
<el-icon :size="28">
|
||||
<Document v-if="attachment.fileType === 'document'" />
|
||||
@@ -857,14 +860,14 @@
|
||||
<!-- 附件操作 -->
|
||||
<div class="attachment-card-actions">
|
||||
<el-button-group size="small">
|
||||
<el-button
|
||||
<!-- <el-button
|
||||
type="primary"
|
||||
@click="previewAttachment(attachment)"
|
||||
:disabled="!canPreview(attachment)"
|
||||
:title="canPreview(attachment) ? '预览' : '不支持预览'"
|
||||
>
|
||||
<el-icon><View /></el-icon>
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
<el-button type="success" @click="downloadAttachment(attachment)" title="下载">
|
||||
<el-icon><Download /></el-icon>
|
||||
</el-button>
|
||||
@@ -1230,6 +1233,7 @@ import { getInfo } from '@/api/login'; // 添加获取用户详细信息的API
|
||||
import { getToken } from '@/utils/auth'; // 修复:添加getToken导入
|
||||
import { vLoading, ElLoading } from 'element-plus';
|
||||
import { Loading } from '@element-plus/icons-vue';
|
||||
import request from '@/utils/request';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
@@ -1271,7 +1275,7 @@ const workerOptions = ref<Array<{ value: string | number; label: string; userNam
|
||||
|
||||
// 附件相关数据
|
||||
const attachmentList = ref<any[]>([]);
|
||||
const uploadAction = ref('/dev-api/hq/pm/attachment/upload'); // 修复:使用正确的API路径
|
||||
const uploadAction = ref(import.meta.env.VITE_APP_BASE_API + '/hq/pm/attachment/upload'); // 修复:使用正确的API路径
|
||||
const uploadHeaders = ref({
|
||||
'Authorization': `Bearer ${getToken() || ''}`,
|
||||
'clientid': import.meta.env.VITE_APP_CLIENT_ID || 'e5cd7e4891bf95d1d19206ce24a7b32e'
|
||||
@@ -1826,7 +1830,10 @@ const submitForm = () => {
|
||||
buttonLoading.value = true;
|
||||
try {
|
||||
let orderId: string | number;
|
||||
|
||||
// todo form.attachementCount的数量等于附件栏中附件的数量
|
||||
console.log('form.value', form.value);
|
||||
console.log('attachmentList 长度:', attachmentList.value.length);
|
||||
form.value.attachmentCount=attachmentList.value.length
|
||||
if (form.value.id) {
|
||||
await updateRepairOrder(form.value);
|
||||
orderId = form.value.id;
|
||||
@@ -2330,7 +2337,9 @@ const handleUploadSuccess = (response: any, file: any) => {
|
||||
|
||||
if (response.code === 200) {
|
||||
proxy?.$modal.msgSuccess(`文件 ${file.name} 上传成功`);
|
||||
|
||||
// todo
|
||||
console.log('orderDetail', orderDetail.value);
|
||||
// orderDetail.value.attachmentCount++;
|
||||
// 立即记录附件数据
|
||||
const attachmentData = response.data;
|
||||
if (attachmentData && attachmentData.id) {
|
||||
@@ -2415,12 +2424,28 @@ const handleDownloadAttachment = async (file: any) => {
|
||||
target: document.body
|
||||
});
|
||||
|
||||
const response = await fetch(downloadUrl);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
// const response = await fetch(downloadUrl);
|
||||
// if (!response.ok) {
|
||||
// throw new Error(`HTTP error! status: ${response.status}`);
|
||||
// }
|
||||
// 通过fetch获取文件内容,强制下载
|
||||
// const response = await req('/resource/oss/download/' + attachment.filePath);
|
||||
const response = await request({
|
||||
url: '/resource/oss/download/' + downloadUrl,
|
||||
method: 'get',
|
||||
responseType: 'blob',
|
||||
timeout: 30000 // 30秒超时
|
||||
});
|
||||
// 由于axios响应拦截器对blob类型响应直接返回blob数据
|
||||
// 这里response直接就是blob对象,而不是包含data属性的响应对象
|
||||
const blob = response;
|
||||
|
||||
// 验证响应数据
|
||||
if (!blob) {
|
||||
throw new Error('响应数据为空');
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
// const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
|
||||
const link = document.createElement('a');
|
||||
@@ -2713,12 +2738,23 @@ const downloadAttachment = async (attachment: any) => {
|
||||
});
|
||||
|
||||
// 通过fetch获取文件内容,强制下载
|
||||
const response = await fetch(attachment.filePath);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
// const response = await req('/resource/oss/download/' + attachment.filePath);
|
||||
const response = await request({
|
||||
url: '/resource/oss/download/' + attachment.filePath,
|
||||
method: 'get',
|
||||
responseType: 'blob',
|
||||
timeout: 30000 // 30秒超时
|
||||
});
|
||||
// 由于axios响应拦截器对blob类型响应直接返回blob数据
|
||||
// 这里response直接就是blob对象,而不是包含data属性的响应对象
|
||||
const blob = response;
|
||||
|
||||
// 验证响应数据
|
||||
if (!blob) {
|
||||
throw new Error('响应数据为空');
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
// const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
|
||||
// 创建下载链接
|
||||
|
||||
Reference in new issue
Block a user