leaveDetail.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div id="leaveDetail">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-col :span="24" class="top">
  6. <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
  7. </el-col>
  8. <el-col :span="24" class="main">
  9. <leaveRequest :form="form" @submits="submits" @submit="submitForm" @cancelClick="cancelClick" :types="types"></leaveRequest>
  10. </el-col>
  11. </el-col>
  12. </el-row>
  13. </div>
  14. </template>
  15. <script>
  16. import NavBar from '@/layout/common/topInfo.vue';
  17. import leaveRequest from '@/layout/user/leaveRequest.vue';
  18. import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
  19. const { mapActions: mapLeave } = createNamespacedHelpers('leave');
  20. export default {
  21. name: 'leaveDetail',
  22. props: {},
  23. components: {
  24. NavBar, //头部导航
  25. leaveRequest, //请假申请
  26. },
  27. data: () => ({
  28. form: {},
  29. title: '',
  30. isleftarrow: '',
  31. transitionName: 'fade',
  32. navShow: true,
  33. types: '',
  34. }),
  35. created() {
  36. this.search();
  37. },
  38. computed: {
  39. type() {
  40. return this.$route.query.type;
  41. },
  42. ...mapState(['user']),
  43. keyWord() {
  44. let meta = this.$route.meta;
  45. let main = meta.title || '';
  46. return main;
  47. },
  48. },
  49. mounted() {
  50. this.title = this.$route.meta.title;
  51. this.isleftarrow = this.$route.meta.isleftarrow;
  52. },
  53. watch: {
  54. $route(to, from) {
  55. this.title = to.meta.title;
  56. this.isleftarrow = to.meta.isleftarrow;
  57. },
  58. },
  59. methods: {
  60. ...mapLeave(['create']),
  61. async search() {
  62. console.log(this.type);
  63. this.$set(this, `types`, this.type);
  64. },
  65. async submitForm(form) {
  66. // this.form.studentid = '5e4f3d096a90e861b0f30871';
  67. this.form.studentid = this.user.userid;
  68. this.form.type = '0';
  69. let data = this.form;
  70. let res = await this.create(data);
  71. if (res.errcode === 0) {
  72. let msg = `${this.keyWord}添加成功`;
  73. if (this.$checkRes(res, msg)) this.cancelClick();
  74. } else {
  75. let msg = `${this.keyWord}添加失败`;
  76. }
  77. },
  78. async submits(form) {
  79. // this.form.studentid = '5e4f3d096a90e861b0f30871';
  80. this.form.studentid = this.user.userid;
  81. this.form.type = '1';
  82. let data = this.form;
  83. let res = await this.create(data);
  84. if (res.errcode === 0) {
  85. let msg = `${this.keyWord}添加成功`;
  86. if (this.$checkRes(res, msg)) this.cancelClick();
  87. } else {
  88. let msg = `${this.keyWord}添加失败`;
  89. }
  90. },
  91. cancelClick() {
  92. if (this.types == 0) {
  93. this.$router.push({ path: '/user/leave' });
  94. } else {
  95. this.$router.push({ path: '/user/quit' });
  96. }
  97. },
  98. },
  99. };
  100. </script>
  101. <style lang="less" scoped>
  102. .style {
  103. width: 100%;
  104. min-height: 667px;
  105. position: relative;
  106. background-color: #f9fafc;
  107. }
  108. .top {
  109. height: 46px;
  110. overflow: hidden;
  111. }
  112. .main {
  113. min-height: 570px;
  114. }
  115. </style>