<template>
  <u-modal
    :title="title"
    :width="width"
    :visible="visible"
    contentFull
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    cancelText="关闭">
    <!-- 第二版 -->
    <!-- <spotcheck-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" :dataList="dataList"></spotcheck-form> -->
    <!-- 第三版 -->
    <spotcheck-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></spotcheck-form>
  </u-modal>
</template>

<script>

  import SpotcheckForm from './SpotcheckForm.vue'
  export default {
    name: 'SpotcheckModal',
    components: {
        SpotcheckForm
    },
    props: {
      // dataList: {
      //   type: Object,
      //   default: function(){
      //       return {} // 使用工厂函数返回默认值
      //   }
      // },
    },
    data () {
      return {
        title:'',
        width:800,
        visible: false,
        disableSubmit: false
      }
    },
    methods: {
      add () {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.add();
        })
      },
      edit (record) {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.edit(record);
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.$refs.realForm.submitForm();
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>