增加下载文件

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

Loading…
Cancel
Save