Преглед на файлове

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

修复多个视图组件中表单关闭后未重置的问题,添加@closed和destroy-on-close事件
统一使用Object.assign替代直接赋值进行表单重置
优化rateList组件中班次和大队名称的显示逻辑
huoyi преди 1 ден
родител
ревизия
ec0fdb1f82

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

@@ -83,7 +83,7 @@
83
       v-model:limit="queryParams.pageSize" @pagination="getList" />
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
       <el-form ref="dailyLuggageCheckInRef" :model="form" :rules="rules" label-width="140px">
87
       <el-form ref="dailyLuggageCheckInRef" :model="form" :rules="rules" label-width="140px">
88
         <el-row :gutter="20">
88
         <el-row :gutter="20">
89
           <el-col :span="12">
89
           <el-col :span="12">
@@ -382,7 +382,7 @@ function cancel() {
382
 
382
 
383
 // 表单重置
383
 // 表单重置
384
 function reset() {
384
 function reset() {
385
-  form.value = {
385
+  Object.assign(form, {
386
     id: null,
386
     id: null,
387
     statDate: null,
387
     statDate: null,
388
     shiftType: null,
388
     shiftType: null,
@@ -416,7 +416,7 @@ function reset() {
416
     aiMarkTotal: 0,
416
     aiMarkTotal: 0,
417
     aiMissImageTotal: 0,
417
     aiMissImageTotal: 0,
418
     aiErrorImageTotal: 0
418
     aiErrorImageTotal: 0
419
-  }
419
+  })
420
   proxy.resetForm('dailyLuggageCheckInRef')
420
   proxy.resetForm('dailyLuggageCheckInRef')
421
 }
421
 }
422
 
422
 
@@ -473,12 +473,14 @@ function submitForm() {
473
         updateDailyLuggageCheckIn(form).then(response => {
473
         updateDailyLuggageCheckIn(form).then(response => {
474
           proxy.$modal.msgSuccess('修改成功')
474
           proxy.$modal.msgSuccess('修改成功')
475
           open.value = false
475
           open.value = false
476
+          reset()
476
           getList()
477
           getList()
477
         })
478
         })
478
       } else {
479
       } else {
479
         addDailyLuggageCheckIn(form).then(response => {
480
         addDailyLuggageCheckIn(form).then(response => {
480
           proxy.$modal.msgSuccess('新增成功')
481
           proxy.$modal.msgSuccess('新增成功')
481
           open.value = false
482
           open.value = false
483
+          reset()
482
           getList()
484
           getList()
483
         })
485
         })
484
       }
486
       }

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

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

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

@@ -103,7 +103,7 @@
103
       v-model:limit="queryParams.pageSize" @pagination="getList" />
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
       <el-form ref="missedInspectionRef" :model="form" :rules="rules" label-width="140px">
107
       <el-form ref="missedInspectionRef" :model="form" :rules="rules" label-width="140px">
108
         <el-row :gutter="20">
108
         <el-row :gutter="20">
109
           <el-col :span="12">
109
           <el-col :span="12">
@@ -673,12 +673,14 @@ function submitForm() {
673
         updateMissedInspection(form).then(response => {
673
         updateMissedInspection(form).then(response => {
674
           proxy.$modal.msgSuccess('修改成功')
674
           proxy.$modal.msgSuccess('修改成功')
675
           open.value = false
675
           open.value = false
676
+          reset()
676
           getList()
677
           getList()
677
         })
678
         })
678
       } else {
679
       } else {
679
         addMissedInspection(form).then(response => {
680
         addMissedInspection(form).then(response => {
680
           proxy.$modal.msgSuccess('新增成功')
681
           proxy.$modal.msgSuccess('新增成功')
681
           open.value = false
682
           open.value = false
683
+          reset()
682
           getList()
684
           getList()
683
         })
685
         })
684
       }
686
       }

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

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