<template>
  <el-dialog v-dialogDrag ref="diaFrom" title="移交" :close-on-click-modal="false" :visible.sync="isTransfer" width="45%"
    top="10px" :before-close="cancel">
    <el-form ref="transferForm" :model="form" label-width="110px" class="transferBox" :rules="rules">
      <el-form-item label="移交路径：" prop="outPath">
        <el-input v-model="form.outPath" placeholder="请输入移交文件所在的文件夹如：D:/新建文件夹"></el-input>
      </el-form-item>
      <!-- <el-form-item label=" ">
        <div class="tips">请输入移交文件所在的文件夹！</div>
      </el-form-item> -->
      <el-form-item label="移交去向：" prop="transferTo">
        <el-input v-model="form.transferTo" placeholder="请输入移交单位名称"></el-input>
      </el-form-item>
      <el-form-item label=" ">
        <el-button size="mini" @click="submitTransfer('transferForm')" type="primary">确定移交</el-button>
        <el-button size="mini" @click="cancel" type="info">取消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>
<script>
  import {
    transferEEP
  } from "@/api/archives-management/fileManagement/dataBrowsing"
  import {
    message,
    downlaodzip,
  } from '@/utils/common'
  export default {
    props: {
      treeRow: {
        type: Object,
        default: () => {},
      },
      isTransfer: {
        type: Boolean,
        default: () => false,
      },
      transSelectId:{
        type:String,
        default:()=>""
      },
      currentTableItem:{
        type:Object,
        default:()=>{}
      }
    },
    data() {
      return {
        form: {
          outPath: "D:/新建文件夹",
          transferTo:""
        },
        rules: {
          outPath:[
            {
              required: true,
              message: "请输入移交文件所在的文件夹如：D:/新建文件夹",
              trigger: "blur",
            },
          ],
          transferTo:[
            {
              required: true,
              message: "请输入移交单位名称",
              trigger: "blur",
            },
          ],
        }
      }
    },
    methods: {
      cancel() {
        this.$refs.transferForm.resetFields();
        this.$emit("cancel")
      },
      submitTransfer(formName) {
        this.$refs[formName].validate((valid)=>{
          if(valid){
            let data = {
              ids: this.transSelectId,
              classId: this.treeRow.id,
              checkLink: "YJ",
              fondscode: this.currentTableItem.tableData[0].fonds_no,
              path: this.form.outPath,
              transferTo:this.form.transferTo,
              entityId:this.currentTableItem.entityId.toString(),
              
            }
            transferEEP(data).then(res => {
              message("success", "移交成功", 3000);
              downlaodzip(res, "移交eep");
              this.cancel();
            }).then(()=>{
              this.$emit('refresh')
            })
          }else{
            return false;
          }
        })
        
      }
    },
    created() {}
  }

</script>
<style lang="scss" scoped>
  .transferBox {
    padding: 20px;

    .tips {
      color: red;
      letter-spacing: 1px;
      font-weight: 600;
    }
  }

</style>
