Browse Source

货权重量管理

FEI 2 weeks ago
parent
commit
4b34238fe3
1 changed files with 81 additions and 8 deletions
  1. 81
    8
      src/views/sto/main/cargo.vue

+ 81
- 8
src/views/sto/main/cargo.vue View File

49
             <span>{{ scope.row.useWeight ? scope.row.useWeight.toFixed(3) : '0.000' }}</span>
49
             <span>{{ scope.row.useWeight ? scope.row.useWeight.toFixed(3) : '0.000' }}</span>
50
           </template>
50
           </template>
51
         </el-table-column>
51
         </el-table-column>
52
-        <!-- 新增启用状态列 -->
53
-        <el-table-column prop="enableStatus" label="启用状态" width="100" align="center">
52
+        <!-- 启用状态列 -->
53
+<!--        <el-table-column prop="enableStatus" label="启用状态" width="100" align="center">
54
           <template #default="scope">
54
           <template #default="scope">
55
-            <el-tag :type="scope.row.enableStatus === '1' ? 'success' : 'info'">
56
-              {{ scope.row.enableStatus === '1' ? '已启用' : '未启用' }}
57
-            </el-tag>
55
+            <el-switch
56
+                v-model="scope.row.enableStatus"
57
+                :active-value="'1'"
58
+                :inactive-value="'0'"
59
+                @change="handleEnableStatusChange(scope.row)"
60
+            />
61
+          </template>
62
+        </el-table-column>-->
63
+        <el-table-column label="启用状态操作" width="120" fixed="right">
64
+          <template #default="scope">
65
+            <el-button
66
+                plain
67
+                :type="scope.row.enableStatus === '1' ? 'danger' : 'success'"
68
+                size="mini"
69
+                @click="handleToggleEnableStatus(scope.row)"
70
+                :loading="enableStatusLoading"
71
+            >
72
+              {{ scope.row.enableStatus === '1' ? '禁用' : '启用' }}
73
+            </el-button>
58
           </template>
74
           </template>
59
         </el-table-column>
75
         </el-table-column>
60
         <el-table-column label="操作" width="120" fixed="right">
76
         <el-table-column label="操作" width="120" fixed="right">
247
         weight: '',
263
         weight: '',
248
         ordNo: '',
264
         ordNo: '',
249
         remark: '',
265
         remark: '',
250
-        enableStatus: '0' // 新增启用状态字段
266
+        enableStatus: '0',
267
+        sumWeight: 0
251
       },
268
       },
252
       // 分页相关
269
       // 分页相关
253
       currentPage: 1,
270
       currentPage: 1,
270
       logPageSize: 10,
287
       logPageSize: 10,
271
       // 当前选中的货权记录(用于日志查询)
288
       // 当前选中的货权记录(用于日志查询)
272
       currentCargoRecord: null,
289
       currentCargoRecord: null,
290
+      // 启用状态修改加载状态
291
+      enableStatusLoading: false,
273
       // 表单验证规则
292
       // 表单验证规则
274
       rules: {
293
       rules: {
275
         uperCustomerId: [
294
         uperCustomerId: [
296
         return true
315
         return true
297
       }
316
       }
298
       // 编辑时,如果启用状态为1且可使用量为0,则禁用减少操作
317
       // 编辑时,如果启用状态为1且可使用量为0,则禁用减少操作
299
-      return this.form.enableStatus === '1' && this.form.sumWeight === 0
318
+      return this.form.enableStatus === '1' && (this.form.sumWeight === 0 || this.form.sumWeight === null)
300
     }
319
     }
301
   },
320
   },
302
   mounted() {
321
   mounted() {
341
         weight: '',
360
         weight: '',
342
         ordNo: '',
361
         ordNo: '',
343
         remark: '',
362
         remark: '',
344
-        enableStatus: '0'
363
+        enableStatus: '0',
364
+        sumWeight: 0
345
       }
365
       }
346
       this.dialogVisible = true
366
       this.dialogVisible = true
347
       // 清除表单验证
367
       // 清除表单验证
433
       this.dialogVisible = false
453
       this.dialogVisible = false
434
     },
454
     },
435
 
455
 
456
+    // 切换启用状态
457
+    handleToggleEnableStatus(row) {
458
+      const newStatus = row.enableStatus === '1' ? '0' : '1'
459
+      const action = newStatus === '1' ? '启用' : '禁用'
460
+
461
+      this.$confirm(`确定要${action}此货权记录吗?`, '提示', {
462
+        type: 'warning'
463
+      }).then(() => {
464
+        this.updateEnableStatus(row.id, newStatus)
465
+      }).catch(() => {})
466
+    },
467
+
468
+    // 更新启用状态
469
+    updateEnableStatus(id, enableStatus) {
470
+      this.enableStatusLoading = true
471
+      const url = 'sto/Cargo/updateEnableStatus'
472
+      const param = {
473
+        id: id,
474
+        enableStatus: enableStatus
475
+      }
476
+
477
+      axios.post(url, param).then(response => {
478
+        if (response.data.code == 0) {
479
+          this.$message({
480
+            message: '操作成功',
481
+            type: 'success',
482
+          })
483
+          this.getTableData() // 刷新表格数据
484
+        } else {
485
+          this.$message({
486
+            type: 'error',
487
+            message: '操作失败:' + response.data.msg
488
+          })
489
+          // 操作失败,刷新表格以恢复正确的状态
490
+          this.getTableData()
491
+        }
492
+        this.enableStatusLoading = false
493
+      }).catch(error => {
494
+        this.enableStatusLoading = false
495
+        this.$message({
496
+          type: 'error',
497
+          message: '请求失败:' + error
498
+        })
499
+        // 请求失败,刷新表格以恢复正确的状态
500
+        this.getTableData()
501
+      })
502
+    },
503
+
504
+    // 开关状态改变事件
505
+    handleEnableStatusChange(row) {
506
+      this.updateEnableStatus(row.id, row.enableStatus)
507
+    },
508
+
436
     // 分页大小改变
509
     // 分页大小改变
437
     handleSizeChange(val) {
510
     handleSizeChange(val) {
438
       this.pageSize = val
511
       this.pageSize = val

Loading…
Cancel
Save