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

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 7
           style="width: 200px" />
8 8
       </el-form-item>
9 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 15
       </el-form-item>
14 16
       <el-form-item>
15 17
         <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
@@ -89,8 +91,11 @@
89 91
           </el-col>
90 92
           <el-col :span="12">
91 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 99
             </el-form-item>
95 100
           </el-col>
96 101
         </el-row>
@@ -304,11 +309,7 @@ const { queryParams, form, rules } = toRefs(data)
304 309
 /** 查询候检区数据列表 */
305 310
 function getList() {
306 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 313
     collectWaitingAreaDataList.value = response.rows
313 314
     total.value = response.total
314 315
     loading.value = false
@@ -379,12 +380,7 @@ function handleUpdate(row) {
379 380
   reset()
380 381
   const _id = row.id || ids.value
381 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 384
     open.value = true
389 385
     title.value = "修改候检区数据"
390 386
   })
@@ -394,19 +390,14 @@ function handleUpdate(row) {
394 390
 function submitForm() {
395 391
   proxy.$refs["collectWaitingAreaDataRef"].validate(valid => {
396 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 395
           proxy.$modal.msgSuccess("修改成功")
405 396
           open.value = false
406 397
           getList()
407 398
         })
408 399
       } else {
409
-        addCollectWaitingAreaData(submitData).then(response => {
400
+        addCollectWaitingAreaData(form.value).then(response => {
410 401
           proxy.$modal.msgSuccess("新增成功")
411 402
           open.value = false
412 403
           getList()

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

@@ -170,13 +170,6 @@
170 170
             </el-form-item>
171 171
           </el-col>
172 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 174
         <!-- T2区域 -->
182 175
         <el-divider content-position="left">T2区域数据</el-divider>
@@ -224,18 +217,6 @@
224 217
             </el-form-item>
225 218
           </el-col>
226 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 220
       </el-form>
240 221
       <template #footer>
241 222
         <div class="dialog-footer">
@@ -410,30 +391,6 @@ const data = reactive({
410 391
 
411 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 395
 function getList() {
439 396
   loading.value = true
@@ -471,7 +428,6 @@ function reset() {
471 428
     t1GunAmmo: null,
472 429
     t1Illegal: null,
473 430
     t1Other: null,
474
-    t1Total: null,
475 431
     // T2区域数据
476 432
     t2FireSource: null,
477 433
     t2Knife: null,
@@ -484,9 +440,7 @@ function reset() {
484 440
     t2Tool: null,
485 441
     t2GunAmmo: null,
486 442
     t2Illegal: null,
487
-    t2Other: null,
488
-    t2Total: null,
489
-    grandTotal: null
443
+    t2Other: null
490 444
   }
491 445
   proxy.resetForm("seizeDataRef")
492 446
 }
@@ -532,9 +486,6 @@ function handleUpdate(row) {
532 486
 function submitForm() {
533 487
   proxy.$refs["seizeDataRef"].validate(valid => {
534 488
     if (valid) {
535
-      // 提交前重新计算总数
536
-      calculateTotals()
537
-      
538 489
       if (form.value.id != null) {
539 490
         updateSeizeData(form.value).then(response => {
540 491
           proxy.$modal.msgSuccess("修改成功")