<template>
  <div>
    <!-- 标题 -->
    <el-row class="tag">发布公告</el-row>

    <!-- 分割线 -->
    <hr style="background-color: #cccccc; height: 1px; border: 0" />
    <div style="margin: 20px 0"></div>

    <!-- 公告输入区域 -->
    <el-row>
      <el-col :span="1">公告：</el-col>
      <el-col :span="18">
        <el-input
          type="textarea"
          :rows="10"
          resize="none"
          placeholder="请输入公告"
          v-model="textarea"
        >
        </el-input>
      </el-col>
    </el-row>

    <!-- 发布按钮 -->
    <el-row style="marginTop: 20px">
      <el-col :span="6" :offset="1">
        <el-button type="primary" @click="handlePublish">立即发布</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      textarea: null,
    };
  },
  methods: {
    // 发布公告请求
    async handlePublish() {
      if (this.textarea != null) {
        let params = {
          noticeContent: this.textarea,
        };
        let res = await this.$API.repair.reqGetPublishNotice(params);
        // console.log(res);
        if (res.status == 200) {
          this.$message.success("公告发布成功");
          this.textarea = null;
        } else {
          console.log("发布公告失败");
          this.$message.error(res.errmsg);
        }
      } else {
        this.$message.warning("内容不能为空");
      }
    },
  },
};
</script>

<style scoped>
.tag {
  width: 108px;
  height: 50px;
  font-size: 24px;
  font-family: Microsoft YaHei-3970(82674968);
  font-weight: bold;
  line-height: 60px;
}
</style>