<template>
  <div id="policy">
    <supermarkettable-detail :tableData="tableData" :total="total" :info="info" @query="query"></supermarkettable-detail>
  </div>
</template>

<script>
import supermarkettableDetail from '@/components/supermaket/supermarkettableDetail.vue';
import { createNamespacedHelpers, mapGetters, mapState } from 'vuex';
import _ from 'loadsh';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: transaction } = createNamespacedHelpers('transaction');
export default {
  name: 'policy',
  props: {},
  components: {
    supermarkettableDetail,
  },
  data: () => ({
    info: {},
    policyInfo: {},
    display: 'list',
    columnName: '',
    contentList: [],
    total: 1,
    skip: '',
    limit: 10,
    tableData: [],
  }),
  async created() {
    this.searchSite();
    this.jiaoyilist();
  },
  computed: {
    totaltype() {
      return this.$route.query.totaltype;
    },
  },
  methods: {
    ...mapSite(['showInfo']),
    ...transaction({ transactionQuery: 'query', ProductFetch: 'fetch', ProductDelete: 'delete' }),

    // 查询站点信息
    async searchSite() {
      let res = await this.showInfo();
      let object = JSON.parse(JSON.stringify(res.data));
      if (object) {
        this.$set(this, `info`, res.data);
      } else {
        this.$message.error(res.errmsg ? res.errmsg : 'error');
      }
    },
    async jiaoyilist({ skip = 0, limit = 10 } = {}) {
      const res = await this.transactionQuery({ skip, limit });
      this.$set(this, `tableData`, res.data);
      this.$set(this, `total`, res.total);
    },
    async query(val) {
      console.log(val);

      this.jiaoyilist({ skip: (val - 1) * this.limit, limit: this.limit });
    },
  },
};
</script>

<style lang="scss" scoped></style>
