| | |
| | | </div> |
| | | </div> |
| | | <el-form-item prop="name" style="margin-top: 38px"> |
| | | <el-upload action="https://jsonplaceholder.typicode.com/posts/" :file-list="fileList"> |
| | | <el-upload action="#" :file-list="fileList" :http-request="handleUpload" |
| | | :before-upload="beforeUpload" :on-preview="handlePreview" :on-remove="handleRemove"> |
| | | <el-button size="small" type="primary">点击上传</el-button> |
| | | <div slot="tip" class="el-upload__tip">支持任意格式文件上传</div> |
| | | </el-upload> |
| | | </el-form-item> |
| | | <div class="header-title" style="width: 100%;"> |
| | |
| | | </el-form> |
| | | </Card> |
| | | <chooseProject @submit="getProjectData" :show="showChoose" @close="showChoose = false"></chooseProject> |
| | | <SelectMember :projectId="projectData.length&&projectData[0].id" title="选择菌种实验员" ref="selectMember" @submit="selectUser" :singleSelect="true" /> |
| | | <SelectMember :projectId="projectData.length && projectData[0].id" title="选择菌种实验员" ref="selectMember" |
| | | @submit="selectUser" :singleSelect="true" /> |
| | | |
| | | </div> |
| | | |
| | |
| | | import { Card } from 'element-ui'; |
| | | import AiEditor from '@/components/AiEditor' |
| | | import ChooseProject from '@/components/chooseProject/index.vue' |
| | | import { customUploadRequest, getFullUrl } from "@/utils/utils"; |
| | | import SelectMember from '@/components/SelectMember' |
| | | import { add,getDetail,update } from './service' |
| | | import { add, getDetail, update } from './service' |
| | | |
| | | export default { |
| | | components: { AiEditor, ChooseProject, SelectMember }, |
| | |
| | | } |
| | | }, |
| | | mounted() { |
| | | // 滚动到页面顶部 |
| | | this.$nextTick(() => { |
| | | // 滚动到页面顶部 |
| | | this.$nextTick(() => { |
| | | window.scrollTo(0, 0); |
| | | }); |
| | | if (this.$route.query.id) { |
| | |
| | | }; |
| | | |
| | | let arr = data.evaluate.split(',') |
| | | |
| | | this.fileList = (data.enclosureUrl ? JSON.parse(data.enclosureUrl) : []) |
| | | this.assessmentTable = this.assessmentTable.map((item, index) => { |
| | | item.selectedScore = Number(arr[index]) |
| | | return item |
| | | }) |
| | | |
| | | this.selectedMember = [{ |
| | | nickName:data.experimentName, |
| | | userId:data.experimentId |
| | | nickName: data.experimentName, |
| | | userId: data.experimentId |
| | | }] |
| | | |
| | | this.projectData = data.projectTeam ? |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | handlePreview(file) { |
| | | if (file.url) { |
| | | window.open(file.url, '_blank'); |
| | | } else { |
| | | this.$message.warning('无可预览地址'); |
| | | } |
| | | }, |
| | | |
| | | // 上传前校验 |
| | | beforeUpload(file) { |
| | | return true; |
| | | }, |
| | | // 自定义上传处理 |
| | | handleUpload(options) { |
| | | const { file, onSuccess, onError } = options; |
| | | |
| | | // 使用封装的customUploadRequest方法 |
| | | customUploadRequest({ |
| | | file, |
| | | onSuccess: (res) => { |
| | | if (res.code === 200) { |
| | | const fileObj = { |
| | | id: new Date().getTime(), |
| | | reportId: this.$route.query.id ? this.$route.query.id : "", |
| | | fileUrl: res.msg || res.data || "", |
| | | reportType: 2, // 报告类型 |
| | | fileName: file.name, |
| | | fileSize: file.size, |
| | | }; |
| | | |
| | | // 添加到文件列表显示 |
| | | this.fileList.push({ |
| | | name: file.name, |
| | | url: getFullUrl(fileObj.fileUrl), |
| | | uid: fileObj.id, |
| | | }); |
| | | |
| | | // 添加到表单数据 |
| | | this.form.feasibilityReportFiles.push(fileObj); |
| | | this.$message.success("文件上传成功"); |
| | | onSuccess(res); |
| | | } |
| | | }, |
| | | onError: (err) => { |
| | | this.$message.error("文件上传失败"); |
| | | onError(err); |
| | | }, |
| | | }); |
| | | }, |
| | | // 删除文件 |
| | | handleRemove(file) { |
| | | const index = this.fileList.findIndex((item) => item.name === file.name); |
| | | if (index !== -1) { |
| | | this.fileList.splice(index, 1); |
| | | this.form.feasibilityReportFiles.splice(index, 1); |
| | | } |
| | | }, |
| | | async addData() { |
| | | if (this.submitLoading) return; |
| | | this.submitLoading = true; |
| | |
| | | return; |
| | | } |
| | | const params = { |
| | | isDraft: this.form.isDraft ? this.form.isDraft : 0, |
| | | isDraft: 0, |
| | | projectId: this.projectData[0].id, |
| | | experimentId: this.selectedMember[0].userId, |
| | | enclosureUrl: this.fileList.length && JSON.stringify(this.fileList), |
| | | // reportCode: this.form.reportCode, |
| | | reportContent: this.$refs.materialEditor.getContent(), |
| | | reportName: this.form.reportName, |
| | | evaluateTotal: this.totalScore, |
| | | evaluate: str.join(','), |
| | | evaluate: str.join(','), |
| | | reportType: 4 |
| | | }; |
| | | if (this.$route.query.id) { |
| | |
| | | isDraft: 1, |
| | | projectId: this.projectData[0].id, |
| | | experimentId: this.selectedMember[0].userId, |
| | | enclosureUrl: this.fileList.length && JSON.stringify(this.fileList), |
| | | // reportCode: this.form.reportCode, |
| | | reportContent: this.$refs.materialEditor.getContent(), |
| | | reportName: this.form.reportName, |
| | |
| | | evaluate: str.join(','), |
| | | reportType: 4 |
| | | }; |
| | | if (this.$route.query.id) { |
| | | params.id = this.$route.query.id |
| | | update(params).then(res => { |
| | | this.submitLoading = false; |
| | | if (res.code == 200) { |
| | | this.$message.success('编辑成功'); |
| | | this.$router.back() |
| | | } |
| | | }).catch(() => { |
| | | this.submitLoading = false; |
| | | }) |
| | | return |
| | | } |
| | | add(params).then(res => { |
| | | this.draftLoading = false; |
| | | if (res.code == 200) { |