<template>
  <div>
    <el-alert style="margin: 20px 0;"
              title="审核意见"
              :closable="false"
              class="alert"
              type="info">
    </el-alert>
    <el-input type="textarea"
              :autosize="{ minRows: 2, maxRows: 4 }"
              placeholder="请输入审核意见"
              v-model="remark">
    </el-input>
    <div slot="footer"
         class="dialog-footer">
      <!-- <el-button @click="$listeners.close">取 消</el-button> -->
      <el-button type="primary"
                 @click="submit(1)"
                 v-if="permission('musicGroupPaymentCalender/auditPass')">审核通过</el-button>
      <el-button type="danger"
                 @click="submit(0)"
                 v-if="permission('musicGroupPaymentCalender/auditRefuse')">驳回</el-button>
      <el-button @click="$emit('close')">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import { permission } from '@/utils/directivePage'
import { auditPass, auditRefuse } from "@/api/auditManager";
export default {
  props: ["selList"],
  data () {
    return {
      remark: "",
    };
  },
  methods: {
    async submit (val) {
      if (!this.remark) {
        return this.$message.error("请输入审核意见");
      }
      if (val) {
        try {
          await this.$confirm('是否确认批量审核通过', '提示', {
            type: 'warning'
          })
          await auditPass({ batchNo: this.selList.map(item => item.batchNo).join(','), auditMemo: this.remark }).then((res) => {
            if (res.code == 200) {
              this.$message.success('批量审核通过')
              this.$emit('close')
              this.$emit('submited')
            }
          });
        } catch (error) {}
      } else {
        try {
          await this.$confirm('是否确认批量驳回', '提示', {
            type: 'warning'
          })
          await auditRefuse({ batchNo: this.selList.map(item => item.batchNo).join(','), auditMemo: this.remark }).then((res) => {
            if (res.code == 200) {
              this.$message.success('批量驳回成功')
              this.$emit('close')
              this.$emit('submited')
            }
          });
        } catch (error) {}
      }
    },
    permission (str) {
      return permission(str)
    }
  },
};
</script>
<style lang="less" scoped>
.dialog-footer {
  margin-top: 20px;
  display: block;
  text-align: right;
}
</style>
