|
|
|
@ -5,20 +5,20 @@ G |
|
|
|
:close-on-click-modal="false"> |
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
|
|
|
<el-row> |
|
|
|
<!-- 名称 --> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item :label="$t('page.business.study.studyMethod.mc')" prop="mc"> |
|
|
|
<SelectTestArea v-model="form.mc" /> |
|
|
|
<el-form-item :label="$t('page.business.study.studyMethod.mc')" prop="ffmc"> |
|
|
|
<el-input type="text" v-model="form.ffmc" maxlength="20" |
|
|
|
:placeholder="$t('form.placeholderInput')" /> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
<el-row> |
|
|
|
<!-- 方法 --> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item :label="$t('page.business.study.studyMethod.ff')" prop="mc"> |
|
|
|
<el-form-item :label="$t('page.business.study.studyMethod.ff')" prop="fileUlr"> |
|
|
|
<el-upload class="upload-demo" :before-upload="handleBeforeUpload" :on-error="handleUploadError" |
|
|
|
:on-exceed="handleExceed" :on-success="handleUploadSuccess" :show-file-list="false" :headers="headers" |
|
|
|
:action="uploadFileUrl" accept=".pdf" :limit="1" :file-list="fileList"> |
|
|
|
:on-exceed="handleExceed" :on-success="handleUploadSuccess" :show-file-list="true" :headers="headers" |
|
|
|
:on-remove="handleRemove" :action="uploadFileUrl" accept=".pdf" :limit="1" :file-list="fileList"> |
|
|
|
<el-button size="small" type="primary">{{ $t('page.business.study.studyMethod.scwj') }}</el-button> |
|
|
|
<div slot="tip" class="el-upload__tip">{{ $t('page.business.study.studyMethod.wjm') }}</div> |
|
|
|
</el-upload> |
|
|
|
@ -70,47 +70,33 @@ G |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { studyRoom_save } from "@/api/business/study/studyRoom" |
|
|
|
import { studyMethod_save } from "@/api/business/study/studyMethod" |
|
|
|
import { mapGetters } from 'vuex' |
|
|
|
import BusinessSelect from '@/views/business/comps/select/BusinessSelect'; |
|
|
|
import SelectTestArea from '@/views/business/comps/select/SelectTestArea'; |
|
|
|
import SelectRoom from '@/views/business/comps/select/SelectRoom'; |
|
|
|
import SelectAnimalSpecies from '@/views/business/comps/select/SelectAnimalSpecies'; |
|
|
|
import SelectCage from '@/views/business/comps/select/SelectCage'; |
|
|
|
import { getToken } from "@/utils/auth" |
|
|
|
|
|
|
|
export default { |
|
|
|
name: "XzSyj", |
|
|
|
components: { BusinessSelect, SelectTestArea, SelectRoom, SelectCage, SelectAnimalSpecies }, |
|
|
|
components: {}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
open: false, |
|
|
|
form: {}, |
|
|
|
form: { |
|
|
|
mc: '', |
|
|
|
fileUrl: '', |
|
|
|
fileName: '' |
|
|
|
}, |
|
|
|
uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload", |
|
|
|
headers: { |
|
|
|
Authorization: "Bearer " + getToken(), |
|
|
|
}, |
|
|
|
fileList: [], |
|
|
|
rules: { |
|
|
|
syqy: [{ |
|
|
|
required: true, |
|
|
|
message: ' ', |
|
|
|
trigger: 'blur' |
|
|
|
}], |
|
|
|
syjh: [{ |
|
|
|
required: true, |
|
|
|
message: ' ', |
|
|
|
trigger: 'blur' |
|
|
|
}], |
|
|
|
dwzs: [{ |
|
|
|
required: true, |
|
|
|
message: ' ', |
|
|
|
trigger: 'blur' |
|
|
|
}], |
|
|
|
lj: [{ |
|
|
|
ffmc: [{ |
|
|
|
required: true, |
|
|
|
message: ' ', |
|
|
|
trigger: 'blur' |
|
|
|
}], |
|
|
|
kssyyl: [{ |
|
|
|
fileUrl: [{ |
|
|
|
required: true, |
|
|
|
message: ' ', |
|
|
|
trigger: 'blur' |
|
|
|
@ -136,32 +122,83 @@ export default { |
|
|
|
}, |
|
|
|
reset() { |
|
|
|
this.form = { |
|
|
|
id: null, |
|
|
|
syqy: null, |
|
|
|
syjh: null, |
|
|
|
dwzs: null, |
|
|
|
lj: null, |
|
|
|
ffmc: null, |
|
|
|
fileUrl: '', |
|
|
|
fileName: '', |
|
|
|
qmrmm: null, |
|
|
|
kssyyl: '', |
|
|
|
qmyy: '上传文件', |
|
|
|
bjbz: '' |
|
|
|
} |
|
|
|
this.fileList = [] |
|
|
|
this.resetForm("form") |
|
|
|
}, |
|
|
|
show(studyId) { |
|
|
|
show(study) { |
|
|
|
this.reset() |
|
|
|
this.form.studyId = studyId |
|
|
|
this.form.studyId = study.studyId |
|
|
|
this.form.studySubjectId = study.studySubjectId |
|
|
|
this.open = true |
|
|
|
}, |
|
|
|
save() { |
|
|
|
this.$refs["form"].validate(valid => { |
|
|
|
if (valid) { |
|
|
|
studyRoom_save(this.form).then(response => { |
|
|
|
studyMethod_save(this.form).then(response => { |
|
|
|
this.open = false |
|
|
|
this.$emit('callback') |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 上传前校检格式和大小 |
|
|
|
handleBeforeUpload(file) { |
|
|
|
let fileType = ['pdf'] |
|
|
|
// 校检文件类型 |
|
|
|
if (fileType) { |
|
|
|
const fileName = file.name.split('.') |
|
|
|
const fileExt = fileName[fileName.length - 1] |
|
|
|
const isTypeOk = fileType.indexOf(fileExt) >= 0 |
|
|
|
if (!isTypeOk) { |
|
|
|
this.$modal.msgError('文件格式不正确,请上传pdf格式文件!') |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
// 校检文件名是否包含特殊字符 |
|
|
|
if (file.name.includes(',')) { |
|
|
|
this.$modal.msgError('文件名不正确,不能包含英文逗号!') |
|
|
|
return false |
|
|
|
} |
|
|
|
this.$modal.loading("正在上传文件,请稍候...") |
|
|
|
this.number++ |
|
|
|
return true |
|
|
|
}, |
|
|
|
// 文件个数超出 |
|
|
|
handleExceed() { |
|
|
|
this.$modal.msgError('上传文件数量不能超过1个!') |
|
|
|
}, |
|
|
|
// 上传失败 |
|
|
|
handleUploadError(err) { |
|
|
|
this.$modal.msgError("上传文件失败,请重试") |
|
|
|
this.$modal.closeLoading() |
|
|
|
}, |
|
|
|
// 上传成功回调 |
|
|
|
handleUploadSuccess(res, file) { |
|
|
|
console.log(res) |
|
|
|
if (res.code === 200) { |
|
|
|
this.form.fileUrl = res.data.url |
|
|
|
this.form.fileName = res.data.name |
|
|
|
this.fileList.push({ name: res.data.name, url: res.data.url }) |
|
|
|
this.$modal.closeLoading() |
|
|
|
} else { |
|
|
|
this.number-- |
|
|
|
this.$modal.closeLoading() |
|
|
|
this.$modal.msgError(res.msg) |
|
|
|
this.$refs.fileUpload.handleRemove(file) |
|
|
|
} |
|
|
|
}, |
|
|
|
handleRemove() { |
|
|
|
this.form.fileUrl = '' |
|
|
|
this.form.fileName = '' |
|
|
|
this.fileList = [] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|