<template>
  <div id="stock">
    <el-col :span="24" class="debt">
      <el-col :span="24" class="top">
        <topInfo :topTitle="topTitle" :display="display"></topInfo>
      </el-col>
      <el-col :span="24" class="search">
        <searchInfo @clickBtn="clickBtn"></searchInfo>
      </el-col>
      <el-col :span="24" class="main">
        <stockList :debtTable="debtTable" :total="total" @deleteRow="deleteRow" @clickRest="clickRest"></stockList>
      </el-col>
    </el-col>
  </div>
</template>

<script>
import topInfo from '@/layout/common/topInfo.vue';
import searchInfo from '@/layout/common/needSearchInfo.vue';
import stockList from '@/layout/businessneed/stockList.vue';
import { createNamespacedHelpers, mapGetters, mapState } from 'vuex';
const { mapActions: stockneed } = createNamespacedHelpers('stockneed');
export default {
  name: 'stock',
  props: {},
  components: {
    topInfo, //头部导航
    searchInfo, //搜素
    stockList, //股权需求列表
  },
  data: () => ({
    topTitle: '股权需求',
    display: 'none',
    debtTable: [],
    total: '',
    jgpro: '0',
  }),
  created() {
    this.getStockList();
  },
  computed: {
    ...mapState(['user']),
  },
  methods: {
    ...stockneed(['stockList']),
    async getStockList({ skip = 1, limit = 10, jg_id = this.user.userid } = {}) {
      const res = await this.stockList({ skip, limit, jg_id });
      this.$set(this, `debtTable`, res.res);
      this.$set(this, `total`, res.total);
    },
    async clickBtn(message) {
      //查询
      this.jgpro = message;
      var skip = 0;
      var limit = 10;
      if (message == 1) {
        var jg_id = '0';
        const res = await this.stockList({ skip, limit, jg_id });
        this.$set(this, `debtTable`, res.res);
        this.$set(this, `total`, res.total);
      } else {
        var jg_id = this.user.userid;
        const res = await this.stockList({ skip, limit, jg_id });
        this.$set(this, `debtTable`, res.res);
        this.$set(this, `total`, res.total);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.debt {
  padding: 20px;
}
.top {
  border-bottom: 1px solid #ccc;
}
</style>
