|
|
|
@ -1,5 +1,5 @@ |
|
|
|
<script> |
|
|
|
import {ossUpload, previewOssFileById, queryOss, removeOss} from "../../../api/oss/oss"; |
|
|
|
import {ossUpload, ossUpgrade, previewOssFileById, queryOss, removeOss} from "../../../api/oss/oss"; |
|
|
|
|
|
|
|
export default { |
|
|
|
name: "ossComponents", |
|
|
|
@ -59,6 +59,18 @@ export default { |
|
|
|
readonly: { |
|
|
|
type: Boolean, |
|
|
|
default: false |
|
|
|
}, |
|
|
|
requireFileNoRev: { |
|
|
|
type: Boolean, |
|
|
|
default: false |
|
|
|
}, |
|
|
|
enableUpgrade: { |
|
|
|
type: Boolean, |
|
|
|
default: false |
|
|
|
}, |
|
|
|
singleUpload: { |
|
|
|
type: Boolean, |
|
|
|
default: false |
|
|
|
} |
|
|
|
}, |
|
|
|
data(){ |
|
|
|
@ -72,9 +84,21 @@ export default { |
|
|
|
ossForm:{ |
|
|
|
orderRef2:'', |
|
|
|
orderRef3:'', |
|
|
|
fileNo:'', |
|
|
|
rev:null, |
|
|
|
remark:'' |
|
|
|
}, |
|
|
|
fileList:[], |
|
|
|
upgradeVisible:false, |
|
|
|
upgradeLoading:false, |
|
|
|
upgradeFileList:[], |
|
|
|
upgradeForm:{ |
|
|
|
sourceId:'', |
|
|
|
fileNo:'', |
|
|
|
currentRev:null, |
|
|
|
newRev:null, |
|
|
|
fileRemark:'' |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
@ -108,9 +132,14 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
this.fileList = []; |
|
|
|
this.ossForm.fileNo = ''; |
|
|
|
this.ossForm.rev = 1; |
|
|
|
this.ossForm.remark = ''; |
|
|
|
this.ossVisible = true |
|
|
|
}, |
|
|
|
onExceedFileLimit(){ |
|
|
|
this.$message.warning('当前场景仅允许上传1个文件'); |
|
|
|
}, |
|
|
|
onRemoveFile(file, fileList){ |
|
|
|
this.fileList = fileList |
|
|
|
}, |
|
|
|
@ -122,6 +151,16 @@ export default { |
|
|
|
this.$message.error('请选择文件'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (this.requireFileNoRev){ |
|
|
|
if (!this.ossForm.fileNo){ |
|
|
|
this.$message.error('文件编码不能为空'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!this.ossForm.rev || this.ossForm.rev <= 0){ |
|
|
|
this.$message.error('版本号必须大于0'); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
let formData = new FormData(); |
|
|
|
for (let i = 0; i < this.fileList.length; i++) { |
|
|
|
formData.append('file', this.fileList[i].raw); |
|
|
|
@ -130,6 +169,10 @@ export default { |
|
|
|
formData.append('orderRef2', this.ossForm.orderRef2); |
|
|
|
formData.append('orderRef3', this.orderRef3); |
|
|
|
formData.append('fileRemark', this.ossForm.remark); |
|
|
|
if (this.requireFileNoRev){ |
|
|
|
formData.append('fileNo', this.ossForm.fileNo); |
|
|
|
formData.append('rev', this.ossForm.rev); |
|
|
|
} |
|
|
|
this.uploadLoading = true; |
|
|
|
ossUpload(formData).then(({data})=>{ |
|
|
|
if (data && data.code === 0){ |
|
|
|
@ -149,6 +192,70 @@ export default { |
|
|
|
this.uploadLoading = false; |
|
|
|
}) |
|
|
|
}, |
|
|
|
handleVersionUpgrade(){ |
|
|
|
if (this.selectionDataList.length !== 1){ |
|
|
|
this.$message.warning('请选择一条文件记录进行升版'); |
|
|
|
return; |
|
|
|
} |
|
|
|
const row = this.selectionDataList[0]; |
|
|
|
if (!row.fileNo){ |
|
|
|
this.$message.warning('当前文件缺少文件编码,无法升版'); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (row.invalidationTime){ |
|
|
|
this.$message.warning('当前文件已失效,请选择有效版本'); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.$nextTick(()=>{ |
|
|
|
if (this.$refs.upgradeUpload){ |
|
|
|
this.$refs.upgradeUpload.clearFiles(); |
|
|
|
} |
|
|
|
}) |
|
|
|
this.upgradeFileList = []; |
|
|
|
this.upgradeForm.sourceId = row.id; |
|
|
|
this.upgradeForm.fileNo = row.fileNo; |
|
|
|
this.upgradeForm.currentRev = row.rev || 1; |
|
|
|
this.upgradeForm.newRev = (row.rev || 1) + 1; |
|
|
|
this.upgradeForm.fileRemark = row.fileRemark || ''; |
|
|
|
this.upgradeVisible = true; |
|
|
|
}, |
|
|
|
onUpgradeFileChange(file, fileList){ |
|
|
|
this.upgradeFileList = fileList; |
|
|
|
}, |
|
|
|
onUpgradeFileRemove(file, fileList){ |
|
|
|
this.upgradeFileList = fileList; |
|
|
|
}, |
|
|
|
handleSubmitUpgrade(){ |
|
|
|
if (this.upgradeFileList.length === 0){ |
|
|
|
this.$message.error('请选择需要上传的新版本文件'); |
|
|
|
return; |
|
|
|
} |
|
|
|
let formData = new FormData(); |
|
|
|
formData.append('file', this.upgradeFileList[0].raw); |
|
|
|
formData.append('sourceId', this.upgradeForm.sourceId); |
|
|
|
formData.append('fileRemark', this.upgradeForm.fileRemark || ''); |
|
|
|
this.upgradeLoading = true; |
|
|
|
ossUpgrade(formData).then(({data})=>{ |
|
|
|
if (data && data.code === 0){ |
|
|
|
this.$message.success(data.msg); |
|
|
|
this.upgradeVisible = false; |
|
|
|
this.handleQuery(); |
|
|
|
if (this.$refs.table){ |
|
|
|
this.$refs.table.clearSelection(); |
|
|
|
} |
|
|
|
}else { |
|
|
|
this.$message.warning(data.msg); |
|
|
|
} |
|
|
|
this.upgradeLoading = false; |
|
|
|
}).catch((error)=>{ |
|
|
|
console.error('文件升版失败:', error); |
|
|
|
const errorMsg = error.response && error.response.data && error.response.data.msg |
|
|
|
? error.response.data.msg |
|
|
|
: (error.message || '文件升版失败'); |
|
|
|
this.$message.error(errorMsg); |
|
|
|
this.upgradeLoading = false; |
|
|
|
}) |
|
|
|
}, |
|
|
|
handleRemove(row){ |
|
|
|
this.$confirm('确认删除吗?', '提示').then(() => { |
|
|
|
let ids = [row.id] |
|
|
|
@ -293,6 +400,9 @@ export default { |
|
|
|
<template v-if="downloadVisible&&!readonly"> |
|
|
|
<el-button type="primary" @click="handleDownload">下载</el-button> |
|
|
|
</template> |
|
|
|
<template v-if="enableUpgrade&&saveVisible&&effectiveVisibleFlag&&!readonly&&!disabled"> |
|
|
|
<el-button type="primary" @click="handleVersionUpgrade">升版</el-button> |
|
|
|
</template> |
|
|
|
<el-table |
|
|
|
:height="height" |
|
|
|
:data="dataList" |
|
|
|
@ -343,13 +453,25 @@ export default { |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<slot></slot> |
|
|
|
<el-col :span="12" v-if="requireFileNoRev"> |
|
|
|
<el-form-item label="文件编码"> |
|
|
|
<el-input v-model.trim="ossForm.fileNo" maxlength="100"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12" v-if="requireFileNoRev"> |
|
|
|
<el-form-item label="版本号"> |
|
|
|
<el-input-number v-model="ossForm.rev" :min="1" :step="1" controls-position="right" style="width: 100%;"></el-input-number> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label=" " class="auto"> |
|
|
|
<el-upload drag :file-list="fileList" |
|
|
|
action="#" ref="upload" |
|
|
|
:on-remove="onRemoveFile" |
|
|
|
:on-change="onChangeFile" |
|
|
|
multiple |
|
|
|
:multiple="!singleUpload" |
|
|
|
:limit="singleUpload ? 1 : 999" |
|
|
|
:on-exceed="onExceedFileLimit" |
|
|
|
:auto-upload="false"> |
|
|
|
<i class="el-icon-upload"></i> |
|
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
|
|
|
@ -368,6 +490,53 @@ export default { |
|
|
|
<el-button @click="ossVisible = false">关闭</el-button> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<el-dialog title="附件升版" :visible.sync="upgradeVisible" v-drag width="500px" append-to-body :close-on-click-modal="false"> |
|
|
|
<el-form :model="upgradeForm" label-width="100px"> |
|
|
|
<el-row :gutter="10"> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="文件编码"> |
|
|
|
<el-input v-model="upgradeForm.fileNo" readonly></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="当前版本"> |
|
|
|
<el-input :value="upgradeForm.currentRev" readonly></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="新版本"> |
|
|
|
<el-input :value="upgradeForm.newRev" readonly></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="新版本文件"> |
|
|
|
<el-upload drag |
|
|
|
action="#" |
|
|
|
ref="upgradeUpload" |
|
|
|
:file-list="upgradeFileList" |
|
|
|
:on-change="onUpgradeFileChange" |
|
|
|
:on-remove="onUpgradeFileRemove" |
|
|
|
:limit="1" |
|
|
|
:on-exceed="onExceedFileLimit" |
|
|
|
:auto-upload="false"> |
|
|
|
<i class="el-icon-upload"></i> |
|
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
|
|
|
</el-upload> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="备注"> |
|
|
|
<el-input type="textarea" v-model="upgradeForm.fileRemark" resize="none" :autosize="{minRows: 3, maxRows: 3}"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</el-form> |
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
<el-button type="primary" :loading="upgradeLoading" @click="handleSubmitUpgrade">确定</el-button> |
|
|
|
<el-button @click="upgradeVisible = false">关闭</el-button> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
|