<template>
  <div>
    <el-descriptions title="汇票详情">
      <el-descriptions-item label="汇票名">{{ list[0].name }}</el-descriptions-item>
      <el-descriptions-item label="汇票编号">{{ list[0].draftNo }}</el-descriptions-item>
      <el-descriptions-item label="承兑人">{{ list[0].acceptorName }}</el-descriptions-item>
      <el-descriptions-item label="出票人">{{ list[0].drawersName }}</el-descriptions-item>
      <el-descriptions-item label="金额">{{ list[0].money }}</el-descriptions-item>
      <el-descriptions-item label="最高贷款额度">{{ list[0].loanLimit }}</el-descriptions-item>
      <el-descriptions-item label="服务费率">{{ list[0].serviceRate }}</el-descriptions-item>
      <el-descriptions-item label="服务费">{{ list[0].serviceMoney }}</el-descriptions-item>
      <el-descriptions-item label="利率">{{ list[0].interestRate }}</el-descriptions-item>
      <el-descriptions-item label="利息">{{ list[0].interest }}</el-descriptions-item>
      <el-descriptions-item label="承兑日期">{{ list[0].acceptDate }}</el-descriptions-item>
      <el-descriptions-item label="出票日期">{{ list[0].expireDate }}</el-descriptions-item>
      <el-descriptions-item label="预计贴现日">{{ list[0].expectDiscountDate }}</el-descriptions-item>
      <el-descriptions-item label="附件">
        <el-image style="width: 100px; height: 100px" :src="list[0].picList" :preview-src-list="list[0].picList" />
      </el-descriptions-item>
      <el-descriptions-item label="审核状态">{{ list[0].statusText }}</el-descriptions-item>
      <el-descriptions-item v-if="checked==1" label="审核反馈">{{ list[0].feedback }}</el-descriptions-item>
      <el-descriptions-item v-if="checked==1" label="反馈截图">
        <el-image style="width: 100px; height: 100px" :src="list[0].feedbackPicList" :preview-src-list="list[0].picList" />
      </el-descriptions-item>
    </el-descriptions>
    <el-input
      v-if="checked==0"
      v-model="feed.feedback"
      type="textarea"
      placeholder="请输入审核反馈内容"
      style="width: 200px;"
    />
    <el-row v-if="checked==0">
      <el-col style="margin:0 auto;">
        <div class="titlesa">
          <span>上传反馈截图</span>
        </div>
        <div>
          <el-upload
            accept=".pdf, .jpg, .jpeg, .png"
            action="#"
            :file-list="fileArr"
            list-type="picture-card"
            :show-file-list="true"
            :auto-upload="false"
            :before-upload="beforeUpload"
            :on-success="upSuccess"
            :on-error="upError"
            :on-change="imgPreview"
          >

            <i class="el-icon-plus" />
          </el-upload>
          <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="feed.feedbackPicList" alt="">
          </el-dialog>
        </div>
      </el-col>
    </el-row>
    <div class="btn">
      <el-button v-if="checked==0" type="success" @click="success">审核成功</el-button>
      <el-button v-if="checked==0" type="danger" @click="failed">审核失败</el-button>
      <el-button type="primary" @click="back">返回</el-button>
    </div>
  </div>

</template>

<script>
export default {
  data() {
    return {
      list: [],
      checked: '',
      feed: {
        feedback: '',
        feedbackPicList: [
          'https:\/\/easygolf.oss-ap-southeast-6.aliyuncs.com\/golf\/2022-03\/18\/88df7532ff7de229b617.jpg'
        ],
        id: '',
        approveStatus: ''
      }

    }
  },
  mounted() {
    this.checked = this.$store.state.user.checked
    this.feed.id = this.$route.query.id
    const id = this.$route.query.id
    this.$request({
      url: '/api/Contract/contractDraft/' + id,
      method: 'get'
    }).then((res) => {
      this.list.push(res.data)
      console.log(this.list)
    })
  },
  methods: {
    success() {
      this.feed.approveStatus = 1
      this.$request({
        url: 'api/Contract/approveContractDraft',
        method: 'post',
        data: this.feed
      }).then((res) => {
        if (res.code == 200) {
          this.$message({
            type: 'success',
            message: '提交成功'
          })
        } else {
          this.$message({
            type: 'success',
            message: '提交失败'
          })
        }
      })
    },
    failed() {
      this.feed.approveStatus = 2
      this.$request({
        url: 'api/Contract/approveContractDraft',
        method: 'post',
        data: this.feed
      }).then((res) => {
        if (res.code == 200) {
          this.$message({
            type: 'success',
            message: '提交成功'
          })
        } else {
          this.$message({
            type: 'success',
            message: '提交失败'
          })
        }
      })
    },
    back() {
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="scss">
	.btn{
		display: flex;
		// justify-content: space-around;
	}
</style>
