commit: 一期,修改版本号

This commit is contained in:
republicline 2025-02-12 14:15:51 +08:00
parent 7e38b7a511
commit 198ae7d820
5 changed files with 572 additions and 783 deletions

View File

@ -24,24 +24,52 @@ export function handleHttpUpload(options: any) {
})
}
// export function handleHttpUploadUrl(options: any, url: string | undefined) {
// let formData = new FormData();
// formData.append('file', options.file);
// formData.append('dir', options.dir)
// return new Promise((resolve) => {
// try {
// request({
// url: url,
// method: 'post',
// headers: {
// 'Content-Type': 'multipart/form-data',
// },
// data: formData,
// }).then((res: any) => {
// resolve(res.data)
// });
// } catch (error) {
// resolve(error)
// }
// })
// }
export function handleHttpUploadUrl(options: any, url: string | undefined) {
let formData = new FormData();
formData.append('file', options.file);
formData.append('dir', options.dir)
return new Promise((resolve) => {
try {
request({
url: url,
method: 'post',
headers: {
'Content-Type': 'multipart/form-data',
},
data: formData,
}).then((res: any) => {
resolve(res.data)
});
} catch (error) {
resolve(error)
}
})
}
formData.append('dir', options.dir);
return new Promise((resolve, reject) => { // 使用 reject 来处理错误
request({
url: url,
method: 'post',
headers: {
'Content-Type': 'multipart/form-data',
},
data: formData,
}).then((res: any) => {
if (res.data && res.data.code !== 0) {
// 如果返回的 code 不为 0拒绝 Promise
reject(res.data);
} else {
// console.log(res.message);
resolve(res.message);
}
}).catch((error) => {
// 网络请求遇到其他错误时也拒绝 Promise
reject(error);
});
});
}

Binary file not shown.

View File

@ -1,23 +1,23 @@
<template>
<el-dialog v-model="dialogVisible" :title="title" width="50%">
<el-upload action="#" v-model:file-list="fileList" drag accept=".xls, .xlsx"
:auto-upload="false" :limit="1" :http-request="handleUpload" ref="uploadRef">
<div class="el-upload__text" style="padding: 40px 10px;font-size: 20px;">
将文件拖到此处 <em>点击上传</em>
</div>
<template #tip>
<div class="el-upload__tip" style="font-size: 16px;">
仅允许导入xlsxlsx格式文件<span class="main-color" style="cursor: pointer;"
@click="downloadTemplate">下载模板</span>
</div>
</template>
</el-upload>
<el-dialog v-model="dialogVisible" :title="title" width="50%">
<el-upload action="#" v-model:file-list="fileList" drag accept=".xls, .xlsx"
:auto-upload="false" :limit="1" :http-request="handleUpload" ref="uploadRef">
<div class="el-upload__text" style="padding: 40px 10px;font-size: 20px;">
将文件拖到此处 <em>点击上传</em>
</div>
<template #tip>
<div class="el-upload__tip" style="font-size: 16px;">
仅允许导入xlsxlsx格式文件<span class="main-color" style="cursor: pointer;"
@click="downloadTemplate">下载模板</span>
</div>
</template>
</el-upload>
<div style="text-align: right;margin-top: 20px;">
<el-button class="f18" @click="dialogVisible = false">取消</el-button>
<el-button class="f18" type="primary" @click="importData">确认</el-button>
</div>
</el-dialog>
<div style="text-align: right;margin-top: 20px;">
<el-button class="f18" @click="dialogVisible = false">取消</el-button>
<el-button class="f18" type="primary" @click="importData">确认</el-button>
</div>
</el-dialog>
</template>
<script lang='ts' setup>
@ -30,9 +30,9 @@ import {handleHttpUploadUrl} from "@/api/file-upload";
const emit = defineEmits(['success', 'error'])
const props = defineProps({
title: String,
templateUrl: String, //
importUrl: String, //
title: String,
templateUrl: String, //
importUrl: String, //
})
const dialogVisible = ref(false)
@ -40,44 +40,59 @@ const fileList = ref<UploadUserFile[]>([])
const uploadRef = ref()
defineExpose({
open,
close
open,
close
})
function open() {
dialogVisible.value = true
dialogVisible.value = true
}
function close() {
dialogVisible.value = false
dialogVisible.value = false
}
const downloadTemplate = () => {
downBlobFile(props.templateUrl, {}, "temp.xlsx")
downBlobFile(props.templateUrl, {}, "temp.xlsx")
}
const importData = () => {
// console.log(fileList.value)
if (fileList.value.length === 0) {
ElMessage.warning('请上传符合格式的xls或xlsx文件')
return
}
uploadRef.value.submit()
// emit('error')
// console.log(fileList.value)
if (fileList.value.length === 0) {
ElMessage.warning('请上传符合格式的xls或xlsx文件')
return
}
uploadRef.value.submit()
}
function handleUpload(options: any) {
handleHttpUploadUrl(options, props.importUrl).then((res: any) => {
if (res.code == 0) {
ElMessage.success('上传成功')
close()
emit('success')
} else {
ElMessage.error(res.msg ? res.msg : "上传失败")
emit("error");
}
})
handleHttpUploadUrl(options, props.importUrl)
.then((res: any) => {
console.log(res)
if (res === 'Request failed with status code 403') {
ElMessage.error('上传失败,请检查权限信息')
return
}
ElMessage.success('上传成功');
close();
emit('success');
})
.catch((error: any) => {
//
if (error.data && error.data.length > 0) {
const errorMessages = error.data
.map(item => `${item.lineNum}: ${item.errors.join(', ')}`)
.join('; ');
ElMessage.error(`上传失败: ${errorMessages}`);
} else {
ElMessage.error(error.msg || '上传失败');
}
emit("error");
});
}
</script>
<style lang='scss' scoped></style>

View File

@ -3,14 +3,14 @@ import {Session} from "@/utils/storage";
import {ElMessage} from "element-plus";
// 本地调试版本:
// const vitalUrl = "ws://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken()
// // const medicineUrl = "ws://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken()
// const chatUrl = "ws://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken()
const vitalUrl = "ws://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken()
// const medicineUrl = "ws://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken()
const chatUrl = "ws://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken()
// 服务器部署版本
const vitalUrl = "wss://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken()
// const medicineUrl = "wss://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken()
const chatUrl = "wss://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken()
// const vitalUrl = "wss://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken()
// // const medicineUrl = "wss://" + window.location.host + "/socket.io/admin/rax/addMedicine?token=" + Session.getToken()
// const chatUrl = "wss://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken()
// 测试echars
// const vitalUrl = "wss://" + "110.41.142.124" + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken()

File diff suppressed because it is too large Load Diff