Browse Source

修改移动端设备审批

余思翰 4 days ago
parent
commit
1f5bc034ba

+ 15
- 4
oa-ui-app/pages/components/DevicePicker.vue View File

106
       handler(val) {
106
       handler(val) {
107
         this.selectedList = Array.isArray(val) ? [...val] : [val];
107
         this.selectedList = Array.isArray(val) ? [...val] : [val];
108
       }
108
       }
109
+    },
110
+    'queryParams.status': {
111
+      handler() {
112
+        this.handleSearch();
113
+      }
109
     }
114
     }
110
   },
115
   },
111
 
116
 
124
 
129
 
125
     // 加载设备数据
130
     // 加载设备数据
126
     async loadData() {
131
     async loadData() {
127
-      if (this.loading || !this.hasMore) return;
132
+      if (this.loading) return;
128
 
133
 
129
       this.loading = true;
134
       this.loading = true;
130
       try {
135
       try {
131
         const res = await listDevice(this.queryParams);
136
         const res = await listDevice(this.queryParams);
132
-        this.list = this.queryParams.pageNum === 1
133
-          ? res.rows
134
-          : [...this.list, ...res.rows];
137
+        
138
+        // 如果是第一页,直接替换列表
139
+        if (this.queryParams.pageNum === 1) {
140
+          this.list = res.rows;
141
+        } else {
142
+          // 如果不是第一页,追加到列表
143
+          this.list = [...this.list, ...res.rows];
144
+        }
135
 
145
 
136
         this.hasMore = res.total > this.queryParams.pageNum * this.queryParams.pageSize;
146
         this.hasMore = res.total > this.queryParams.pageNum * this.queryParams.pageSize;
137
         this.queryParams.pageNum++;
147
         this.queryParams.pageNum++;
142
 
152
 
143
     // 搜索处理
153
     // 搜索处理
144
     handleSearch() {
154
     handleSearch() {
155
+      // 重置分页参数
145
       this.queryParams.pageNum = 1;
156
       this.queryParams.pageNum = 1;
146
       this.hasMore = true;
157
       this.hasMore = true;
147
       this.list = [];
158
       this.list = [];

+ 110
- 27
oa-ui-app/pages/form/device/device.vue View File

20
 
20
 
21
       <!-- 填报日期 -->
21
       <!-- 填报日期 -->
22
       <uni-forms-item label="填报日期" class="form-item">
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
       </uni-forms-item>
24
       </uni-forms-item>
25
 
25
 
26
       <!-- 选择项目 -->
26
       <!-- 选择项目 -->
33
       <!-- 设备选择 -->
33
       <!-- 设备选择 -->
34
       <uni-forms-item label="选择设备" required class="form-item" name="devices">
34
       <uni-forms-item label="选择设备" required class="form-item" name="devices">
35
         <uv-button type="primary" @click="openDevice = true" v-if="taskName == '设备申请'">+ 选择设备</uv-button>
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
         <uni-table v-if="deviceList.length > 0">
38
         <uni-table v-if="deviceList.length > 0">
38
           <uni-tr>
39
           <uni-tr>
39
             <uni-th>序号</uni-th>
40
             <uni-th>序号</uni-th>
56
 
57
 
57
       <!-- 申领事由 -->
58
       <!-- 申领事由 -->
58
       <uni-forms-item label="申领事由" required class="form-item" name="applyReason">
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
       </uni-forms-item>
62
       </uni-forms-item>
61
 
63
 
62
       <!-- 日期选择 -->
64
       <!-- 日期选择 -->
63
       <view class="date-range">
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
         </uni-forms-item>
69
         </uni-forms-item>
70
         <uni-forms-item label="共计" class="form-item">
70
         <uni-forms-item label="共计" class="form-item">
71
           <text>{{ form.days + '天' }}</text>
71
           <text>{{ form.days + '天' }}</text>
102
 
102
 
103
       <!-- 安排设备意见 -->
103
       <!-- 安排设备意见 -->
104
       <uni-forms-item label="安排设备意见" class="form-item" v-if="taskName == '安排设备'">
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
       </uni-forms-item>
107
       </uni-forms-item>
107
 
108
 
108
       <!-- 分管审核意见 -->
109
       <!-- 分管审核意见 -->
109
       <uni-forms-item label="分管审核意见" class="form-item" v-if="taskName == '分管审核'">
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
       </uni-forms-item>
113
       </uni-forms-item>
112
 
114
 
113
       <!-- 归还确认 -->
115
       <!-- 归还确认 -->
134
 
136
 
135
       <!-- 需维修设备 -->
137
       <!-- 需维修设备 -->
136
       <uni-forms-item label="需维修设备" class="form-item" v-if="taskName == '归还确认'">
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
       </uni-forms-item>
141
       </uni-forms-item>
139
 
142
 
140
       <!-- 备注 -->
143
       <!-- 备注 -->
149
 
152
 
150
       <!-- 操作按钮 -->
153
       <!-- 操作按钮 -->
151
       <view class="form-actions">
154
       <view class="form-actions">
155
+        <uv-button style="margin-bottom: 5px;" type="warning" @click="saves">保存</uv-button>
152
         <uv-button type="primary" @click="submit" v-if="taskName == '设备申请'">提交申请</uv-button>
156
         <uv-button type="primary" @click="submit" v-if="taskName == '设备申请'">提交申请</uv-button>
153
         <template v-else>
157
         <template v-else>
154
-          <uv-button type="warning" @click="saves">保存</uv-button>
155
           <uv-button type="primary" @click="completeApply">完成审批</uv-button>
158
           <uv-button type="primary" @click="completeApply">完成审批</uv-button>
156
         </template>
159
         </template>
157
       </view>
160
       </view>
186
   data() {
189
   data() {
187
     return {
190
     return {
188
       form: {
191
       form: {
192
+        user: {
193
+          nickName: ''
194
+        },
195
+        dept: {
196
+          deptName: ''
197
+        },
189
         projectId: '',
198
         projectId: '',
190
         applyDate: '',
199
         applyDate: '',
191
         applyReason: '',
200
         applyReason: '',
194
         days: 0,
203
         days: 0,
195
         dispatchComment: '',
204
         dispatchComment: '',
196
         managerComment: '',
205
         managerComment: '',
206
+        devices: [],
197
         repairDevices: [],
207
         repairDevices: [],
198
         remark: '',
208
         remark: '',
199
         returnDate: ''
209
         returnDate: ''
200
       },
210
       },
211
+      dateRange: [],
201
       rules: {
212
       rules: {
202
         projectId: {
213
         projectId: {
203
           rules: [{ required: true, errorMessage: '请选择项目' }]
214
           rules: [{ required: true, errorMessage: '请选择项目' }]
208
         applyReason: {
219
         applyReason: {
209
           rules: [{ required: true, errorMessage: '请输入申领事由' }]
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
       applierUserName: '',
226
       applierUserName: '',
223
       selectDevice: [],
231
       selectDevice: [],
224
       deviceList: [],
232
       deviceList: [],
225
       modifyDeviceList: [],
233
       modifyDeviceList: [],
226
-      returnDevicesList: []
227
-    }
234
+      returnDevicesList: [],
235
+      formTotal: 0
236
+    };
228
   },
237
   },
229
   methods: {
238
   methods: {
230
     initForm() {
239
     initForm() {
231
       getDeviceApproval(this.taskForm.formId).then(res => {
240
       getDeviceApproval(this.taskForm.formId).then(res => {
232
         if (res.data) {
241
         if (res.data) {
242
+          this.formTotal = 1;
233
           this.form = res.data;
243
           this.form = res.data;
234
           this.deviceList = res.data.devices || [];
244
           this.deviceList = res.data.devices || [];
235
           this.modifyDeviceList = res.data.modifyDevices || [];
245
           this.modifyDeviceList = res.data.modifyDevices || [];
236
           this.returnDevicesList = res.data.returnDevices || [];
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
         } else {
250
         } else {
251
+          this.form.applier = this.$store.getters.userId;
238
           this.form.applyDate = parseTime(new Date(), "{y}-{m}-{d}");
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
     handleConfirm(project) {
260
     handleConfirm(project) {
243
       this.selectedProject = project;
261
       this.selectedProject = project;
248
       this.deviceList = Array.isArray(devices) ? devices : [devices];
266
       this.deviceList = Array.isArray(devices) ? devices : [devices];
249
       this.form.devices = this.deviceList.map(item => item.deviceId);
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
     calculateDay() {
277
     calculateDay() {
252
       if (this.form.beginDate && this.form.endDate) {
278
       if (this.form.beginDate && this.form.endDate) {
253
         const begin = new Date(this.form.beginDate);
279
         const begin = new Date(this.form.beginDate);
254
         const end = new Date(this.form.endDate);
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
     replaceRowData(row, index) {
286
     replaceRowData(row, index) {
278
       });
306
       });
279
     },
307
     },
280
     saves() {
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
         uni.showToast({
366
         uni.showToast({
283
-          title: '保存成功',
284
-          icon: 'success'
367
+          title: error.message || '保存失败',
368
+          icon: 'error'
285
         });
369
         });
286
-      });
370
+      }
287
     },
371
     },
288
     completeApply() {
372
     completeApply() {
289
       modifyDeviceApproval(this.form).then(res => {
373
       modifyDeviceApproval(this.form).then(res => {
320
 }
404
 }
321
 
405
 
322
 .date-range {
406
 .date-range {
323
-  display: flex;
407
+  // display: flex;
324
   flex-wrap: wrap;
408
   flex-wrap: wrap;
325
   gap: 32rpx;
409
   gap: 32rpx;
326
 }
410
 }
327
 
411
 
328
 .form-actions {
412
 .form-actions {
329
-  display: flex;
330
   justify-content: center;
413
   justify-content: center;
331
   gap: 32rpx;
414
   gap: 32rpx;
332
   margin-top: 32rpx;
415
   margin-top: 32rpx;

+ 1
- 1
oa-ui/src/views/flowable/form/oa/deviceForm.vue View File

2
  * @Author: ysh
2
  * @Author: ysh
3
  * @Date: 2024-03-07 13:44:39
3
  * @Date: 2024-03-07 13:44:39
4
  * @LastEditors: Please set LastEditors
4
  * @LastEditors: Please set LastEditors
5
- * @LastEditTime: 2025-01-13 09:43:18
5
+ * @LastEditTime: 2025-04-14 15:27:27
6
 -->
6
 -->
7
 
7
 
8
 <template>
8
 <template>

Loading…
Cancel
Save