<template>
  <div id="leaveDetail">
    <el-row>
      <el-col :span="24" class="info">
        <el-col :span="24" class="native">
          <topNative></topNative>
        </el-col>
        <el-col :span="24" class="form">
          <formLeave :form="form" @submit="onSubmit" @cancelClick="cancelClick"></formLeave>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import topNative from '@/layout/common/footInfo.vue';
import formLeave from '@/layout/user/formLeave.vue';

import { createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: mapLeave } = createNamespacedHelpers('leave');
export default {
  name: 'leaveDetail',
  props: {},
  components: {
    topNative, //导航
    formLeave, //请假
  },
  data: () => ({
    form: {},
  }),
  created() {},
  computed: {
    keyWord() {
      let meta = this.$route.meta;
      let main = meta.title || '';
      return main;
    },
  },
  methods: {
    ...mapLeave(['create']),
    async onSubmit(form) {
      this.form.studentid = '99991';
      let data = this.form;
      let res = await this.create(data);
      let msg = `${this.keyWord}添加成功`;
      if (this.$checkRes(res, msg)) this.cancelClick();
    },
    cancelClick() {
      this.$router.push({ path: '/user/leave' });
    },
  },
};
</script>

<style lang="less" scoped>
.info {
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background-color: #f9fafc;
}
.native {
  margin: 0 0 50px 0;
}
</style>
