src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue
@@ -8,11 +8,12 @@
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <ProcessModalForm ref="realForm" @ok="submitCallback"/>
    <ProcessModalForm ref="realForm" @ok="submitCallback" :allDeviceList="allDeviceList"/>
  </j-modal>
</template>
<script>
  import dncApi from '@/api/dnc'
  import ProcessModalForm from './ProcessModalForm.vue'
  export default {
@@ -29,46 +30,88 @@
      return {
        title: '',
        width: 700,
        visible: false
        visible: false,
        allDeviceList: [],
        isAddNextLevel: false // 是否为添加下级,作为树节点是否展开的判断
      }
    },
    watch: {
      visible: {
        handler(value) {
          if (value) this.getAllDeviceListByApi()
        }
      }
    },
    created() {
      this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
    },
    methods: {
      getAllDeviceListByApi() {
        dncApi.getAllDeviceListApi()
          .then(res => {
            if (res.success) this.allDeviceList = res.list
          })
      },
      /**
       * 创建
       * @param modalTitle
       * 点击部件创建部件下级工序
       */
      handleComponentAddRelative(modalTitle) {
        this.title = modalTitle
      handleComponentAddRelative() {
        this.isAddNextLevel = true
        this.visible = true
        this.$nextTick(() => {
          this.$refs.realForm.add()
          if (this.$refs.realForm) {
            this.$refs.realForm.add({
              productId: this.currentTreeNodeInfo.entity.productId,
              componentId: this.currentTreeNodeInfo.entity.componentId
            })
          }
        })
      },
      handleProcessAdd(modalTitle) {
        this.title = modalTitle
      /**
       * 点击工序添加同级工序
       */
      handleProcessAdd() {
        this.isAddNextLevel = false
        this.visible = true
        this.$nextTick(() => {
          this.$refs.realForm.add()
          if (this.$refs.realForm) {
            this.$refs.realForm.add({
              productId: this.currentTreeNodeInfo.entity.productId,
              componentId: this.currentTreeNodeInfo.entity.componentId,
              partsId: this.currentTreeNodeInfo.entity.partsId
            })
          }
        })
      },
      handlePartsAddRelative(modalTitle) {
        this.title = modalTitle
      // 创建工艺规程版本下级工序
      handleVersionAddChild() {
        this.isAddNextLevel = true
        this.visible = true
        this.$nextTick(() => {
          this.$refs.realForm.add()
          if (this.$refs.realForm) {
            this.$refs.realForm.add({
              productId: this.currentTreeNodeInfo.entity.productId,
              componentId: this.currentTreeNodeInfo.entity.componentId,
              partsId: this.currentTreeNodeInfo.entity.partsId,
              psvId: this.currentTreeNodeInfo.id
            })
          }
        })
      },
      handleProcessEdit(modalTitle) {
        this.title = modalTitle
      /**
       * 编辑工序信息
       */
      handleProcessEdit() {
        this.isAddNextLevel = false
        this.visible = true
        this.$nextTick(() => {
          this.$refs.realForm.edit(this.currentTreeNodeInfo.entity)
          if (this.$refs.realForm) {
            this.$refs.realForm.edit({ id: this.currentTreeNodeInfo.id, ...this.currentTreeNodeInfo.entity })
          }
        })
      },
@@ -77,7 +120,7 @@
      },
      submitCallback() {
        this.$emit('ok')
        this.$emit('submitSuccess', this.isAddNextLevel)
        this.visible = false
      },
@@ -87,7 +130,10 @@
      },
      triggerCorrespondingMethod({ methodName, modalTitle }) {
        if (this[methodName]) this[methodName](modalTitle)
        if (this[methodName]) {
          this[methodName]()
          this.title = modalTitle
        }
      }
    }
  }