<template>
  <div id="detail">
    <el-row>
      <el-col :span="24">
        <el-col :span="24" class="top">
          <detailTopInfo :topTitle="topTitle" :display="display" @goBack="goBack"></detailTopInfo>
        </el-col>
        <el-col :span="24" class="main">
          <detailInfo :ruleForm="ruleForm" @submitForm="submitForm" @resetForm="resetForm" @outForm="outForm" :formTitle="formTitle"></detailInfo>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import detailTopInfo from '@/layout/custom/detailTopInfo.vue';
import detailInfo from '@/layout/financeclaims/stockDetailInfo.vue';

import { createNamespacedHelpers } from 'vuex';
const { mapActions } = createNamespacedHelpers('institution');
const { mapActions: Mapdictionary } = createNamespacedHelpers('dictionary');
export default {
  name: 'detail',
  props: {},
  components: {
    detailTopInfo, //表单头部按钮
    detailInfo, //表单内容
  },
  data: () => ({
    topTitle: '股权产品管理',
    display: 'block',
    formTitle: '股权产品信息',
    ruleForm: {},
  }),
  created() {
    this.search();
  },
  computed: {
    id() {
      return this.$route.query.id;
    },
  },
  methods: {
    ...mapActions(['query', 'delete', 'fetch', 'update']),
    async search() {
      const res = await this.fetch(this.id);
      if (res.errcode === 0) {
        this.$set(this, `ruleForm`, res.data);
      }
    },
    // 审核股权产品信息+通过
    submitForm({ data }) {
      data.status = '2';
      let res = this.update(data);
      this.$checkRes(res, '审核通过成功', '审核通过失败');
      this.goBack();
    },
    // 审核股权产品信息+拒绝
    resetForm({ data }) {
      data.status = '0';
      let res = this.update(data);
      this.$checkRes(res, '审核拒绝成功', '审核拒绝失败');
      this.goBack();
    },
      // 下架股权产品
    outForm({ data }) {
      data.status = '3';
      let res = this.update(data);
      this.$checkRes(res, '下架产品成功', '下架产品失败');
      this.goBack();
    },
    // 返回
    goBack() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="less" scoped>
.top {
  height: 50px;
  margin: 0 0 10px 0;
}
.main {
  min-height: 765px;
  background: #ffffff;
  padding: 20px;
}
</style>
