<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="style">
        <el-col :span="24" class="top">
          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
        </el-col>
        <el-col :span="24" class="main">
          <el-tabs v-model="activeName" type="card">
            <el-tab-pane label="正在洽谈" name="first">
              <zzqt :zzqtList="zzqtList"></zzqt>
            </el-tab-pane>
            <el-tab-pane label="达成意向" name="second">
              <dcyx :dcyxList="dcyxList"></dcyx>
            </el-tab-pane>
            <el-tab-pane label="交易完成" name="third">
              <jywc :jywcList="jywcList"></jywc>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import zzqt from './parts/zzqt.vue';
import dcyx from './parts/dcyx.vue';
import jywc from './parts/jywc.vue';
import { mapState, createNamespacedHelpers } from 'vuex';
import NavBar from '@/layout/common/topInfo.vue';
const { mapActions: transaction } = createNamespacedHelpers('transaction');
const { mapActions: dock } = createNamespacedHelpers('dock');
export default {
  name: 'index',
  props: {},
  components: { NavBar, zzqt, dcyx, jywc },
  data: function() {
    return {
      // 头部标题
      title: '',
      // meta为true
      isleftarrow: '',
      // 返回
      navShow: true,
      activeName: 'first',
      zzqtList: [ ],
      dcyxList: [],
      jywcList: [],
      dock_id:''
    };
  },
  created() {
     this.searchInfo();
  },
  methods: {
    ...transaction({ transactionsfetch: 'fetch', transactionslist: 'query', transactiondetele: 'detele', transactionupdate: 'update' }),
    ...dock({ dockQuery: 'query', dockfetch: 'fetch',dockupdate:'update' }),
    async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
       let res = await this.dockfetch(this.user.uid);
      this.$set(this, `dock_id`, res.data.id);
      let arr = await this.transactionslist({ skip, limit, dockid: this.dock_id, ...info });
      var zzqt = arr.data.filter(item => item.status === '0');
      var dcyx = arr.data.filter(item => item.status === '1');
      var jywc = arr.data.filter(item => item.status === '2');
      this.$set(this, `zzqtList`, zzqt);
      this.$set(this, `dcyxList`, dcyx);
      this.$set(this, `jywcList`, jywc);
    },
  },
  computed: { ...mapState(['user']) },
  mounted() {
    this.title = this.$route.meta.title;
    this.isleftarrow = this.$route.meta.isleftarrow;
  },
};
</script>

<style lang="less" scoped>
.style {
  width: 100%;
  min-height: 667px;
  position: relative;
}
.top {
  height: 46px;
  overflow: hidden;
  position: relative;
  z-index: 999;
}
.main {
  min-height: 570px;
}
</style>
