<template>
  <div style=" position: relative;" class="bottom1 bottom_tab">
    <el-tabs v-model="activeName2" type="card" @tab-click="handleClick">
      <el-tab-pane label="公告通知" name="notice">
        <notice ref="noticelist"></notice>
        <a
          href="javascript:void(0);"
          @click="fuli_set"
          v-if="is_creator==1 || manager_type==2 || manager_type ==3"
        >编辑</a>
        <a
          href="javascript:void(0);"
          @click="dialogCreateVisible = true"
          style="right:55px;"
          v-if="is_creator==1 || manager_type==2 || manager_type ==3"
        >发布</a>
      </el-tab-pane>
      <el-tab-pane label="福利待遇" name="welfare">
        <fuli ref="fulilist"></fuli>
        <a
          href="javascript:void(0);"
          @click="fuli_set"
          v-if="is_creator==1 || manager_type==2 || manager_type ==3"
        >编辑</a>
        <a
          href="javascript:void(0);"
          @click="dialogCreateVisible = true"
          style="right:55px;"
          v-if="is_creator==1 || manager_type==2 || manager_type ==3"
        >发布</a>
      </el-tab-pane> 
    </el-tabs>

    <el-dialog
      title="编辑信息"
      :visible.sync="dialogRewardVisible"
      width="600px"
      :close-on-click-modal="false"
      @close="load_fulilist"
    >
      <RewardList ></RewardList>
    </el-dialog>
     <!-- <RewardList ref="RewardListCom"></RewardList> -->
    <!-- 公告以及福利待遇发布弹窗 -->
    <el-dialog
      append-to-body
      title="添加信息"
      width="450px"
      :visible.sync="dialogCreateVisible"
      :close-on-click-modal="false"
      @open="CreateOpen"
    >
      <RewardCreate :type="activeName2" ref="RewardCreateCom" @send-success="InfoSendSuccess"></RewardCreate>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="CreateSend">保 存</el-button>
      </div>
    </el-dialog>

  </div>
</template>


<script>
import fuli from "./fuli";
import notice from "./notice";

import RewardList from "@/views/dashboard/components/RewardList";
import RewardCreate from "@/views/dashboard/components/RewardCreate";
export default {
  components: { fuli, RewardList, notice,RewardCreate },
  data() {
    return {
      manager_type: this.$store.getters.user_info.manager_type,
      is_creator: this.$store.getters.user_info.is_creator,
      activeName2: "notice",
      dialogRewardVisible: false,
      dialogCreateVisible: false
    };
  },
  methods: {
    CreateSend() {
      this.$refs["RewardCreateCom"].FormSend();
    },
    InfoSendSuccess(data) {
      this.dialogCreateVisible = false;
      this.load_fulilist()
    },
    CreateOpen() {
      const _this = this;
      this.$nextTick(() => {
        _this.$refs["RewardCreateCom"].FormReset();
      });
    },
    load_fulilist() {
      if(this.activeName2 == 'notice'){
        this.$refs["noticelist"].loadTableData();
      } else{
        this.$refs["fulilist"].loadTableData();
      }
    },
    fuli_set() {
      this.dialogRewardVisible = true;
    },
    handleClick(tab, event) {
      console.log(tab, event);
    }
  }
};
</script>
<style>
.bottom_tab .is-active {
  background-color: #fff;
  color: rgba(96, 98, 102, 1) !important;
  border-radius: 3px 3px 0 0;
}
</style>
