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

<script>
import detailTopInfo from '@/layout/custom/detailTopInfo.vue';
import detailInfo from '@/layout/companyidentify/detailInfo.vue';
import { createNamespacedHelpers } from 'vuex';
const { mapActions: companyidentify } = createNamespacedHelpers('companyidentify');
const { mapActions: profession } = createNamespacedHelpers('profession');
const { mapActions: dictionary } = createNamespacedHelpers('dictionary');

export default {
  name: 'detail',
  props: {},
  components: {
    detailTopInfo, //头部导航
    detailInfo, //审核
  },
  data: () => ({
    display: 'block',
    topTitle: '企业信息查看',
    formTitle: '企业信息查看',
    ruleForm: {},
  }),
  created() {
    this.search();
  },
  computed: {
    id() {
      return this.$route.query.id;
    },
  },
  methods: {
    ...companyidentify(['query', 'delete', 'fetch', 'update', 'updateStatus']),
    async search() {
      const res = await this.fetch(this.id);
      if (res.errcode === 0) {
        this.$set(this, `ruleForm`, res.data);
      }
    },

    // 提交
    async submitForm({ data }) {
      data.status = '1';
      const res = await this.updateStatus(data);
      this.$checkRes(res, '认证成功', '发布失败');
      this.$router.push({ path: '/companyidentify/index' });
    },
    // 取消
    resetForm({ data }) {
      data.status = '2';
      let res = this.update(data);
      this.$checkRes(res, '认证失败', '发布失败');
      this.$router.push({ path: '/companyidentify/index' });
    },
    // 返回
    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>
