
<!--
  @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="releaseText+'说明'"
    width="860px"
    center
    custom-class="el-dialog_table"
    append-to-body
  >
    <div class="el-dialog-p0">
      <el-form
        ref="form"
        :model="formData"
        :rules="rules"
        :inline-message="true"
      >
        <table class="from_table">
          <tr>
            <td>
              <el-form-item :label="'请填写'+releaseText+'说明'" 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>
        </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'
export default {
  name: 'PatchAuditDialog',
  props: {
    dialogData: {
      type: Object,
      default: function() {
        return {
          dialog: false, // 弹框打开关闭 默认关闭
          status: '00' // 整单释放 整单退回字段 00退回 01释放 默认 00 退回
        }
      }
    }
  },
  data() {
    return {
      confirmLoading: false, // 暂存Loding
      formData: {
        reason: '', // 释放说明
        status: '' // 整单释放 整单退回字段 00 释放 01退回
      },
      // 校验规则
      rules: {
        reason: [{ required: true, validator: characters1_auto, trigger: 'blur' }] // 审核意见
      }
    }
  },
  computed: {
    releaseText() {
      return this.dialogData.status === '00' ? '退回' : '释放'
    }
  },
  created() {

  },
  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>
