提交 8ca54ead authored 作者: lidongxu's avatar lidongxu

fix(licenses/qualityins): 修复:证照中心支持覆盖式上传文件以及文件名称显示不全问题修复

上级 34ed930e
...@@ -114,12 +114,14 @@ ...@@ -114,12 +114,14 @@
<!-- 上传 PDF / 图片 --> <!-- 上传 PDF / 图片 -->
<el-form-item label="上传 PDF / 图片" <el-form-item label="上传 PDF / 图片"
prop="fileList"> prop="fileList">
<el-upload v-model:file-list="formData.fileList" <el-upload :file-list="formData.fileList"
ref="uploadRef"
class="upload-demo" class="upload-demo"
action="#" action="#"
accept="application/pdf, image/*" accept="application/pdf, image/*"
:http-request="httpRequestFn" :http-request="httpRequestFn"
:limit="1"> :limit="1"
:on-exceed="handleExceed">
<el-button size="small" <el-button size="small"
type="primary"> type="primary">
点击上传 点击上传
...@@ -161,6 +163,8 @@ import { getQualityInsPageList, uploadFileToOSSAPI, postQualityIns, getProductNa ...@@ -161,6 +163,8 @@ import { getQualityInsPageList, uploadFileToOSSAPI, postQualityIns, getProductNa
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { getFileTypeExt, parseTime } from '@/utils' import { getFileTypeExt, parseTime } from '@/utils'
import { genFileId } from 'element-plus'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const queryParams = reactive({ const queryParams = reactive({
...@@ -298,15 +302,27 @@ const submitForm = async () => { ...@@ -298,15 +302,27 @@ const submitForm = async () => {
}) })
} }
// 上传文件
const httpRequestFn = async (file) => { const httpRequestFn = async (file) => {
console.log('zoulema?')
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const url = await uploadFileToOSSAPI(`licenses/qualityIns/${date.getFullYear()}-${month}/${useUserStore().empInfo.empNo}/${uuidv4()}.${getFileTypeExt(file.file.name)}`, file.file) const url = await uploadFileToOSSAPI(`licenses/qualityIns/${date.getFullYear()}-${month}/${useUserStore().empInfo.empNo}/${uuidv4()}.${getFileTypeExt(file.file.name)}`, file.file)
formData.fileList[0].url = url formData.fileList[0] = {
name: file.file.name,
url,
}
// 重新校验表单 // 重新校验表单
proxy.$refs.formRef.validateField('fileList') proxy.$refs.formRef.validateField('fileList')
} }
// 替换文件
const uploadRef = ref(null)
const handleExceed = async (files) => {
const file = files[0]
uploadRef.value.clearFiles()
formData.fileList = []
httpRequestFn({ file })
}
</script> </script>
<style scoped <style scoped
...@@ -314,4 +330,30 @@ const httpRequestFn = async (file) => { ...@@ -314,4 +330,30 @@ const httpRequestFn = async (file) => {
.el-table { .el-table {
margin-top: 20px; margin-top: 20px;
} }
::v-deep(.el-upload-list__item-info) {
width: auto !important;
/* 覆盖el-upload文件名称样式,让宽度由内容撑开 */
::v-deep(.el-upload-list__item-file-name) {
text-overflow: initial !important;
overflow: visible !important;
white-space: normal !important;
white-space: nowrap !important;
/* 关键:不换行 */
max-width: none !important;
width: auto !important;
display: inline-block !important;
}
}
/* 完成提示按钮 */
::v-deep(.el-upload-list__item-status-label) {
right: auto !important;
}
/* 清除按钮 */
::v-deep(.el-icon--close) {
right: auto !important;
}
</style> </style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论