<template>
  <div>
     <el-dialog title="审批批注" :visible.sync="isShow" @open="dialogOpen" class="imageplayer-audit-dialog">
       <el-form label-width="150px">
         <el-form-item label="批示：">
           <el-input type="textarea" :rows="6" v-model="postil" style="width:80%;"></el-input>
         </el-form-item>
       </el-form>
      <div slot="footer">
        <el-button @click="isShow = false">取 消</el-button>
        <el-button type="primary" @click="confirmClickHandler" :loading="confirmLoading">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>

import util from '@src/common/util.js'

export default {
  data() {
    return {
      postil: '',
      confirmLoading: false
    }
  },
  computed: {
    isShow: {
      get() {
        return this.show
      },
      set(val) {
        this.$emit('update:show', val)
      }
    }
  },
  methods: {
    async dialogOpen() {
      this.confirmLoading = false
      let initImagePlayer = await axios.get(
        '/ui/imageplayer/initimageplayer',
        {
          params: {
            ID: this.ID
          }
        }
      )
      this.postil = initImagePlayer.data.data.postil
    },
    async confirmClickHandler() {
      let obj = {
        status: 'notpass',
        postil: this.postil
      }
      this.confirmLoading = true
      let audit = await axios.put(`/ui/imageplayer/${this.ID}/audit`, obj)
      if (audit.data.status === 1) {
        this.$emit('callback')
        this.isShow = false
      }
      this.confirmLoading = false
      util.showResponseMessage(audit.data)
    }
  },
  props: {
    ID: {
      required: true
    },
    show: {
      type: Boolean,
      required: true
    }
  }
}
</script>

<style>
/* 在一般情况下dialog宽为680像素，在逻辑分辨率480像素以下dialog宽为96% */
.imageplayer-audit-dialog .el-dialog {
  width: 680px;
}
@media (max-width: 480px) {
  .imageplayer-audit-dialog .el-dialog {
    width: 96%;
  }
}
</style>
