|
|
|
@ -185,6 +185,7 @@
|
|
|
|
|
:on-error="handleUploadError"
|
|
|
|
|
:on-exceed="handleExceed"
|
|
|
|
|
:on-remove="handleRemove(scope.row)"
|
|
|
|
|
:on-preview="handlePreview"
|
|
|
|
|
>
|
|
|
|
|
<el-button slot="trigger" :disabled="scope.row.ifstarts" size="small" type="primary">上传文件</el-button>
|
|
|
|
|
</el-upload>
|
|
|
|
@ -357,6 +358,36 @@
|
|
|
|
|
handleExceed(){
|
|
|
|
|
$.modal.msgWarning('超出个数限制,最多只能上传一个文件!');
|
|
|
|
|
},
|
|
|
|
|
handlePreview(file){
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/common/download/resource?resource=' + file.url,
|
|
|
|
|
type: 'GET',
|
|
|
|
|
xhrFields: {
|
|
|
|
|
responseType: 'blob'
|
|
|
|
|
},
|
|
|
|
|
success: function (data, status, xhr) {
|
|
|
|
|
let contentType = xhr.getResponseHeader('Content-Type');
|
|
|
|
|
let filename = file.name;
|
|
|
|
|
if (navigator.msSaveBlob) {
|
|
|
|
|
// 兼容 IE
|
|
|
|
|
navigator.msSaveBlob(data, filename);
|
|
|
|
|
} else {
|
|
|
|
|
let blob = new Blob([data], { type: contentType });
|
|
|
|
|
let url = URL.createObjectURL(blob);
|
|
|
|
|
let a = document.createElement('a');
|
|
|
|
|
a.href = url;
|
|
|
|
|
a.download = filename;
|
|
|
|
|
document.body.appendChild(a);
|
|
|
|
|
a.click();
|
|
|
|
|
document.body.removeChild(a);
|
|
|
|
|
URL.revokeObjectURL(url);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
error: function (xhr, status, error) {
|
|
|
|
|
console.error('下载文件失败:', error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
validateEndTime(rule, value, callback) {
|
|
|
|
|
// if (value && this.postForm.checkStartTime && new Date(value).getTime() < new Date(this.postForm.checkStartTime).getTime()) {
|
|
|
|
|
// callback(new Error('结束日期不能早于开始日期'));
|
|
|
|
|