ソースを参照

货权重量管理

FEI 2週間前
コミット
4b34238fe3
1個のファイルの変更81行の追加8行の削除
  1. 81
    8
      src/views/sto/main/cargo.vue

+ 81
- 8
src/views/sto/main/cargo.vue ファイルの表示

@@ -49,12 +49,28 @@
49 49
             <span>{{ scope.row.useWeight ? scope.row.useWeight.toFixed(3) : '0.000' }}</span>
50 50
           </template>
51 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 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 74
           </template>
59 75
         </el-table-column>
60 76
         <el-table-column label="操作" width="120" fixed="right">
@@ -247,7 +263,8 @@ export default {
247 263
         weight: '',
248 264
         ordNo: '',
249 265
         remark: '',
250
-        enableStatus: '0' // 新增启用状态字段
266
+        enableStatus: '0',
267
+        sumWeight: 0
251 268
       },
252 269
       // 分页相关
253 270
       currentPage: 1,
@@ -270,6 +287,8 @@ export default {
270 287
       logPageSize: 10,
271 288
       // 当前选中的货权记录(用于日志查询)
272 289
       currentCargoRecord: null,
290
+      // 启用状态修改加载状态
291
+      enableStatusLoading: false,
273 292
       // 表单验证规则
274 293
       rules: {
275 294
         uperCustomerId: [
@@ -296,7 +315,7 @@ export default {
296 315
         return true
297 316
       }
298 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 321
   mounted() {
@@ -341,7 +360,8 @@ export default {
341 360
         weight: '',
342 361
         ordNo: '',
343 362
         remark: '',
344
-        enableStatus: '0'
363
+        enableStatus: '0',
364
+        sumWeight: 0
345 365
       }
346 366
       this.dialogVisible = true
347 367
       // 清除表单验证
@@ -433,6 +453,59 @@ export default {
433 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 510
     handleSizeChange(val) {
438 511
       this.pageSize = val

読み込み中…
キャンセル
保存