mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 13:04:57 +08:00
commit: 一期,修改版本号
This commit is contained in:
parent
7e38b7a511
commit
198ae7d820
|
@ -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) {
|
export function handleHttpUploadUrl(options: any, url: string | undefined) {
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
formData.append('file', options.file);
|
formData.append('file', options.file);
|
||||||
formData.append('dir', options.dir)
|
formData.append('dir', options.dir);
|
||||||
return new Promise((resolve) => {
|
|
||||||
try {
|
return new Promise((resolve, reject) => { // 使用 reject 来处理错误
|
||||||
request({
|
request({
|
||||||
url: url,
|
url: url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
data: formData,
|
data: formData,
|
||||||
}).then((res: any) => {
|
}).then((res: any) => {
|
||||||
resolve(res.data)
|
if (res.data && res.data.code !== 0) {
|
||||||
});
|
// 如果返回的 code 不为 0,拒绝 Promise
|
||||||
} catch (error) {
|
reject(res.data);
|
||||||
resolve(error)
|
} else {
|
||||||
}
|
// console.log(res.message);
|
||||||
})
|
resolve(res.message);
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
// 网络请求遇到其他错误时也拒绝 Promise
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
Binary file not shown.
|
@ -1,23 +1,23 @@
|
||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="dialogVisible" :title="title" width="50%">
|
<el-dialog v-model="dialogVisible" :title="title" width="50%">
|
||||||
<el-upload action="#" v-model:file-list="fileList" drag accept=".xls, .xlsx"
|
<el-upload action="#" v-model:file-list="fileList" drag accept=".xls, .xlsx"
|
||||||
:auto-upload="false" :limit="1" :http-request="handleUpload" ref="uploadRef">
|
:auto-upload="false" :limit="1" :http-request="handleUpload" ref="uploadRef">
|
||||||
<div class="el-upload__text" style="padding: 40px 10px;font-size: 20px;">
|
<div class="el-upload__text" style="padding: 40px 10px;font-size: 20px;">
|
||||||
将文件拖到此处,或 <em>点击上传</em>
|
将文件拖到此处,或 <em>点击上传</em>
|
||||||
</div>
|
</div>
|
||||||
<template #tip>
|
<template #tip>
|
||||||
<div class="el-upload__tip" style="font-size: 16px;">
|
<div class="el-upload__tip" style="font-size: 16px;">
|
||||||
仅允许导入xls、xlsx格式文件。<span class="main-color" style="cursor: pointer;"
|
仅允许导入xls、xlsx格式文件。<span class="main-color" style="cursor: pointer;"
|
||||||
@click="downloadTemplate">下载模板</span>
|
@click="downloadTemplate">下载模板</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
|
|
||||||
<div style="text-align: right;margin-top: 20px;">
|
<div style="text-align: right;margin-top: 20px;">
|
||||||
<el-button class="f18" @click="dialogVisible = false">取消</el-button>
|
<el-button class="f18" @click="dialogVisible = false">取消</el-button>
|
||||||
<el-button class="f18" type="primary" @click="importData">确认</el-button>
|
<el-button class="f18" type="primary" @click="importData">确认</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang='ts' setup>
|
<script lang='ts' setup>
|
||||||
|
@ -30,9 +30,9 @@ import {handleHttpUploadUrl} from "@/api/file-upload";
|
||||||
const emit = defineEmits(['success', 'error'])
|
const emit = defineEmits(['success', 'error'])
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
title: String,
|
title: String,
|
||||||
templateUrl: String, // 模板下载地址
|
templateUrl: String, // 模板下载地址
|
||||||
importUrl: String, // 上传接口地址
|
importUrl: String, // 上传接口地址
|
||||||
})
|
})
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
|
@ -40,44 +40,59 @@ const fileList = ref<UploadUserFile[]>([])
|
||||||
const uploadRef = ref()
|
const uploadRef = ref()
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open,
|
open,
|
||||||
close
|
close
|
||||||
})
|
})
|
||||||
|
|
||||||
function open() {
|
function open() {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadTemplate = () => {
|
const downloadTemplate = () => {
|
||||||
downBlobFile(props.templateUrl, {}, "temp.xlsx")
|
downBlobFile(props.templateUrl, {}, "temp.xlsx")
|
||||||
}
|
}
|
||||||
const importData = () => {
|
const importData = () => {
|
||||||
// console.log(fileList.value)
|
// console.log(fileList.value)
|
||||||
if (fileList.value.length === 0) {
|
if (fileList.value.length === 0) {
|
||||||
ElMessage.warning('请上传符合格式的xls或xlsx文件')
|
ElMessage.warning('请上传符合格式的xls或xlsx文件')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uploadRef.value.submit()
|
uploadRef.value.submit()
|
||||||
// emit('error')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpload(options: any) {
|
function handleUpload(options: any) {
|
||||||
handleHttpUploadUrl(options, props.importUrl).then((res: any) => {
|
handleHttpUploadUrl(options, props.importUrl)
|
||||||
if (res.code == 0) {
|
.then((res: any) => {
|
||||||
ElMessage.success('上传成功')
|
console.log(res)
|
||||||
close()
|
if (res === 'Request failed with status code 403') {
|
||||||
emit('success')
|
ElMessage.error('上传失败,请检查权限信息')
|
||||||
} else {
|
return
|
||||||
ElMessage.error(res.msg ? res.msg : "上传失败")
|
}
|
||||||
emit("error");
|
|
||||||
}
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang='scss' scoped></style>
|
<style lang='scss' scoped></style>
|
||||||
|
|
|
@ -3,14 +3,14 @@ import {Session} from "@/utils/storage";
|
||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
|
|
||||||
// 本地调试版本:
|
// 本地调试版本:
|
||||||
// const vitalUrl = "ws://" + window.location.host + "/socket.io/admin/rax/vitalSignsMedicine?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 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 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 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 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 chatUrl = "wss://" + window.location.host + "/socket.io/admin/rax/chatRoom?token=" + Session.getToken()
|
||||||
|
|
||||||
// 测试echars
|
// 测试echars
|
||||||
// const vitalUrl = "wss://" + "110.41.142.124" + "/socket.io/admin/rax/vitalSignsMedicine?token=" + Session.getToken()
|
// 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
Loading…
Reference in New Issue
Block a user