<template>
  <div id="followHistoryDetail">
    <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="main">
          <el-col :span="24" class="back">
            <detailTop @goBack="goBack"></detailTop>
          </el-col>
          <el-col :span="24" class="info">
            <followHistoryForm :ruleForm="followForm"></followHistoryForm>
          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import topInfo from '@/layout/common/topInfo.vue';
import detailTop from '@/layout/common/detailTop.vue';
import followHistoryForm from '@/layout/done/followHistoryForm.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: claimneed } = createNamespacedHelpers('claimneed');
const { mapActions: financefollow } = createNamespacedHelpers('follow');
export default {
  name: 'followHistoryDetail',
  props: {},
  components: {
    topInfo, //头部导航
    detailTop, //头部返回
    followHistoryForm, //关注债权需求详情
  },
  data: () => ({
    display: 'none',
    topTitle: '完成债权需求详情',
    followForm: {},
  }),
  created() {
    this.searchInfo();
  },
  computed: {
    id() {
      return this.$route.query.id;
    },
    money() {
      return this.$route.query.money;
    },
    finaltime() {
      return this.$route.query.finaltime;
    },
  },
  methods: {
    ...claimneed(['one']),
    ...financefollow(['credit', 'followlist', 'delete']),
    getLocalTime(nS) {
      return new Date(parseInt(nS)).toLocaleString().replace(/:\d{1,2}$/, ' ');
    },
    async searchInfo() {
      if (this.id) {
        const res = await this.one({ id: this.id });
        const finaldata = res.data;
        finaldata[0].finmoney = this.money;
        finaldata[0].historytime = this.getLocalTime(this.finaltime);
        this.$set(this, `followForm`, finaldata);
      }
    },

    // 返回
    goBack() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="less" scoped>
.debt {
  padding: 20px;
}
.top {
  border-bottom: 1px solid #ccc;
}
.main {
  border-radius: 10px;
  margin: 20px 0 0 0;
  box-shadow: 0 0 3px #666;
}
.main .back {
  padding: 10px 0 10px 15px;
}
</style>
