<template>
  <div id="detail">
    <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">
            <detailInfo :ruleForm="ruleForm" :rules="rules" @submitForm="submitForm" @resetForm="resetForm"></detailInfo>
          </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 detailInfo from '@/layout/supermarket/detailInfo.vue';
// import { createNamespacedHelpers } from 'vuex';
// const { mapActions } = createNamespacedHelpers('companyup');
// const { mapActions: shenhe } = createNamespacedHelpers('');
export default {
  name: 'detail',
  props: {},
  components: {
    topInfo, //头部导航
    detailTop, //返回
    detailInfo, //提交
  },
  data: () => ({
    rules: {},
    display: 'none',
    topTitle: '债权产品',
    ruleForm: {
      name: '产品1',
      top: '1',
      publish_time: '21:12',
      status: '1',
      news: [
        {
          news_name: '123',
          news_info: '123',
        },
      ],
    },
  }),
  created() {
    // this.search();
  },
  computed: {
    id() {
      return this.$route.query.id;
    },
  },
  methods: {
    // ...mapActions(['query', 'delete', 'fetch', 'update']),
    // ...shenhe({ userquery: 'query', create: 'create' }),
    // async search() {
    //   const res = await this.fetch(this.id);
    //   console.log(res);
    //   this.$set(this, `ruleForm`, res.data);
    // },

    // // 提交
    submitForm(ruleForm) {
      // this.ruleForm.status = 1;
      // console.log(this.ruleForm);
      // let res = this.update(this.ruleForm);
      // this.$router.push({ path: '/supermarket/debt' });
      // let data = {};
      // data.status = 0;
      // data.product_id = this.ruleForm.id;
      // data.type = 0;
      // status;
      // let acc = this.create(data);
    },
    // // 取消
    resetForm(ruleForm) {
      // this.ruleForm.status = 2;
      // console.log(this.ruleForm);
      // let res = this.update(this.ruleForm);
      // this.$router.push({ path: '/supermarket/debt' });
      // let data = {};
      // data.status = 1;
      // data.product_id = this.ruleForm.id;
      // data.type = 0;
      // status;
      // let acc = this.create(data);
    },
    // 返回
    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>
