<template>
  <!-- 禁言弹窗 -->
  <el-dialog
    title="禁言"
    :visible.sync="dialogFormVisible"
    :modal-append-to-body="false"
  >
    <el-form :model="formProhibition">
      <el-form-item label="请选择禁言时效">
        <el-radio-group v-model="formProhibition.type">
          <el-radio :label="0">次日解禁</el-radio>
          <el-radio :label="1">一个月后解禁</el-radio>
          <el-radio :label="2">永久禁言</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancelProhibition()">取 消</el-button>
      <el-button type="primary" @click="submitProhibition()">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { addCommentBlack } from "@/api/videoLive";
export default {
  props: {
    productId: {
      type: Number | String
    },
    productType: {
      type: Number
    },
    scope: {
      // 范围类型 1产品 2产品类型 3全局
      type: Number
    }
  },
  data() {
    return {
      formProhibition: {
        userName: "",
        phone: "",
        type: 0,
        content: "无"
      },
      dialogFormVisible: false
    };
  },
  methods: {
    cancelProhibition() {
      this.formProhibition = {
        userName: "",
        phone: "",
        type: 0,
        content: "无"
      };
      this.dialogFormVisible = false;
    },
    submitProhibition() {
      if (![0, 1, 2].includes(this.formProhibition.type)) return;
      const data = {
        productId: this.productId,
        productType: this.productType,
        type: this.formProhibition.type,
        userName: this.formProhibition.userName,
        userPhone: this.formProhibition.phone,
        scope: this.scope,
        content: this.formProhibition.content
      };
      addCommentBlack(data).then(res => {
        if (res.code === 0) {
          this.$message({
            message: "禁言成功",
            showClose: false,
            type: "success"
          });
          this.$emit("callback", this.formProhibition.phone);
          this.formProhibition = {
            userName: "",
            phone: "",
            type: 0
          };
          this.dialogFormVisible = false;
        }
      });
    }
  }
};
</script>
