fuliqi
2024-11-28 b1c351f8a0d16008524d4f17bb1948f836f5a7b0
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
110
111
112
113
114
115
116
117
118
119
120
<template>
  <div class="policy-info">
    <el-form ref="demoFormRef" :disabled="disabled" :model="documentsInfoForm" class="dialog_form">
      <el-row :gutter="0">
        <el-col :span="20">
          <el-form-item label="附件:" label-width="100px" prop="appendix" style="width: 100%">
            <div style="display: flex;gap: 10px">
              <file-upload v-model="documentsInfoForm.fileList"
                           :fileType="accept"
                           :isShowTip="false"/>
              <div v-if="documentsInfoForm.fileList.length === 0" style="color: #a9afbc">支持上传PDF格式文件</div>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
 
<script>
 
import {
  addProjectInvestmentFunding,
  editProjectInvestmentFunding,
  getProjectInvestmentFundingById
} from "@/api/projectEngineering/projectInvestmentFunding";
import Cookies from "js-cookie";
import {addDocumentInfo, getDocumentInfoById} from "@/api/projectEngineering/projectInfo";
 
export default {
  props: {
    disabled: {
      required: true,
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      documentsInfoForm: {
        fileList: [],
        projectId: ''
      },
      projectForm: {},
      accept: ['pdf'],
    };
  },
  methods: {
    getDocumentsInfo() {
      getDocumentInfoById(this.documentsInfoForm.projectId).then(res => {
        this.documentsInfoForm = res.data;
        if(!this.documentsInfoForm.fileList) {
          this.documentsInfoForm.fileList = []
        }
      });
    },
    submit() {
      if (!this.projectForm.id) {
        this.$message.error("请先保存投资管理基本信息")
      } else {
        this.documentsInfoForm.projectId = this.projectForm.id;
        addDocumentInfo(this.documentsInfoForm).then(response => {
          this.$modal.msgSuccess("提交成功");
        });
      }
    },
  },
  mounted() {
    this.documentsInfoForm.projectId = this.$route.query.projectId;
    const documentsInfoForm = Cookies.get("documentsInfoForm");
    const projectForm = Cookies.get("projectForm");
 
    const parsedDocumentsInfoForm = documentsInfoForm ? JSON.parse(documentsInfoForm) : null;
    const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null;
    if (parsedDocumentsInfoForm) {
      this.documentsInfoForm = parsedDocumentsInfoForm
    }
    if (parsedProjectForm) {
      this.projectForm = parsedProjectForm
    }
    // 如果路由存在id且没有缓存,视为编辑或查看,调用api
    if (this.documentsInfoForm.projectId && !parsedDocumentsInfoForm) {
      this.getDocumentsInfo();
    }
  },
  beforeDestroy() {
    Cookies.set("documentsInfoForm", JSON.stringify(this.documentsInfoForm));
  },
 
};
</script>
 
<style lang="scss" scoped>
.item {
  width: 100%;
}
 
.documents-info-items {
  display: inline-block;
  width: 100%;
  height: 130px;
  border: 1px solid #dbdeea;
  background-color: #f3f7fc;
 
  .upload-files-items {
    margin-top: 10px;
    margin-left: 50px;
  }
}
 
.input-row {
  display: flex;
  width: 100%;
 
  .input-item {
    width: 100%;
  }
}
 
</style>