|
@@ -2,7 +2,7 @@
|
2
|
2
|
* @Author: ysh
|
3
|
3
|
* @Date: 2024-02-29 11:44:28
|
4
|
4
|
* @LastEditors: Please set LastEditors
|
5
|
|
- * @LastEditTime: 2024-03-07 17:25:40
|
|
5
|
+ * @LastEditTime: 2024-03-08 15:12:42
|
6
|
6
|
-->
|
7
|
7
|
<!--
|
8
|
8
|
* @Author: wrh
|
|
@@ -15,22 +15,24 @@
|
15
|
15
|
<div>
|
16
|
16
|
<h2 style="text-align: center;">用车申请表</h2>
|
17
|
17
|
<div>
|
18
|
|
- <el-form :model="form" label-width="100px">
|
|
18
|
+ <el-form ref="carForm" :model="form" label-width="100px" :rules="rules">
|
19
|
19
|
<!-- 申请人填写 -->
|
20
|
20
|
<el-row :gutter="20">
|
21
|
21
|
<el-col :span="6" :xs="24">
|
22
|
22
|
<el-form-item label="申请人:" prop="user">
|
23
|
|
- <el-input v-model="form.user"></el-input>
|
|
23
|
+ <!-- <el-input v-model="form.user"></el-input> -->
|
|
24
|
+ {{ form.user }}
|
24
|
25
|
</el-form-item>
|
25
|
26
|
</el-col>
|
26
|
27
|
<el-col :span="6" :xs="24">
|
27
|
28
|
<el-form-item label="所在部门:" prop="deptName">
|
28
|
|
- <el-input v-model="form.deptName"></el-input>
|
|
29
|
+ <!-- <el-input v-model="form.deptName"></el-input> -->
|
|
30
|
+ {{ form.deptName }}
|
29
|
31
|
</el-form-item>
|
30
|
32
|
</el-col>
|
31
|
33
|
<el-col :span="6" :xs="24">
|
32
|
34
|
<el-form-item label="申请时间:" prop="date">
|
33
|
|
- <el-date-picker style="width:140px;" v-model="form.date" value-format="yyyy-MM-dd" type="date"
|
|
35
|
+ <el-date-picker style="width:140px;" v-model="form.applyDate" value-format="yyyy-MM-dd" type="date"
|
34
|
36
|
placeholder="选择日期">
|
35
|
37
|
</el-date-picker>
|
36
|
38
|
</el-form-item>
|
|
@@ -65,14 +67,14 @@
|
65
|
67
|
</el-form-item>
|
66
|
68
|
<el-row>
|
67
|
69
|
<el-col :span="6" :xs="24">
|
68
|
|
- <el-form-item label="开始日期:">
|
|
70
|
+ <el-form-item label="开始日期:" prop="beginDate">
|
69
|
71
|
<el-date-picker style="width:140px;" v-model="form.beginDate" value-format="yyyy-MM-dd" type="date"
|
70
|
72
|
placeholder="选择日期" @change="calculateDay">
|
71
|
73
|
</el-date-picker>
|
72
|
74
|
</el-form-item>
|
73
|
75
|
</el-col>
|
74
|
76
|
<el-col :span="6" :xs="24">
|
75
|
|
- <el-form-item label="结束日期:">
|
|
77
|
+ <el-form-item label="结束日期:" prop="endDate">
|
76
|
78
|
<el-date-picker style="width:140px;" v-model="form.endDate" value-format="yyyy-MM-dd" type="date"
|
77
|
79
|
placeholder="选择日期" @change="calculateDay">
|
78
|
80
|
</el-date-picker>
|
|
@@ -115,13 +117,17 @@
|
115
|
117
|
<el-row style="text-align: center;" v-if="taskName == '用车申请'">
|
116
|
118
|
<el-button type="primary" @click="submit">提交申请</el-button>
|
117
|
119
|
</el-row>
|
|
120
|
+ <el-row style="text-align: center;" v-else>
|
|
121
|
+ <el-button type="primary" @click="completeApply">完成审批</el-button>
|
|
122
|
+ </el-row>
|
118
|
123
|
</div>
|
119
|
124
|
</div>
|
120
|
125
|
</template>
|
121
|
126
|
|
122
|
127
|
<script>
|
123
|
128
|
import { listProject, getProject } from "@/api/oa/project/project";
|
124
|
|
-import { listCar } from "@/api/oa/car/car";
|
|
129
|
+import { listCar, getCar } from "@/api/oa/car/car";
|
|
130
|
+import { listCarApproval, getCarApproval, updateCarApproval, submitCarApproval, modifyCarApproval } from '@/api/oa/car/carApproval'
|
125
|
131
|
import { listDriver } from "@/api/system/post";
|
126
|
132
|
import {
|
127
|
133
|
complete, rejectTask, returnList, returnTask, getNextFlowNode, delegate, flowTaskForm,
|
|
@@ -139,8 +145,7 @@ export default {
|
139
|
145
|
}
|
140
|
146
|
},
|
141
|
147
|
created() {
|
142
|
|
- this.form.user = this.$store.getters.name;
|
143
|
|
- this.form.deptName = this.$store.getters.deptName;
|
|
148
|
+
|
144
|
149
|
this.getProjectList();
|
145
|
150
|
this.getCarList();
|
146
|
151
|
this.getDriverList();
|
|
@@ -148,38 +153,111 @@ export default {
|
148
|
153
|
data() {
|
149
|
154
|
return {
|
150
|
155
|
form: {
|
151
|
|
- date: new Date(),
|
152
|
156
|
days: '',
|
153
|
|
- drivers: []
|
|
157
|
+ drivers: [],
|
|
158
|
+ user: '',
|
|
159
|
+ applyDate: undefined,
|
|
160
|
+ deptName: '',
|
|
161
|
+ applier: '',
|
|
162
|
+ },
|
|
163
|
+ rules: {
|
|
164
|
+ projectNumber: [
|
|
165
|
+ { required: true, message: '请选择项目编号', trigger: 'change' },
|
|
166
|
+ ],
|
|
167
|
+ passengers: [
|
|
168
|
+ { required: true, message: '请选择输入乘车人数', trigger: 'change' },
|
|
169
|
+ ],
|
|
170
|
+ beginDate: [
|
|
171
|
+ { required: true, message: '请选择开始日期', trigger: 'change' },
|
|
172
|
+ ],
|
|
173
|
+ endDate: [
|
|
174
|
+ { required: true, message: '请选择结束日期', trigger: 'change' },
|
|
175
|
+ ],
|
|
176
|
+ applyReason: [
|
|
177
|
+ { required: true, message: '请输入用车理由', trigger: 'blur' },
|
|
178
|
+ ],
|
154
|
179
|
},
|
155
|
180
|
projectList: [],
|
156
|
181
|
carList: [],
|
157
|
182
|
driverList: [],
|
158
|
183
|
chooseProject: {},
|
159
|
184
|
isSelect: false,
|
|
185
|
+ formTotal: 0
|
160
|
186
|
}
|
161
|
187
|
},
|
|
188
|
+ mounted() {
|
|
189
|
+ this.initForm();
|
|
190
|
+ },
|
162
|
191
|
methods: {
|
|
192
|
+ // 初始化表单
|
|
193
|
+ initForm() {
|
|
194
|
+ getCarApproval(this.taskForm.formId).then(res => {
|
|
195
|
+ if (this.isEmptyObject(res.data)) {
|
|
196
|
+ this.formTotal = 0;
|
|
197
|
+ this.form.user = this.$store.getters.name;
|
|
198
|
+ this.form.applier = this.$store.getters.userId;
|
|
199
|
+ this.form.deptName = this.$store.getters.deptName;
|
|
200
|
+ this.form.applyDate = new Date();
|
|
201
|
+ }
|
|
202
|
+ else {
|
|
203
|
+ this.formTotal = 1;
|
|
204
|
+ console.log(res);
|
|
205
|
+ let data = res.data;
|
|
206
|
+ if (res.data.drivers == null || res.rows.drivers == undefined || res.rows.drivers == "") {
|
|
207
|
+ data.drivers = []
|
|
208
|
+ } else {
|
|
209
|
+ data.drivers = data.drivers.split(',');
|
|
210
|
+ }
|
|
211
|
+ this.form = data;
|
|
212
|
+ }
|
|
213
|
+ })
|
|
214
|
+ },
|
163
|
215
|
submit() {
|
|
216
|
+ this.$refs['carForm'].validate((valid) => {
|
|
217
|
+ debugger
|
|
218
|
+ if (valid) {
|
|
219
|
+ this.form.formId = this.taskForm.formId;
|
|
220
|
+ let formData = new FormData();
|
|
221
|
+ let jsonForm = JSON.stringify(this.form);
|
|
222
|
+ formData.append("form", jsonForm);
|
|
223
|
+ const params = { taskId: this.taskForm.taskId };
|
|
224
|
+ if (this.formTotal != 0) {
|
|
225
|
+ modifyCarApproval(formData);
|
|
226
|
+ } else {
|
|
227
|
+ submitCarApproval(formData);
|
|
228
|
+ }
|
|
229
|
+ // 获取下一个流程节点
|
|
230
|
+ getNextFlowNode(params).then(res => {
|
|
231
|
+ const data = res.data;
|
|
232
|
+ this.taskForm.formData = formData;
|
|
233
|
+ this.getNextFlowNodeApproval();
|
|
234
|
+ })
|
|
235
|
+ }
|
|
236
|
+ })
|
|
237
|
+ },
|
|
238
|
+ completeApply() {
|
164
|
239
|
let formData = new FormData();
|
165
|
240
|
let jsonForm = JSON.stringify(this.form);
|
166
|
241
|
formData.append("form", jsonForm);
|
167
|
|
- const params = { taskId: this.taskForm.taskId }
|
|
242
|
+ modifyCarApproval(formData);
|
|
243
|
+ const params = { taskId: this.taskForm.taskId };
|
168
|
244
|
// 获取下一个流程节点
|
169
|
245
|
getNextFlowNode(params).then(res => {
|
170
|
246
|
const data = res.data;
|
171
|
|
- debugger
|
172
|
247
|
this.taskForm.formData = formData;
|
173
|
|
- complete(this.taskForm).then(response => {
|
174
|
|
- this.$modal.msgSuccess(response.msg);
|
175
|
|
- this.goBack();
|
176
|
|
- });
|
|
248
|
+ this.getNextFlowNodeApproval();
|
177
|
249
|
})
|
178
|
250
|
},
|
179
|
251
|
// 获取下一个审批人
|
180
|
252
|
getNextFlowNodeApproval() {
|
181
|
|
- getUsersDeptLeader()
|
182
|
|
- this.$set(this.taskForm.variables, "approval", selectVal.join(','));
|
|
253
|
+ getUsersDeptLeader({ userId: this.$store.getters.userId }).then(res => {
|
|
254
|
+ let userId = res.data.userId;
|
|
255
|
+ this.$set(this.taskForm.variables, "approval", userId);
|
|
256
|
+ complete(this.taskForm).then(response => {
|
|
257
|
+ this.$modal.msgSuccess(response.msg);
|
|
258
|
+ this.$emit('goBack')
|
|
259
|
+ });
|
|
260
|
+ })
|
183
|
261
|
},
|
184
|
262
|
// 查询项目列表
|
185
|
263
|
getProjectList() {
|
|
@@ -228,6 +306,7 @@ export default {
|
228
|
306
|
let y2 = new Date(this.form.endDate);
|
229
|
307
|
if (y2 < y1) {
|
230
|
308
|
this.form.days = '';
|
|
309
|
+ this.$message.error('开始时期和结束日期选择错误');
|
231
|
310
|
return
|
232
|
311
|
}
|
233
|
312
|
let sub = Math.abs(y2 - y1);
|
|
@@ -237,6 +316,14 @@ export default {
|
237
|
316
|
this.form.days = '';
|
238
|
317
|
}
|
239
|
318
|
|
|
319
|
+ },
|
|
320
|
+ isEmptyObject(obj) {
|
|
321
|
+ for (var key in obj) {
|
|
322
|
+ if (obj.hasOwnProperty(key)) {
|
|
323
|
+ return false;
|
|
324
|
+ }
|
|
325
|
+ }
|
|
326
|
+ return true;
|
240
|
327
|
}
|
241
|
328
|
},
|
242
|
329
|
}
|