index.vue
6.53 KB
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
<template>
<div class="flow-form" v-loading="loading">
<div class="com-title">
<h1>销假申请</h1>
<span class="number">单据号:{{ dataForm.billNo }}</span>
</div>
<el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="110px" :disabled="setting.readonly">
<el-row>
<el-col v-if="judgeShow('flowTitle')" :span="12">
<el-form-item label="流程标题" prop="flowTitle">
<el-input v-model="dataForm.flowTitle" placeholder="流程标题" :disabled="judgeWrite('flowTitle')" />
</el-form-item>
</el-col>
<el-col v-if="judgeShow('flowUrgent')" :span="12">
<el-form-item label="紧急程度" prop="flowUrgent">
<el-select v-model="dataForm.flowUrgent" placeholder="选择紧急程度" :disabled="judgeWrite('flowUrgent')">
<el-option v-for="item in flowUrgentOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col v-if="judgeShow('applyUser')" :span="12">
<el-form-item label="申请人员" prop="applyUser">
<el-input v-model="dataForm.applyUser" readonly :disabled="judgeWrite('applyUser')" />
</el-form-item>
</el-col>
<el-col v-if="judgeShow('applyDate')" :span="12">
<el-form-item label="申请日期" prop="applyDate">
<el-date-picker v-model="dataForm.applyDate" type="date" value-format="timestamp" format="yyyy-MM-dd"
:editable="false" readonly :disabled="judgeWrite('applyDate')" />
</el-form-item>
</el-col>
<el-col v-if="judgeShow('applyDept')" :span="12">
<el-form-item label="申请部门" prop="applyDept">
<el-input v-model="dataForm.applyDept" readonly :disabled="judgeWrite('applyDept')" />
</el-form-item>
</el-col>
<el-col v-if="judgeShow('applyPost')" :span="12">
<el-form-item label="申请职位" prop="applyPost">
<el-input v-model="dataForm.applyPost" readonly :disabled="judgeWrite('applyPost')" />
</el-form-item>
</el-col>
<el-col v-if="judgeShow('attendanceRecordId')" :span="24">
<el-form-item label="销假记录" prop="attendanceRecordId">
<el-select v-model="dataForm.attendanceRecordId" filterable placeholder="请选择待销假的考勤记录" style="width:100%"
:disabled="judgeWrite('attendanceRecordId') || candidateLoading">
<el-option v-for="c in leaveCandidates" :key="c.id" :label="c.attendanceDate + ' · ' + c.statusText"
:value="c.id" />
</el-select>
</el-form-item>
</el-col>
<el-col v-if="judgeShow('cancelReason')" :span="24">
<el-form-item label="销假原因" prop="cancelReason">
<el-input v-model="dataForm.cancelReason" type="textarea" :rows="3" placeholder="请说明销假原因"
:disabled="judgeWrite('cancelReason')" />
</el-form-item>
</el-col>
<el-col v-if="judgeShow('fileJson')" :span="24">
<el-form-item label="相关附件" prop="fileJson">
<NCC-UploadFz v-model="fileList" type="workFlow" :disabled="judgeWrite('fileJson')" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
</template>
<script>
import comMixin from '../../workFlowForm/mixin'
import { Info, Create, Update } from '@/api/workFlow/workFlowForm'
import { getLeaveCancelCandidates } from '@/api/extend/attendanceRecord'
export default {
name: 'LeaveCancelApplyForm',
mixins: [comMixin],
data() {
return {
billEnCode: 'WF_LeaveCancelApplyNo',
formApiKey: 'leaveCancelApply',
candidateLoading: false,
leaveCandidates: [],
dataForm: {
id: '',
flowId: '',
billNo: '',
flowTitle: '',
flowUrgent: 1,
applyUser: '',
applyDate: '',
applyDept: '',
applyPost: '',
attendanceRecordId: '',
cancelReason: '',
fileJson: '',
description: ''
},
dataRule: {
flowTitle: [{ required: true, message: '流程标题不能为空', trigger: 'blur' }],
flowUrgent: [{ required: true, message: '紧急程度不能为空', trigger: 'change' }],
attendanceRecordId: [{ required: true, message: '请选择待销假记录', trigger: 'change' }],
cancelReason: [{ required: true, message: '销假原因不能为空', trigger: 'blur' }]
}
}
},
methods: {
selfInit() {
this.dataForm.applyDate = new Date().getTime()
this.dataForm.flowTitle = this.userInfo.userName + '的销假申请'
this.dataForm.applyUser = this.userInfo.userName + '/' + this.userInfo.userAccount
this.dataForm.applyDept = this.userInfo.organizeName
if (this.userInfo.positionIds && this.userInfo.positionIds.length) {
this.dataForm.applyPost = this.userInfo.positionIds.map(o => o.name).join(',')
}
this.loadLeaveCandidates()
},
loadLeaveCandidates() {
this.candidateLoading = true
getLeaveCancelCandidates({}).then(res => {
this.leaveCandidates = res.data || []
}).finally(() => {
this.candidateLoading = false
})
},
selfGetInfo() {
Info(this.formApiKey, this.setting.id).then(res => {
this.dataForm = res.data
if (res.data.fileJson) {
this.fileList = JSON.parse(res.data.fileJson)
}
this.loadLeaveCandidates()
this.$emit('setPageLoad')
})
},
exist() {
return true
},
selfSubmit() {
this.dataForm.status = this.eventType === 'submit' ? 0 : 1
if (this.eventType === 'save') return this.selfHandleRequest()
this.$confirm('确定提交销假申请?审批通过后将自动执行考勤销假。', '提示', { type: 'warning' }).then(() => {
this.selfHandleRequest()
}).catch(() => { })
},
selfHandleRequest() {
if (!this.dataForm.id) delete this.dataForm.id
if (this.eventType === 'save') this.$emit('setLoad', true)
const formMethod = this.dataForm.id ? Update : Create
formMethod(this.formApiKey, this.dataForm).then(res => {
this.$message({
message: res.msg, type: 'success', duration: 1500, onClose: () => {
if (this.eventType === 'save') this.$emit('setLoad', false)
this.$emit('close', true)
}
})
}).catch(() => {
if (this.eventType === 'save') this.$emit('setLoad', false)
})
}
}
}
</script>