Forráskód Böngészése

请假接口更新

guhongwei 5 éve
szülő
commit
d300b6be2c

+ 1 - 1
src/layout/user/leaveList.vue

@@ -12,7 +12,7 @@
           <p>开始时间:{{ item.starttime }}</p>
           <p>结束时间:{{ item.endtime }}</p>
         </el-col>
-        <el-col :span="10" class="ispass"> 请假结果:{{ item.ispass === '0' ? '未通过' : '通过' }} </el-col>
+        <el-col :span="10" class="ispass"> 请假结果:{{ item.ispass === '0' ? '未通过' : item.ispass === '1' ? '通过' : '审核中' }} </el-col>
       </el-col>
     </el-row>
   </div>

+ 1 - 0
src/router/index.js

@@ -44,6 +44,7 @@ const routes = [
   {
     path: '/user/leaveDetail',
     name: 'user',
+    meta: { title: '请假', sub: '管理' },
     component: () => import('../views/user/leaveDetail.vue'),
   },
   // 个人信息-请假结果

+ 4 - 1
src/store/index.js

@@ -1,11 +1,14 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
+import leave from './leave';
 
 Vue.use(Vuex);
 
 export default new Vuex.Store({
+  modules: {
+    leave,
+  },
   state: {},
   mutations: {},
   actions: {},
-  modules: {},
 });

+ 38 - 0
src/store/leave.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  leaveInfo: `/api/train/leave`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.leaveInfo}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.leaveInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.leaveInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.leaveInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.leaveInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 14 - 14
src/views/user/leave.vue

@@ -20,6 +20,8 @@
 
 <script>
 import leaveList from '@/layout/user/leaveList.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapLeave } = createNamespacedHelpers('leave');
 export default {
   name: 'leave',
   props: {},
@@ -27,22 +29,20 @@ export default {
     leaveList,
   },
   data: () => ({
-    leaveList: [
-      {
-        starttime: '2020-02-18',
-        endtime: '2020-02-20',
-        ispass: '0',
-      },
-      {
-        starttime: '2020-02-18',
-        endtime: '2020-02-20',
-        ispass: '1',
-      },
-    ],
+    leaveList: [],
   }),
-  created() {},
+  created() {
+    this.searchInfo();
+  },
   computed: {},
-  methods: {},
+  methods: {
+    ...mapLeave(['query']),
+    async searchInfo({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      // console.log(res.data);
+      this.$set(this, `leaveList`, res.data);
+    },
+  },
 };
 </script>
 

+ 16 - 3
src/views/user/leaveDetail.vue

@@ -28,6 +28,8 @@
 </template>
 
 <script>
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapLeave } = createNamespacedHelpers('leave');
 export default {
   name: 'leaveDetail',
   props: {},
@@ -36,10 +38,21 @@ export default {
     form: {},
   }),
   created() {},
-  computed: {},
+  computed: {
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
   methods: {
-    onSubmit() {
-      console.log(form);
+    ...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' });

+ 26 - 7
src/views/user/leaveReason.vue

@@ -12,10 +12,12 @@
             请假理由:
             <span class="span">{{ reasonInfo.reason }}</span>
           </p>
-          <p>
-            请假拒绝理由:
-            <span class="span">{{ reasonInfo.refcause }}</span>
-          </p>
+          <span v-if="reasonInfo.ispass === '0' || reasonInfo.ispass === '1'">
+            <p>
+              请假拒绝理由:
+              <span class="span">{{ reasonInfo.refcause }}</span>
+            </p>
+          </span>
         </el-col>
       </el-col>
     </el-row>
@@ -23,6 +25,8 @@
 </template>
 
 <script>
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapLeave } = createNamespacedHelpers('leave');
 export default {
   name: 'leaveReason',
   props: {},
@@ -35,9 +39,23 @@ export default {
       refcause: '拒绝理由拒绝理由拒绝理由拒绝理由拒绝理由拒绝理由拒绝理由拒绝理由',
     },
   }),
-  created() {},
-  computed: {},
-  methods: {},
+  created() {
+    this.searchInfo();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  methods: {
+    ...mapLeave(['fetch']),
+    async searchInfo() {
+      if (this.$route.query.id) {
+        const res = await this.fetch(this.id);
+        this.$set(this, `reasonInfo`, res.data);
+      }
+    },
+  },
 };
 </script>
 
@@ -66,6 +84,7 @@ p {
   padding: 10px 0;
 }
 .reason p .span {
+  width: 100%;
   display: inline-block;
   text-indent: 2rem;
   line-height: 30px;

+ 14 - 0
vue.config.js

@@ -17,11 +17,25 @@ module.exports = {
     port: '8001',
     //api地址前缀
     proxy: {
+      '/files': {
+        target: 'http://smart.cc-lotus.info',
+        changeOrigin: true,
+        ws: true,
+      },
+      '/ws': {
+        target: 'http://smart.cc-lotus.info',
+        ws: true,
+      },
       '/weixin': {
         target: 'http://smart.cc-lotus.info',
         changeOrigin: true,
         ws: true,
       },
+      '/api': {
+        target: 'http://free.liaoningdoupo.com',
+        changeOrigin: true,
+        ws: true,
+      },
     },
   },
 };