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.
 
 
 
 
 

960 lines
28 KiB

<template>
<div class="mod-config">
<!-- 查询条件 -->
<el-form :inline="true" label-position="top" :model="searchData">
<el-form-item :label="'BU'">
<el-select v-model="searchData.buNo" placeholder="请选择" clearable style="width: 90px">
<el-option
v-for = "i in buList"
:key = "i.buNo"
:label = "i.buDesc"
:value = "i.buNo">
</el-option>
</el-select>
</el-form-item>
<el-form-item :label="'物料编码'">
<el-input v-model="searchData.partNo" clearable style="width: 120px"></el-input>
</el-form-item>
<el-form-item :label="'物料名称'">
<el-input v-model="searchData.partDesc" clearable style="width: 300px"></el-input>
</el-form-item>
<el-form-item prop="partType2" label="零件类型">
<el-select v-model="searchData.partType2" clearable style="width: 100px">
<el-option label="成品" value="Manufactured"></el-option>
<el-option label="半成品" value="Manufactured Recipe"></el-option>
</el-select>
</el-form-item>
<el-form-item :label="'BOM版本号'">
<el-input v-model="searchData.engChgLevel" style="width: 70px"></el-input>
</el-form-item>
<el-form-item :label="' '">
<el-button v-if="!authSearch" @click="getDataList()">查询</el-button>
<download-excel
:fields="fields()"
:data="exportData"
type="xls"
:name="exportName"
:header="exportHeader"
:footer="exportFooter"
:fetch="createExportData"
:before-generate="startDownload"
:before-finish="finishDownload"
worksheet="导出信息"
class="el-button el-button--primary el-button--medium">
{{ "导出" }}
</download-excel>
</el-form-item>
</el-form>
<!-- bom列表 -->
<el-table
:height="height"
:data="dataList"
border
ref="bomHeaderTable"
@row-click="headerClickRow"
@current-change="changeCurrentRow"
v-loading="queryLoading"
style="width: 100%">
<el-table-column
v-for="(item,index) in columnList" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed === ''?false:item.fixed"
:min-width="item.columnWidth"
:label="item.columnLabel">
<template slot-scope="scope">
<span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
</template>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="80"
label="操作">
<template slot-scope="scope">
<el-link style="cursor: pointer" v-loading="queryLoading" @click="copyBomModal(scope.row)">BOM复制</el-link>
</template>
</el-table-column>
</el-table>
<!-- 分页插件 -->
<el-pagination style="margin-top: 0px"
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 200, 500]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 页签 -->
<el-tabs v-model="activeTable" style="width: 100%" :style="{height: secondHeight + 50 + 'px'}" type="border-card" @tab-click="tabClick" class="customer-tab">
<!-- Graphical Structure页签 -->
<el-tab-pane label="Graphical Structure" name="GraphicalStructure">
<el-row>
<el-col :style="{width: leftWidth + 'px',height: secondHeight + 'px'}" class="down-tree">
<el-tree
:data="treeData"
:props="defaultProps"
:default-expand-all="true"
:expand-on-click-node="false"
node-key="id"
highlight-current
@node-click="handleNodeClick"
ref="tree">
</el-tree>
</el-col>
<el-col :style="{width: rightWidth + 'px',height: secondHeight + 'px'}" style="margin-left: 10px">
<el-table
:height="secondHeight"
:data="componentPartList"
border
style="width: 100%">
<el-table-column
v-for="(item,index) in componentPartColumnList" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed==''?false:item.fixed"
:min-width="item.columnWidth"
:label="item.columnLabel">
<template slot-scope="scope">
<span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
</el-tab-pane>
</el-tabs>
<!-- chooseList模态框 -->
<ChooseList ref="baseList" @getBaseData="getBaseData"></ChooseList>
<copy-bom-modal ref="copyBomModal" @refreshPageTables="getDataList"></copy-bom-modal>
</div>
</template>
<script>
import {
bomSearchHeader, // bom列表查询
getAlternativeTree, // 查询bom替代树形
getComponentPartList, // 查询子物料
saveCopyBomInfo, // 新增数据到临时表
} from '@/api/part/bomSearch3.js'
import {getSiteAndBuByUserName2} from "@/api/qc/qc.js"
import ChooseList from '@/views/modules/common/Chooselist_eam'
import copyBomModal from "./copy_bom_modal.vue"
export default {
components: {
copyBomModal,
ChooseList
},
watch: {
searchData: {
deep: true,
handler: function (newV, oldV) {
this.searchData.partNo = this.searchData.partNo.toUpperCase()
}
}
},
data () {
return {
// 导出
exportData: [],
exportName: 'BOM多级查询' + this.dayjs().format('YYYYMMDDHHmmss'),
exportHeader: ['BOM多级查询'],
exportFooter: [],
resultList: [],
buList: [],
menuId: this.$route.meta.menuId,
// ======== 行高 ========
height: 200,
secondHeight: 200,
leftWidth: 300,
rightWidth: '',
// ======== 分页 ========
pageIndex: 1,
pageSize: 50,
totalPage: 0,
// 条件查询
searchData: {
site: '',
buNo: '',
userName: this.$store.state.user.name,
partNo: '',
partDesc: '',
bomType: '',
engChgLevel: '',
partType2: '',
page: 1,
limit: 10
},
// loading
queryLoading: false,
// 初始页签
activeTable: 'GraphicalStructure',
// ======== 数据对象 ========
alternativeData: {
site: '',
partNo: '',
partDesc: '',
bomType: '',
engChgLevel: '',
alternativeNo: '',
alternativeDescription: '',
minLotQty: '',
noteText: '',
status: '',
},
// ======== 选中的当前行数据 ========
headerCurrentRow: {},
defaultProps: {
children: "list",
label: "id",
},
// ======== 数据列表 ========
dataList: [],
treeData: [],
componentPartList: [],
// ======== 列表表头 ========
columnList: [
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1PartNo',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'partNo',
headerAlign: 'center',
align: 'center',
columnLabel: '物料编码',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 120
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1PartDesc',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'partDesc',
headerAlign: 'center',
align: 'left',
columnLabel: '物料名称',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 300
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1PartType2Desc',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'partType2Desc',
headerAlign: 'center',
align: 'left',
columnLabel: '零件类型',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 120
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1BomType',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'bomType',
headerAlign: 'center',
align: 'center',
columnLabel: '制造类型',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 100
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1EngChgLevel',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'engChgLevel',
headerAlign: 'center',
align: 'right',
columnLabel: 'BOM版本号',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 100
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1engRevision',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'engRevision',
headerAlign: 'center',
align: 'center',
columnLabel: '工程版本号',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 100
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1NetWeight',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'netWeight',
headerAlign: 'center',
align: 'right',
columnLabel: '净重',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 100
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1EffPhaseInDate',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'effPhaseInDate',
headerAlign: 'center',
align: 'center',
columnLabel: '生效日期',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 130
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1EffPhaseOutDate',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'effPhaseOutDate',
headerAlign: 'center',
align: 'center',
columnLabel: '失效日期',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 130
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1CreateDate',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'createDate',
headerAlign: 'center',
align: 'center',
columnLabel: '创建时间',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 170
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1CreateBy',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'createByDesc',
headerAlign: 'center',
align: 'center',
columnLabel: '创建人',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 100
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1UpdateDate',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'updateDate',
headerAlign: 'center',
align: 'center',
columnLabel: '更新时间',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 170
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table1UpdateBy',
tableId: '601002002Table1',
tableName: 'BOMHeader表',
columnProp: 'updateByDesc',
headerAlign: 'center',
align: 'center',
columnLabel: '更新人',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 100
}
],
componentPartColumnList: [
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2LineSequence',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'lineSequence',
headerAlign: 'center',
align: 'center',
columnLabel: '序号',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 50
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2ComponentPart',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'componentPart',
headerAlign: 'center',
align: 'center',
columnLabel: '物料编码',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 120
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2ComponentPartDesc',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'componentPartDesc',
headerAlign: 'center',
align: 'left',
columnLabel: '物料名称',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 300
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2QtyPerAssembly',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'qtyPerAssembly',
headerAlign: 'center',
align: 'right',
columnLabel: '单位用量',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 80
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2ComponentScrap',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'componentScrap',
headerAlign: 'center',
align: 'right',
columnLabel: '调机量',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 80
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2ShrinkageFactor',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'shrinkageFactor',
headerAlign: 'center',
align: 'right',
columnLabel: '损耗率',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 80
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2ConsumptionItem',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'consumptionItem',
headerAlign: 'center',
align: 'center',
columnLabel: '消耗项目',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 80
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2PrintUnitName',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'printUnitName',
headerAlign: 'center',
align: 'center',
columnLabel: '物料单位',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 60
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2IssueType',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'issueType',
headerAlign: 'center',
align: 'center',
columnLabel: '生产属性',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 140
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2OperationNo',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'operationNo',
headerAlign: 'center',
align: 'left',
columnLabel: '工序编码',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 80
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2OperationName',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'operationName',
headerAlign: 'center',
align: 'left',
columnLabel: '工序名称',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 120
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2IssueToLoc',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'issueToLocName',
headerAlign: 'center',
align: 'center',
columnLabel: '发料库位',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 80
},
{
userId: this.$store.state.user.name,
functionId: 601002002,
serialNumber: '601002002Table2NoteText',
tableId: '601002002Table2',
tableName: 'BOMComponent表',
columnProp: 'noteText',
headerAlign: 'center',
align: 'left',
columnLabel: '备注',
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 150
},
],
// ======== 必填规则 ========
// ======== 复选数据集 ========
// ======== 模态框开关控制 ========
authSearch: false,
}
},
mounted () {
this.$nextTick(() => {
this.height = window.innerHeight / 2 - 140
/*第二个表格高度的动态调整*/
this.secondHeight = window.innerHeight - this.height - 220
this.rightWidth = window.innerWidth - this.leftWidth - 275
})
},
created () {
// 按钮控制
this.getButtonAuthData()
// 获取用户的 site 和 bu
this.getSiteAndBuByUserName2()
if (!this.authSearch) {
// 获取数据列表
this.getDataList()
}
},
methods: {
// ======== 分页相关方法 ========
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
// 获取用户的bu
getSiteAndBuByUserName2 () {
let tempData = {
username: this.$store.state.user.name,
}
getSiteAndBuByUserName2(tempData).then(({data}) => {
if (data.code === 0) {
this.buList = data.rows
}
})
},
// ======== 列表数据操作方法 ========
// 获取数据列表
getDataList () {
this.searchData.limit = this.pageSize
this.searchData.page = this.pageIndex
this.queryLoading = true
bomSearchHeader(this.searchData).then(({data}) => {
if (data.code === 0) {
this.dataList = data.page.list
this.pageIndex = data.page.currPage
this.pageSize = data.page.pageSize
this.totalPage = data.page.totalCount
// 判断是否全部存在数据
if (this.dataList.length > 0) {
// 设置选中行
this.$refs.bomHeaderTable.setCurrentRow(this.dataList[0])
this.headerClickRow(this.dataList[0])
} else {
this.headerCurrentRow = {}
}
// 加载当前的页签的table
this.refreshCurrentTabTable()
}
this.queryLoading = false
})
},
// 单机选中信息
headerClickRow (row) {
this.$refs.bomHeaderTable.toggleRowSelection(row)
this.headerCurrentRow = JSON.parse(JSON.stringify(row))
},
// 树节点单机事件
handleNodeClick (e) {
// 查询替代子物料
getComponentPartList(e).then(({data}) => {
if (data && data.code === 0) {
this.componentPartList = data.rows
} else {
this.componentPartList = []
}
})
},
// copyBom
copyBomModal (row) {
this.queryLoading = true
row.createBy = this.$store.state.user.name
// 新增数据到临时表
saveCopyBomInfo(row).then(({data}) => {
if (data && data.code === 0) {
this.$nextTick(() => {
this.$refs.copyBomModal.init(row)
})
this.queryLoading = false
} else {
this.queryLoading = false
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
}).catch(() => {
this.queryLoading = false
})
},
// ======== 页签切换相关方法 ========
// 列表表格选择替换
tabClick (tab, event) {
// 刷新列表数据
this.refreshCurrentTabTable()
},
// 当前值发生变化的时候修改
changeCurrentRow (row, oldRow) {
// 判断是否是获取焦点的事件
if (row) {
this.headerCurrentRow = JSON.parse(JSON.stringify(row))
//刷新当前页表
this.refreshCurrentTabTable()
this.componentPartList = []
}
},
// 刷新页签的table数据
refreshCurrentTabTable () {
if (this.activeTable === 'GraphicalStructure') {
// 获取bom替代树形
this.getAlternativeTree()
}
},
// 获取bom替代树形
getAlternativeTree () {
getAlternativeTree(this.headerCurrentRow).then(({data}) => {
if (data && data.code === 0) {
this.treeData = data.rows
if (this.treeData.length > 0) {
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.treeData[0].id);
this.handleNodeClick(this.treeData[0])
})
}
} else {
this.$message.warning(data.msg)
}
})
},
// ======== chooseList相关方法 ========
// 获取基础数据列表S
getBaseList (val, type) {
this.tagNo = val
this.$nextTick(() => {
let strVal = ''
if (val === 117) {
strVal = this.componentData.issueToLoc
}
this.$refs.baseList.init(val, strVal)
})
},
// 列表方法的回调
getBaseData (val) {
if (this.tagNo === 117) {
this.componentData.issueToLoc = val.location_id
this.componentData.issueToLocName = val.location_name
}
},
//获取按钮的权限数据
getButtonAuthData () {
let searchFlag = this.isAuth(this.menuId+":search")
//处理页面的权限数据
this.authSearch = !searchFlag
},
// ======== 导出相关方法 ========
// 导出excel
async createExportData () {
this.searchData.limit = -1
this.searchData.page = 1
await bomSearchHeader(this.searchData).then(({data}) => {
this.resultList = data.page.list
})
return this.resultList
},
startDownload () {},
finishDownload () {},
fields () {
let json = '{'
this.columnList.forEach((item, index) => {
if (index == this.columnList.length - 1) {
json += '"' + item.columnLabel + '"' + ':' + '"' + item.columnProp + '"'
} else {
json += '"' + item.columnLabel + '"' + ':' + '"' + item.columnProp + '"' + ','
}
})
json += '}'
let s = eval('(' + json + ')')
return s
},
}
}
</script>
<style scoped lang="scss">
.el-table /deep/ .cell{
height: auto;
line-height: 1.5;
}
.down-tree{
//height: 470px;
display: block;
overflow-y: scroll;
}
/deep/ .el-tabs--border-card>.el-tabs__content{
padding: 5px;
}
</style>