import Pannel from '@/components/pannel/index.vue';
import ScrollTable from '@/components/scroll-table-details/index.vue';
import {financeWarningZjzcdeyjList, financeWarningZjwlmgcyjList, financeWarningZjwlbgfyjList} from "../../../api";
import {mapGetters} from "vuex";
import AssetDetails from './asset-details/index.vue';
export default {
  components: {
    ScrollTable,
    Pannel,
    AssetDetails
  },
  props: {
    showBottom: {
      type: Boolean,
      default: false
    },
    bottomTit: {
      type: String,
      default: ''
    }
  },
  computed: {
    ...mapGetters(['year', 'deptId'])
  },
  data () {
    return {
      headers: ['摘要', '日期', '借方金额', '贷方金额'],
      data: [],
      dataDetail: [],
    };
  },
  watch: {
    year: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    deptId: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    },
    bottomTit: {
      handler () {
        this.getData();
      },
      immediate: true, // 立即执行
    }
  },
  created () {
  },
  mounted () {

  },
  methods: {
    tabChange () {

    },
    lineClick1 (val) {
      console.log(val)
      this.$emit('clickDetail', val)
    },
    getData () {
      if (this.year, this.deptId) {
        this.data = [];
        switch (this.bottomTit) {

          case "大额":
            financeWarningZjzcdeyjList(this.deptId, this.year).then(res => {
              let data = res.rows;
              // .map(item => {
              //   return [item.voucherSummary, item.bookDate, item.jieAmount, item.daiAmount]
              // })
              this.data = data;
            })
            break;

          case "敏感":
            financeWarningZjwlmgcyjList(this.deptId, this.year).then(res => {
              let data = res.rows;
              // .map(item => {
              //   return [item.voucherSummary, item.bookDate, item.jieAmount, item.daiAmount]
              // })
              this.data = data;
            })
            break;

          case "不规范":
            financeWarningZjwlbgfyjList(this.deptId, this.year).then(res => {
              let data = res.rows;
              // .map(item => {
              //   return [item.voucherSummary, item.bookDate, item.jieAmount, item.daiAmount]
              // })
              this.data = data;
            })
            break;
        }

      }
    }
  }
};
