<template>
  <div>
    <el-dialog title="审批批注" :visible.sync="isShow" @open="dialogOpen" class="advertiseposition-audit-dialog">
      <el-form label-width="150px">
        <el-form-item label="批示：">
          <el-input type="textarea" :rows="6" v-model="adpPostil" 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 {
      confirmLoading: false
    }
  },
  computed: {
    isShow: {
      get() {
        return this.show
      },
      set(val) {
        this.$emit('update:show', val)
      }
    },
    adpPostil() {
      return this.postil
    }
  },
  methods: {
    dialogOpen() {
      this.confirmLoading = false
    },
    async confirmClickHandler() {
      this.confirmLoading = true
      let obj = {
        status: 'notpass',
        postil: this.postil
      }
      let res = await axios.put(`/ui/atverdiseposition/${this.ID}/adpaudit`, obj)
      util.showResponseMessage(res.data)
      this.confirmLoading = false
      if (res.data.status === 1) {
        this.$emit('update:postil', this.adpPostil)
        this.$emit('callback')
        this.isShow = false
      }
    }
  },
  props: {
    show: {
      type: Boolean,
      required: true
    },
    ID: {
      type: [String, Number],
      required: true
    },
    postil: {
      String,
      required: true
    }
  }
}
</script>

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