<template>
  <view class="container">
    <view class="tabs">
      <u-tabs
        :list="tabsList"
        font-size="30"
        :current="current"
        active-color="#2a56f7"
        @change="fnTabsChange"
      />
    </view>

    <safety-production v-show="current === 0" :department="department" />
    <dangerous-operations-qiye
      v-show="current === 1"
      :department="department"
    />
  </view>
</template>

<script>
import SafetyProduction from "./safety_production.vue";
import DangerousOperationsQiye from "./dangerous_operations_qiye.vue";
import { getDepartment } from "@/api";
export default {
  components: {
    SafetyProduction,
    DangerousOperationsQiye,
  },
  data() {
    return {
      tabsList: [{ name: "安全生产费用" }, { name: "危险作业" }],
      current: 0,
      department: [],
    };
  },
  onLoad() {
    this.fnGetDepartment();
  },
  methods: {
    async fnGetDepartment() {
      const resData = await getDepartment();
      this.department = JSON.parse(resData.zTreeNodes);
    },
    async fnTabsChange(event) {
      this.current = event.index;
    },
  },
};
</script>
<style scoped lang="scss">
.container {
  width: 100%;
  background: #fafafa;

  .tabs {
    width: 100%;
    background: #ffffff;
    border-bottom: 1px solid #eeeeee;
  }
}
</style>
