You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

929 lines
29 KiB

<!--零件匹配关系页-->
<template>
<div class="cr-body-content">
<div style="float: left">
<flexbox class="content-header">
<el-button
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="handleCreate"
>条件查询
</el-button>
<el-button
type="warning"
plain
icon="el-icon-search"
size="mini"
style="margin-left: 15px"
@click="searchALl()"
>查询全部任务信息
</el-button>
<el-button
class="filter-item"
plain
size="mini"
type="warning"
icon="el-icon-bottom"
@click="downloadTemplate()"
>点击下载系统导入模板
</el-button>
<span style="margin-left: 10px; color: #ff5640"
>说明上传模板时模板名后请加上当前日期例如红旗一轿手工出库单20220617</span
>
<!-- <el-tooltip class="item" effect="dark" content="手动刷新" placement="top">
<el-button
size="mini"
circle
icon="el-icon-refresh"
@click="refresh()"
/>
</el-tooltip>
<span style="margin-left: 10px; color: #ff5640"
>说明每间隔一分钟进行自动刷新</span
> -->
<!-- 刷新 -->
</flexbox>
</div>
<div style="float: right">
<flexbox class="content-header">
<el-tooltip
class="item"
effect="dark"
content="手动刷新"
placement="top"
>
<el-button
size="mini"
circle
icon="el-icon-refresh"
@click="refresh()"
/>
</el-tooltip>
<span style="margin-left: 10px; color: #ff5640; float: right"
>说明每间隔30秒进行自动刷新</span
>
</flexbox>
</div>
<!--表格渲染-->
<el-table
ref="multipleTable"
v-loading="listLoading"
element-loading-text="拼命加载中..."
element-loading-spinner="el-icon-loading"
class="cr-table"
:data="list"
:height="tableHeight"
:cell-style="cellStyle"
size="small"
stripe
border
highlight-current-row
style="width: 100%"
@sort-change="sortChange"
@selection-change="handleSelectionChange"
@row-click="handleRowClick"
@filter-change="filterChange"
>
<el-table-column
prop="actionName"
label="操作名称(单击箭头过滤)"
width="165"
column-key="actionName"
:filters="[
{ text: '导入', value: '导入' },
{ text: '导出', value: '导出' },
{ text: '消息', value: '消息' },
]"
filter-placement="bottom-end"
:filter-method="filterHandler"
>
<template slot-scope="scope">
<el-tag
v-for="(item, index) in menuCateMap"
v-show="scope.row.actionName == item.value"
:key="index"
:type="item.cssName"
>
{{ item.label }}
</el-tag>
</template>
</el-table-column>
<!-- <el-table-column
prop="actionName"
label="操作名称"
width="150"
filter-placement="bottom-end"
>
<template slot-scope="scope">
<el-tag
v-for="(item, index) in menuCateMap"
v-show="scope.row.actionName == item.value"
:key="index"
:type="item.cssName"
>
{{ item.label }}
</el-tag>
</template>
</el-table-column> -->
<el-table-column
v-for="(item, index) in getDefaultField"
:key="index"
:prop="item.prop"
:label="item.label"
:min-width="item.width"
:formatter="fieldFormatter"
show-overflow-tooltip
:gutter="0"
>
<template slot="header" slot-scope="scope">
{{ scope.column.label }}
</template>
</el-table-column>
<el-table-column
prop="stateName"
label="状态(单击箭头过滤)"
width="165"
column-key="stateName"
:filters="[
{ text: '执行完成(任务成功)', value: 'Succeeded' },
{ text: '执行完成(任务失败)', value: 'Failed' },
{ text: '执行中', value: 'Processing' },
{ text: '等待执行', value: 'Enqueued' },
]"
filter-placement="bottom-end"
:filter-method="filterHandler"
>
<template slot-scope="scope">
<el-tag
v-for="(item, index) in stateNameCateMap"
v-show="scope.row.stateName == item.value"
:key="index"
:type="item.cssName"
>
{{ item.label }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="left" width="280">
<template slot-scope="scope">
<el-button
v-if="
scope.row.actionName == '导出' &&
scope.row.stateName == 'Succeeded' &&
scope.row.downFileName != ''
"
size="mini"
type="text"
@click="handleDownload(scope.row)"
icon="el-icon-edit"
>下载</el-button
>
<el-button
v-if="
scope.row.actionName == '导出' &&
scope.row.error != '' &&
scope.row.stateName == 'Succeeded'
"
size="mini"
type="text"
@click="handleDownload(scope.row)"
icon="el-icon-edit"
>检验失败,下载</el-button
>
<el-button
v-if="
scope.row.actionName == '导入' &&
scope.row.error != '' &&
scope.row.stateName == 'Succeeded'
"
size="mini"
type="text"
@click="handleDownload(scope.row)"
icon="el-icon-edit"
>检验失败,下载</el-button
>
<el-button
v-if="scope.row.actionName != '导出'"
size="mini"
type="text"
icon="el-icon-view"
@click="handleView(scope.row)"
>详细</el-button
>
</template>
</el-table-column>
</el-table>
<div class="table-footer">
<!-- 分页控件 style="margin-top: -25px;margin-bottom:-25px;float:right;"-->
<pagination
v-show="totalCount > 0"
:total="totalCount"
:page.sync="page"
:limit.sync="listQuery.MaxResultCount"
@pagination="getList"
/>
</div>
<!-- 任务日志详细 -->
<el-dialog
title="任务详细"
:visible.sync="openView"
width="700px"
append-to-body
>
<el-form ref="form" :model="form" label-width="120px" size="mini">
<el-row>
<el-col :span="24">
<div class="overall">
<!-- 步骤条 -->
<div class="steps-box">
<ul class="steps">
<li
v-for="(item, index) in stepList"
:key="index"
:class="{ active: activeIndex - 1 === index }"
>
<p :class="{ li_active: activeIndex > index }">
<i :class="item.icon"></i>
</p>
<div
class="text"
:class="{ li_active: activeIndex > index }"
>
{{ item.title }}
</div>
</li>
</ul>
</div>
<!-- 步骤条对应内容 -->
<div class="Article-content">
<el-tabs v-model="activeName">
<el-tab-pane label="基本信息" name="first">
<div class="dialog-body">
<div
class="content"
v-for="(item, index) in stepList"
:key="index"
v-show="activeIndex == index + 1"
>
<div>
<el-card style="height: 300px; margin: 2px">
<div
v-if="activeIndex == 1"
slot="header"
class="clearfix"
>
<span>当前状态:等待执行</span>
</div>
<div
v-else-if="activeIndex == 2"
slot="header"
class="clearfix"
>
<span>当前状态:执行中...</span>
</div>
<div
v-else-if="activeIndex == 3"
slot="header"
class="clearfix"
>
<div id="chatarea">
<div
style="display: inline; color: #71d87f"
v-if="
form.stateName == 'Succeeded' &&
form.error == ''
"
>
执行结果:任务执行成功
</div>
<div
style="display: inline; color: #ff5640"
v-if="
form.stateName == 'Succeeded' &&
form.error != ''
"
>
执行结果:任务执行成功(检验失败)
</div>
<div
style="display: inline; color: #ff5640"
v-else-if="form.stateName == 'Failed'"
>
执行结果:任务执行失败
</div>
</div>
</div>
<div>
<el-col :span="12">
<el-form-item label="模块名称:">{{
form.name
}}</el-form-item>
<el-form-item label="操作名称:">{{
form.actionName
}}</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="创建人:">{{
form.creator
}}</el-form-item>
<el-form-item label="创建时间:">
<el-date-picker
value-format="yyyy-MM-dd hh:mm:ss"
format="yyyy-MM-dd hh:mm:ss"
v-model="form.createdAt"
type="date"
class="picker"
disabled
></el-date-picker>
</el-form-item>
</el-col>
<!-- <el-col :span="24">
<el-form-item
label="异常信息:"
style="color: #ff5640"
v-if="form.stateName == 'Failed'"
>
<el-button
class="result-info__btn--err"
type="text"
@click="downloadErrData(form.error)"
>下载错误数据</el-button
>
</el-form-item>
<el-form-item
label="生成数据:"
style="color: #ff5640"
v-else-if="
form.stateName == 'Succeeded' &&
form.actionName == '导出'
"
>
<el-button
class="result-info__btn--err"
type="text"
@click="downloadErrData(form.downFileName)"
>下载生成数据</el-button
>
</el-form-item>
</el-col> -->
</div>
</el-card>
</div>
</div>
</div>
</el-tab-pane>
<el-tab-pane
label="附件列表"
name="second"
v-if="form.actionName == '导入'"
>
<div>
<Detail
:customerInfos="form.taskId"
style="height: 300px; margin: 2px"
></Detail>
</div>
</el-tab-pane>
</el-tabs>
</div>
</div>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="openView = false">关 闭</el-button>
</div>
</el-dialog>
<!--表单渲染-->
<el-dialog
:visible.sync="dialogFormVisible"
:close-on-click-modal="false"
:title="formTitle"
append-to-body
width="550px"
>
<el-form ref="formCount" :inline="true" :model="formCount" size="mini">
<el-row>
<el-col :md="4" :xs="24">
<el-form-item label="任务编号" />
</el-col>
<el-col :md="20" :xs="24" style="margin-left: -80px">
<el-form-item prop="taskId">
<el-input v-model="formCount.taskId" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="4" :xs="24">
<el-form-item label="模块名称" />
</el-col>
<el-col :md="20" :xs="24" style="margin-left: -80px">
<el-form-item prop="name">
<el-input v-model="formCount.name" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="4" :xs="24">
<el-form-item label="创建人" />
</el-col>
<el-col :md="20" :xs="24" style="margin-left: -80px">
<el-form-item prop="creator">
<el-input v-model="formCount.creator" />
</el-form-item>
</el-col>
</el-row>
<!-- <el-row>
<el-col :xs="24">
<el-form-item prop="version" label="请选择日期:">
<el-date-picker
v-model="ReceiveTimeVale"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
</el-col>
<el-col :xs="24">
<el-form-item prop="version" label="结算状态:">
<el-radio-group v-model="form.resource">
<el-radio label="未结"></el-radio>
<el-radio label="部分结算"></el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row> -->
</el-form>
<div slot="footer" class="dialog-footer">
<!-- <el-button type="text" @click="dialogFormVisible = false"
>取消</el-button
> -->
<el-button @click="resetForm('formCount')">重置</el-button>
<el-button v-loading="formLoading" type="primary" @click="save"
>确认</el-button
>
</div>
</el-dialog>
</div>
</template>
<script>
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
import permission from "@/directive/permission/index.js";
import { downloadFile } from "@/utils/crmindex.js";
import CRMTableHead from "../components/CRMTableHead";
import moment from "moment";
import Detail from "./detail.vue";
export default {
name: "BackGroundWork",
components: { Pagination, CRMTableHead, Detail },
directives: { permission },
data() {
return {
crmType: "backJob",
selectValue: "",
selectNameValue: "",
// 是否显示详细弹出层
openView: false,
formTitle: "",
timer: null, //定时器名称
//当前位置
activeIndex: 1,
//默认显示基本信息
activeName: "first",
//步骤条步数
stepList: [
{
title: "等待执行",
icon: "el-icon-sort",
},
{
title: "执行中",
icon: "el-icon-refresh",
},
{
title: "执行完成",
icon: "el-icon-check",
},
],
customerInfos: "",
searchContent: "", // 输入内容
form: {},
formCount: {},
list: null,
totalCount: 0,
listLoading: true,
formLoading: false,
// 高级搜索
filterObj: {
type: Object,
default: () => {
return {};
},
},
listQuery: {
taskId: "",
},
page: 1,
dialogFormVisible: false,
multipleSelection: [],
tableHeight: document.documentElement.clientHeight - 260,
isEdit: false,
menuCateMap: [
{ label: "导入", value: "导入", cssName: "primary" },
{ label: "导出", value: "导出", cssName: "warning" },
{ label: "消息", value: "消息", cssName: "info" },
],
stateNameCateMap: [
{ label: "执行完成(任务成功)", value: "Succeeded", cssName: "success" },
{ label: "执行中...", value: "Processing", cssName: "primary" },
{ label: "执行完成(任务失败)", value: "Failed", cssName: "danger" },
{ label: "等待执行", value: "Enqueued", cssName: "warning" },
],
};
},
mounted() {
var self = this;
window.onresize = function () {
var offsetHei = document.documentElement.clientHeight;
self.tableHeight = offsetHei - 190;
};
this.timer = setInterval(() => {
this.listQuery.taskId = "";
this.listQuery.stateName = "";
setTimeout(this.getList, 0);
}, 1000 * 30); //30秒刷新一次页面
// 通过$once来监听定时器,在beforeDestroy钩子可以被清除。
this.$once("hook:beforeDestroy", () => {
clearInterval(timer);
});
},
created() {
this.getList();
},
beforeDestroy() {
clearInterval(this.timer);
this.timer = null;
},
computed: {
getDefaultField() {
var tempsTabs = [];
tempsTabs.push({
label: "任务编号",
prop: "taskId",
width: 150,
});
tempsTabs.push({
label: "模块名称",
prop: "name",
width: 200,
});
// tempsTabs.push({
// label: "操作名称",
// prop: "actionName",
// width: 120,
// });
tempsTabs.push({
label: "创建人",
prop: "creator",
width: 100,
});
tempsTabs.push({
label: "电子邮箱",
prop: "email",
width: 100,
});
tempsTabs.push({
label: "创建时间",
prop: "createdAt",
width: 125,
});
// tempsTabs.push({
// label: "状态",
// prop: "stateName",
// width: 100,
// });
return tempsTabs;
},
},
methods: {
// 下载模板操作
downloadTemplate() {
let downfilename = "系统导入模板.rar";
this.$axios
.BolbGets("/api/settleaccount/getblobfile/download/" + downfilename)
.then((response) => {
downloadFile(response, downfilename);
this.$notify({
title: "成功",
message: "模板下载成功!",
type: "success",
duration: 2000,
});
})
.catch(() => {});
},
resetForm(formName) {
this.formCount = {};
},
save() {
console.log("参数:" + JSON.stringify(this.formCount));
this.$axios
.posts("/api/settleaccount/Job/list", this.formCount)
.then((response) => {
this.list = response;
setTimeout(() => {
//大数据量加载时
this.listLoading = false;
}, 500);
this.dialogFormVisible = false;
})
.catch(() => {
this.listLoading = false;
});
},
handleCreate() {
// this.$nextTick(() => {
// this.$refs["formCount"].resetFields();
// });
this.formTitle = "条件查询";
this.isEdit = false;
this.form = {};
this.dialogFormVisible = true;
},
searchALl() {
this.listLoading = true;
this.listQuery.taskId = "";
this.$axios
.posts("/api/settleaccount/Job/list", this.listQuery)
.then((response) => {
this.list = response;
setTimeout(() => {
//大数据量加载时
this.listLoading = false;
}, 500);
})
.catch(() => {
this.listLoading = false;
});
},
filterHandler(value, row, column) {
const property = column["property"];
return row[property] === value;
},
/** 任务详细信息 */
handleView(row) {
this.listQuery.taskId = row.taskId;
this.$axios
.posts("/api/settleaccount/Job/list", this.listQuery)
.then((response) => {
this.form = response[0];
switch (response[0].stateName) {
case "Succeeded":
case "Failed":
this.activeIndex = 3;
break;
case "Processing":
this.activeIndex = 2;
break;
case "Enqueued":
this.activeIndex = 1;
break;
}
this.openView = true;
});
},
/**
* 刷新
*/
refresh() {
this.list = [];
this.listQuery.taskId = "";
this.listQuery.stateName = "";
this.getList();
},
// 监听筛选项的变化
filterChange(filterObj) {
console.log(filterObj.actionName);
if (filterObj.actionName.length > 0) {
console.log("点击筛选");
} else {
console.log("点击重置");
}
},
/**
* 导出类型的文件
*/
downloadErrData(param) {
let fileNameOfProject = param;
console.log("下载文件名称:" + fileNameOfProject);
this.$axios
.BolbGets(
"/api/settleaccount/getblobfile/download/" + fileNameOfProject
)
.then((response) => {
if (fileNameOfProject.indexOf("_") != -1) {
let downName =
fileNameOfProject.slice(0, fileNameOfProject.lastIndexOf("_")) +
fileNameOfProject.slice(fileNameOfProject.lastIndexOf("."));
downloadFile(response, downName);
this.$notify({
title: "成功",
message: "数据-导出成功!",
type: "success",
duration: 2000,
});
} else {
downloadFile(response, fileNameOfProject);
this.$notify({
title: "成功",
message: "数据-导出成功!",
type: "success",
duration: 2000,
});
}
this.listLoading = false;
})
.catch((error) => {
this.listLoading = false;
});
},
selectOptionsChange(params) {
// if (params != "") {
// let obj = {};
// obj = this.versionList.find((item) => {
// return item.value === params; //筛选出匹配数据
// });
// this.getfactoryValue = obj.label;
// }
//this.getList();
this.listLoading = true;
this.listQuery.stateName = this.selectValue;
this.$axios
.posts("/api/settleaccount/Job/list", this.listQuery)
.then((response) => {
this.list = [];
this.list = response;
setTimeout(() => {
//大数据量加载时
this.listLoading = false;
}, 500);
})
.catch(() => {
this.listLoading = false;
});
},
selectMameOptionsChange(params) {
// this.listLoading = true;
// this.listQuery.stateName = this.selectValue;
// this.$axios
// .posts("/api/settleaccount/Job/list", this.listQuery)
// .then((response) => {
// this.list = [];
// this.list = response;
// setTimeout(() => {
// //大数据量加载时
// this.listLoading = false;
// }, 500);
// })
// .catch(() => {
// this.listLoading = false;
// });
},
/** 刷新列表 */
handleHandle(data) {
if (data.type !== "edit") {
this.getList();
}
},
/** 格式化字段 */
fieldFormatter(row, column) {
if (column.property === "stateName") {
return {
Succeeded: "执行完成(成功)",
Processing: "执行中...",
Failed: "执行完成(失败)",
Enqueued: "等待执行",
}[row[column.property]];
}
if (column.property == "createdAt") {
var date = row[column.property];
if (date == undefined) {
return "";
}
return moment(date).format("YYYY-MM-DD HH:mm:ss");
}
return row[column.property] || "--";
},
handleDownload(row) {
if (row.stateName == "Succeeded" && row.actionName == "导出") {
this.downloadErrData(row.downFileName);
} else if (
row.stateName == "Succeeded" &&
row.error != "" &&
row.actionName == "导入"
) {
this.downloadErrData(row.error);
}
},
getList() {
this.listLoading = true;
//导入界面中超链接过来的参数
this.listQuery.taskId = JSON.stringify(this.$route.params.taskId);
//this.listQuery.SkipCount = (this.page - 1) * 10;
this.$axios
.posts("/api/settleaccount/Job/list", this.listQuery)
.then((response) => {
this.list = response;
setTimeout(() => {
//大数据量加载时
this.listLoading = false;
}, 500);
})
.catch(() => {
this.listLoading = false;
});
},
fetchData(id) {
//循环动态,取客户名称
this.$axios
.gets("/api/settleaccount/MaterialRelationship/" + id)
.then((response) => {
this.form = response;
});
},
handleFilter() {
this.page = 1;
this.getList();
this.listQuery.Filters = [];
if (this.searchContent != "") {
var column = "erpMaterialCode";
let filter = {
logic: 0,
column: column,
action: 6,
value: this.searchContent,
};
this.listQuery.Filters.push(filter);
}
this.getList();
},
resetQuery() {},
sortChange(data) {
const { prop, order } = data;
if (!prop || !order) {
this.handleFilter();
return;
}
this.listQuery.Sorting = prop + " " + order;
this.handleFilter();
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
/** 通过回调控制style */
cellStyle({ row, column, rowIndex, columnIndex }) {
var item = this.list[rowIndex];
if (column.property === "stateName") {
if (item.stateName === "Succeeded") {
return { color: "#71d87f", cursor: "pointer" };
} else if (item.stateName === "Processing") {
return { color: "#d87171", cursor: "pointer" };
} else if (item.stateName === "Failed") {
return { color: "#ff5640", cursor: "pointer" };
}
}
return { textAlign: "left" };
//}
},
handleRowClick(row, column, event) {
this.$refs.multipleTable.clearSelection();
this.$refs.multipleTable.toggleRowSelection(row);
},
},
};
</script>
<style lang="scss" scoped>
@import "../styles/crmtable.scss";
@import "../styles/steps.scss";
</style>
</style>