wanshenmean
昨天 0b2869539598059704e1d208e2bcb18603b0fe0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<template>
  <div class="config-container">
    <el-card class="config-card">
      <template #header>
        <span>出库时效配置</span>
      </template>
      <el-form :model="form" label-width="180px" v-loading="loading">
        <el-form-item label="GW首放入库时效(小时)">
          <el-input-number
            v-model="form.gw1FirstHours"
            :min="0.01"
            :max="999"
            :precision="2"
            :step="1"
          />
        </el-form-item>
        <el-form-item label="GW二放入库时效(小时)">
          <el-input-number
            v-model="form.gw1SecondHours"
            :min="0.01"
            :max="999"
            :precision="2"
            :step="0.01"
          />
        </el-form-item>
        <el-form-item label="CW出库时效(小时)">
          <el-input-number
            v-model="form.cw1Hours"
            :min="0.01"
            :max="999"
            :precision="2"
            :step="1"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSave" :loading="saving">
            保存
          </el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>
 
<script>
import { ref, onMounted } from "vue";
import { ElMessage } from "element-plus";
import http from "@/api/http";
 
export default {
  name: "outboundTimeConfig",
  setup() {
    const loading = ref(false);
    const saving = ref(false);
    const form = ref({
      gw1FirstHours: 24,
      gw1SecondHours: 0.05,
      cw1Hours: 3,
    });
 
    /// 加载当前配置
    const loadConfig = async () => {
      loading.value = true;
      try {
        const res = await http.post("/api/OutboundTimeConfig/get", {}, false);
        if (res.status) {
          form.value = {
            gw1FirstHours: res.data.gw1FirstHours,
            gw1SecondHours: res.data.gw1SecondHours,
            cw1Hours: res.data.cw1Hours,
          };
        }
      } finally {
        loading.value = false;
      }
    };
 
    /// 保存配置
    const handleSave = async () => {
      saving.value = true;
      try {
        const res = await http.post("/api/OutboundTimeConfig/update", form.value, false);
        if (res.status) {
          ElMessage.success("保存成功");
        } else {
          ElMessage.error(res.message || "保存失败");
        }
      } finally {
        saving.value = false;
      }
    };
 
    onMounted(() => {
      loadConfig();
    });
 
    return { form, loading, saving, handleSave };
  },
};
</script>
 
<style scoped>
.config-container {
  padding: 20px;
}
.config-card {
  max-width: 600px;
}
</style>