|
|
|
@ -24,6 +24,16 @@ |
|
|
|
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue" |
|
|
|
:disabled="getDisabled()" :placeholder="getPlaceholder()" @change="onItemCheckboxChange"> |
|
|
|
</el-checkbox> |
|
|
|
<div v-else-if="type === 'checkboxList'" class="flex1 checkbox-list-container" |
|
|
|
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')"> |
|
|
|
<el-checkbox-group v-model="inputValue" @change="onInputChange"> |
|
|
|
<div v-for="option in item.options" :key="option.value" class="checkbox-item"> |
|
|
|
<el-checkbox :label="option.value" :disabled="getDisabled()"> |
|
|
|
{{ option.label }} |
|
|
|
</el-checkbox> |
|
|
|
</div> |
|
|
|
</el-checkbox-group> |
|
|
|
</div> |
|
|
|
<el-date-picker v-else-if="type === 'dateTime'" type="datetime" class="flex1" |
|
|
|
:class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue" |
|
|
|
:disabled="getDisabled()" format="yyyy/MM/dd HH:mm:ss" :placeholder="getPlaceholder()" |
|
|
|
@ -53,15 +63,12 @@ |
|
|
|
</div> |
|
|
|
<template v-else-if="type === 'attachment'"> |
|
|
|
<el-upload ref="uploadRef" class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview" |
|
|
|
:headers="headers" |
|
|
|
:before-remove="beforeRemove" |
|
|
|
:on-remove="handleRemove" multiple :limit="10" |
|
|
|
:on-success="handleSuccess" |
|
|
|
:on-change="handleChange" |
|
|
|
:on-exceed="handleExceed" :file-list="fileList" |
|
|
|
:auto-upload="false"> |
|
|
|
<el-button :disabled="getDisabled()" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" size="small" type="primary">点击上传</el-button> |
|
|
|
<span v-if="error" class = "atta-tips">请上传附件</span> |
|
|
|
:headers="headers" :before-remove="beforeRemove" :on-remove="handleRemove" multiple :limit="10" |
|
|
|
:on-success="handleSuccess" :on-change="handleChange" :on-exceed="handleExceed" |
|
|
|
:file-list="fileList" :auto-upload="false"> |
|
|
|
<el-button :disabled="getDisabled()" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" |
|
|
|
size="small" type="primary">点击上传</el-button> |
|
|
|
<span v-if="error" class="atta-tips">请上传附件</span> |
|
|
|
<div slot="tip" class="el-upload__tip">支持扩展名:.rar .zip .doc .docx .pdf .jpg,文件大小不超过2MB</div> |
|
|
|
</el-upload> |
|
|
|
</template> |
|
|
|
@ -194,8 +201,8 @@ export default { |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
inputValue: this.value, |
|
|
|
oldValue: this.value, // 记录上一次的值 |
|
|
|
inputValue: this.type === 'checkboxList' && !Array.isArray(this.value) ? [] : this.value, |
|
|
|
oldValue: this.type === 'checkboxList' && !Array.isArray(this.value) ? [] : this.value, // 记录上一次的值 |
|
|
|
showModal: false, // 控制模态框显示 |
|
|
|
modificationRecords: [], // 存储修改记录 |
|
|
|
modalTimer: null, // 用于延迟隐藏模态框 |
|
|
|
@ -206,11 +213,11 @@ export default { |
|
|
|
visible: false,//是否显示弹窗 |
|
|
|
checkboxValue: this.getChecked(),//是否选中 |
|
|
|
uuid: getuuid(), // 唯一标识符,用于EventBus事件匹配 |
|
|
|
regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq','jcb'], //试剂/仪器/供试品等类型 |
|
|
|
regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb'], //试剂/仪器/供试品等类型 |
|
|
|
selectRegentInfo: {},//选择的试剂/仪器/供试品等信息 |
|
|
|
fileList: [],//上传的文件列表 |
|
|
|
uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload", |
|
|
|
headers: { |
|
|
|
headers: { |
|
|
|
Authorization: "Bearer " + getToken(), |
|
|
|
}, |
|
|
|
pendingUploadFile: null, // 用于存储待上传的文件 |
|
|
|
@ -219,7 +226,7 @@ export default { |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
value(newVal) { |
|
|
|
this.inputValue = newVal; |
|
|
|
this.inputValue = this.type === 'checkboxList' && !Array.isArray(newVal) ? [] : newVal; |
|
|
|
} |
|
|
|
}, |
|
|
|
filters: { |
|
|
|
@ -227,10 +234,10 @@ export default { |
|
|
|
|
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
if(this.item.type === 'attachment'){ |
|
|
|
try{ |
|
|
|
if (this.item.type === 'attachment') { |
|
|
|
try { |
|
|
|
this.fileList = JSON.parse(this.value); |
|
|
|
}catch(e){ |
|
|
|
} catch (e) { |
|
|
|
this.fileList = []; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -253,21 +260,21 @@ export default { |
|
|
|
EventBus.$off("onMixReagentSubmit", this.onMixReagentSubmit) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
onInstrumentSubmit(data){ |
|
|
|
if(data.uuid !== this.uuid) return; |
|
|
|
onInstrumentSubmit(data) { |
|
|
|
if (data.uuid !== this.uuid) return; |
|
|
|
this.selectRegentInfo = data; |
|
|
|
console.log(data,"yq") |
|
|
|
console.log(data, "yq") |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 文件状态改变时的钩子,添加文件、上传成功、上传失败时都会被调用 |
|
|
|
handleChange(file, fileList) { |
|
|
|
// 如果是新添加的文件(status为ready),进行验证 |
|
|
|
if (file.status === 'ready') { |
|
|
|
const isAllowedType = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', |
|
|
|
'application/x-rar-compressed', 'application/zip', |
|
|
|
const isAllowedType = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', |
|
|
|
'application/x-rar-compressed', 'application/zip', |
|
|
|
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'].includes(file.raw.type) |
|
|
|
const isLt2M = file.size / 1024 / 1024 < 2 |
|
|
|
|
|
|
|
|
|
|
|
if (!isAllowedType) { |
|
|
|
this.$message.error(`文件 ${file.name} 格式不支持!只能上传 JPG/PNG/GIF/PDF/RAR/ZIP/DOC/DOCX 格式的文件`) |
|
|
|
// 从fileList中移除该文件 |
|
|
|
@ -288,25 +295,25 @@ export default { |
|
|
|
this.fileList = [...fileList]; |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果已经有文件在列表中(不包括当前新添加的),需要验证电子签名 |
|
|
|
const existingFiles = fileList.filter(f => f !== file && f.status === 'success'); |
|
|
|
if (existingFiles.length > 0) { |
|
|
|
// 保存待上传的文件信息 |
|
|
|
this.pendingUploadFile = file; |
|
|
|
|
|
|
|
|
|
|
|
// 从fileList中暂时移除新文件,等待签名验证 |
|
|
|
const index = fileList.indexOf(file); |
|
|
|
if (index > -1) { |
|
|
|
fileList.splice(index, 1); |
|
|
|
} |
|
|
|
this.fileList = [...fileList]; |
|
|
|
|
|
|
|
|
|
|
|
// 触发电子签名弹窗 |
|
|
|
EventBus.$emit('showEditSignDialog', { uuid: this.uuid }); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 没有现有文件或验证通过,手动提交上传 |
|
|
|
this.$nextTick(() => { |
|
|
|
// 找到对应的upload组件并提交 |
|
|
|
@ -316,16 +323,16 @@ export default { |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 更新fileList |
|
|
|
this.fileList = fileList; |
|
|
|
}, |
|
|
|
handleSuccess(res, file, fileList) { |
|
|
|
if(res.code == 200){ |
|
|
|
if (res.code == 200) { |
|
|
|
this.fileList = fileList; |
|
|
|
// 更新inputValue为文件路径列表,方便后续保存 |
|
|
|
this.inputValue = JSON.stringify(this.getFileList(fileList)); |
|
|
|
this.$emit("change",this.inputValue) |
|
|
|
this.$emit("change", this.inputValue) |
|
|
|
this.onCommonHandleSaveRecord(); |
|
|
|
this.$message.success('文件上传成功'); |
|
|
|
} else { |
|
|
|
@ -341,10 +348,10 @@ export default { |
|
|
|
getFileList(fileList) { |
|
|
|
const list = []; |
|
|
|
fileList.forEach(item => { |
|
|
|
const o = {name:item.name}; |
|
|
|
if(item.url){//回填的数据 |
|
|
|
const o = { name: item.name }; |
|
|
|
if (item.url) {//回填的数据 |
|
|
|
o.url = item.url |
|
|
|
}else{//新上传的 |
|
|
|
} else {//新上传的 |
|
|
|
o.url = item.response.data.url |
|
|
|
} |
|
|
|
list.push(o) |
|
|
|
@ -410,7 +417,7 @@ export default { |
|
|
|
//试剂弹窗提交 |
|
|
|
onMixReagentSubmit(data) { |
|
|
|
if (data.uuid !== this.uuid) return; |
|
|
|
|
|
|
|
|
|
|
|
// 创建一个验证控制器,用于收集各级验证结果 |
|
|
|
const validationController = { |
|
|
|
isPrevented: false, |
|
|
|
@ -420,11 +427,11 @@ export default { |
|
|
|
if (msg) this.errorMsg = msg; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 触发自定义验证事件,让父组件判断是否满足需求 |
|
|
|
// 父组件可以通过validationController.prevent(msg)来阻止提交 |
|
|
|
this.$emit('beforeReagentSubmit', data, validationController); |
|
|
|
|
|
|
|
|
|
|
|
// 检查是否被阻止 |
|
|
|
if (validationController.isPrevented) { |
|
|
|
// 验证不通过,显示错误信息 |
|
|
|
@ -433,11 +440,11 @@ export default { |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 验证通过,继续执行 |
|
|
|
this.executeReagentSubmit(data); |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 执行试剂提交的共同逻辑 |
|
|
|
executeReagentSubmit(data) { |
|
|
|
this.inputValue = data.selectedId; |
|
|
|
@ -458,7 +465,7 @@ export default { |
|
|
|
let eventName = "showSelectMixReagentDialog"; |
|
|
|
if (type === "yq") { |
|
|
|
eventName = "showSelectInstrumentDialog"; |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
const sjType = { |
|
|
|
sj: "1",//试剂 |
|
|
|
gsp: "7",//供试品 |
|
|
|
@ -473,7 +480,7 @@ export default { |
|
|
|
...params, |
|
|
|
type: sjType[type] |
|
|
|
}; |
|
|
|
if(type === "mix"){ |
|
|
|
if (type === "mix") { |
|
|
|
params.mixType = true; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -721,14 +728,14 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
async onCommonHandleSaveRecord(val) { |
|
|
|
|
|
|
|
|
|
|
|
const isEmpty = this.isValueEmpty(this.inputValue); |
|
|
|
if (this.error && !isEmpty) { |
|
|
|
this.$emit('update:error', false); |
|
|
|
} else if (!this.error && isEmpty) { |
|
|
|
this.$emit('update:error', true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 创建验证控制器,让父组件可以在保存前进行验证 |
|
|
|
const validationController = { |
|
|
|
isPrevented: false, |
|
|
|
@ -738,14 +745,14 @@ export default { |
|
|
|
if (msg) this.errorMsg = msg; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 触发beforeSaveRecord事件,让父组件进行验证 |
|
|
|
this.$emit('beforeSaveRecord', { |
|
|
|
value: this.inputValue, |
|
|
|
oldValue: this.oldValue, |
|
|
|
fieldKey: this.fieldKey |
|
|
|
}, validationController); |
|
|
|
|
|
|
|
|
|
|
|
// 检查是否被阻止 |
|
|
|
if (validationController.isPrevented) { |
|
|
|
// 验证不通过,显示错误信息 |
|
|
|
@ -757,7 +764,7 @@ export default { |
|
|
|
this.$emit('input', this.inputValue); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!this.isFieldsRecord) {//是否需要记录修改记录 |
|
|
|
this.$emit("blur", this.inputValue); |
|
|
|
this.$emit('input', this.inputValue); |
|
|
|
@ -821,7 +828,7 @@ export default { |
|
|
|
if (this.templateFillType === "actFill") {//只有实际填报的时候才记录修改记录 |
|
|
|
this.updateZdxgjl(record); |
|
|
|
} |
|
|
|
this.$nextTick(()=>{ |
|
|
|
this.$nextTick(() => { |
|
|
|
EventBus.$emit('onModifyRecord', params,) |
|
|
|
if (this.regentType.includes(this.item.type)) { |
|
|
|
this.$emit("onRegentSubmit", this.selectRegentInfo); |
|
|
|
@ -1213,6 +1220,7 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.error-border { |
|
|
|
|
|
|
|
.el-input-group__prepend, |
|
|
|
@ -1356,9 +1364,61 @@ export default { |
|
|
|
display: flex; |
|
|
|
justify-content: flex-end; |
|
|
|
} |
|
|
|
|
|
|
|
.atta-tips { |
|
|
|
color: #ff5d5d; |
|
|
|
font-size: 12px; |
|
|
|
margin-left: 5px; |
|
|
|
} |
|
|
|
|
|
|
|
.checkbox-list-container { |
|
|
|
padding: 12px; |
|
|
|
border: 1px solid #dcdfe6; |
|
|
|
border-radius: 4px; |
|
|
|
transition: all 0.3s; |
|
|
|
|
|
|
|
&.error-border { |
|
|
|
border-color: #ff5d5d !important; |
|
|
|
box-shadow: 0 0 6px #ffc3c3 !important; |
|
|
|
} |
|
|
|
|
|
|
|
.checkbox-item { |
|
|
|
margin-right: 16px; |
|
|
|
&:not(:last-child) { |
|
|
|
margin-bottom: 10px; |
|
|
|
} |
|
|
|
// display: inline-block; |
|
|
|
} |
|
|
|
|
|
|
|
.el-checkbox { |
|
|
|
&.is-checked { |
|
|
|
.el-checkbox__label { |
|
|
|
color: #606266; |
|
|
|
} |
|
|
|
|
|
|
|
.el-checkbox__inner { |
|
|
|
background-color: #f9c588; |
|
|
|
border-color: #f9c588; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.orange-border { |
|
|
|
.checkbox-list-container { |
|
|
|
border-color: #f9c588; |
|
|
|
|
|
|
|
&:hover { |
|
|
|
border-color: #f79b31; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.orange-bg { |
|
|
|
.checkbox-list-container { |
|
|
|
background-color: #FFF1F1 !important; |
|
|
|
border-color: #f9c588; |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |