|
@@ -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) => ({
|