<!--
 * @Author: wrh
 * @Date: 2024-04-26 17:52:02
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2025-05-27 16:06:46
-->
<template>
  <div class="app-container" v-loading="loading">
    <el-empty description="预算未编制，等待项目负责人编制" v-if="!haveBudget"></el-empty>
    <div v-if="haveBudget">
      <!-- <h3 class="text-center">{{ title }}</h3> -->
      <div>
        <budget-info :taskForm="taskForm" v-if="isOld"></budget-info>
        <new-budget-info :taskForm="taskForm" v-else></new-budget-info>
      </div>
    </div>
  </div>
</template>

<script>
import { listBudget } from "@/api/oa/budget/budget";
import { listBudgetCar } from "@/api/oa/budget/budgetCar";
import { listBudgetDevice } from "@/api/oa/budget/budgetDevice";
import { listBudgetSettle } from "@/api/oa/budget/budgetSettle";
import { listBudgetStaff } from "@/api/oa/budget/budgetStaff";
import { listProjectWork } from "@/api/oa/project/projectWork";
import BudgetInfo from "../budget/budgetInfo.vue";
import NewBudgetInfo from "../budget/adjust/newBudgetInfo.vue";
export default {
  components: {
    BudgetInfo,
    NewBudgetInfo,
  },
  props: {
    taskForm: Object,
    require: true,
  },
  computed: {
    projectNumber() {
      return this.$store.state.projectProcess.projectNumber;
    },
    projectName() {
      return this.$store.state.projectProcess.projectName;
    },
  },
  data() {
    return {
      haveBudget: false,
      title: "",
      form: {},
      loading: true,
      budgetId: '',
      isOld: false,
    };
  },
  mounted() {
    this.initBudget();
    setTimeout(() => {
      this.title = "【" + this.projectNumber + "-" + this.projectName + "】项目预算";
      this.loading = false;
    }, 500);
  },
  methods: {
    initBudget() {
      let projectId = this.taskForm.formId;
      listBudget({ projectId }).then(res => {
        if (res.total != 0) {
          this.haveBudget = true;
          this.budgetId = res.rows[0].budgetId;
          if (res.rows[0].project.projectNumber.substring(0, 4) >= 2025) {
            this.isOld = false;
          } else {
            this.isOld = true;
          }
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
