<template>
  <div class="details-margin-top-120 apply">
    <div class="apply-body">
      <layout-register :headerTitle="'在线报名'">
        <template v-slot:left>
          <slide-list :active="active" :list="FilterJson.list"></slide-list>
        </template>
        <template v-slot:right>
          <PageHeader :title="FilterJson[active].header" @goback="goback" />
          <z-form
            :formConfig="FilterJson[active]"
            ref="form"
            :defaultValue="FilterJson[active].ruleForm"
            @on-action="actionHandle"
          >
            <template v-slot:submit>
              <button-list :list="FilterJson[active].button" @buttnClick="buttnClick" />
            </template>
          </z-form>
        </template>
      </layout-register>
    </div>
  </div>
</template>

<script>
import LayoutRegister from '@/components/layout-register.vue'
import FilterJson from './filterType.json'
import ZForm from '@/components/form.vue'
import SlideList from '@/components/slide-list.vue'
import PageHeader from '@/components/page-header.vue'
import ButtonList from '@/components/button-list.vue'
import Login from '@/pages/login/components/action/index.js'
export default {
  name: 'apply',
  components: {
    LayoutRegister,
    ZForm,
    SlideList,
    PageHeader,
    ButtonList
  },
  data() {
    return {
      FilterJson,
      active: 0
    }
  },
  methods: {
    buttnClick(item) {
      item.loading = true
      const params = {
        keep: this.transferKeep
      }
      params[item.event](item)
    },
    actionHandle(queries) {
      FilterJson[this.active].ruleForm = Object.assign({}, queries)
    },
    goback() {
      this.$router.push({
        name: 'apply'
      })
    },
    transferKeep(item) {
      console.log(Login)
      this.$refs.form.submit().then(state => {
        if (state) {
          this.$message({
            message: '报名成功',
            type: 'success'
          })
        } else {
          item.loading = false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.apply {
  height: 100%;
  width: 100%;
  .apply-body {
    width: 80%;
    margin: 0 auto;
  }
}
</style>
