<template>
  <div class="gather-box">
    <el-container>
      <el-header>
        <el-page-header title @back="goBack" content="默认采集人设置"></el-page-header>
        <img src="../../assets/imageOne/24.png" alt class="gather-img" @click="save()" />
      </el-header>

      <!-- 主内容 -->
      <el-main :style="'height:' + fullHeight + 'px'">
        <el-input type="textarea" :rows="10"  placeholder="请输入内容" v-model.trim="textarea"></el-input>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "gather",
  inject: ['reload'],
  data() {
    return {
      textarea: "",
      fullHeight: document.documentElement.clientHeight,
    };
  },
  computed: {
    numA() {
      return this.$store.state.changableNum;
    }
  },
   watch: {
    fullHeight(val) {
      //监控浏览器高度变化
      if (!this.timer) {
        this.fullHeight = val;
        this.timer = true;
        let that = this;
        setTimeout(function() {
          //防止过度调用监测事件，导致卡顿
          that.timer = false;
        }, 400);
      }
    }
  },
  methods: {
    //动态获取浏览器高度
    get_boderHeight() {
      const that = this;
      window.onresize = () => {
        return (() => {
          window.fullHeight = document.documentElement.clientHeight;
          that.fullHeight = window.fullHeight;
        })();
      };
    },

    goBack() {
      let _this = this;
      this.$router.push("/system");
      location.reload(); //实现视图强制刷新
    },

    //点击图标保存到本地
    save() {
      let _this = this;
      if (_this.textarea !== "") {
        localStorage.setItem("textarea", _this.textarea);
        // localStorage.setItem('userName',_this.textarea)
        this.$message({
          type: 'success',
          message: '保存成功!',
        });
        const  timer = setInterval (() => {
          location.reload();
        },500)
        this.$router.push("/system");
      } else {
      this.$notify({
        title: '警告',
        message: '采集人不能为空',
        type: 'warning'
        });
      }
    }
  }
};
</script>

<style lang="scss">
@import "../../assets/style/bus.scss";
@import "../../assets/style/scss/gather.scss";
</style>
