<template>
|
<j-modal
|
:title="title"
|
:width="width"
|
:visible="visible"
|
switchFullscreen
|
:maskClosable="false"
|
@ok="handleOk"
|
@cancel="handleCancel"
|
cancelText="关闭">
|
<ProcessModalForm ref="realForm" @ok="submitCallback"/>
|
</j-modal>
|
</template>
|
|
<script>
|
import ProcessModalForm from './ProcessModalForm.vue'
|
|
export default {
|
name: 'ProcessModal',
|
components: {
|
ProcessModalForm
|
},
|
props: {
|
currentTreeNodeInfo: {
|
type: Object
|
}
|
},
|
data() {
|
return {
|
title: '',
|
width: 700,
|
visible: false,
|
isAddNextLevel: false // 是否为添加下级,作为树节点是否展开的判断
|
}
|
},
|
created() {
|
this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
|
},
|
methods: {
|
/**
|
* 点击部件创建部件下级工序
|
*/
|
handleComponentAddRelative() {
|
this.isAddNextLevel = true
|
this.visible = true
|
this.$nextTick(() => {
|
if (this.$refs.realForm) {
|
this.$refs.realForm.add({
|
productId: this.currentTreeNodeInfo.entity.productId,
|
componentId: this.currentTreeNodeInfo.entity.componentId
|
})
|
}
|
})
|
},
|
|
|
/**
|
* 点击零件创建零件下级工序
|
*/
|
handlePartsAddRelative() {
|
this.isAddNextLevel = true
|
this.visible = true
|
this.$nextTick(() => {
|
if (this.$refs.realForm) {
|
this.$refs.realForm.add({
|
productId: this.currentTreeNodeInfo.entity.productId,
|
componentId: this.currentTreeNodeInfo.entity.componentId,
|
partsId: this.currentTreeNodeInfo.entity.partsId
|
})
|
}
|
})
|
},
|
|
/**
|
* 点击工序添加同级工序
|
*/
|
handleProcessAdd() {
|
this.isAddNextLevel = false
|
this.visible = true
|
this.$nextTick(() => {
|
if (this.$refs.realForm) {
|
this.$refs.realForm.add({
|
productId: this.currentTreeNodeInfo.entity.productId,
|
componentId: this.currentTreeNodeInfo.entity.componentId,
|
partsId: this.currentTreeNodeInfo.entity.partsId
|
})
|
}
|
})
|
},
|
|
/**
|
* 编辑工序信息
|
*/
|
handleProcessEdit() {
|
this.isAddNextLevel = false
|
this.visible = true
|
this.$nextTick(() => {
|
if (this.$refs.realForm) {
|
this.$refs.realForm.edit({ id: this.currentTreeNodeInfo.id, ...this.currentTreeNodeInfo.entity })
|
}
|
})
|
},
|
|
handleOk() {
|
this.$refs.realForm.submitForm()
|
},
|
|
submitCallback() {
|
this.$emit('submitSuccess', this.isAddNextLevel)
|
this.visible = false
|
},
|
|
handleCancel() {
|
this.$emit('close')
|
this.visible = false
|
},
|
|
triggerCorrespondingMethod({ methodName, modalTitle }) {
|
if (this[methodName]) {
|
this[methodName]()
|
this.title = modalTitle
|
}
|
}
|
}
|
}
|
</script>
|