<template>
  <div>
    <ych-modal
      :fullscreen="false"
      :title="title"
      :maskClosable="false"
      :visible="showModal"
      :footer="null"
      size="middle"
      @cancel="handleCancel"
      :destroyOnClose="true">
      <!-- 文件上传 -->
      <KFileUpload
        ref="fileUpload"
        style="margin-top: 20px;"
        :item-row="itemRow"
        :item-detail="itemDetail"
        :propSource="JSON.parse(JSON.stringify(dataSource))"
        @setFieldValue="setSubFieldValue"
        :recordConfig="record"
        :disabled="record.options.disabled"
      />
    </ych-modal>
  </div>
</template>
<script>

  import KFileUpload from "../../packages/KFileUpload";
  export default {
    name: 'SubTableFileButton',
    props: {
      record: Object,
      itemRow: {
        default: () => {},
        type: Object
      },
      itemDetail: {
        default: () => {},
        type: Object
      },
      showModal: Boolean,
      title: String,
      dataSource: Array
    },
    components: {
      KFileUpload
    },
    methods: {
      handleCancel(){
        this.$refs.fileUpload.saveTable();
        setTimeout(() => {
          this.$emit('close',true)
        },200)
      },
      setSubFieldValue(key,dataSource,record) {
        console.log(key,dataSource,record, 'file')
        this.$emit('setFieldValue',key,dataSource, record);
      }
    }
  }
</script>
