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.
 
 
 
 
 
 

894 lines
26 KiB

<!--总成模块信息管理页-->
<template>
<div class="cr-body-content">
<div ref="box">
<flexbox class="content-header">
<el-form
:model="listQuery"
ref="queryForm"
v-show="showSearch"
:inline="true"
>
<el-form-item label="总成编码" prop="ErpAssemblyCode " class="forimitem">
<el-input
v-model="listQuery.ErpAssemblyCode"
placeholder="请输入总成编码"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="总成名称" prop="ErpAssemblyName " class="forimitem">
<el-input
v-model="listQuery.ErpAssemblyName"
placeholder="请输入总成名称"
clearable
size="small"
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="车型:" prop="vehicleModelCode" class="forimitem">
<el-select
v-model="listQuery.vehicleModelCode"
clearable
placeholder="请选择"
size="medium"
style="margin-right: 15px"
@change="valueselectChange"
>
<el-option
v-for="item in vehicleModelList"
:key="item.id"
:label="item.dicItemName"
:value="item.dicItemCode"/>
</el-select>
</el-form-item>
<el-form-item class="formitem">
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleFilter"
>搜索</el-button
>
<el-button
icon="el-icon-refresh"
size="mini"
@click="resetQuery('queryForm')"
>重置</el-button
>
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
style="margin-left: 15px"
@click="handleDownload()"
>导出(Excel)
</el-button>
</el-form-item>
<el-divider class="divider1" ></el-divider>
<el-form-item style="margin-bottom: 0px;margin-top: 10px">
<el-button
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="handleCreate"
>新增
</el-button>
<el-button
class="filter-item"
size="mini"
type="primary"
icon="el-icon-edit"
@click="handleUpdate"
>修改
</el-button>
<el-button
class="filter-item"
size="mini"
type="primary"
icon="el-icon-delete"
@click="handleDelete"
>删除
</el-button>
<el-button
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="handleImportSAP"
>导入(SAP对接)
</el-button>
</el-form-item>
</el-form>
</flexbox>
</div>
<div class="l-table">
<!--表格渲染-->
<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"
:header-cell-style="headerRowStyle"
size="small"
stripe
border
highlight-current-row
style="width: 100%"
@sort-change="sortChange"
@selection-change="handleSelectionChange"
@row-click="handleRowClick"
>
<el-table-column type="selection" width="44px"></el-table-column>
<el-table-column
label="ERP总成编码"
prop="erpAssemblyCode"
sortable="custom"
align="center"
width="420px"
>
<template slot-scope="scope">
<span class="link-type" @click="handleDrawerOpen(scope.row)">{{
scope.row.erpAssemblyCode
}}</span>
</template>
</el-table-column>
<el-table-column
label="ERP总成名称"
prop="erpAssemblyName "
sortable="custom"
align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.erpAssemblyName }}</span>
</template>
</el-table-column>
<el-table-column
label="ERP总成版本"
prop="erpAssemblyVersion "
sortable="custom"
align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.erpAssemblyVersion }}</span>
</template>
</el-table-column>
<el-table-column
label="车型"
prop="vehicleModel "
sortable="custom"
align="center"
>
<template slot-scope="scope">
<span>{{ scope.row.vehicleModel }}</span>
</template>
</el-table-column>
</el-table>
<!--表单渲染-->
<el-dialog
:visible.sync="dialogFormVisible"
:close-on-click-modal="false"
:title="formTitle"
width="700px"
@close='closeDialog'
>
<el-form
ref="form"
:inline="true"
:model="form"
:rules="rules"
size="small"
label-width="120px"
>
<el-row>
<el-col :span="4">
<el-form-item label="总成编码:" required />
</el-col>
<el-col :span="20">
<el-form-item prop="erpAssemblyCode">
<el-input
style="width: 400px"
v-model="form.erpAssemblyCode"
:disabled="isEdit"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4">
<el-form-item label="总成名称:" required />
</el-col>
<el-col :span="20">
<el-form-item prop="erpAssemblyName">
<el-input
style="width: 400px"
v-model="form.erpAssemblyName"
:disabled="isEdit"
/>
</el-form-item>
</el-col>
</el-row>
<!-- <el-row>
<el-col :span="4">
<el-form-item label="总成类型:" required />
</el-col>
<el-col :span="20">
<el-form-item prop="erpAssemblyType">
<el-input
style="width: 200px"
v-model="form.erpAssemblyType"
:disabled="isEdit"
/>
</el-form-item>
</el-col>
</el-row> -->
<el-row>
<el-col :span="4">
<el-form-item label="车型:" required />
</el-col>
<el-col :span="20">
<el-form-item prop="vehicleModel">
<el-select
style="width: 200px"
v-model="form.vehicleModel"
:disabled="isEdit"
>
<el-option
v-for="item in vehicleModelList"
:key="item.id"
:label="item.dicItemName"
:value="item.dicItemCode"/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-table
ref="DetialTable"
v-loading="listLoading"
element-loading-text="拼命加载中..."
element-loading-spinner="el-icon-loading"
class="cr-table"
:data="form.details"
:height="detailTableHeight"
:cell-style="cellStyle"
:header-cell-style="headerRowStyle"
size="small"
stripe
border
highlight-current-row
style="width: 100%"
@row-click="handleRowClick"
>
<!-- <el-table-column type="selection" width="44px"></el-table-column> -->
<el-table-column prop="partCode" label="客户零件代码" width="150px" >
<template slot-scope="scope">
<el-input v-model="scope.row.partCode" size="mini" style="width:135px"></el-input>
</template>
</el-table-column>
<el-table-column prop="description" label="客户零件名称">
<template slot-scope="scope">
<el-input v-model="scope.row.description" size="mini"></el-input>
</template>
</el-table-column>
<el-table-column prop="partNum" label="客户零件数量" width="120px" >
<template slot-scope="scope">
<el-input-number v-model="scope.row.partNum" :min="1" size="mini" style="width:100px"></el-input-number>
</template>
</el-table-column>
<el-table-column prop="isKey" label="是否Key件" align="center" width="80px" > <!-- label-class-name="DisabledSelection" 去除列头全选-->
<template slot-scope="scope">
<el-checkbox v-model="scope.row.isKey"></el-checkbox>
</template>
</el-table-column>
<!-- <el-table-column prop="description" label="描述">
<template slot-scope="scope">
<el-input v-model="scope.row.disdescriptionKey"></el-input>
</template>
</el-table-column> -->
<el-table-column prop="description" width="35px">
<template slot="header">
<el-button @click="handleAddDetails" icon="el-icon-plus" type="text"></el-button>
</template>
<template slot-scope="scope">
<el-button @click="handleDeleteDetails(scope.$index, scope.row)" icon="el-icon-minus" type="text"></el-button>
</template>
</el-table-column>
</el-table>
</el-row>
</el-form>
<!--表格渲染-->
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="dialogFormVisible = false"
>取消</el-button
>
<el-button v-loading="formLoading" type="primary" @click="save"
>确认</el-button
>
</div>
</el-dialog>
</div>
<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"
/>
<!-- 导入Excel组件 -->
<importExcel
ref="importexcel"
:show="showExcelImport"
:crmType="crmType"
@close="importExcelData"
/>
</div>
<!-- 抽屉控件 -->
<el-drawer
title="信息详细页"
size="75%"
direction="rtl"
:visible.sync="drawer"
:before-close="handleDrawerClose"
>
<div>
<Detail
v-bind:customerInfos="customerInfos"
style="margin-top: -35px"
></Detail>
</div>
</el-drawer>
</div>
</template>
<script>
import Pagination from "@/components/Pagination";
import permission from "@/directive/permission/index.js";
import CRMTableHead from "../../components/CRMTableHead";
import importExcel from "@/components/ImportTxt";
import Lockr from "lockr";
import moment from "moment";
import Detail from "./detail.vue";
import { downloadFile } from "@/utils/crmindex.js";
//组件计量单位
const bomUnit = [
{ key: 0, display_name: "PC" },
{ key: 1, display_name: "TON" },
{ key: 2, display_name: "Other" },
];
const projectTypeKeyValue = bomUnit.reduce((acc, cur) => {
acc[cur.key] = cur.display_name;
return acc;
}, {});
export default {
name: "AssemblyCfgERP",
components: { Pagination, CRMTableHead, importExcel, Detail },
directives: { permission },
filters: {
IsCustomerSignFilter(status) {
//翻译是否签字
const statusMap = {
true: "",
false: "",
};
return statusMap[status];
},
},
data() {
const validVersion = (rule, value, callback) => {
let numberReg = /^\d{6}$/;
if (!numberReg.test(value)) {
callback(new Error("只能为6位数字"));
} else {
callback();
}
};
return {
crmType: "AssemblyCfgERP",
rules: {
erpAssemblyName: [
{ required: true, message: "必须输入", trigger: "blur" },
],
},
valueSelect: "",
customerInfos: [],
dialogOptions: [],
versionValue: "",
searchContent: "", // 输入内容
showExcelImport: false,
drawer: false,
list: null,
totalCount: 0,
listLoading: true,
customerInfo: {
bomId: "",
},
// 高级搜索
filterObj: {
type: Object,
default: () => {
return {};
},
},
listQuery: {
SkipCount: 0,
MaxResultCount: 15,
ErpAssemblyName: undefined,
ErpAssemblyCode: undefined,
vehicleModel:undefined,
},
listExportQuery: {
erpAssemblyCode: undefined,
erpAssemblyName: undefined,
},
vehicleModelQuery:{
dicTypeName:"派格车型",
},
form:{
details:[]
},
page: 1,
// 显示搜索条件
showSearch: true,
bomUnit,
multipleSelection: [],
drawer: false,
dialogFormVisible: false,
formTitle: "",
isEdit: false,
formLoading: false,
dialogFormVisible: false,
tableHeight: document.documentElement.clientHeight - 280,
detailTableHeight:250,
details:[], //修改子表数据源
vehicleModelList:[],//车型list
};
},
mounted() {
this.$nextTick(() => {
var offsetHei = document.documentElement.clientHeight;
//console.log(offsetHei);
let boxH = this.$refs.box.offsetHeight;
this.tableHeight = offsetHei - boxH - 57 - 79;//57为footer高度,79为页面上部标签高度
//console.log(boxH);
//console.log(this.tableHeight);
});
},
created() {
this.getvehicleModel();
this.getList();
},
computed: {
getDefaultField() {
var tempsTabs = [];
// tempsTabs.push({
// label: "ERP总成名称",
// prop: "erpAssemblyName ",
// width: 220,
// });
tempsTabs.push({
label: "ERP总成版本",
prop: "erpAssemblyVersion ",
width: 100,
});
return tempsTabs;
},
},
methods: {
//抽屉
handleDrawerOpen(param) {
this.drawer = true;
var parentId = param.id; //主键id
this.customerInfos = [
{
ParentId: parentId,
},
];
},
handleDrawerClose(done) {
done();
},
save() {
this.$refs.form.validate((valid) => {
if (valid) {
console.log("保存参数:" + JSON.stringify(this.form));
this.formLoading = true;
if (this.isEdit) {
//修改
this.$axios
.puts("/api/newjit/assembly-cfg-erp/" + this.form.id, this.form)
.then((response) => {
this.formLoading = false;
this.$notify({
title: "成功",
message: "更新成功",
type: "success",
duration: 2000,
});
this.dialogFormVisible = false;
this.getList();
})
.catch(() => {
this.formLoading = false;
});
} else {
//insert添加
console.log(JSON.stringify(this.form));
this.$axios
.posts("/api/newjit/assembly-cfg-erp", this.form)
.then((response) => {
this.formLoading = false;
this.$notify({
title: "成功",
message: "新增成功",
type: "success",
duration: 2000,
});
this.dialogFormVisible = false;
this.getList();
})
.catch(() => {
this.formLoading = false;
});
}
}
});
},
/** 新增 */
handleCreate() {
if (this.$refs["form"] !== undefined) {
this.$nextTick(() => {
this.$refs["form"] = [];
this.$refs["form"].resetFields();
});
}
this.formTitle = "新增";
this.isEdit = false;
this.form = {};
this.details = [];
//this.getvehicleModel();
this.dialogFormVisible = true;
},
/** 修改 */
handleUpdate(row) {
this.formTitle = "修改";
this.isEdit = true;
this.details = [];
//this.getvehicleModel();
if (this.multipleSelection.length != 1) {
this.$message({
message: "编辑必须选择单行",
type: "warning",
});
return;
} else {
this.fetchData(this.multipleSelection[0].id);
this.dialogFormVisible = true;
}
},
/** 删除 */
handleDelete(row) {
if (this.multipleSelection.length != 1) {
this.$message({
message: "编辑必须选择单行",
type: "warning",
});
return;
}
// this.$alert("暂时不支持批量删除", "提示", {
// confirmButtonText: "确定",
// callback: (action) => {
// //
// },
// });
this.$confirm("是否删除总成" + this.multipleSelection[0].erpAssemblyCode + "?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.$axios
.deletes("/api/newjit/assembly-cfg-erp/"+ this.multipleSelection[0].id)
.then((response) => {
const index = this.list.indexOf(this.multipleSelection[0]);
this.$notify({
title: "成功",
message: "删除成功",
type: "success",
duration: 2000,
});
this.getList();
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
fetchData(id) {
//循环动态
this.$axios
.gets("/api/newjit/assembly-cfg-erp/" + id)
.then((response) => {
this.form = response.item;
//this.details = response.item.details;
//console.log(this.details);
});
},
/** 导出功能 */
handleDownload() {
this.listLoading = true;
this.listExportQuery.erpAssemblyCode = this.listQuery.ErpAssemblyCode;
this.listExportQuery.erpAssemblyName = this.listQuery.ErpAssemblyName;
console.log(JSON.stringify(this.listExportQuery));
this.$axios
.posts("/api/newjit/assembly-cfg-erp/export", this.listExportQuery)
.then((res) => {
let filename = res.item;
this.$axios
.BolbGets("/api/newjit/exclude-part-cfg/download/" + filename)
.then((response) => {
if (filename.indexOf("_") != -1) {
let downName =
filename.slice(0, filename.lastIndexOf("_")) +
filename.slice(filename.lastIndexOf("."));
downloadFile(response, downName);
this.$notify({
title: "成功",
message: "数据-导出成功",
type: "success",
duration: 2000,
});
} else {
downloadFile(response, filename);
this.$notify({
title: "成功",
message: "数据-导出成功",
type: "success",
duration: 2000,
});
}
this.listLoading = false;
});
});
this.listLoading = false;
},
/** 重置按钮操作 */
resetQuery(refName) {
//this.$refs[refName].resetFields();
this.listQuery.ErpAssemblyName = "";
this.listQuery.ErpAssemblyCode = "";
this.listQuery.vehicleModelCode = "";
this.getvehicleModel();
this.handleQuery();
},
/** 搜索按钮操作 */
handleQuery() {
this.listQuery.SkipCount = 1;
this.getList();
},
selectValue(params) {
//版本下拉选择
this.versionValue = params.value;
this.getList();
},
selectOptionsChange(item) {
this.getList();
},
importExcelData() {
//关闭导入窗体时调用
this.listLoading = false;
this.showExcelImport = false;
this.getList();
},
/** 刷新列表 */
handleHandle(data) {
if (data.type !== "edit") {
this.getList();
}
},
/*添加明细空行*/
handleAddDetails() {
this.$forceUpdate();
if (this.form.details === undefined) {
this.form.details = [];
//console.log(679);
}
let obj = {};
obj.partCode = "";
obj.description = "";
obj.partNum = "";
obj.isKey = false;
obj.description = "";
//console.log(this.form.details);
this.form.details.push(obj);
//console.log(688);
},
handleDeleteDetails(index){
this.form.details.splice(index, 1);
//console.log(693);
},
/** 格式化字段 */
fieldFormatter(row, column) {
if (column.property === "billStatus") {
return { 0: "未生效", 2: "已生效", 3: "已发布" }[row[column.property]];
}
if (column.property == "onlineTime" || column.property == "receiveTime") {
var date = row[column.property];
if (date == undefined) {
return "";
}
return moment(date).format("YYYY-MM-DD HH:mm:ss");
}
return row[column.property] || "--";
},
roleFilter(type) {
return projectTypeKeyValue[type];
},
getList() {
this.listLoading = true;
this.listQuery.SkipCount = (this.page - 1) * 10;
this.$axios
.gets("/api/newjit/assembly-cfg-erp/list", this.listQuery)
.then((response) => {
this.list = response.items;
this.totalCount = response.totalCount;
setTimeout(() => {
//大数据量加载时
this.listLoading = false;
}, 500);
})
.catch(() => {
this.listLoading = false;
});
},
getDetialList(partCode) {
this.listLoading = true;
console.log("详表条件" + JSON.stringify(this.customerInfo.parentId));
this.$axios
.gets("/api/newjit/assembly-cfg-erp/" + this.customerInfo.parentId)
.then((response) => {
console.log(partCode)
if(partCode !== "" && partCode !== undefined)
{
//console.log(partCode)
this.list = response.item.details.filter(u => u.partCode === partCode);
}
else
{
this.list = response.item.details;
}
//alert(JSON.stringify(response.Items))
//this.totalCount = response.totalCount;
setTimeout(() => {
//大数据量加载时
this.listLoading = false;
}, 500);
})
.catch(() => {
this.listLoading = false;
});
},
valueselectChange(){},
handleImportSAP(){
//导入
this.showExcelImport = true;
this.$refs.importexcel.handleImportExcelClick();
},
handleFilter() {
this.page = 1;
this.getList();
},
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 }) {
if (column.property === "qty") {
return { textAlign: "right" };
} else {
return { textAlign: "left" };
}
},
/** 通过回调控制表头style */
headerRowStyle({ row, column, rowIndex, columnIndex }) {
if (column.property === "qty") {
return { textAlign: "right", background: "#FAFAFA" };
} else {
return { textAlign: "left", background: "#FAFAFA" };
}
},
handleRowClick(row, column, event) {
this.$refs.multipleTable.clearSelection();
this.$refs.multipleTable.toggleRowSelection(row);
},
getvehicleModel()
{
this.$axios
.gets(
"/api/newjit/dic/list",this.vehicleModelQuery
)
.then((response) => {
//console.log(response);
this.vehicleModelList = response.item;
//console.log()
})
.catch(() => {
});
},
closeDialog(){
//this.multipleSelection = [];//清空数据
},
},
};
</script>
<style lang="scss" scoped>
@import "../../../pg-fis/styles/crmtable.scss";
// /*表格全选框去除空框*/
// .el-table >>> .DisabledSelection .cell .el-checkbox__inner {
// display: none;
// position: relative;
// }
// /*表格全选框改为:选择*/
// .el-table >>> .DisabledSelection .cell:before {
// content: "是否Key件";
// position: absolute;
// left: 7px;
// }
.divider1{
margin: 0 ;
width: 118%;
}
.formitem{
margin-bottom: 0;
}
</style>