<template>
|
<div>
|
<el-row class="el-row-tab" @contextmenu.prevent.native="">
|
<el-table
|
id="processTable"
|
:data="tableData"
|
highlight-current-row
|
@row-contextmenu="procRightClick"
|
@row-click="handleCurrentChange"
|
border
|
class="show_table"
|
size='mini'
|
:height="tableHeight"
|
style="width: 100%">
|
<el-table-column
|
prop="processCode"
|
label="工序号"
|
sortable
|
>
|
</el-table-column>
|
<el-table-column
|
prop="craftNo"
|
label="工艺编号"
|
sortable
|
class-name="right"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="processName"
|
label="工序名称"
|
sortable
|
class-name="left"
|
>
|
</el-table-column>
|
|
|
</el-table>
|
<div class="tableRightMenu">
|
<ContextMenu
|
ref="ContextMenu"
|
@showProcessAddDialog="showProcessAddDialog"
|
@showProcessEditDialog="showProcessEditDialog"
|
@showUploadDialog="showUploadDialog"
|
@processDelete="processDelete"
|
/>
|
</div>
|
</el-row>
|
</div>
|
</template>
|
|
<script>
|
import * as productApi from '../api/product'
|
import Bus from './bus.js'
|
import ContextMenu from '@/module/productManager/components/processContextMenu.vue'
|
|
export default {
|
name: "process_table_info",
|
props: ['nodeList'],
|
components: {
|
ContextMenu
|
},
|
data() {
|
return {
|
processMenuVisible: false,
|
processFromVisible: false,
|
processUploadVisible: false,
|
tableHeight: 500,
|
addLoading: false,
|
deleteParam: {
|
id: ''
|
},
|
processRow: [],
|
nodeData: {
|
index: '',
|
list: []
|
},
|
params: {
|
productId: '',
|
componentId: '',
|
partsId: ''
|
},
|
contextQueryParams: {
|
flag: 2, //查询按钮的范围 1 菜单 2 对象
|
param: 'process', //查询参数,按类型而不同 1 菜单路径 2 对象权限码
|
objectId: null, //flag 为2时需要传递该参数 该参数与param对应数据id
|
relativeObjectId: null, //param 为process,document,file 时需要传该参数 该参数为关联树节点的id
|
relativeParam: null, //param 为process,document,file 时需要传该参数 该参数为关联树节点的对象权限码
|
},
|
tableData: [],
|
fileList: [],
|
fileLen: 0,
|
docUploadParams: {
|
attributionId: '',
|
attributionType: 5,
|
docClassCode: 'NC',
|
}
|
}
|
},
|
methods: {
|
queryProcessList() {
|
this.params.productId = JSON.parse(JSON.stringify(this.nodeList.list)).productId;
|
this.params.componentId = JSON.parse(JSON.stringify(this.nodeList.list)).componentId;
|
if (this.nodeList.index == 3) {
|
this.params.partsId = JSON.parse(JSON.stringify(this.nodeList.list)).partsId;
|
} else {
|
this.params.partsId = '';
|
}
|
productApi.query_process_list(this.params).then((res) => {
|
if (res.success) {
|
this.tableData = res.list;
|
}
|
});
|
},
|
handleSizeChange(val) {
|
this.params.size = val;
|
//this.query();
|
},
|
//右键菜单
|
procRightClick(row, column, event) { // 鼠标右击触发事件
|
if (event != undefined) {
|
this.processRow = row;
|
if (this.nodeList.index == 2) {
|
this.contextQueryParams.relativeParam = 'component';
|
this.contextQueryParams.relativeObjectId = this.nodeList.list.componentId;
|
} else if (this.nodeList.index == 3) {
|
this.contextQueryParams.relativeParam = 'parts';
|
this.contextQueryParams.relativeObjectId = this.nodeList.list.partsId;
|
}
|
this.contextQueryParams.objectId = row.processId;
|
this.handleCurrentChange(row)
|
this.$refs.ContextMenu.processRightClick(row, column, event, this.contextQueryParams);
|
}
|
},
|
//点击
|
handleCurrentChange(val) {
|
this.nodeData.index = 5;
|
this.nodeData.list = val;
|
this.$emit('indexChange', this.nodeData); // 调用父组件传递过来的方法,同时把数据传递出去
|
},
|
showProcessAddDialog() {
|
this.$emit('showProcessAddDialog')
|
},
|
showProcessEditDialog() {
|
this.$emit('showProcessEditDialog', this.processRow)
|
},
|
showUploadDialog() {
|
this.docUploadParams.attributionId = this.processRow.processId;
|
this.$emit('showUploadDialog', this.docUploadParams)
|
},
|
processDelete() {
|
this.$confirm('确认提交吗?', '提示', {}).then(() => {
|
this.deleteParam.id = this.processRow.processId;
|
console.log('ncTableData', this.ncTableData)
|
if (this.ncTableData && this.ncTableData.length > 0) {
|
this.$message({
|
message: '不能删除已挂载程序的工序',
|
type: 'error'
|
});
|
} else {
|
productApi.process_delete(this.deleteParam).then((res) => {
|
if (res.success) {
|
this.queryProcessList();
|
this.$emit('indexChange', this.nodeList); // 调用父组件传递过来的方法,同时把数据传递出去
|
this.$message({
|
message: res.message,
|
type: 'success'
|
});
|
} else if (res.message) {
|
this.$message({
|
message: res.message,
|
type: 'error'
|
});
|
}
|
});
|
}
|
});
|
}
|
},
|
//监听
|
watch: {
|
nodeList: {
|
deep: true, // 深度监听
|
handler(newValue, oldValue) {
|
if (this.nodeList.index > 1) {
|
this.queryProcessList()
|
}
|
}
|
}
|
},
|
//初始化 模板渲染前调用
|
created() {
|
Bus.$off('queryProcessList');
|
Bus.$on("queryProcessList", () => {
|
this.queryProcessList()
|
});
|
Bus.$on('sendNcTableData', value => {
|
this.ncTableData = value
|
})
|
},
|
mounted() {
|
this.queryProcessList();
|
|
let h = document.getElementById('filesTab').offsetHeight;
|
if (h > 0) {
|
this.$nextTick(function () {
|
this.tableHeight = h - 95;
|
})
|
}
|
},
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.el-row-tab {
|
border: 1px solid #EBEEF5;
|
}
|
|
.tableRightMenu {
|
position: absolute;
|
top: 0;
|
height: 100%;
|
}
|
|
</style>
|