xiangpei
2025-05-06 5c929cfb5286a31a4e067cbc61e8774f4e7d42ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<template>
    <div class="c-process-task">
        <div class="c-process-task__form">
            <leave-apply-form
                v-if="taskType === 'leaveapply'"
                :step="step"
                :form-info="formInfo"
                @submit="handleSubmit"
                @cancel="handleCancel"
                @reject="handleReject"
            ></leave-apply-form>
            <purchase-form
                v-if="taskType === 'purchase'"
                :step="step"
                :form-info="formInfo"
                @submit="handleSubmit"
            ></purchase-form>
            <meeting-form
                v-if="taskType === 'meeting'"
                :step="step"
                :form-info="formInfo"
                @submit="handleSubmit"
            ></meeting-form>
        </div>
        <div>
            <time-line :activities="activities"></time-line>
        </div>
    </div>
</template>
 
<script>
import {
    getProcessByTaskid,
    processTask,
    fillMeetingRecord,
    checkoutLeave,
    forceEnd,
    rejectLeave,
    updatePurchase,
    getInfoByTaskId
} from "./api/myTodoList";
import TimeLine from './components/TimeLine.vue';
 
import leaveApplyForm from './components/leaveApplyForm.vue';
import meetingForm from './components/meetingForm.vue';
import purchaseForm from './components/purchaseForm.vue';
import LeaveApply from '../function/leaveApply.vue';
const urlMap = {
    // 部门领导审批
    "deptleadercheck": "/leaveapply/deptleadercheck",
    // 人事审批
    "hrcheck": "/leaveapply/hrcheck",
    // 销假
    "destroyapply": "/leaveapply/destroyapply",
    // 请假流程中拒绝过程,回到申请人进行修改
    "modifyapply": "/leaveapply/modifyapply",
    // 发起请假申请,此处为驳回后返回的位置
    "addleave": "/leaveapply/addleave",
 
    purchasemanager: "/purchase/purchasemanager",
    finance: "/purchase/finance",
    pay: "/purchase/pay",
    receiveitem: "/purchase/receiveitem",
    manager: "/purchase/manager",
    // 拒绝后,申请人重新申请
    updateapply: "/purchase/updateapply",
 
    input: "/meeting/input",
    signate: "/meeting/signate"
}
export default {
    components: {
        TimeLine,
        leaveApplyForm,
        meetingForm,
        purchaseForm,
        LeaveApply
    },
    data() {
        return {
            activities: [],
            taskType: "",
            step: "",
            taskId: "",
            formInfo: {}
        };
    },
    mounted() {
        console.log("待办", this.$route.params)
        const {taskId, taskType, step} = this.$route.params;
        this.taskId = taskId;
        this.taskType = taskType;
        this.step = step;
        getProcessByTaskid(taskId).then(res => {
            console.log("拿到流程信息", res);
            this.activities = res;
        });
        console.log("step","taskId",step ,urlMap[step], taskId);
        getInfoByTaskId(urlMap[step], taskId).then(res => {
            console.log("step","taskId", res);
            if (res.data) {
                this.formInfo = res.data;
            }
        });
    },
    methods: {
        handleSubmit(data) {
            if (this.taskType === "meeting") {
                if (this.step === "input") {
                    const id = this.$route.query.id;
                    const {content} = data;
                    fillMeetingRecord({
                        id,
                        content
                    }).then(res => {
                        console.log("审批通过!");
                    });
                }
            }
 
            if (this.taskType === "leaveapply") {
                if (
                    this.step === "destroyapply"
                    || this.step === "addLeave"
                    || this.step === "modifyapply"
                ) {
                    const {realityStartTime, realityEndTime, reapply} = data;
                    const id = this.$route.query.id;
                    const taskId = this.taskId;
                    checkoutLeave({
                        ...data,
                        id,
                        taskId
                    }).then(res => {
                        console.log("销假成功!");
                    });
                }
            }
 
            if (this.taskType === "purchase") {
                const id = this.$route.query.id;
                const taskId = this.taskId;
                if ( this.step === "updateapply") {
                    updatePurchase({
                        ...data,
                        id,
                        taskId
                    }).then(res => {
                        console.log("更新成功!");
                    });
                }
            }
            processTask({
                taskId: this.taskId,
                ...data
            }).then(res => {
                this.$message.success("处理成功!");
                this.$tab.closePage(this.$route).then(({ visitedViews }) => {
                    this.toLastView(visitedViews, this.$route)
                });
            });
        },
        toLastView(visitedViews, view) {
            const latestView = visitedViews.slice(-1)[0]
            if (latestView) {
                this.$router.push(latestView.fullPath)
            } else {
                // now the default is to redirect to the home page if there is no tags-view,
                // you can adjust it according to your needs.
                if (view.name === 'Dashboard') {
                // to reload home page
                this.$router.replace({ path: '/redirect' + view.fullPath })
                } else {
                this.$router.push('/')
                }
            }
        },
        handleCancel() {
            forceEnd(this.taskId).then(res => {
                console.log("撤销成功");
                this.$tab.closePage(this.$route).then(({ visitedViews }) => {
                    this.toLastView(visitedViews, this.$route)
                });
            });
        },
        handleReject() {
            rejectLeave(this.taskId).then(res => {
                console.log("驳回成功!");
                this.$tab.closePage(this.$route).then(({ visitedViews }) => {
                    this.toLastView(visitedViews, this.$route)
                });
            })
        },
    }
};
</script>
 
<style>
.c-process-task {
    padding: 16px;
    display: flex;
    justify-content: center;
}
.c-process-task__form {
    width: 500px;
}
</style>