wukai пре 3 дана
родитељ
комит
5f91127a13

+ 20 - 22
src/views/dashboard/input/cogs.vue

@@ -78,20 +78,20 @@
       <button @click="regenerateHistoricalData" class="add-btn">重新生成过去12个月</button>
       <table class="data-table">
         <thead>
-          <tr>
-            <th>月份</th>
-            <th v-for="(key, index) in ['n1', 'n2', 'n3', 'n4', 'n5', 'n6']" :key="index">{{ formData.curr[key] }}</th>
-          </tr>
+        <tr>
+          <th>月份</th>
+          <th v-for="(key, index) in ['n1', 'n2', 'n3', 'n4', 'n5', 'n6']" :key="index">{{ formData.curr[key] }}</th>
+        </tr>
         </thead>
         <tbody>
-          <tr v-for="(item, index) in formData.his.n1" :key="index">
-            <td>
-              <input type="text" v-model="formData.his.n1[index].month" placeholder="请输入月份">
-            </td>
-            <td v-for="(key, idx) in ['n1', 'n2', 'n3', 'n4', 'n5', 'n6']" :key="idx">
-              <input type="number" v-model="formData.his[key][index].value" placeholder="请输入值">
-            </td>
-          </tr>
+        <tr v-for="(item, index) in formData.his.n1" :key="index">
+          <td>
+            <input type="text" v-model="formData.his.n1[index].month" placeholder="请输入月份">
+          </td>
+          <td v-for="(key, idx) in ['n1', 'n2', 'n3', 'n4', 'n5', 'n6']" :key="idx">
+            <input type="number" v-model="formData.his[key][index].value" placeholder="请输入值">
+          </td>
+        </tr>
         </tbody>
       </table>
     </div>
@@ -184,6 +184,7 @@
 <script>
 import {onMounted, reactive, ref} from 'vue';
 import {getCogs, saveCogs} from "@/api/house/input";
+import {ElMessage} from 'element-plus';
 
 export default {
   name: "CogsInput",
@@ -247,15 +248,12 @@ export default {
       fetchData();
     });
 
-    const submitForm = async () => {
-      try {
-        await saveCogs(formData);
-        alert('表单提交成功');
-      } catch (error) {
-        console.error('提交失败:', error);
-        alert('提交失败');
-      }
+    const submitForm = () => {
+      saveCogs(formData).then(response => {
+        ElMessage.success("保存成功");
+      });
     };
+
     const generatePastMonths = () => {
       const months = [];
       const now = new Date();
@@ -271,7 +269,7 @@ export default {
     // 添加重新生成历史数据的方法
     const regenerateHistoricalData = () => {
       const newMonths = generatePastMonths();
-      
+
       // 更新每个成本项的月份数据
       const costKeys = ['n1', 'n2', 'n3', 'n4', 'n5', 'n6'];
       costKeys.forEach(key => {
@@ -282,7 +280,7 @@ export default {
           }));
         }
       });
-      
+
       // 更新总趋势数据的月份
       if (formData.trend && Array.isArray(formData.trend)) {
         formData.trend = formData.trend.map((item, index) => ({

+ 6 - 9
src/views/dashboard/input/rev.vue

@@ -254,7 +254,7 @@
 <script>
 import {onMounted, reactive, ref} from 'vue';
 import {getRev, saveRev} from "@/api/house/input";
-import {ElOption, ElSelect} from 'element-plus';
+import {ElMessage, ElOption, ElSelect} from 'element-plus';
 
 export default {
   name: "RevInput",
@@ -422,15 +422,12 @@ export default {
       formData.gpList.splice(index, 1);
     };
 
-    const submitForm = async () => {
-      try {
-        // 调用 saveRev 提交表单数据
-        await saveRev(formData);
-        console.log('表单提交成功');
-      } catch (error) {
-        console.error('提交失败:', error);
-      }
+    const submitForm = () => {
+      saveRev(formData).then(response => {
+        ElMessage.success("修改成功");
+      });
     };
+
     return {
       formData,
       countryOptions,

+ 6 - 9
src/views/dashboard/input/sales.vue

@@ -189,7 +189,7 @@
 <script>
 import {onMounted, reactive, ref} from 'vue';
 import {getSales, saveSales} from "@/api/house/input";
-
+import {ElMessage, ElOption, ElSelect} from 'element-plus';
 export default {
   name: "SalesInput",
   setup() {
@@ -221,14 +221,11 @@ export default {
     onMounted(() => {
       fetchData();
     });
-    const submitForm = async () => {
-      try {
-        // 调用 saveRev 提交表单数据
-        await saveSales(formData);
-        console.log('表单提交成功');
-      } catch (error) {
-        console.error('提交失败:', error);
-      }
+
+    const submitForm = () => {
+      saveSales(formData).then(response => {
+        ElMessage.success("保存成功");
+      });
     };
     const addSalesItem = () => {
       formData.sales = formData.sales.map((item, index) => ({