+
@@ -63,6 +63,7 @@ import Step from "@/components/Template/Step";
import templateMixin from "../../mixins/templateMixin";
import CustomTable from '@/components/Template/CustomTable.vue';
import { uniqeResource } from "@/utils/calUnitTools";
+import {getuuid} from "@/utils/index";
import { getBaseInfoFormConfig, getStorageFormConfig, getRemarkFormConfig, getYbsmFormConfig,getTableColumns } from "../../formConfig/sp/SP0021";
const refConfig = {
baseInfoRef: "baseInfoRef",
@@ -110,20 +111,40 @@ export default {
},
},
data() {
- return {
- refConfig,
- formData: {},
- };
- },
+ return {
+ refConfig,
+ };
+ },
mounted() {
-
+ if(this.fillType === 'preFill'){//预填的时候默认新增一个。
+ this.onAdd()
+ }
},
methods: {
//删除样本说明
- deleteConfig(){},
+ deleteConfig(index){
+ // 确保 ybsmDataList 存在
+ if (!this.formData.ybsmDataList) {
+ this.formData.ybsmDataList = [{}];
+ return;
+ }
+ if (this.formData.ybsmDataList.length > 1) {
+ this.formData.ybsmDataList.splice(index, 1);
+ } else {
+ this.$message.warning('至少需要保留一个样本说明项');
+ }
+ },
//新增样本说明
onAdd(){
-
+ if (!this.formData.ybsmDataList) {
+ this.$set(this.formData, 'ybsmDataList', []);
+ }
+ // 添加新的平行配制配置
+ this.formData.ybsmDataList.push({
+ id: getuuid(),
+ ybsmFormData: {},
+ stepData: [],
+ });
},
onLoadExcelData(excelData) {
const data = excelData.splice(1);
@@ -146,12 +167,43 @@ export default {
},
//获取已填写的表单数据
getFilledFormData() {
- return this.getFilledFormDataByRefs(compRefs)
+ // 基础表单数据
+ const baseData = this.getFilledFormDataByRefs(compRefs);
+ // 处理多个样本说明项
+ const ybsmDataList = this.formData.ybsmDataList.map((item, index) => {
+ const ybsmFormData = this.$refs[`ybsmFormPackageRef${index}`]?.getFilledFormData() || {};
+ const ybsmTableData = this.$refs[`ybsmTableRef${index}`]?.getFilledFormData() || [];
+ const stepData = this.$refs[`stepRef${index}`]?.getFilledFormData() || {};
+ return {
+ ...ybsmFormData,
+ ybsmData: ybsmTableData,
+ stepData: stepData
+ };
+ });
+ return {
+ ...baseData,
+ ybsmDataList
+ };
},
//获取填写完成的表单数据
async getFormData() {
+ // 基础表单验证
let content = await this.validFormFields(compRefs);
- return content;
+ if (!content) return null;
+
+ // 验证多个样本说明项
+ for (let index = 0; index < this.formData.ybsmDataList.length; index++) {
+ // 验证样本说明表单
+ const ybsmFormValid = await this.$refs[`ybsmFormPackageRef${index}`]?.validFormFields() || true;
+ if (!ybsmFormValid) return null;
+
+ // 验证步骤数据
+ const stepValid = await this.$refs[`stepRef${index}`]?.getFormData() || true;
+ if (!stepValid) return null;
+ }
+
+ // 获取所有数据
+ return this.getFilledFormData();
},
getResource() {
let content = this.getFilledFormData();
@@ -179,14 +231,21 @@ export default {
})
}
//使用的试剂、仪器
- const stepResource = this.$refs.stepRef.getStepResource()
- this.resourceTmp = uniqeResource(tmpResource, stepResource.sjResource || [])
- this.yqResourceTmp = stepResource.yqResource || []
+ let allSjResource = [];
+ let allYqResource = [];
+ // 收集所有样本说明项的步骤资源
+ for (let index = 0; index < this.formData.ybsmDataList.length; index++) {
+ const stepResource = this.$refs[`stepRef${index}`]?.getStepResource() || { sjResource: [], yqResource: [] };
+ allSjResource = [...allSjResource, ...(stepResource.sjResource || [])];
+ allYqResource = [...allYqResource, ...(stepResource.yqResource || [])];
+ }
+ this.resourceTmp = uniqeResource(tmpResource, allSjResource)
+ this.yqResourceTmp = allYqResource
return this.resourceTmp;
},
//保存
async onSave() {
- let content = await this.$refs.stepRef.getFormData();
+ let content = await this.getFormData();
console.log(content);
},
diff --git a/src/views/business/comps/template/dialog/SelectMixReagentDialog.vue b/src/views/business/comps/template/dialog/SelectMixReagentDialog.vue
index 499c7c8..fb2b23d 100644
--- a/src/views/business/comps/template/dialog/SelectMixReagentDialog.vue
+++ b/src/views/business/comps/template/dialog/SelectMixReagentDialog.vue
@@ -8,6 +8,7 @@
给药制剂列表
@@ -82,7 +83,7 @@ export default {
otherChecked: false,
selectedId: "",
selectedCode: "bh",
- currentRow: {},
+ currentRow: null,
radio: 1,
bzList: [],
depart: "",
@@ -99,12 +100,17 @@ export default {
title:"选择试剂",
currentType: '1',//当前选择的类型
qxbdType:"",//前序表单类型
+ //是否显示单选框或复选框
+ checkType: "radio",
}
},
computed: {
isDisabled() {
if (this.otherChecked && this.otherReagent) {//如果选中了其他,那么就不校验是否选择了试剂
return false;
+ }else if(this.checkType === "checkbox"){
+ console.log(this.currentRow,"this.currentRow")
+ return !this.currentRow || this.currentRow.length === 0;
}
return !this.selectedId;
}
@@ -115,12 +121,13 @@ export default {
this.uuid = data.uuid
}
//type:sj(试剂列表)gsp(供试品列表)gyzj(给药制剂列表)
- const { type, sourceFrom = "step", mixType = false } = data;
+ const { type, sourceFrom = "step", mixType = false ,checkType = "radio"} = data;
this.currentType = type;
if(type==15){
this.selectedCode = 'id'
this.qxbdType = data.qxbdType || '';
}
+ this.checkType = checkType;
this.mixType = mixType;
this.sourceFrom = sourceFrom;
this.studyFormId = studyFormId;
@@ -136,7 +143,7 @@ export default {
this.otherChecked = val;
if (val) {//如果选中了其他,那么就清空选中的id
this.selectedId = "";
- this.currentRow = {};
+ this.currentRow = null;
}
},
handleShowTableInfo(type) {
@@ -179,13 +186,22 @@ export default {
return
}
this.$emit('submit', selectedValue, row);
+ let callbackData = { selectInfo, uuid: this.uuid, selectedId: selectedValue, row,selectType:this.selectType };
+ if(this.checkType === "checkbox"){
+ callbackData = {
+ uuid: this.uuid,
+ selectedRows: row,
+ }
+ }
// 触发eventBus事件
- EventBus.$emit("onMixReagentSubmit", { selectInfo, uuid: this.uuid, selectedId: selectedValue, row,selectType:this.selectType });
+ EventBus.$emit("onMixReagentSubmit", callbackData);
// this.visible = false;
},
// 选择试剂时处理
handleSelect(code, row) {
- this.selectedId = code;
+ if(this.checkType === "radio"){
+ this.selectedId = code;
+ }
this.currentRow = row;
},
}