<template>
  <el-dialog
    :title="title"
    :visible.sync="modal"
    width="80%"
    :close-on-click-modal="false"
    @close="
      res => {
        $emit('cancel');
      }
    "
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="审核状态" prop="auditStatus">
        <el-radio-group v-model="form.auditStatus">
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="-1">不通过</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="审核备注">
        <el-input
          v-model="form.auditMsg"
          type="textarea"
          :rows="2"
          placeholder="请输入内容"
        >
        </el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="modal = false">取消</el-button>
      <el-button type="primary" @click="handleConfirm">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { auditMultiItem } from '@/api/photoWarehouse';

export default {
  name: 'photoVerifyMultItem',

  props: {
    ids: {
      type: Array,
      default: ()=>[]
    },
  },

  data() {
    return {
      title: '照片批量审核详情',
      modal: true,
      form: {
        auditStatus: null,
        auditMsg: ''
      },
      rules: {
        auditStatus: [
          { required: true, message: '请选择是否通过', trigger: 'blur' }
        ]
      }
    };
  },

  mounted() {},

  methods: {

    handleConfirm() {
      this.$refs.form.validate(async valid => {
        if (valid) {
          const params = {
            auditStatus: this.form.auditStatus,
            auditMsg: this.form.auditMsg
          };
          if (this.ids.length > 0) params.ids = this.ids;
          console.log(params)
          const { success, msg } = await auditMultiItem(params);
          if (success) {
            this.$success('保存成功！');
            this.modal = false;
            this.$g_emit('photo_reload');
          }
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.pre-img {
  height: 80px;
}
</style>
