<template>
  <div>
      <el-dialog
        v-dialogDrag
        :visible.sync="showModal"
        :close-on-click-modal="false"
        width="30%"
        title="部署流程"
      >
      <div>
        <el-upload
          :action="action"
          :on-success="_handleSuccess"
          :with-credentials="true"
          :show-file-list="false"
          :accept="accept"
        >
          <el-button type="small">
            上传文件
          </el-button>
        </el-upload>
      </div>
      <div slot="footer" class="btn-width">
        <el-button style="margin-left: 8px" @click="_cancel">
          取消
        </el-button>
      </div>
      </el-dialog>
  </div>
</template>
<script>
import global from '../../../api/config'
/**
 * BPMN 流程导入
 */
export default {
  data() {
    return {
      id: '',
      action: global.baseURL + '/v1/flow-process/deploy',
      file: null,
      loadingStatus: false,
      showModal: false,
      accept: '.text/bpmn,.text/xml,.bpmn20.xml'
    }
  },
  methods: {
    _cancel() {
      this.showModal = false
    },
    _open() {
      this.showModal = true
    },
    _handleSuccess(resp) {
      if (resp.data) {
        this.showModal = false
        this.$emit('on-result-change')
        this.$message.success('上传成功')
      } else {
        this.$message.error(resp.msg)
      }
    }
  }
}
</script>
