增加下载文件

ywj_dev
wj 2 years ago
parent 72c7693ccd
commit d1e1c39ef0

@ -25,4 +25,13 @@ export function findConfig(query) {
});
}
export function downloadFile(query) {
return axios({
url: "/sps/sync/download/info/file",
method: "get",
params: query,
responseType: 'blob'
});
}

@ -12,9 +12,8 @@
<el-form-item class="query-form-item">
<el-select v-model="filterQuery.status" placeholder="处理状态">
<el-option label="全部" value=""></el-option>
<el-option label="等待处理" value="0"></el-option>
<el-option label="已处理" value="1"></el-option>
<el-option label="异常" value="2"></el-option>
<el-option label="异常" value="1"></el-option>
<el-option label="已处理" value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item>
@ -79,30 +78,32 @@
show-overflow-tooltip
></el-table-column>
<el-table-column
label="文件地址"
prop="cacheFilePath"
show-overflow-tooltip
></el-table-column>
<el-table-column label="操作" fixed="right" width="160">
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click.native.stop="detailDialog(scope.row.id)"
>详情
</el-button
>
<el-button
type="text"
size="small"
@click.native.stop="deleteDialog(scope.row.id)"
>删除
</el-button
>
<el-popconfirm @confirm="downFile(scope.row)" confirm-button-text='' cancel-button-text='' class="mr10"
icon="el-icon-info" icon-color="blck" title="是否确认要下载文件?" v-if="scope.row.cacheFilePath">
<el-button type="text" size="small" slot="reference">下载
</el-button>
</el-popconfirm>
<el-popconfirm @confirm="deleteData(scope.row.id)" confirm-button-text='' cancel-button-text=''
icon="el-icon-info" icon-color="red" title="是否确认要删除这条数据?">
<el-button type="text" size="small" slot="reference">删除
</el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<el-pagination
:total="total"
:page-size="filterQuery.limit"
@current-change="handleCurrentChange"
layout="prev, pager, next"
:total="total"
:current-page="filterQuery.page"
></el-pagination>
</el-card>
@ -121,7 +122,7 @@
</template>
<script>
import {filterLog, deleteLog, findConfig} from "@/api/sync/spsSyncDownload";
import {filterLog, deleteLog, findConfig,downloadFile} from "@/api/sync/spsSyncDownload";
import store from "@/store";
export default {
@ -129,7 +130,7 @@ export default {
return {
filterQuery: {
taskId: null,
status: "1",
status: "",
page: 1,
limit: 10,
syncTime: null,
@ -150,8 +151,8 @@ export default {
},
status: {
0: "等待处理",
1: "处理完成",
2: "处理异常",
1: "处理异常",
2: "处理完成",
},
configQuery: {
@ -190,7 +191,7 @@ export default {
});
this.filterQuery = {
taskId: null,
status: "1",
status: "",
page: 1,
limit: 20,
};
@ -203,7 +204,7 @@ export default {
this.loading = false;
if (response.code == 20000) {
this.list = response.data.list || [];
this.total = response.data.total || 0;
this.total = response.data.total?Number.parseInt(response.data.total):0;
} else {
this.$message.error(response.message);
}
@ -284,8 +285,8 @@ export default {
statusFilterType(status) {
const statusMap = {
0: "warning",
1: "success",
2: "danger",
1: "danger",
2: "success",
};
return statusMap[status];
},
@ -296,7 +297,35 @@ export default {
this.syncInfo = item.remark;
}
})
}
},
downFile(rows) {
downloadFile({
'id': rows.id
}).then(res => {
let blob = new Blob([res])
let fileName = rows.cacheFilePath.substring(rows.cacheFilePath.lastIndexOf('/'))
let link = document.createElement("a")
link.href = window.URL.createObjectURL(blob)
link.download = fileName
link.style.display = 'none'
document.body.appendChild(link)
link.click()
window.URL.revokeObjectURL(link.href)
document.body.removeChild(link)
})
},
deleteData(id) {
deleteLog({id}).then((response) => {
if (response.code == 20000) {
this.filterQuery.page = 1
this.$message.success("删除成功");
} else {
this.$message.error(response.message);
}
this.getList();
})
.catch(() => {});
}
},
mounted() {
@ -307,8 +336,9 @@ export default {
ADMIN_ID: store.getters.adminId,
ADMIN_TOKEN: store.getters.token,
};
this.getList();
this.total = 0;
this.getConfig();
this.getList();
},
};
</script>

Loading…
Cancel
Save