Commit 13ebe374 by 张立顺

Merge branch 'SAAS+V4.53.0-0528' of http://192.168.3.233:8090/saas_plus/dj-car-l…

…ife-system into SAAS+V4.53.0-0528
2 parents 3ce97d57 76886a30
...@@ -59,13 +59,14 @@ ...@@ -59,13 +59,14 @@
accept=".xlsx,.xls,.doc,.pdf,.docx,.jpg,.png" accept=".xlsx,.xls,.doc,.pdf,.docx,.jpg,.png"
class="upload-file" class="upload-file"
:show-file-list="false" :show-file-list="false"
:file-list="item.uploadFileList" :file-list.sync="item.uploadFileList"
:limit="6" :limit="6"
:auto-upload="false" :auto-upload="false"
:on-remove="importFileChange" :on-remove="importFileChange"
:on-change="(file, fileList) => handleFileChange(file, fileList, item) :on-change="(file, fileList) => handleFileChange(file, fileList, item)
" "
:on-exceed="hanldeOnExceed"> :on-exceed="hanldeOnExceed"
:key="uploadKey">
<div class="upload-txt">+ 上传文件</div> <div class="upload-txt">+ 上传文件</div>
</el-upload> </el-upload>
<div class="upload-tips">注:请上传{{ item.title }}。</div> <div class="upload-tips">注:请上传{{ item.title }}。</div>
...@@ -257,7 +258,7 @@ export default { ...@@ -257,7 +258,7 @@ export default {
editChildRef: "editChildRef", editChildRef: "editChildRef",
editFormData: [], editFormData: [],
formRules: {}, formRules: {},
uploadFileList: [], uploadKey: 0,
baseData: { baseData: {
merchantOpt: [] // 流量方信息 merchantOpt: [] // 流量方信息
}, },
...@@ -447,17 +448,13 @@ export default { ...@@ -447,17 +448,13 @@ export default {
// 获取文件 // 获取文件
importFileChange(file, fileList) { importFileChange(file, fileList) {
console.log("fileList111", fileList) console.log('delete', file, fileList)
this.uploadFileList = fileList
this.infoForm.attachmentList = deepClone(fileList)
console.log(fileList, "fileList")
}, },
handleFileChange(file, fileList, targetItem) { handleFileChange(file, fileList, targetItem) {
console.log("file", file) console.log("file", file)
console.log("fileList", fileList) console.log("fileList", fileList)
console.log("targetItem", targetItem) console.log("targetItem", targetItem)
// return false targetItem.uploadFileList = fileList
// setTimeout(() => {
var reader = new FileReader() var reader = new FileReader()
var fileInfo = file.raw var fileInfo = file.raw
if ( if (
...@@ -473,6 +470,7 @@ export default { ...@@ -473,6 +470,7 @@ export default {
message: "文件格式不支持上传", message: "文件格式不支持上传",
type: "error" type: "error"
}) })
targetItem.uploadFileList.pop() // 手动删除数组最后一项,更新绑定的数组
return false return false
} }
// 默认10MB // 默认10MB
...@@ -483,16 +481,14 @@ export default { ...@@ -483,16 +481,14 @@ export default {
message: "上传文件大小不能超过" + limitSize + "MB!", message: "上传文件大小不能超过" + limitSize + "MB!",
type: "error" type: "error"
}) })
// this.uploadFileList = this.uploadFileList.filter((item) => {
targetItem.uploadFileList = targetItem.uploadFileList.filter((item) => { targetItem.uploadFileList = targetItem.uploadFileList.filter((item) => {
return item.size / 1024 / 1024 < 10 return item.size / 1024 / 1024 < limitSize
}) })
console.log('targetItem.uploadFileList', targetItem.uploadFileList)
return false return false
} }
reader.readAsDataURL(fileInfo) reader.readAsDataURL(fileInfo)
reader.onload = (e) => { reader.onload = (e) => {
const _formData = this.infoForm
// _formData[targetItem.name].push({
targetItem.files.push({ targetItem.files.push({
fileUrl: "", fileUrl: "",
uploadProgress: 0, uploadProgress: 0,
...@@ -501,14 +497,12 @@ export default { ...@@ -501,14 +497,12 @@ export default {
fileType: 1, // 文件类型(1.申请附件,2.结算凭证) fileType: 1, // 文件类型(1.申请附件,2.结算凭证)
cancelAxios: {} cancelAxios: {}
}) })
// const index = _formData[targetItem.name].length - 1
const index = targetItem.files.length - 1 const index = targetItem.files.length - 1
const fileData = e.target.result const fileData = e.target.result
const base64 = const base64 =
fileInfo.name.split(".")[fileInfo.name.split(".").length - 1] + fileInfo.name.split(".")[fileInfo.name.split(".").length - 1] +
"@" + "@" +
fileData.split(",")[1] fileData.split(",")[1]
// const requestEvent = fileInfo.type == 'application/pdf' ? uploadPDF : uploadExcel
const fileTypeKey = { const fileTypeKey = {
"application/pdf": "pdf", "application/pdf": "pdf",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
...@@ -552,12 +546,12 @@ export default { ...@@ -552,12 +546,12 @@ export default {
// this.btnLoding = false // this.btnLoding = false
this.clearItem(targetItem, index) // 上传失败将内容清空 不删除数组 防止其它上传进度 找不到对应下标 this.clearItem(targetItem, index) // 上传失败将内容清空 不删除数组 防止其它上传进度 找不到对应下标
}) })
// console.log("_formData[targetItem.name]", _formData[targetItem.name]) console.log("handleFileChange end targetItem", targetItem)
console.log("targetItem.files", targetItem.files)
} }
// }, 50) // }, 50)
}, },
hanldeOnExceed(files, fileList) { hanldeOnExceed(files, fileList) {
console.log("hanldeOnExceed", files, fileList)
this.$message({ this.$message({
message: "最多可上传6个文件", message: "最多可上传6个文件",
type: "error" type: "error"
...@@ -566,8 +560,6 @@ export default { ...@@ -566,8 +560,6 @@ export default {
// 删除文件 // 删除文件
handleFileDelete(targetItem, subIndex) { handleFileDelete(targetItem, subIndex) {
this.clearItem(targetItem, subIndex) this.clearItem(targetItem, subIndex)
// console.log(subIndex)
// this.infoForm.attachmentList.splice(subIndex, 1)
}, },
// 预览文件 // 预览文件
handleFileView(item) { }, handleFileView(item) { },
...@@ -590,6 +582,8 @@ export default { ...@@ -590,6 +582,8 @@ export default {
// this.$set(targetItem.files[subIndex], "uploadProgress", "") // this.$set(targetItem.files[subIndex], "uploadProgress", "")
targetItem.files.splice(subIndex, 1) targetItem.files.splice(subIndex, 1)
targetItem.uploadFileList.splice(subIndex, 1) targetItem.uploadFileList.splice(subIndex, 1)
this.uploadKey++ // 改变 key 值,触发重新渲染
console.log('clearItem targetItem', targetItem)
}, },
// 上传文件,转码为base64 // 上传文件,转码为base64
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!