<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="top">
        <topInfo :topTitle="topTitle" :display="display" @add="add"></topInfo>
      </el-col>
      <el-col :span="24" class="main">
        <el-col :span="24" class="search">
          <searchInfo @sousuo="sousuo"></searchInfo>
        </el-col>
        <el-col :span="24" class="list">
          <newsInfo
            :debtTable="debtTable"
            @handleCurrentChange="handleCurrentChange"
            @deleteRow="deleteRow"
            :total="total"
            :totals="totals"
            :totalss="totalss"
            @handleClick="handleClick"
          ></newsInfo>
        </el-col>
      </el-col>
    </el-row>
  </div>
  <!--
  <template>
    <div id="index">
      <el-row
        <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></searchInfo>  </el-col> 
          <el-col :span="24" class="main">  <newsInfo :debtTable="debtTable" :total="total" @handleClick="handleClick"></newsInfo> // </el-col> //
        </el-col>
      </el-row>
    </div>
  </template> -->
</template>
<script>
import topInfo from '@/layout/common/topInfo.vue';
import searchInfo from '@/layout/common/searchInfo.vue';
import newsInfo from '@/layout/financeclaims/stockIndexInfo.vue';
import { createNamespacedHelpers } from 'vuex';
const { mapActions } = createNamespacedHelpers('institution');
export default {
  name: 'index',
  props: {},
  components: {
    topInfo, //头部导航
    searchInfo, //搜素
    newsInfo, //
  },
  data: () => ({
    // display: 'none',
    display: 'block',
    topTitle: '股权产品列表',
    debtTable: [],
    total: 0,
    totals: 0,
    totalss: 0,
    skip: '',
    info: {},
  }),
  created() {
    // this.search();
    // this.searchstatus1();
    // this.searchelse();
  },
  computed: {
    status() {
      return this.$route.params.status;
    },
  },
  watch: {
    // status(news) {
    //   if (news == 1) {
    //     this.search();
    //   }
    // },
    status: {
      handler(oval) {
        console.log(oval);
        this.debtTable = [];
        console.log(this.debtTable);
        this.skip = '';
        this.info = {};
        this.search();
      },
      //立刻
      immediate: true,
      deep: true,
    },
  },
  methods: {
    add() {
      // this.$router.push({ path: '/test/detail' });
    },

    ...mapActions(['query', 'delete']),
    async search({ skip = 0, limit = 10, ...info } = {}) {
      // console.log(this.info.name);
      let type = { name: this.info.name };
      skip = this.skip;
      info = type;
      const res = await this.query({ skip, limit, ...info });
      const data = res.data.filter(item => item.type != '0' && item.status != '0');
      this.$set(this, `debtTable`, data);
      this.$set(this, `total`, res.total);
    },

    async deleteRow(id) {
      const res = await this.delete(id);
      this.$checkRes(res, '删除成功', '删除失败');
      this.search();
    },
    async handleCurrentChange({ skip, limit, currentPage }) {
      this.$set(this, `skip`, skip);
      console.log(this.type);
      this.search();
    },
    //搜索
    async sousuo(search) {
      this.$set(this, `info`, search);
      this.search();
    },
    handleClick(newid) {
      this.$router.push({ path: '/financeclaims/stockDetail', query: { id: newid } });
    },
  },
};
</script>

<style lang="less" scoped>
.top {
  height: 50px;
  margin: 0 0 10px 0;
}
.main {
  height: 765px;
  background: #ffffff;
}
.search {
  width: 97%;
  height: 35px;
  margin: 20px;
}
.list {
  padding: 0 20px;
}
</style>
