fuliqi
2024-11-29 7adbf0551f6a6b307e66cdd6537ab45fc5a2bf11
src/views/projectEngineering/projectLibrary/component/PolicyInfo.vue
@@ -10,10 +10,10 @@
        <el-col :span="20">
          <el-form-item label="符合行业政策:" label-width="180px" prop="industryPolicy" style="width: 100%">
            <div style="display: flex">
              <file-upload v-model="policyInfoForm.fileList"
              <file-upload v-model="fileList"
                           :fileType="accept"
                           :isShowTip="false"/>
              <div v-if="policyInfoForm.fileList.length === 0" style="color: #a9afbc; margin-left: 10px">
              <div v-if="fileList.length === 0" style="color: #a9afbc; margin-left: 10px">
                支持上传PDF格式文件
              </div>
            </div>
@@ -159,7 +159,6 @@
<script>
import Cookies from "js-cookie";
import {
  addProjectInvestmentPolicyCompliance,
  editProjectInvestmentPolicyCompliance,
@@ -173,25 +172,26 @@
      type: Boolean,
      default: false,
      required: true
    }
    },
  },
  data() {
    return {
      policyInfoForm: {
        id: '',
        projectId: '',
        fileList: [],
        belongsToIndustryAdjustmentDirectory: null,
        belongsToWesternEncouragedDirectory: null,
        notBannedOrControlledProject: true,
        informationIsTrue: true,
        specialPlanningCompliance: '',
        energyCheck: null,
        annualEnergyConsumption: '',
        annualElectricityConsumption: '',
        noOnlyCheckType: null,
        remarks: ''
        // id: '',
        // projectId: '',
        // fileList: [],
        // belongsToIndustryAdjustmentDirectory: null,
        // belongsToWesternEncouragedDirectory: null,
        // notBannedOrControlledProject: true,
        // informationIsTrue: true,
        // specialPlanningCompliance: '',
        // energyCheck: null,
        // annualEnergyConsumption: '',
        // annualElectricityConsumption: '',
        // noOnlyCheckType: null,
        // remarks: ''
      },
      fileList: [],
      accept: ['pdf'],
      rules: {
        industrialPolicyProhibition: [{required: true, message: '请选择', trigger: 'change'}],
@@ -200,35 +200,36 @@
    };
  },
  mounted() {
    this.policyInfoForm.projectId = this.$route.query.projectId;
    const policyInfoForm = Cookies.get("policyInfoForm");
    const projectForm = Cookies.get("projectForm");
    const policyInfoForm = localStorage.getItem("policyInfoForm");
    const projectForm = localStorage.getItem("projectForm");
    const parsedPolicyInfoForm = policyInfoForm ? JSON.parse(policyInfoForm) : null;
    const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null;
    if (parsedPolicyInfoForm) {
      this.policyInfoForm = parsedPolicyInfoForm
      if(this.policyInfoForm.fileList) this.fileList = this.policyInfoForm.fileList
    }
    if (parsedProjectForm) {
      this.projectForm = parsedProjectForm
    }
    // 如果路由存在id且没有缓存,视为编辑或查看,调用api
    if (this.policyInfoForm.projectId && !parsedPolicyInfoForm) {
    if (this.$route.query.projectId && !parsedPolicyInfoForm) {
      this.getProjectInvestmentPolicyCompliance();
    } else {
      this.policyInfoForm.informationIsTrue= true;
      this.policyInfoForm.notBannedOrControlledProject = true;
    }
  },
  beforeDestroy() {
    Cookies.set("policyInfoForm", JSON.stringify(this.policyInfoForm));
    if(Object.keys(this.policyInfoForm).length !==0) localStorage.setItem("policyInfoForm", JSON.stringify(this.policyInfoForm));
  },
  methods: {
    getProjectInvestmentPolicyCompliance() {
      getProjectInvestmentPolicyComplianceById(this.policyInfoForm.projectId).then(res => {
      getProjectInvestmentPolicyComplianceById(this.$route.query.projectId).then(res => {
        this.policyInfoForm = res.data;
        if(!this.policyInfoForm.fileList) {
          this.policyInfoForm.fileList = []
        }
        this.policyInfoForm.notBannedOrControlledProject =true
        this.policyInfoForm.informationIsTrue =true
        this.policyInfoForm.notBannedOrControlledProject = true
        this.policyInfoForm.informationIsTrue = true
        this.fileList =this.policyInfoForm.fileList
      });
    },
    submit() {
@@ -238,7 +239,8 @@
        this.$refs["policyInfoFormRef"].validate(valid => {
          if (valid) {
            this.policyInfoForm.projectId = this.projectForm.id;
            if (this.policyInfoForm.id != null) {
            this.policyInfoForm.fileList = this.fileList
            if (this.policyInfoForm.id) {
              editProjectInvestmentPolicyCompliance(this.policyInfoForm).then(response => {
                this.$modal.msgSuccess("修改成功");
                //跳转到下个组件