|
@@ -20,7 +20,7 @@
|
20
|
20
|
|
21
|
21
|
<!-- 填报日期 -->
|
22
|
22
|
<uni-forms-item label="填报日期" class="form-item">
|
23
|
|
- <uni-datetime-picker v-model="form.applyDate" type="date" :disabled="taskName != '设备申请'" />
|
|
23
|
+ <text>{{ form.applyDate }}</text>
|
24
|
24
|
</uni-forms-item>
|
25
|
25
|
|
26
|
26
|
<!-- 选择项目 -->
|
|
@@ -33,7 +33,8 @@
|
33
|
33
|
<!-- 设备选择 -->
|
34
|
34
|
<uni-forms-item label="选择设备" required class="form-item" name="devices">
|
35
|
35
|
<uv-button type="primary" @click="openDevice = true" v-if="taskName == '设备申请'">+ 选择设备</uv-button>
|
36
|
|
- <device-picker :visible.sync="openDevice" :selected.sync="selectDevice" @confirm="handleDeviceConfirm"></device-picker>
|
|
36
|
+ <device-picker :visible.sync="openDevice" :selected.sync="selectDevice"
|
|
37
|
+ @confirm="handleDeviceConfirm"></device-picker>
|
37
|
38
|
<uni-table v-if="deviceList.length > 0">
|
38
|
39
|
<uni-tr>
|
39
|
40
|
<uni-th>序号</uni-th>
|
|
@@ -56,16 +57,15 @@
|
56
|
57
|
|
57
|
58
|
<!-- 申领事由 -->
|
58
|
59
|
<uni-forms-item label="申领事由" required class="form-item" name="applyReason">
|
59
|
|
- <uni-easyinput type="textarea" v-model="form.applyReason" placeholder="请输入申领事由" :disabled="taskName != '设备申请'" />
|
|
60
|
+ <uni-easyinput type="textarea" v-model="form.applyReason" placeholder="请输入申领事由"
|
|
61
|
+ :disabled="taskName != '设备申请'" />
|
60
|
62
|
</uni-forms-item>
|
61
|
63
|
|
62
|
64
|
<!-- 日期选择 -->
|
63
|
65
|
<view class="date-range">
|
64
|
|
- <uni-forms-item label="开始日期" required class="form-item" name="beginDate">
|
65
|
|
- <uni-datetime-picker v-model="form.beginDate" type="date" :disabled="taskName != '设备申请'" @change="calculateDay" />
|
66
|
|
- </uni-forms-item>
|
67
|
|
- <uni-forms-item label="结束日期" required class="form-item" name="endDate">
|
68
|
|
- <uni-datetime-picker v-model="form.endDate" type="date" :disabled="taskName != '设备申请'" @change="calculateDay" />
|
|
66
|
+ <uni-forms-item label="使用日期" required class="form-item" name="dateRange">
|
|
67
|
+ <uni-datetime-picker v-model="dateRange" type="daterange" rangeSeparator="至" :clearIcon="false"
|
|
68
|
+ :disabled="taskName != '设备申请'" @change="handleDateRangeChange" />
|
69
|
69
|
</uni-forms-item>
|
70
|
70
|
<uni-forms-item label="共计" class="form-item">
|
71
|
71
|
<text>{{ form.days + '天' }}</text>
|
|
@@ -102,12 +102,14 @@
|
102
|
102
|
|
103
|
103
|
<!-- 安排设备意见 -->
|
104
|
104
|
<uni-forms-item label="安排设备意见" class="form-item" v-if="taskName == '安排设备'">
|
105
|
|
- <uni-easyinput type="textarea" v-model="form.dispatchComment" placeholder="请输入安排设备意见" :disabled="taskName != '安排设备'" />
|
|
105
|
+ <uni-easyinput type="textarea" v-model="form.dispatchComment" placeholder="请输入安排设备意见"
|
|
106
|
+ :disabled="taskName != '安排设备'" />
|
106
|
107
|
</uni-forms-item>
|
107
|
108
|
|
108
|
109
|
<!-- 分管审核意见 -->
|
109
|
110
|
<uni-forms-item label="分管审核意见" class="form-item" v-if="taskName == '分管审核'">
|
110
|
|
- <uni-easyinput type="textarea" v-model="form.managerComment" placeholder="请输入分管审核意见" :disabled="taskName != '分管审核'" />
|
|
111
|
+ <uni-easyinput type="textarea" v-model="form.managerComment" placeholder="请输入分管审核意见"
|
|
112
|
+ :disabled="taskName != '分管审核'" />
|
111
|
113
|
</uni-forms-item>
|
112
|
114
|
|
113
|
115
|
<!-- 归还确认 -->
|
|
@@ -134,7 +136,8 @@
|
134
|
136
|
|
135
|
137
|
<!-- 需维修设备 -->
|
136
|
138
|
<uni-forms-item label="需维修设备" class="form-item" v-if="taskName == '归还确认'">
|
137
|
|
- <uni-data-select v-model="form.repairDevices" :localdata="modifyDeviceList" multiple :disabled="taskName != '归还确认'" />
|
|
139
|
+ <uni-data-select v-model="form.repairDevices" :localdata="modifyDeviceList" multiple
|
|
140
|
+ :disabled="taskName != '归还确认'" />
|
138
|
141
|
</uni-forms-item>
|
139
|
142
|
|
140
|
143
|
<!-- 备注 -->
|
|
@@ -149,9 +152,9 @@
|
149
|
152
|
|
150
|
153
|
<!-- 操作按钮 -->
|
151
|
154
|
<view class="form-actions">
|
|
155
|
+ <uv-button style="margin-bottom: 5px;" type="warning" @click="saves">保存</uv-button>
|
152
|
156
|
<uv-button type="primary" @click="submit" v-if="taskName == '设备申请'">提交申请</uv-button>
|
153
|
157
|
<template v-else>
|
154
|
|
- <uv-button type="warning" @click="saves">保存</uv-button>
|
155
|
158
|
<uv-button type="primary" @click="completeApply">完成审批</uv-button>
|
156
|
159
|
</template>
|
157
|
160
|
</view>
|
|
@@ -186,6 +189,12 @@ export default {
|
186
|
189
|
data() {
|
187
|
190
|
return {
|
188
|
191
|
form: {
|
|
192
|
+ user: {
|
|
193
|
+ nickName: ''
|
|
194
|
+ },
|
|
195
|
+ dept: {
|
|
196
|
+ deptName: ''
|
|
197
|
+ },
|
189
|
198
|
projectId: '',
|
190
|
199
|
applyDate: '',
|
191
|
200
|
applyReason: '',
|
|
@@ -194,10 +203,12 @@ export default {
|
194
|
203
|
days: 0,
|
195
|
204
|
dispatchComment: '',
|
196
|
205
|
managerComment: '',
|
|
206
|
+ devices: [],
|
197
|
207
|
repairDevices: [],
|
198
|
208
|
remark: '',
|
199
|
209
|
returnDate: ''
|
200
|
210
|
},
|
|
211
|
+ dateRange: [],
|
201
|
212
|
rules: {
|
202
|
213
|
projectId: {
|
203
|
214
|
rules: [{ required: true, errorMessage: '请选择项目' }]
|
|
@@ -208,11 +219,8 @@ export default {
|
208
|
219
|
applyReason: {
|
209
|
220
|
rules: [{ required: true, errorMessage: '请输入申领事由' }]
|
210
|
221
|
},
|
211
|
|
- beginDate: {
|
212
|
|
- rules: [{ required: true, errorMessage: '请选择开始日期' }]
|
213
|
|
- },
|
214
|
|
- endDate: {
|
215
|
|
- rules: [{ required: true, errorMessage: '请选择结束日期' }]
|
|
222
|
+ dateRange: {
|
|
223
|
+ rules: [{ required: true, errorMessage: '请选择使用日期' }]
|
216
|
224
|
}
|
217
|
225
|
},
|
218
|
226
|
applierUserName: '',
|
|
@@ -223,21 +231,31 @@ export default {
|
223
|
231
|
selectDevice: [],
|
224
|
232
|
deviceList: [],
|
225
|
233
|
modifyDeviceList: [],
|
226
|
|
- returnDevicesList: []
|
227
|
|
- }
|
|
234
|
+ returnDevicesList: [],
|
|
235
|
+ formTotal: 0
|
|
236
|
+ };
|
228
|
237
|
},
|
229
|
238
|
methods: {
|
230
|
239
|
initForm() {
|
231
|
240
|
getDeviceApproval(this.taskForm.formId).then(res => {
|
232
|
241
|
if (res.data) {
|
|
242
|
+ this.formTotal = 1;
|
233
|
243
|
this.form = res.data;
|
234
|
244
|
this.deviceList = res.data.devices || [];
|
235
|
245
|
this.modifyDeviceList = res.data.modifyDevices || [];
|
236
|
246
|
this.returnDevicesList = res.data.returnDevices || [];
|
|
247
|
+ if (this.form.beginDate && this.form.endDate) {
|
|
248
|
+ this.dateRange = [this.form.beginDate, this.form.endDate];
|
|
249
|
+ }
|
237
|
250
|
} else {
|
|
251
|
+ this.form.applier = this.$store.getters.userId;
|
238
|
252
|
this.form.applyDate = parseTime(new Date(), "{y}-{m}-{d}");
|
|
253
|
+ let name = this.applierUserName.split('-');
|
|
254
|
+ this.form.user.nickName = name[0];
|
|
255
|
+ this.form.dept.deptName = name[1];
|
|
256
|
+ this.formTotal = 0;
|
239
|
257
|
}
|
240
|
|
- })
|
|
258
|
+ });
|
241
|
259
|
},
|
242
|
260
|
handleConfirm(project) {
|
243
|
261
|
this.selectedProject = project;
|
|
@@ -248,11 +266,21 @@ export default {
|
248
|
266
|
this.deviceList = Array.isArray(devices) ? devices : [devices];
|
249
|
267
|
this.form.devices = this.deviceList.map(item => item.deviceId);
|
250
|
268
|
},
|
|
269
|
+ handleDateRangeChange(e) {
|
|
270
|
+ if (Array.isArray(e) && e.length === 2) {
|
|
271
|
+ const [start, end] = e;
|
|
272
|
+ this.form.beginDate = start;
|
|
273
|
+ this.form.endDate = end;
|
|
274
|
+ this.calculateDay();
|
|
275
|
+ }
|
|
276
|
+ },
|
251
|
277
|
calculateDay() {
|
252
|
278
|
if (this.form.beginDate && this.form.endDate) {
|
253
|
279
|
const begin = new Date(this.form.beginDate);
|
254
|
280
|
const end = new Date(this.form.endDate);
|
255
|
|
- this.form.days = Math.ceil((end - begin) / (1000 * 60 * 60 * 24)) + 1;
|
|
281
|
+ if (!isNaN(begin.getTime()) && !isNaN(end.getTime())) {
|
|
282
|
+ this.form.days = Math.ceil((end - begin) / (1000 * 60 * 60 * 24)) + 1;
|
|
283
|
+ }
|
256
|
284
|
}
|
257
|
285
|
},
|
258
|
286
|
replaceRowData(row, index) {
|
|
@@ -278,12 +306,68 @@ export default {
|
278
|
306
|
});
|
279
|
307
|
},
|
280
|
308
|
saves() {
|
281
|
|
- updateDeviceApproval(this.form).then(res => {
|
|
309
|
+ try {
|
|
310
|
+ // 构建提交数据
|
|
311
|
+ let submitData = {
|
|
312
|
+ ...this.form,
|
|
313
|
+ formId: this.taskForm.formId,
|
|
314
|
+ deviceApplyId: this.taskForm.formId,
|
|
315
|
+ };
|
|
316
|
+ let formData = new FormData();
|
|
317
|
+ let jsonForm = JSON.stringify(submitData);
|
|
318
|
+ formData.append("form", jsonForm);
|
|
319
|
+ console.log(formData.get('form'));
|
|
320
|
+ // 根据表单状态选择接口
|
|
321
|
+ if (this.formTotal !== 0) {
|
|
322
|
+ modifyDeviceApproval(formData).then(res => {
|
|
323
|
+ console.log('修改响应:', res);
|
|
324
|
+ if (res.code === 200) {
|
|
325
|
+ uni.showToast({
|
|
326
|
+ title: '保存成功',
|
|
327
|
+ icon: 'success'
|
|
328
|
+ });
|
|
329
|
+ } else {
|
|
330
|
+ uni.showToast({
|
|
331
|
+ title: res.msg || '保存失败',
|
|
332
|
+ icon: 'error'
|
|
333
|
+ });
|
|
334
|
+ }
|
|
335
|
+ }).catch(error => {
|
|
336
|
+ console.error('修改错误:', error);
|
|
337
|
+ uni.showToast({
|
|
338
|
+ title: error.message || '保存失败',
|
|
339
|
+ icon: 'error'
|
|
340
|
+ });
|
|
341
|
+ });
|
|
342
|
+ } else {
|
|
343
|
+ submitDeviceApproval(formData).then(res => {
|
|
344
|
+ console.log('提交响应:', res);
|
|
345
|
+ if (res.code === 200) {
|
|
346
|
+ uni.showToast({
|
|
347
|
+ title: '保存成功',
|
|
348
|
+ icon: 'success'
|
|
349
|
+ });
|
|
350
|
+ } else {
|
|
351
|
+ uni.showToast({
|
|
352
|
+ title: res.msg || '保存失败',
|
|
353
|
+ icon: 'error'
|
|
354
|
+ });
|
|
355
|
+ }
|
|
356
|
+ }).catch(error => {
|
|
357
|
+ console.error('提交错误:', error);
|
|
358
|
+ uni.showToast({
|
|
359
|
+ title: error.message || '保存失败',
|
|
360
|
+ icon: 'error'
|
|
361
|
+ });
|
|
362
|
+ });
|
|
363
|
+ }
|
|
364
|
+ } catch (error) {
|
|
365
|
+ console.error('保存方法错误:', error);
|
282
|
366
|
uni.showToast({
|
283
|
|
- title: '保存成功',
|
284
|
|
- icon: 'success'
|
|
367
|
+ title: error.message || '保存失败',
|
|
368
|
+ icon: 'error'
|
285
|
369
|
});
|
286
|
|
- });
|
|
370
|
+ }
|
287
|
371
|
},
|
288
|
372
|
completeApply() {
|
289
|
373
|
modifyDeviceApproval(this.form).then(res => {
|
|
@@ -320,13 +404,12 @@ export default {
|
320
|
404
|
}
|
321
|
405
|
|
322
|
406
|
.date-range {
|
323
|
|
- display: flex;
|
|
407
|
+ // display: flex;
|
324
|
408
|
flex-wrap: wrap;
|
325
|
409
|
gap: 32rpx;
|
326
|
410
|
}
|
327
|
411
|
|
328
|
412
|
.form-actions {
|
329
|
|
- display: flex;
|
330
|
413
|
justify-content: center;
|
331
|
414
|
gap: 32rpx;
|
332
|
415
|
margin-top: 32rpx;
|