
<!--
  @description: 采购单管理-整单释放退回详细说明弹框
  @Modifier：gmy
  @routerPath:
  @date: 2020-09-7 10:45:28
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialogData.dialog"
    :close-on-click-modal="false"
    :lock-scroll="false"
    title="退回说明"
    width="1000px"
    custom-class="el-dialog__body-p0"
    top="calc((100vh - 336px) / 2)"
  >
    <div class="main">
      <el-form
        ref="form"
        :model="formData"
        :rules="rules"
        :inline-message="true"
      >
        <table class="from_table">
          <tr>
            <td>
              <el-form-item label="请填写退回说明" prop="reason" />
            </td>
            <td>
              <el-input
                v-model="formData.reason"
                :autosize="{ minRows: 10, maxRows: 10 }"
                type="textarea"
                maxlength="1000"
                show-word-limit
                style="width:100%"
              />
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="附件" prop="reason" />
            </td>
            <td>
              <upload
                ref="upload"
                :title="''"
                :data="fileData"
                :auto-delete="true"
                :auto-upload="true"
                :limit="10"
                :file-size="200"
                tip-text="上传附件格式（*.doc;*.docx;*.pdf;*.png;*.jpg;*.zip;*.xlsx;*.xls;*.rar）单个文件不得超过200M"
                accept=".doc,.docx,.pdf,.png,.jpg,.zip,.jpeg,.txt,.xls,.ppt,.pptx,.rar"
                file-ref="fileRef"
                but-text="点击上传"
              />
            </td>
          </tr>
        </table>
      </el-form>
      <div class="but_footer">
        <div class="but_footer-h">
          <div class="but_footer-but">
            <!-- 审核按钮 -->
            <el-button :loading="confirmLoading" type="primary" @click="explainYetSignUp('form')">
              确 定
            </el-button>
            <el-button :loading="confirmLoading" @click="explainNoSignUp()">
              取 消
            </el-button>
          </div>
        </div>
      </div>
    </div>
  </el-dialog>
</template>

<script>
/* 校验方法*/
import { characters1_auto } from '@/assets/js/validate'
import upload from '@comp/common/updownload/upload' // 文件上传组件

export default {
  name: 'PatchAuditDialog',
  components: {
    upload
  },
  props: {
    dialogData: {
      type: Object,
      default: function() {
        return {
          dialog: false, // 弹框打开关闭 默认关闭
          bizId: '', // 附件id
          status: '00' // 整单释放 整单退回字段 00 释放 01退回 默认 00 释放
        }
      }
    }
  },
  data() {
    return {
      confirmLoading: false, // 暂存Loding
      fileData: {
        fileType: 'biz_type_assign_return_plan_file',
        bizId: ''
      },
      formData: {
        reason: '', // 释放说明
        status: '' // 整单释放 整单退回字段 00 释放 01退回
      },
      // 校验规则
      rules: {
        reason: [{ required: true, validator: characters1_auto, trigger: 'blur' }] // 审核意见
      }
    }
  },
  created() {
    this.fileData.bizId = this.dialogData.bizId
  },
  methods: {
    // 审核通过
    explainYetSignUp(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.confirmLoading = true
          // 获取项目类型B类 00 非B类01
          this.formData.status = this.dialogData.status
          // 输入说明情况的回调
          this.$emit('projectRelease', this.formData)
          this.dialogData.dialog = false
        } else {
          this.confirmLoading = false
        }
      })
    },
    // 审核不通过
    explainNoSignUp(formName) {
      // 关闭弹框
      this.dialogData.dialog = false
    }
  }
}
</script>

<style scoped lang="less">
</style>
