同步 -- 文件下载

prod
wj 2 years ago
parent bbbc0d379e
commit 2c39c94848

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

@ -95,7 +95,8 @@ import {
deleteLog,
createSchedule,
findConfig,
updateConfig
updateConfig,
infoByStatus
} from "@/api/sync/spsSyncStatus";
import store from "@/store";

@ -22,7 +22,7 @@
<el-button type="primary" icon="search" @click="getList"></el-button>
</el-button-group>
</el-form-item>
<!-- <el-form-item>
<!-- <el-form-item>
<el-button-group style="display:flex;">
<el-button type="primary" icon="search" @click="downloadNow(1)"></el-button>
<el-button type="primary" icon="search" @click="downloadNow(2)"></el-button>
@ -33,98 +33,49 @@
</el-row>
</el-form>
<el-table
v-loading="loading"
:data="list"
style="width: 100%"
>
<el-table v-loading="loading" :data="list" style="width: 100%">
<el-table-column label="序号" type="index"></el-table-column>
<el-table-column
label="任务ID"
prop="taskId"
width="140"
show-overflow-tooltip
></el-table-column>
<el-table-column label="任务ID" prop="taskId" width="140" show-overflow-tooltip></el-table-column>
<el-table-column
label="任务类型"
prop="type"
width="140"
show-overflow-tooltip
>
<el-table-column label="任务类型" prop="type" width="140" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{scope.row.type }}</span>
</template>
</el-table-column>
<el-table-column
label="状态"
prop="status"
width="140"
show-overflow-tooltip
>
<el-table-column label="状态" prop="status" width="140" show-overflow-tooltip>
<template slot-scope="scope">
<el-tag
:type="statusFilterType(scope.row.status)"
>{{ status[scope.row.status] }}
</el-tag
>
<el-tag :type="statusFilterType(scope.row.status)">{{ status[scope.row.status] }}
</el-tag>
</template>
</el-table-column>
<el-table-column
label="开始时间"
width="180"
prop="startTime"
show-overflow-tooltip
></el-table-column>
<el-table-column
label="结束时间"
width="180"
prop="endTime"
show-overflow-tooltip
></el-table-column>
<el-table-column label="开始时间" width="180" prop="startTime" show-overflow-tooltip></el-table-column>
<el-table-column label="结束时间" width="180" prop="endTime" show-overflow-tooltip></el-table-column>
<el-table-column
label="同步信息"
prop="remark"
show-overflow-tooltip
></el-table-column>
<el-table-column label="同步信息" prop="remark" 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
:page-size="filterQuery.limit"
@current-change="handleCurrentChange"
layout="prev, pager, next"
:total="total"
:current-page="filterQuery.page"
></el-pagination>
<el-pagination :page-size="filterQuery.limit" @current-change="handleCurrentChange" layout="prev, pager, next"
:total="total" :current-page="filterQuery.page"></el-pagination>
</el-card>
<el-dialog
title="同步信息"
width="25%"
:close-on-click-modal="false"
:close-on-press-escape="false"
:visible.sync="syncVisible"
>
<el-dialog title="同步信息" width="25%" :close-on-click-modal="false" :close-on-press-escape="false"
:visible.sync="syncVisible">
<span v-text="syncInfo" style="white-space:pre-line;" class="syncInfo"></span>
</el-dialog>
@ -132,256 +83,280 @@
</template>
<script>
import {filterLog, deleteLog, findConfig} from "@/api/sync/spsSyncDownload";
import store from "@/store";
import ShowText from "../sync/showText";
import {downloadNow} from "@/api/sync/spsSyncDownload";
import {
filterLog,
deleteLog,
findConfig,
downloadFile
} from "@/api/sync/spsSyncDownload";
import store from "@/store";
import ShowText from "../sync/showText";
import {
downloadNow
} from "@/api/sync/spsSyncDownload";
export default {
data() {
return {
filterQuery: {
taskId: null,
status: "1",
page: 1,
limit: 10,
syncTime: null,
},
list: [],
headers: {},
detailList: [],
thirdSys: [],
thirdSysDetail: null,
total: 0,
currentRow: null,
editQuery: null,
status: {
1: "处理异常",
2: "处理完成",
},
export default {
data() {
return {
filterQuery: {
taskId: null,
status: "1",
page: 1,
limit: 10,
syncTime: null,
},
list: [],
headers: {},
detailList: [],
thirdSys: [],
thirdSysDetail: null,
total: 0,
currentRow: null,
editQuery: null,
status: {
1: "处理异常",
2: "处理完成",
},
configQuery: {
id: null,
typeBus: null,
typeScan: null,
typeThird: null,
basicProducts: null,
basicCorp: null,
basicInv: null,
basicThirdProducts: null,
basicThirdCorp: null,
basicThirdInv: null,
basicThirdBusOrder: null,
orderScanFinish: null,
dbDiProducts: null,
downstreamEnable: null,
configQuery: {
id: null,
typeBus: null,
typeScan: null,
typeThird: null,
basicProducts: null,
basicCorp: null,
basicInv: null,
basicThirdProducts: null,
basicThirdCorp: null,
basicThirdInv: null,
basicThirdBusOrder: null,
orderScanFinish: null,
dbDiProducts: null,
downstreamEnable: null,
syncTime: null,
},
uploadFileUrl: null,
uploadData: {
thirdSys: "thirdId",
},
templateDlUrl: null,
checked: false,
syncTime: null,
},
uploadFileUrl: null,
uploadData: {
thirdSys: "thirdId",
},
templateDlUrl: null,
checked: false,
syncTime: null,
syncInfo: null,
syncVisible: false
};
},
methods: {
onReset() {
this.$router.push({
path: "",
});
this.filterQuery = {
taskId: null,
status: "",
page: 1,
limit: 20,
syncInfo: null,
syncVisible: false
};
this.getList();
},
getList() {
this.loading = true;
filterLog(this.filterQuery)
.then((response) => {
this.loading = false;
if (response.code == 20000) {
this.list = response.data.list || [];
this.total = response.data.total || 0;
} else {
this.$message.error(response.message);
}
})
.catch(() => {
this.loading = false;
this.list = [];
this.total = 0;
});
},
getConfig() {
findConfig()
.then((response) => {
if (response.code == 20000) {
this.configQuery = response.data;
} else {
this.$message.error(response.message);
}
})
.catch(() => {
this.loading = false;
this.list = [];
this.total = 0;
methods: {
onReset() {
this.$router.push({
path: "",
});
},
this.filterQuery = {
taskId: null,
status: "",
page: 1,
limit: 20,
};
this.getList();
},
getList() {
this.loading = true;
filterLog(this.filterQuery)
.then((response) => {
this.loading = false;
if (response.code == 20000) {
this.list = response.data.list || [];
this.total = response.data.total || 0;
} else {
this.$message.error(response.message);
}
})
.catch(() => {
this.loading = false;
this.list = [];
this.total = 0;
});
},
getConfig() {
findConfig()
.then((response) => {
if (response.code == 20000) {
this.configQuery = response.data;
} else {
this.$message.error(response.message);
}
})
.catch(() => {
this.loading = false;
this.list = [];
this.total = 0;
});
},
cancelDialog(val) {
this.udiImportDetailVisible = false;
this.thrCorpSelectVisible = false;
if (val) {
cancelDialog(val) {
this.udiImportDetailVisible = false;
this.thrCorpSelectVisible = false;
if (val) {
this.getList();
}
},
handleCurrentChange(val) {
this.filterQuery.page = val;
this.getList();
}
}
,
handleCurrentChange(val) {
this.filterQuery.page = val;
this.getList();
}
,
},
createSchedule(type) {
let query = {
createType: type,
syncTime: this.syncTime,
}
createSchedule(type) {
let query = {
createType: type,
syncTime: this.syncTime,
}
createSchedule(query)
.then((response) => {
this.loading = false;
if (response.code == 20000) {
this.$message.success("创建成功!");
} else if (response.code == 501) {
this.$message.warning(response.message);
createSchedule(query)
.then((response) => {
this.loading = false;
if (response.code == 20000) {
this.$message.success("创建成功!");
} else if (response.code == 501) {
this.$message.warning(response.message);
} else {
this.$message.error(response.message);
}
this.getList();
})
.catch(() => {
this.loading = false;
});
},
deleteDialog(rowId) {
this.$confirm("此操作将删除该任务信息, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
let dQuery = {
id: rowId,
};
deleteLog(dQuery)
.then((response) => {
this.loading = false;
if (response.code == 20000) {
this.$message.success("删除成功");
} else {
this.$message.error(response.message);
}
this.getList();
})
.catch(() => {
this.loading = false;
});
})
.catch(() => {});
},
handleChange(response, files, fileList) {
console.log(response);
if (response.code != 20000) {
this.$message.error(response.message);
this.getList();
} else {
// console.log(files[0] + "\n" + this.fileList[0] + "\n" + fileList[0]);
this.$message.success(response.data);
this.getList();
}
},
statusFilterType(status) {
const statusMap = {
2: "success",
1: "danger",
};
return statusMap[status];
},
detailDialog(id) {
this.syncVisible = true;
this.list.forEach(item => {
if (id === item.id) {
this.syncInfo = item.remark;
}
})
},
downloadNow(type) {
//
let params = {
type: type
};
downloadNow(params).then((res) => {
if (res.code === 20000) {
this.$message.success("同步任务创建成功,稍后请刷新查看下载日志!");
} else {
this.$message.error(response.message);
this.$message.error(res.message);
}
this.getList();
}).catch((error) => {
this.$message.error(error.message);
})
.catch(() => {
this.loading = false;
});
},
deleteDialog(rowId) {
this.$confirm("此操作将删除该任务信息, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
},
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)
})
.then(() => {
let dQuery = {
id: rowId,
};
deleteLog(dQuery)
.then((response) => {
this.loading = false;
if (response.code == 20000) {
this.$message.success("删除成功");
} else {
this.$message.error(response.message);
}
this.getList();
})
.catch(() => {
this.loading = false;
});
})
.catch(() => {
});
},
handleChange(response, files, fileList) {
console.log(response);
if (response.code != 20000) {
this.$message.error(response.message);
this.getList();
} else {
// console.log(files[0] + "\n" + this.fileList[0] + "\n" + fileList[0]);
this.$message.success(response.data);
this.getList();
}
},
statusFilterType(status) {
const statusMap = {
2: "success",
1: "danger",
};
return statusMap[status];
mounted() {},
components: {
ShowText
},
detailDialog(id) {
this.syncVisible = true;
this.list.forEach(item => {
if (id === item.id) {
this.syncInfo = item.remark;
}
})
created() {
this.headers = {
ADMIN_ID: store.getters.adminId,
ADMIN_TOKEN: store.getters.token,
};
this.getList();
this.getConfig();
},
downloadNow(type) {
//
let params = {type: type};
downloadNow(params).then((res) => {
if (res.code === 20000) {
this.$message.success("同步任务创建成功,稍后请刷新查看下载日志!");
} else {
this.$message.error(res.message);
}
}).catch((error) => {
this.$message.error(error.message);
})
}
},
mounted() {
},
components: {ShowText},
created() {
this.headers = {
ADMIN_ID: store.getters.adminId,
ADMIN_TOKEN: store.getters.token,
};
this.getList();
this.getConfig();
},
};
};
</script>
<style scoped>
.itemTag {
float: left;
text-align: left;
margin-top: 10px;
width: 100px;
}
.itemTag {
float: left;
text-align: left;
margin-top: 10px;
width: 100px;
}
.text {
font-size: 13px;
font-family: "Microsoft YaHei";
}
.text {
font-size: 13px;
font-family: "Microsoft YaHei";
}
.el-row {
display: flex;
flex-wrap: wrap;
.el-row {
display: flex;
flex-wrap: wrap;
}
}
.el-col {
border-radius: 4px;
flex-wrap: wrap;
}
.el-col {
border-radius: 4px;
flex-wrap: wrap;
}
.syncInfo {
font-size: medium;
font-family: "Microsoft YaHei";
line-height: 25px;
}
.syncInfo {
font-size: medium;
font-family: "Microsoft YaHei";
line-height: 25px;
}
</style>

Loading…
Cancel
Save