瀏覽代碼

refactor(seizeData,collectWaitingAreaData): 优化表单与数据处理逻辑

1. 移除查获数据页面的自动计算总数相关UI和逻辑代码
2. 将候检区数据页面的时间选择器改为下拉选择,简化时间格式处理
huoyi 1 月之前
父節點
當前提交
547938d265
共有 2 個文件被更改,包括 16 次插入74 次删除
  1. 15 24
      src/views/runData/collectWaitingAreaData/index.vue
  2. 1 50
      src/views/runData/seizeData/index.vue

+ 15 - 24
src/views/runData/collectWaitingAreaData/index.vue

@@ -7,9 +7,11 @@
7
           style="width: 200px" />
7
           style="width: 200px" />
8
       </el-form-item>
8
       </el-form-item>
9
       <el-form-item label="时间段" prop="timeSlot">
9
       <el-form-item label="时间段" prop="timeSlot">
10
-        <el-time-picker v-model="queryParams.timeSlot" is-range range-separator="-" start-placeholder="开始时间"
11
-          end-placeholder="结束时间" value-format="HH:mm" format="HH:mm" placeholder="请选择时间段" clearable
12
-          style="width: 200px" />
10
+        <el-select v-model="queryParams.timeSlot" placeholder="请选择时间段" clearable style="width: 200px">
11
+          <el-option label="00:00-08:00" value="00:00-08:00" />
12
+          <el-option label="08:00-17:00" value="08:00-17:00" />
13
+          <el-option label="17:00-24:00" value="17:00-24:00" />
14
+        </el-select>
13
       </el-form-item>
15
       </el-form-item>
14
       <el-form-item>
16
       <el-form-item>
15
         <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
17
         <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
@@ -89,8 +91,11 @@
89
           </el-col>
91
           </el-col>
90
           <el-col :span="12">
92
           <el-col :span="12">
91
             <el-form-item label="时间段" prop="timeSlot">
93
             <el-form-item label="时间段" prop="timeSlot">
92
-              <el-time-picker v-model="form.timeSlot" is-range range-separator="至" start-placeholder="开始时间"
93
-                end-placeholder="结束时间" value-format="HH:mm" format="HH:mm" placeholder="请选择时间段" style="width: 100%" />
94
+              <el-select v-model="form.timeSlot" placeholder="请选择时间段" style="width: 100%">
95
+                <el-option label="00:00-08:00" value="00:00-08:00" />
96
+                <el-option label="08:00-17:00" value="08:00-17:00" />
97
+                <el-option label="17:00-24:00" value="17:00-24:00" />
98
+              </el-select>
94
             </el-form-item>
99
             </el-form-item>
95
           </el-col>
100
           </el-col>
96
         </el-row>
101
         </el-row>
@@ -304,11 +309,7 @@ const { queryParams, form, rules } = toRefs(data)
304
 /** 查询候检区数据列表 */
309
 /** 查询候检区数据列表 */
305
 function getList() {
310
 function getList() {
306
   loading.value = true
311
   loading.value = true
307
-  const params = { ...queryParams.value }
308
-  if (params.timeSlot && Array.isArray(params.timeSlot)) {
309
-    params.timeSlot = params.timeSlot.join('-')
310
-  }
311
-  listCollectWaitingAreaData(params).then(response => {
312
+  listCollectWaitingAreaData(queryParams.value).then(response => {
312
     collectWaitingAreaDataList.value = response.rows
313
     collectWaitingAreaDataList.value = response.rows
313
     total.value = response.total
314
     total.value = response.total
314
     loading.value = false
315
     loading.value = false
@@ -379,12 +380,7 @@ function handleUpdate(row) {
379
   reset()
380
   reset()
380
   const _id = row.id || ids.value
381
   const _id = row.id || ids.value
381
   getCollectWaitingAreaData(_id).then(response => {
382
   getCollectWaitingAreaData(_id).then(response => {
382
-    const data = response.data
383
-    // 转换时间段字符串为数组格式
384
-    if (data.timeSlot && typeof data.timeSlot === 'string' && data.timeSlot.includes('-')) {
385
-      data.timeSlot = data.timeSlot.split('-')
386
-    }
387
-    form.value = data
383
+    form.value = response.data
388
     open.value = true
384
     open.value = true
389
     title.value = "修改候检区数据"
385
     title.value = "修改候检区数据"
390
   })
386
   })
@@ -394,19 +390,14 @@ function handleUpdate(row) {
394
 function submitForm() {
390
 function submitForm() {
395
   proxy.$refs["collectWaitingAreaDataRef"].validate(valid => {
391
   proxy.$refs["collectWaitingAreaDataRef"].validate(valid => {
396
     if (valid) {
392
     if (valid) {
397
-      const submitData = { ...form.value }
398
-      // 转换时间段为字符串格式 08:00-17:00
399
-      if (submitData.timeSlot && Array.isArray(submitData.timeSlot)) {
400
-        submitData.timeSlot = submitData.timeSlot.join('-')
401
-      }
402
-      if (submitData.id != null) {
403
-        updateCollectWaitingAreaData(submitData).then(response => {
393
+      if (form.value.id != null) {
394
+        updateCollectWaitingAreaData(form.value).then(response => {
404
           proxy.$modal.msgSuccess("修改成功")
395
           proxy.$modal.msgSuccess("修改成功")
405
           open.value = false
396
           open.value = false
406
           getList()
397
           getList()
407
         })
398
         })
408
       } else {
399
       } else {
409
-        addCollectWaitingAreaData(submitData).then(response => {
400
+        addCollectWaitingAreaData(form.value).then(response => {
410
           proxy.$modal.msgSuccess("新增成功")
401
           proxy.$modal.msgSuccess("新增成功")
411
           open.value = false
402
           open.value = false
412
           getList()
403
           getList()

+ 1 - 50
src/views/runData/seizeData/index.vue

@@ -170,13 +170,6 @@
170
             </el-form-item>
170
             </el-form-item>
171
           </el-col>
171
           </el-col>
172
         </el-row>
172
         </el-row>
173
-        <el-row :gutter="20">
174
-          <el-col :span="8">
175
-            <el-form-item label="T1总数" prop="t1Total">
176
-              <el-input v-model="form.t1Total" placeholder="自动计算" readonly style="width: 100%" />
177
-            </el-form-item>
178
-          </el-col>
179
-        </el-row>
180
         
173
         
181
         <!-- T2区域 -->
174
         <!-- T2区域 -->
182
         <el-divider content-position="left">T2区域数据</el-divider>
175
         <el-divider content-position="left">T2区域数据</el-divider>
@@ -224,18 +217,6 @@
224
             </el-form-item>
217
             </el-form-item>
225
           </el-col>
218
           </el-col>
226
         </el-row>
219
         </el-row>
227
-        <el-row :gutter="20">
228
-          <el-col :span="8">
229
-            <el-form-item label="T2总数" prop="t2Total">
230
-              <el-input v-model="form.t2Total" placeholder="自动计算" readonly style="width: 100%" />
231
-            </el-form-item>
232
-          </el-col>
233
-          <el-col :span="8">
234
-            <el-form-item label="T1总数+T2总数" prop="grandTotal">
235
-              <el-input v-model="form.grandTotal" placeholder="自动计算" readonly style="width: 100%" />
236
-            </el-form-item>
237
-          </el-col>
238
-        </el-row>
239
       </el-form>
220
       </el-form>
240
       <template #footer>
221
       <template #footer>
241
         <div class="dialog-footer">
222
         <div class="dialog-footer">
@@ -410,30 +391,6 @@ const data = reactive({
410
 
391
 
411
 const { queryParams, form, rules } = toRefs(data)
392
 const { queryParams, form, rules } = toRefs(data)
412
 
393
 
413
-/** 计算总数 */
414
-function calculateTotals() {
415
-  // 计算T1总数
416
-  const t1Fields = ['t1FireSource', 't1Knife', 't1PoliceWeapon', 't1Firework', 't1LiveAnimal', 
417
-                   't1Corrosive', 't1FakeId', 't1Explosive', 't1Tool', 't1GunAmmo', 
418
-                   't1Illegal', 't1Other']
419
-  const t1Total = t1Fields.reduce((sum, field) => {
420
-    return sum + (form.value[field] || 0)
421
-  }, 0)
422
-  form.value.t1Total = t1Total
423
-  
424
-  // 计算T2总数
425
-  const t2Fields = ['t2FireSource', 't2Knife', 't2PoliceWeapon', 't2Firework', 't2LiveAnimal', 
426
-                   't2Corrosive', 't2FakeId', 't2Explosive', 't2Tool', 't2GunAmmo', 
427
-                   't2Illegal', 't2Other']
428
-  const t2Total = t2Fields.reduce((sum, field) => {
429
-    return sum + (form.value[field] || 0)
430
-  }, 0)
431
-  form.value.t2Total = t2Total
432
-  
433
-  // 计算总总数
434
-  form.value.total = t1Total + t2Total
435
-}
436
-
437
 /** 查询查获数据列表 */
394
 /** 查询查获数据列表 */
438
 function getList() {
395
 function getList() {
439
   loading.value = true
396
   loading.value = true
@@ -471,7 +428,6 @@ function reset() {
471
     t1GunAmmo: null,
428
     t1GunAmmo: null,
472
     t1Illegal: null,
429
     t1Illegal: null,
473
     t1Other: null,
430
     t1Other: null,
474
-    t1Total: null,
475
     // T2区域数据
431
     // T2区域数据
476
     t2FireSource: null,
432
     t2FireSource: null,
477
     t2Knife: null,
433
     t2Knife: null,
@@ -484,9 +440,7 @@ function reset() {
484
     t2Tool: null,
440
     t2Tool: null,
485
     t2GunAmmo: null,
441
     t2GunAmmo: null,
486
     t2Illegal: null,
442
     t2Illegal: null,
487
-    t2Other: null,
488
-    t2Total: null,
489
-    grandTotal: null
443
+    t2Other: null
490
   }
444
   }
491
   proxy.resetForm("seizeDataRef")
445
   proxy.resetForm("seizeDataRef")
492
 }
446
 }
@@ -532,9 +486,6 @@ function handleUpdate(row) {
532
 function submitForm() {
486
 function submitForm() {
533
   proxy.$refs["seizeDataRef"].validate(valid => {
487
   proxy.$refs["seizeDataRef"].validate(valid => {
534
     if (valid) {
488
     if (valid) {
535
-      // 提交前重新计算总数
536
-      calculateTotals()
537
-      
538
       if (form.value.id != null) {
489
       if (form.value.id != null) {
539
         updateSeizeData(form.value).then(response => {
490
         updateSeizeData(form.value).then(response => {
540
           proxy.$modal.msgSuccess("修改成功")
491
           proxy.$modal.msgSuccess("修改成功")