<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" :rules="rules" @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 detailTop from '@/layout/common/detailTop.vue';
import detailInfo from '@/layout/companyup/detailInfo.vue';
import { createNamespacedHelpers } from 'vuex';
const { mapActions: companyup } = createNamespacedHelpers('companyup');
const { mapActions: profession } = createNamespacedHelpers('profession');
export default {
  name: 'detail',
  props: {},
  components: {
    detailTopInfo, //头部导航
    detailInfo, //提交
  },
  data: () => ({
    rules: {},
    display: 'block',
    topTitle: '企业修改信息审核',
    formTitle: '企业修改信息',
    ruleForm: {},
  }),
  created() {
    this.search();
  },
  computed: {
    id() {
      return this.$route.query.id;
    },
  },
  methods: {
    ...companyup({ companyupStatus: 'updateStatus', companyupFetch: 'fetch' }),
    async search() {
      const res = await this.companyupFetch(this.id);
      if (res.errcode === 0) {
        this.$set(this, `ruleForm`, res.data);
      }
    },
    // 审核企业修改信息+通过
    submitForm({ data }) {
      data.status = '1';
      let res = this.companyupStatus(data);
      this.$checkRes(res, '审核通过成功', '审核通过失败');
      this.goBack();
    },
    // 审核企业修改信息+拒绝
    resetForm({ data }) {
      data.status = '2';
      let res = this.companyupStatus(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>
