diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index 77bee32..3ea7bd1 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -780,6 +780,9 @@ export default { if (col.qxbdType) { item.qxbdType = col.qxbdType; } + if (col.checkType) { + item.checkType = col.checkType; + } // 支持动态checkboxLabel - 从行数据中获取 const dynamicLabelKey = col.prop + 'Label'; if (currentItem && currentItem[dynamicLabelKey]) { diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index 483acdc..cf619d4 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -628,6 +628,8 @@ export default { params.mixType = true; } else if (item.qxbdType) { params.qxbdType = item.qxbdType; + } else if (item.checkType) { + params.checkType = item.checkType; } } EventBus.$emit(eventName, params) diff --git a/src/components/Template/SelectTable.vue b/src/components/Template/SelectTable.vue index 2ec60b9..2556d2c 100644 --- a/src/components/Template/SelectTable.vue +++ b/src/components/Template/SelectTable.vue @@ -14,12 +14,18 @@ {{ $t('form.reset') }} - - + + + + @@ -46,7 +52,11 @@ export default { type: Object, default: () => {}, }, - showRadio: {//是否显示单选框 + checkType: {//是否显示单选框或复选框 + type: String, + default: "radio", + }, + showCheckbox: {//是否显示复选框 type: Boolean, default: true, }, @@ -79,6 +89,7 @@ export default { data() { return { localSelectedId: "", + localSelectedRows: [], listParams: { pageNum: 1, pageSize: 10, @@ -153,7 +164,11 @@ export default { this.localSelectedId = row[this.selectedCode]; this.$emit("radioSelect", row[this.selectedCode],row); }, - + //复选框点击 + handleSelectionChange(selection) { + this.localSelectedRows = selection; + this.$emit("radioSelect","", selection); + }, } } diff --git a/src/components/Template/mixins/formPackageMixins.js b/src/components/Template/mixins/formPackageMixins.js index 26db979..47c0660 100644 --- a/src/components/Template/mixins/formPackageMixins.js +++ b/src/components/Template/mixins/formPackageMixins.js @@ -75,6 +75,7 @@ export default { parentLabel: item.label, filledCodes: item.filledCodes, qxbdType: item.qxbdType, + checkType: item.checkType, } }, diff --git a/src/views/business/comps/template/comps/sp/SP0021.vue b/src/views/business/comps/template/comps/sp/SP0021.vue index 3d557c3..d92ca00 100644 --- a/src/views/business/comps/template/comps/sp/SP0021.vue +++ b/src/views/business/comps/template/comps/sp/SP0021.vue @@ -15,32 +15,32 @@ :formConfig="storageFormConfig" :formData="formData" /> 新增 -
+
{{ $t('template.common.deleteBtn') + @click="deleteConfig(index)">{{ $t('template.common.deleteBtn') }}
- + 导入动物 + :dataSource="item.ybsmData || []" > - +
@@ -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; }, }