<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    cancelText="关闭">
<!--    <zy-process-component-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></zy-process-component-form>-->
    <zy-process ref="realForm"
                @onChangeRowKey="chuancan"
                @ok="submitCallback"
                :disabled="disableSubmit"></zy-process>
  </j-modal>
</template>

<script>

  import ZyProcessComponentForm from './ZyProcessComponentForm'
  import {postAction} from "@api/manage";
  import ZyProcess from "@views/process/modules/list/ZyProcessList";
  export default {
    name: 'ZyProcessComponentModal',
    components: {
      ZyProcess,
      ZyProcessComponentForm
    },
    data () {
      return {
        model:{
          componentId: '',
          processId: '',
        },
        title:'',
        width:800,
        visible: false,
        disableSubmit: false,
        url: {
          add: "/pro/zyProcessComponent/add",
        }
      }
    },
    methods: {
      add1 (componentId1) {
        this.model.componentId = componentId1;
        //console.log("componentId1: "+componentId1)
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.add1(componentId1);
        })
      },
      edit (record) {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.edit(record);
        })
      },
      chuancan(res) {
        this.model.processId = res;
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        // this.$refs.realForm.submitForm();
        postAction(this.url.add, this.model).then((res) => {
          if (res.success) {
            this.$message.success(res.message);
          } else {
            this.$message.warning(res.message);
          }
          this.$emit('valueChange', 1)
          this.close()

        })
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>
