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

<script>

import ZyProcessModularForm from './ZyProcessModularForm'
import ZyProcess from "@views/zyProcessModular/modules/ZyProcessList";
import {postAction} from "@api/manage";
export default {
  name: 'ZyProcessModularModal',
  components: {
    ZyProcess,
    ZyProcessModularForm
  },
  data () {
    return {
      model:{
        modularId: '',
        processId: '',
      },
      title:'',
      width:800,
      visible: false,
      disableSubmit: false,
      url: {
        add: "/zyProcessModular/zyProcessModular/add",
      },
    }
  },
  methods: {
    add1 (modularId1) {
      this.model.modularId = modularId1;
      //console.log("modal modularId1: "+ modularId1);
      this.visible=true
      this.$nextTick(()=>{
        this.$refs.realForm.add1(modularId1);
      })
    },
    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>