Pārlūkot izejas kodu

fix(views): 修复表单关闭后重置问题并优化代码结构

修复多个视图组件中表单关闭后未重置的问题,添加@closed和destroy-on-close事件
统一使用Object.assign替代直接赋值进行表单重置
优化rateList组件中班次和大队名称的显示逻辑
huoyi 1 dienu atpakaļ
vecāks
revīzija
ec0fdb1f82

+ 5 - 3
src/views/blockingData/dailyLuggageCheckInList/index.vue

@@ -83,7 +83,7 @@
83 83
       v-model:limit="queryParams.pageSize" @pagination="getList" />
84 84
 
85 85
     <!-- 添加或修改每日行李查缉对话框 -->
86
-    <el-dialog :title="title" v-model="open" width="800px" append-to-body>
86
+    <el-dialog :title="title" v-model="open" width="800px" append-to-body @closed="reset" destroy-on-close>
87 87
       <el-form ref="dailyLuggageCheckInRef" :model="form" :rules="rules" label-width="140px">
88 88
         <el-row :gutter="20">
89 89
           <el-col :span="12">
@@ -382,7 +382,7 @@ function cancel() {
382 382
 
383 383
 // 表单重置
384 384
 function reset() {
385
-  form.value = {
385
+  Object.assign(form, {
386 386
     id: null,
387 387
     statDate: null,
388 388
     shiftType: null,
@@ -416,7 +416,7 @@ function reset() {
416 416
     aiMarkTotal: 0,
417 417
     aiMissImageTotal: 0,
418 418
     aiErrorImageTotal: 0
419
-  }
419
+  })
420 420
   proxy.resetForm('dailyLuggageCheckInRef')
421 421
 }
422 422
 
@@ -473,12 +473,14 @@ function submitForm() {
473 473
         updateDailyLuggageCheckIn(form).then(response => {
474 474
           proxy.$modal.msgSuccess('修改成功')
475 475
           open.value = false
476
+          reset()
476 477
           getList()
477 478
         })
478 479
       } else {
479 480
         addDailyLuggageCheckIn(form).then(response => {
480 481
           proxy.$modal.msgSuccess('新增成功')
481 482
           open.value = false
483
+          reset()
482 484
           getList()
483 485
         })
484 486
       }

+ 3 - 1
src/views/blockingData/dailyLuggageInspectionScheduleByTime/index.vue

@@ -67,7 +67,7 @@
67 67
     <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
68 68
       v-model:limit="queryParams.pageSize" @pagination="getList" />
69 69
 
70
-    <el-dialog :title="title" v-model="open" width="1000px" append-to-body>
70
+    <el-dialog :title="title" v-model="open" width="1000px" append-to-body @closed="reset" destroy-on-close>
71 71
       <el-form ref="dailyLuggageInspectionScheduleByTimeRef" :model="form" :rules="rules" label-width="250px">
72 72
         <el-row :gutter="20">
73 73
           <el-col :span="12">
@@ -355,12 +355,14 @@ function submitForm() {
355 355
         updateDailyLuggageInspectionScheduleByTime(form).then(response => {
356 356
           proxy.$modal.msgSuccess('修改成功')
357 357
           open.value = false
358
+          reset()
358 359
           getList()
359 360
         })
360 361
       } else {
361 362
         addDailyLuggageInspectionScheduleByTime(form).then(response => {
362 363
           proxy.$modal.msgSuccess('新增成功')
363 364
           open.value = false
365
+          reset()
364 366
           getList()
365 367
         })
366 368
       }

+ 3 - 1
src/views/blockingData/missedInspectionList/index.vue

@@ -103,7 +103,7 @@
103 103
       v-model:limit="queryParams.pageSize" @pagination="getList" />
104 104
 
105 105
     <!-- 添加或修改漏检对话框 -->
106
-    <el-dialog :title="title" v-model="open" width="1000px" append-to-body>
106
+    <el-dialog :title="title" v-model="open" width="1000px" append-to-body @closed="reset" destroy-on-close>
107 107
       <el-form ref="missedInspectionRef" :model="form" :rules="rules" label-width="140px">
108 108
         <el-row :gutter="20">
109 109
           <el-col :span="12">
@@ -673,12 +673,14 @@ function submitForm() {
673 673
         updateMissedInspection(form).then(response => {
674 674
           proxy.$modal.msgSuccess('修改成功')
675 675
           open.value = false
676
+          reset()
676 677
           getList()
677 678
         })
678 679
       } else {
679 680
         addMissedInspection(form).then(response => {
680 681
           proxy.$modal.msgSuccess('新增成功')
681 682
           open.value = false
683
+          reset()
682 684
           getList()
683 685
         })
684 686
       }

+ 20 - 12
src/views/blockingData/rateList/index.vue

@@ -44,15 +44,17 @@
44 44
     <el-table v-loading="loading" :data="rateList" @selection-change="handleSelectionChange">
45 45
       <el-table-column type="selection" width="55" align="center" />
46 46
       <el-table-column label="日期" align="center" prop="statDate" />
47
-      <el-table-column label="旅检国内区域平均速率(高峰期时段)" align="center" prop="travelInspectionDomesticAvgRatePeak" min-width="120"/>
47
+      <el-table-column label="旅检国内区域平均速率(高峰期时段)" align="center" prop="travelInspectionDomesticAvgRatePeak"
48
+        min-width="120" />
48 49
       <el-table-column label="当班大队" align="center" prop="dutyBrigadeName" />
49 50
       <el-table-column label="T1-A区速率(高峰期时段)" align="center" prop="t1AAreaRatePeak" />
50 51
       <el-table-column label="T1-B区速率(高峰期时段)" align="center" prop="t1BAreaRatePeak" />
51 52
       <el-table-column label="T2-国内速率(高峰期时段)" align="center" prop="t2DomesticRatePeak" />
52 53
       <el-table-column label="T2-国际速率(高峰期时段)" align="center" prop="t2InternationalRatePeak" />
53
-      <el-table-column label="班次" align="center" prop="shift" />
54
+      <el-table-column label="班次" align="center" prop="shiftDesc" />
54 55
       <el-table-column label="T2-中转(高峰期时段)" align="center" prop="t2TransferRatePeak" />
55
-      <el-table-column label="国际及中转区域平均速率(高峰期时段)" align="center" prop="internationalTransferAvgRatePeak" min-width="120"/>
56
+      <el-table-column label="国际及中转区域平均速率(高峰期时段)" align="center" prop="internationalTransferAvgRatePeak"
57
+        min-width="120" />
56 58
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
57 59
         <template #default="scope">
58 60
           <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
@@ -66,7 +68,7 @@
66 68
     <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
67 69
       v-model:limit="queryParams.pageSize" @pagination="getList" />
68 70
 
69
-    <el-dialog :title="title" v-model="open" width="1000px" append-to-body>
71
+    <el-dialog :title="title" v-model="open" width="1000px" append-to-body @closed="reset" destroy-on-close>
70 72
       <el-form ref="rateListRef" :model="form" :rules="rules" label-width="280px">
71 73
         <el-row :gutter="20">
72 74
           <el-col :span="12">
@@ -170,7 +172,7 @@
170 172
 
171 173
 <script setup>
172 174
 import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
173
-import { listRate, getRate, delRate, addRate, updateRate, exportRate,downloadTemplate } from '@/api/blockingData/rateList'
175
+import { listRate, getRate, delRate, addRate, updateRate, exportRate, downloadTemplate } from '@/api/blockingData/rateList'
174 176
 import { listDept } from '@/api/system/dept'
175 177
 import { getToken } from '@/utils/auth'
176 178
 import { UploadFilled } from '@element-plus/icons-vue'
@@ -232,7 +234,7 @@ function getList() {
232 234
 function getDeptList() {
233 235
   listDept({}).then(response => {
234 236
     const deptList = response.data || []
235
-    brigadeOptions.value = deptList.filter(item => item.deptType === 'BRIGADE'&& [311, 314, 315].includes(item.deptId)).map(item => ({
237
+    brigadeOptions.value = deptList.filter(item => item.deptType === 'BRIGADE' && [311, 314, 315].includes(item.deptId)).map(item => ({
236 238
       value: item.deptId,
237 239
       label: item.deptName
238 240
     }))
@@ -245,7 +247,7 @@ function cancel() {
245 247
 }
246 248
 
247 249
 function reset() {
248
-  form.value = {
250
+  Object.assign(form, {
249 251
     id: null,
250 252
     statDate: null,
251 253
     dutyBrigadeId: null,
@@ -258,7 +260,7 @@ function reset() {
258 260
     t2InternationalRatePeak: 0,
259 261
     t2TransferRatePeak: 0,
260 262
     internationalTransferAvgRatePeak: 0
261
-  }
263
+  })
262 264
   proxy.resetForm('rateListRef')
263 265
 }
264 266
 
@@ -299,21 +301,27 @@ function handleUpdate(row) {
299 301
 function submitForm() {
300 302
   proxy.$refs.rateListRef.validate(valid => {
301 303
     if (valid) {
302
-      // if (form.shift) {
303
-      //   const shiftItem = shift.value.find(item => item.value === form.shift)
304
-      //   form.shiftDesc = shiftItem ? shiftItem.label : null
305
-      // }
304
+      if (form.shift) {
305
+        const shiftItem = shift.value.find(item => item.value === form.shift)
306
+        form.shiftDesc = shiftItem ? shiftItem.label : null
307
+      }
308
+      if (form.dutyBrigadeId) {
309
+        const brigadeItem = brigadeOptions.value.find(item => item.value === form.dutyBrigadeId)
310
+        form.dutyBrigadeName = brigadeItem ? brigadeItem.label : null
311
+      }
306 312
 
307 313
       if (form.id != null) {
308 314
         updateRate(form).then(response => {
309 315
           proxy.$modal.msgSuccess('修改成功')
310 316
           open.value = false
317
+          reset()
311 318
           getList()
312 319
         })
313 320
       } else {
314 321
         addRate(form).then(response => {
315 322
           proxy.$modal.msgSuccess('新增成功')
316 323
           open.value = false
324
+          reset()
317 325
           getList()
318 326
         })
319 327
       }