/**
* @Description:邮件服务导入
* @author wx
* @date 2021/1/07
*/
<template>
  <dee-dialog
    :dialog-visible="dialogVisible"
    title="导入邮件服务"
    width="60%"
    @handleClose="handleClose"
  >
    <div class="importTemp-com">
      <el-upload
        ref="upload"
        :action="action"
        :headers="headers"
        :multiple="false"
        :on-change="onFileChange"
        :accept="accept"
        :http-request="submitUploadFile"
      >
        <el-button class="border-none">选择文件:
          <img
            src="/icons/settledlcons/upLoad.png"
          >
        </el-button>
      </el-upload>
      <div class="info">
        <p style="color:rgb(153 152 152);"></p>
      </div>
      <div class="flex-c">
        <el-button
          type="primary"
          class="searchBtn"
          @click="submitUpload"
        >确定</el-button>
        <el-button
          class="searchBtn"
          @click="handleClose"
        >取消</el-button>
      </div>
    </div>
  </dee-dialog>
</template>

<script>
import { post } from '@/utils/http'
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      accept: '.*',
      uploadInput: '',
      headers: {},
      // action: '/MailServerConfig/import?generateOperator=XMLTOVO'
      action: '/MailServerConfig/DxBaseImport'
    }
  },
  computed: {

  },
  watch: {

  },
  created() {
  },
  mounted() {

  },
  methods: {
    onFileChange(file, fileList) {
      if (fileList.length > 1) {
        fileList.splice(0, 1)
      }
      this.uploadInput = file.name
    },
    submitUploadFile(file) {
      this.ePartFile = file
    },
    submitUpload(file) {
      const formData = new FormData()
      if (!this.ePartFile || !this.ePartFile.file) return this.$utils.showMessageWarning('请选择文件')
      if (this.ePartFile !== '') {
        formData.append('file', this.ePartFile.file)
        formData.append('fileType', 'XML')
        post(this.action, formData).then(res => {
          this.handleClose()
          this.$emit('getTableData')
        })
      }
    },
    handleClose() {
      this.$emit('handleClose')
    }
  }
}

</script>
<style lang='scss'>
.importTemp-com{
  .border-none{
    border: none;
    color: #2678cb;
    img{
      padding-left: 15px;
      width: 18px;
      height: 16px;
    }
  }
  .info{
    background: #eee;
    padding: 10px 15px;
    margin-bottom: 20px;
  }
  .flex-c{
    display:flex;
    justify-content: center;
  }
}
</style>