|
|
|
@ -124,23 +124,22 @@ |
|
|
|
<div class="panel-card upload-drop-card"> |
|
|
|
<div class="upload-field-label">订单日志文件(支持多选)</div> |
|
|
|
<div class="upload-zone-wrap"> |
|
|
|
<input |
|
|
|
ref="orderFileInput" |
|
|
|
class="upload-file-input" |
|
|
|
type="file" |
|
|
|
multiple |
|
|
|
accept=".txt,.log,.csv" |
|
|
|
@change="handleOrderFileInputChange"> |
|
|
|
<div |
|
|
|
class="upload-drop-zone" |
|
|
|
@click="triggerOrderFileSelect" |
|
|
|
@dragover.prevent |
|
|
|
@dragenter.prevent |
|
|
|
@drop.prevent="handleOrderFileDrop"> |
|
|
|
<input |
|
|
|
ref="orderFileInput" |
|
|
|
class="upload-file-input" |
|
|
|
type="file" |
|
|
|
multiple |
|
|
|
accept=".txt,.log,.csv" |
|
|
|
@change="handleOrderFileInputChange"> |
|
|
|
<i class="el-icon-upload"></i> |
|
|
|
<div class="upload-main-text">将文件拖到此处,或<em>点击上传</em></div> |
|
|
|
</div> |
|
|
|
<div class="upload-tip-text">可一次选择多个日志文件,保存时会逐个上传</div> |
|
|
|
<div class="upload-tip-text">可一次选择多个日志文件,也可分多次添加,保存时会逐个上传</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
@ -150,7 +149,7 @@ |
|
|
|
<span>待上传文件</span> |
|
|
|
<span>共 {{ uploadOrderFileList.length }} 个</span> |
|
|
|
</div> |
|
|
|
<el-table :data="uploadOrderFileList" border :height="rightTableHeight" style="width: 100%;"> |
|
|
|
<el-table ref="pendingFileTable" :data="uploadOrderFileList" border :height="rightTableHeight" style="width: 100%;"> |
|
|
|
<el-table-column label="文件名" header-align="center" min-width="160" show-overflow-tooltip> |
|
|
|
<template slot-scope="scope"> |
|
|
|
{{ scope.row.name }} |
|
|
|
@ -161,7 +160,7 @@ |
|
|
|
{{ formatFileSize(scope.row.size) }} |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column fixed="right" label="操作" width="60" header-align="center" align="center"> |
|
|
|
<el-table-column label="操作" width="60" header-align="center" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-link style="cursor: pointer" @click="removePendingUploadFile(scope.$index)">移除</el-link> |
|
|
|
</template> |
|
|
|
@ -236,7 +235,6 @@ export default { |
|
|
|
uploadOrderFileList: [], |
|
|
|
uploadResults: [], |
|
|
|
uploadFileUid: 1, |
|
|
|
maxUploadFileCount: 20, |
|
|
|
maxUploadFileSize: 20 * 1024 * 1024, |
|
|
|
uploadRequestTimeoutMs: 1000 * 60 * 20, |
|
|
|
uploadProgress: { |
|
|
|
@ -307,8 +305,8 @@ export default { |
|
|
|
this.leftTableHeight = nextLeftTableHeight |
|
|
|
|
|
|
|
let nextRightTableHeight = nextLayoutHeight - 370 |
|
|
|
if (nextRightTableHeight < 120) { |
|
|
|
nextRightTableHeight = 120 |
|
|
|
if (nextRightTableHeight < 160) { |
|
|
|
nextRightTableHeight = 160 |
|
|
|
} |
|
|
|
this.rightTableHeight = nextRightTableHeight |
|
|
|
}, |
|
|
|
@ -538,12 +536,6 @@ export default { |
|
|
|
return String(status) === '1' ? 'success' : 'danger' |
|
|
|
}, |
|
|
|
|
|
|
|
triggerOrderFileSelect () { |
|
|
|
if (this.$refs.orderFileInput) { |
|
|
|
this.$refs.orderFileInput.click() |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
handleOrderFileInputChange (event) { |
|
|
|
const files = event && event.target && event.target.files |
|
|
|
? Array.prototype.slice.call(event.target.files) |
|
|
|
@ -570,25 +562,20 @@ export default { |
|
|
|
'.log': true, |
|
|
|
'.csv': true |
|
|
|
} |
|
|
|
const nextList = this.uploadOrderFileList.slice() |
|
|
|
const keyMap = {} |
|
|
|
for (let i = 0; i < this.uploadOrderFileList.length; i++) { |
|
|
|
const item = this.uploadOrderFileList[i] |
|
|
|
for (let i = 0; i < nextList.length; i++) { |
|
|
|
const item = nextList[i] |
|
|
|
const itemKey = [item.name || '', item.size || 0, item.lastModified || 0].join('|') |
|
|
|
keyMap[itemKey] = true |
|
|
|
} |
|
|
|
|
|
|
|
let invalidCount = 0 |
|
|
|
let duplicateCount = 0 |
|
|
|
let overLimitCount = 0 |
|
|
|
let overSizeCount = 0 |
|
|
|
let addedCount = 0 |
|
|
|
for (let i = 0; i < files.length; i++) { |
|
|
|
const file = files[i] |
|
|
|
const currentTotal = this.uploadOrderFileList.length + addedCount |
|
|
|
if (currentTotal >= this.maxUploadFileCount) { |
|
|
|
overLimitCount++ |
|
|
|
continue |
|
|
|
} |
|
|
|
const lowerName = (file.name || '').toLowerCase() |
|
|
|
const ext = lowerName.lastIndexOf('.') > -1 ? lowerName.substring(lowerName.lastIndexOf('.')) : '' |
|
|
|
if (!allowedExtMap[ext]) { |
|
|
|
@ -606,7 +593,7 @@ export default { |
|
|
|
} |
|
|
|
keyMap[fileKey] = true |
|
|
|
addedCount++ |
|
|
|
this.uploadOrderFileList.push({ |
|
|
|
nextList.push({ |
|
|
|
uid: 'local_' + this.uploadFileUid++, |
|
|
|
name: file.name, |
|
|
|
size: file.size, |
|
|
|
@ -615,6 +602,9 @@ export default { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
this.uploadOrderFileList = nextList |
|
|
|
this.layoutPendingFileTable() |
|
|
|
|
|
|
|
if (invalidCount > 0) { |
|
|
|
this.$message.warning('仅支持 .txt/.log/.csv 文件,已忽略 ' + invalidCount + ' 个') |
|
|
|
} |
|
|
|
@ -624,14 +614,20 @@ export default { |
|
|
|
if (overSizeCount > 0) { |
|
|
|
this.$message.warning('单个文件不能超过 20MB,已忽略 ' + overSizeCount + ' 个') |
|
|
|
} |
|
|
|
if (overLimitCount > 0) { |
|
|
|
this.$message.warning('最多可上传 20 个文件,已忽略 ' + overLimitCount + ' 个') |
|
|
|
} |
|
|
|
if (addedCount > 0) { |
|
|
|
this.$message.success('已添加文件 ' + addedCount + ' 个') |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
layoutPendingFileTable () { |
|
|
|
this.$nextTick(() => { |
|
|
|
const table = this.$refs.pendingFileTable |
|
|
|
if (table && table.doLayout) { |
|
|
|
table.doLayout() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
removePendingUploadFile (index) { |
|
|
|
this.uploadOrderFileList.splice(index, 1) |
|
|
|
}, |
|
|
|
@ -695,10 +691,6 @@ export default { |
|
|
|
this.$message.warning('请先选择上传文件') |
|
|
|
return false |
|
|
|
} |
|
|
|
if (this.uploadOrderFileList.length > this.maxUploadFileCount) { |
|
|
|
this.$message.warning('最多只能上传 20 个文件') |
|
|
|
return false |
|
|
|
} |
|
|
|
return true |
|
|
|
}, |
|
|
|
|
|
|
|
@ -986,10 +978,19 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
.upload-file-input { |
|
|
|
display: none; |
|
|
|
position: absolute; |
|
|
|
top: 0; |
|
|
|
left: 0; |
|
|
|
z-index: 2; |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
opacity: 0; |
|
|
|
cursor: pointer; |
|
|
|
font-size: 0; |
|
|
|
} |
|
|
|
|
|
|
|
.upload-drop-zone { |
|
|
|
position: relative; |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
align-items: center; |
|
|
|
@ -1053,6 +1054,10 @@ export default { |
|
|
|
margin-top: 0; |
|
|
|
} |
|
|
|
|
|
|
|
.selected-file-wrap /deep/ .el-table__body-wrapper { |
|
|
|
overflow-y: auto; |
|
|
|
} |
|
|
|
|
|
|
|
.upload-result-wrap /deep/ .el-table td { |
|
|
|
padding-top: 2px !important; |
|
|
|
padding-bottom: 2px !important; |
|
|
|
|