From 516db3f78f8b2b3670036d4adbe2271a2e3bc6ca Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Fri, 6 Feb 2026 23:19:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][upd?= =?UTF-8?q?ate]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Template/BaseInfoFormPackage.vue | 4 +- src/components/Template/CustomTable.vue | 3 +- src/components/Template/HandleFormItem.vue | 80 ++++++++++++++++++---- .../Template/mixins/formPackageMixins.js | 13 ++-- .../business/comps/template/comps/sp/SP007.vue | 25 ++----- .../business/comps/template/formConfig/sp/SP007.js | 2 +- 6 files changed, 82 insertions(+), 45 deletions(-) diff --git a/src/components/Template/BaseInfoFormPackage.vue b/src/components/Template/BaseInfoFormPackage.vue index ff6e02e..5773b94 100644 --- a/src/components/Template/BaseInfoFormPackage.vue +++ b/src/components/Template/BaseInfoFormPackage.vue @@ -60,8 +60,8 @@
{{ $t( sItem.label) }}
-
diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index fb7d504..77447e3 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -308,6 +308,7 @@ export default { if (this.templateFillType !== 'actFill') { return } + this.updateDataSourceByRowIndex(rowIndex,{[col.prop]:data.selectedId}) this.$emit("onRegentSubmit", {selectInfo:data,key:col.prop, col, rowIndex, colIndex, rowData:row}) }, isShowAddRos() { @@ -630,7 +631,7 @@ export default { this.checkCompareToOnDataLoad(); }, // 根据行索引更新数据 autoUpdateRecord 是否自动更新记录 - updateDataSourceByRowIndex(rowIndex, data, type) { + updateDataSourceByRowIndex(rowIndex, data) { this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); // if (type === "clickable") {//如果是custom内部的clickable需要判断是否弹窗 // this.showEditSignDialog(rowIndex,data); diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index 33834c0..0d23842 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -55,9 +55,10 @@ 点击上传 -
只能上传jpg/png文件,且不超过500kb
+
支持扩展名:.rar .zip .doc .docx .pdf .jpg
@@ -213,12 +214,6 @@ export default { watch: { value(newVal) { this.inputValue = newVal; - // 当type为clickable时,值变化时调用保存记录方法 - // if (this.item.type === 'clickable') { - // this.$nextTick(() => { - // this.onCommonHandleSaveRecord(newVal); - // }); - // } } }, filters: { @@ -226,6 +221,13 @@ export default { }, mounted() { + if(this.item.type === 'attachment'){ + try{ + this.fileList = JSON.parse(this.value); + }catch(e){ + this.fileList = []; + } + } EventBus.$on('onExternalFieldUpdate', this.handleExternalFieldUpdate); EventBus.$on('onEditSignCancel', this.handleEditSignCancel); EventBus.$on('onEditSignCallback', this.handleEditSignCallback); @@ -245,11 +247,65 @@ export default { EventBus.$off("onMixReagentSubmit", this.onMixReagentSubmit) }, methods: { + handleSuccess(res, file, fileList) { + if(res.code == 200){ + this.fileList = fileList; + // 更新inputValue为文件路径列表,方便后续保存 + this.inputValue = JSON.stringify(this.getFileList(fileList)); + this.$emit("change",this.inputValue) + this.onCommonHandleSaveRecord(); + this.$message.success('文件上传成功'); + } else { + this.$message.error(res.message || '文件上传失败'); + } + }, + getFileList(fileList) { + const list = []; + fileList.forEach(item => { + const o = {name:item.name}; + if(item.url){//回填的数据 + o.url = item.url + }else{//新上传的 + o.url = item.response.data.url + } + list.push(o) + }) + return list; + }, handleRemove(file, fileList) { - console.log(file, fileList); + // 从列表中移除文件 + const index = fileList.indexOf(file); + if (index > -1) { + fileList.splice(index, 1); + } + + // 更新inputValue为剩余文件路径列表 + this.inputValue = JSON.stringify(this.getFileList(fileList)); + this.$emit("change",this.inputValue) + + // 触发保存记录 + this.onCommonHandleSaveRecord(); + + this.$message.info(`文件 ${file.name} 已移除`); }, handlePreview(file) { - console.log(file); + // 预览文件,如果是图片则直接打开,否则下载 + if (file.url) { + const fileType = file.type || file.name.split('.').pop().toLowerCase(); + const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp']; + + if (imageTypes.includes(fileType)) { + // 图片类型,新建窗口预览 + window.open(process.env.VUE_APP_FILE_DOMAIN + file.url, '_blank'); + } else { + // 非图片类型,下载文件 + const link = document.createElement('a'); + link.href = file.url; + link.download = file.name; + link.target = '_blank'; + link.click(); + } + } }, handleExceed(files, fileList) { this.$message.warning(`当前限制选择 10 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`); @@ -262,7 +318,7 @@ export default { if (data.uuid !== this.uuid) return; this.inputValue = data.selectedId; this.selectRegentInfo = data; - this.onCommonHandleSaveRecord(); + this.onCommonHandleSaveRecord(this.inputValue); // this.inputValue = this.item.label; }, //统一处理试剂/供试品等弹窗 @@ -566,12 +622,12 @@ export default { if (this.templateFillType === "actFill") {//只有实际填报的时候才记录修改记录 this.updateZdxgjl(record); } - setTimeout(() => { + this.$nextTick(()=>{ EventBus.$emit('onModifyRecord', params,) if (this.regentType.includes(this.item.type)) { this.$emit("onRegentSubmit", this.selectRegentInfo); } - }, 10); + }) }, //判断两个值是否相等 diff --git a/src/components/Template/mixins/formPackageMixins.js b/src/components/Template/mixins/formPackageMixins.js index 9fe812c..a6bcc3a 100644 --- a/src/components/Template/mixins/formPackageMixins.js +++ b/src/components/Template/mixins/formPackageMixins.js @@ -48,6 +48,7 @@ export default { methods: { //试剂/仪器等弹窗提交 onRegentSubmit(data,key,item){ + this.updateFormData(key,data.selectedId); this.$emit("onRegentSubmit", {selectInfo:data,key,config:item}); }, getRegentItem(item,fieldCode="type"){ @@ -218,6 +219,7 @@ export default { selectInfoKeys.forEach(key => { result[key] = formData[key]; }) + console.log(result,"result") // 更新表单字段 this.formFields = result; this.allFieldsConfig = config; @@ -255,7 +257,7 @@ export default { const errors = []; // 清空之前的错误状态 this.errors = {}; - console.log(allFieldsConfig,"allFieldsConfig") + console.log(allFieldsConfig,formFields,"allFieldsConfig") for (const key in allFieldsConfig) { const o = allFieldsConfig[key]; if (o.otherCode) {// @@ -366,15 +368,8 @@ export default { this.compareFieldsIsEqual(val, compareToValue, key); } }, - onSelectChange(key, val, type) { - // 获取对应的配置 - const currentConfig = this.allFieldsConfig[key]; - if (currentConfig.selectTo) { - this.formFields[currentConfig.selectTo] = val; - } - this.onValueChangeCompareTo(key, val); + onAttachmentChange(key, val) { this.formFields[key] = val; - this.$emit("select", { key, value: val, type }); // 清除该表单项的错误状态 if (this.errors[key]) { this.$set(this.errors, key, false); diff --git a/src/views/business/comps/template/comps/sp/SP007.vue b/src/views/business/comps/template/comps/sp/SP007.vue index 024b3cd..f8d454c 100644 --- a/src/views/business/comps/template/comps/sp/SP007.vue +++ b/src/views/business/comps/template/comps/sp/SP007.vue @@ -26,7 +26,7 @@
- + @@ -82,11 +82,6 @@ export default { }; }, mounted() { - const formData = this.getFormDataByTemplateData(); - if(!formData.targetCodeSn&& this.fillType === "actFill"){ - this.getCode(formData); - } - }, methods: { //打印标签 @@ -98,24 +93,14 @@ export default { EventBus.$emit('showTagPrintDialog', { printConfig }) }, - //获取目标溶液编号 - getCode: debounce(async function (v) { - const result = await getLatestSn({ - count: 1, - pre:v.targetCode, - type:1 - }) - if (result.code == 200) { - this.$refs.stepFormPackageRef.updateFormData("targetCodeSn", result.data[0]) - } - }, 100), + //获取已填写的表单数据 getFilledFormData() { - return this.getFilledFormDataByRefs(["baseInfoRef", "storageConditionRef", "stepFormPackageRef", "stepRef", "remarkRef"]) + return this.getFilledFormDataByRefs(["baseInfoRef", "storageConditionRef", "ybRef","stepRef", "remarkRef","fjRef"]) }, //获取填写完成的表单数据 async getFormData() { - let content = await this.validFormFields(["baseInfoRef", "storageConditionRef", "stepFormPackageRef", "stepRef", "remarkRef"]); + let content = await this.validFormFields(["baseInfoRef", "storageConditionRef", "ybRef","stepRef", "remarkRef","fjRef"]); //生成resource let tmpResource = [] if (this.fillType === "actFill") { @@ -147,7 +132,7 @@ export default { }, //保存 async onSave() { - let content =await this.$refs.stepRef.getFormData(); + let content =await this.$refs.fjRef.getFormData(); console.log(content); }, diff --git a/src/views/business/comps/template/formConfig/sp/SP007.js b/src/views/business/comps/template/formConfig/sp/SP007.js index 122db69..f2d649b 100644 --- a/src/views/business/comps/template/formConfig/sp/SP007.js +++ b/src/views/business/comps/template/formConfig/sp/SP007.js @@ -149,7 +149,7 @@ export const getfjFormConfig = () => { { type: "attachment", config: { - storageCondition: { + attTitle: { label: '标题', type: "attachment", fillType: "preFill",