| @ -0,0 +1,338 @@ | |||
| <template> | |||
| <div class="template-form-item"> | |||
| <div class="config-header"> | |||
| <div>{{ $t('template.common.jtpz') }}</div> | |||
| <el-button v-if="fillType === 'preFill'" type="text" icon="el-icon-delete" | |||
| @click="deleteConfig('ladderConfigs')">{{ | |||
| $t('template.common.deleteBtn') | |||
| }}</el-button> | |||
| </div> | |||
| <BaseInfoFormPackage @onRegentSubmit="(e) => onRegentSubmit(e)" | |||
| @beforeReagentSubmit="(data) => onBeforeReagentSubmit(data)" | |||
| ref="formPackageRef" :formConfig="currentFormConfig" :formData="currentFormData" | |||
| :fieldItemLabel="fieldItemLabel" @blur="(e) => onHandleBlur(e)" | |||
| @select="(e) => onHandleBlur(e)" :prefixKey="prefixKey" /> | |||
| <CustomTable @blur="(e) => onHandleTableBlur(e)" | |||
| ref="tableRef" :showOperation="showOperation" | |||
| :columns="tableColumns" :formData="currentFormData" | |||
| @bodySelectChange="bodySelectChange" | |||
| @beforeSaveRecord="(data) => onBeforeSaveRecord(data )" | |||
| @headerSelectChange="(data) => onHeaderSelectChange(data)" | |||
| :prefixKey="prefixKey" :fieldItemLabel="fieldItemLabel"> | |||
| <template slot="operation" slot-scope="{ row, rowIndex, columns }"> | |||
| <TableOpertaion @printTag="(e) => printTag(e)" | |||
| @startConfig="(val) => startConfig(val )" | |||
| @configComplete="(val) => configComplete(val)" | |||
| @subPackageSubmit="(val) => subPackageSubmit(val)" | |||
| :fillType="fillType" :row="row" :rowIndex="rowIndex" :columns="columns" | |||
| @deleteRow="(rowIndex) => deleteRow(rowIndex)"> | |||
| </TableOpertaion> | |||
| </template> | |||
| </CustomTable> | |||
| <Step class="mt-0 s-container" ref="stepRef" :formData="currentFormData.ladderStepData" | |||
| :fieldItemLabel="fieldItemLabel" :prefixKey="prefixKey"></Step> | |||
| </div> | |||
| </template> | |||
| <script> | |||
| import Step from '@/components/Template/Step.vue'; | |||
| import CustomTable from '@/components/Template/CustomTable.vue'; | |||
| import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue"; | |||
| import BaseInfoFormPackage from '@/components/Template/BaseInfoFormPackage.vue'; | |||
| import templateMixin from "../../../mixins/templateMixin.js"; | |||
| import { addTj, uniqeResource, uniqeResourceOne, addDecimals } from "@/utils/calUnitTools"; | |||
| export default { | |||
| components: { | |||
| Step, | |||
| CustomTable, | |||
| TableOpertaion, | |||
| BaseInfoFormPackage, | |||
| }, | |||
| name: "LadderConfig", | |||
| mixins: [templateMixin], | |||
| props: { | |||
| fillType: { | |||
| type: String, | |||
| default: '', | |||
| }, | |||
| currentFormConfig: { | |||
| type: Array, | |||
| default: () => [], | |||
| }, | |||
| prefixKey: { | |||
| type: String, | |||
| default: '', | |||
| }, | |||
| fieldItemLabel: { | |||
| type: String, | |||
| default: '', | |||
| }, | |||
| currentFormData: { | |||
| type: Object, | |||
| default: () => {}, | |||
| }, | |||
| showOperation: { | |||
| type: Boolean, | |||
| default: false, | |||
| }, | |||
| tableColumns: { | |||
| type: Array, | |||
| default: () => [], | |||
| }, | |||
| configType:{ | |||
| type: String, | |||
| default: 'ladder', | |||
| } | |||
| }, | |||
| methods: { | |||
| getStepResource(){ | |||
| return this.$refs.stepRef?.getStepResource(); | |||
| }, | |||
| getFilledFormData() { | |||
| const baseFormData = this.$refs.formPackageRef?.getFilledFormData(); | |||
| const tableData = this.$refs.tableRef?.getFilledFormData(); | |||
| const stepData = this.$refs.stepRef?.getFilledFormData(); | |||
| return { | |||
| baseFormData, | |||
| tableData, | |||
| stepData:stepData?.stepData || [], | |||
| } | |||
| }, | |||
| //选择试剂提交事件 | |||
| onRegentSubmit(data) { | |||
| const { selectInfo, key } = data; | |||
| const { row } = selectInfo; | |||
| if (key) { | |||
| const packageRef = this.$refs.formPackageRef; | |||
| if (key === "subStartSolution") { | |||
| packageRef.updateFormData("targetAcSolution", row.nd); | |||
| packageRef.updateFormData("subTargetAcSolutionUnit", row.nddw); | |||
| packageRef.onValueChangeCompareTo("targetAcSolution", row.nd, "targetStartSolution"); | |||
| packageRef.onValueChangeCompareTo("subTargetAcSolutionUnit", row.nddw, "subTargetStartSolution"); | |||
| this.updateTableNd(row); | |||
| } | |||
| } | |||
| }, | |||
| //选择实际的时候更新table的浓度 | |||
| updateTableNd(row) { | |||
| const { stepTableFormData = [], headerSelectFields = [] } = this.$refs.tableRef?.getFilledFormData(); | |||
| const newData = JSON.parse(JSON.stringify(stepTableFormData)); | |||
| const params = this.getLadderNdParamsByIndex(rowIndex); | |||
| // 遍历数据,按要求更新起始溶液编号 | |||
| newData.forEach((item, index) => { | |||
| let initNd = row.nd;//起始浓度是上一条记录的实际目标溶液浓度 | |||
| if (index === 0) { | |||
| item.startSolutionCode = row.bh; | |||
| } else { | |||
| item.startSolutionCode = newData[index - 1].targetSolutionCode + newData[index - 1].subTargetSolutionCode; | |||
| initNd = newData[index - 1].actSolutionConcentration; | |||
| } | |||
| const volResult = this.updateSjmbrynd(item, initNd, params); | |||
| if (!volResult) { | |||
| return | |||
| } | |||
| item.actSolutionVolume = volResult.actVol; | |||
| item.actSolutionConcentration = volResult.actNd; | |||
| // 更新stepTableRef组件的数据 | |||
| }) | |||
| this.$refs.tableRef?.updateDataSource(newData); | |||
| }, | |||
| getLadderNdParamsByIndex() { | |||
| const { headerSelectFields = [] } = this.$refs.tableRef?.getFilledFormData(); | |||
| const subTargetAcSolutionUnit = this.$refs.formPackageRef?.getFormDataByKey("subTargetAcSolutionUnit");//获取实际起始溶液浓度 | |||
| return { | |||
| targetStartSolutionUnit: subTargetAcSolutionUnit, | |||
| headerSelectFields | |||
| } | |||
| }, | |||
| onHandleBlur(e) { | |||
| const { targetStartSolution, subTargetStartSolution } = e; | |||
| const { stepTableFormData, headerSelectFields } = this.$refs.tableRef?.getFilledFormData(); | |||
| const params = { | |||
| subTargetStartSolution, | |||
| headerSelectFields | |||
| } | |||
| this.batchUpdateTargetStartSolutionVolume(stepTableFormData, targetStartSolution, params) | |||
| }, | |||
| // 表格失去焦点事件 | |||
| onHandleTableBlur(e) { | |||
| const { configType } = this; | |||
| const { colKey = "", item, rowIndex, headerSelectFields } = e; | |||
| if (colKey === "targetStartSolutionConcentration" || colKey === "targetSolutionVolume" || colKey === "targetSolutionConcentration" || colKey === "targetStartSolutionVolumePrecision" || colKey === "targetDiluentVolumePrecision") { | |||
| if (configType === "ladder") { | |||
| const { targetStartSolution, subTargetStartSolution } = this.$refs.formPackageRef?.getFilledFormData(); | |||
| const params = { | |||
| subTargetStartSolution, | |||
| headerSelectFields | |||
| } | |||
| if (targetStartSolution) { | |||
| this.updateTargetStartSolutionVolume(item, targetStartSolution, params); | |||
| } | |||
| } else if (configType === "paralle") { | |||
| this.paralleUpdateTargetStartSolutionVolume(item, headerSelectFields); | |||
| } | |||
| } else if (colKey === "actStartSolutionVolume" || colKey === "actDiluentVolume") {//实际起始溶液体积和实际目标溶液体积 | |||
| if (configType === "ladder") { | |||
| const targetAcSolution = this.$refs.formPackageRef?.getFormDataByKey("targetAcSolution");//获取实际起始溶液浓度 | |||
| const params = this.getLadderNdParamsByIndex(configIndex); | |||
| if (targetAcSolution) { | |||
| const volResult = this.updateSjmbrynd(item, targetAcSolution, params); | |||
| if (!volResult) { | |||
| return | |||
| } | |||
| this.$refs.tableRef?.updateDataSourceByRowIndex(rowIndex, { | |||
| actSolutionVolume: volResult.actVol, | |||
| actSolutionConcentration: volResult.actNd, | |||
| }); | |||
| } | |||
| } else if (configType === "paralle") { | |||
| const targetAcSolution = item.targetAcSolution || 0;//获取实际起始溶液浓度 | |||
| const params = this.getParalleNdParamsByIndex(item, configIndex); | |||
| if (targetAcSolution) { | |||
| const volResult = this.updateSjmbrynd(item, targetAcSolution, params); | |||
| if (!volResult) { | |||
| return | |||
| } | |||
| this.$refs.tableRef?.updateDataSourceByRowIndex(rowIndex, { | |||
| actSolutionVolume: volResult.actVol, | |||
| actSolutionConcentration: volResult.actNd, | |||
| }); | |||
| } | |||
| } | |||
| } | |||
| }, | |||
| bodySelectChange(data) { | |||
| this.paralleUpdateTargetStartSolutionVolume(data.item, data.headerSelectFields); | |||
| }, | |||
| //平行配置更新体积 | |||
| paralleUpdateTargetStartSolutionVolume(item, headerSelectFields) { | |||
| const volumne = item.targetStartSolutionConcentration; | |||
| const subTargetStartSolution = item.targetStartSolutionConcentrationPrecision; | |||
| const params = { | |||
| headerSelectFields, | |||
| subTargetStartSolution | |||
| } | |||
| if (volumne) { | |||
| this.updateTargetStartSolutionVolume(item, volumne, params); | |||
| } | |||
| }, | |||
| onBeforeSaveRecord(data) { | |||
| if (this.configType === "ladder") { | |||
| const formFields = this.$refs.formPackageRef?.getFilledFormData(); | |||
| this.onCommonVerifyNdException(formFields, data); | |||
| } | |||
| }, | |||
| //选择table header下拉框也要更新体积 | |||
| onHeaderSelectChange(data) { | |||
| const { key, headerSelectFields, dataSource = [] } = data; | |||
| const keys = [ | |||
| 'targetStartSolutionVolumeUnit', | |||
| 'targetDiluentVolumeUnit', | |||
| 'targetSolutionConcentrationUnit', | |||
| 'targetSolutionVolumeUnit', | |||
| ] | |||
| if (keys.includes(key)) { | |||
| if (this.configType === 'ladder') { | |||
| const { targetStartSolution, subTargetStartSolution } = this.$refs.formPackageRef?.getFilledFormData(); | |||
| const params = { | |||
| subTargetStartSolution, | |||
| headerSelectFields | |||
| } | |||
| this.batchUpdateTargetStartSolutionVolume(dataSource, targetStartSolution, params) | |||
| } else { | |||
| dataSource.forEach(item => { | |||
| this.paralleUpdateTargetStartSolutionVolume(item, headerSelectFields); | |||
| }) | |||
| } | |||
| } | |||
| }, | |||
| //标签打印 | |||
| printTag(e) { | |||
| const { nickName, name } = this.$store.getters; | |||
| const { printCode, row, type } = e; | |||
| const currentForm = this.$refs.formPackageRef?.getFilledFormData(); | |||
| const { stepStorageCondition, startDate, expireDate, paralleStepStorageCondition } = currentForm; | |||
| const targetSolutionExpirationDate = row.targetSolutionExpirationDate; | |||
| const lang = this.$i18n.locale; | |||
| const printConfig = { | |||
| "品名": "暂时还不知道品名是哪个字段", | |||
| "存储条件": stepStorageCondition || paralleStepStorageCondition, | |||
| "配制日期": moment(startDate).format("YYYY-MM-DD"), | |||
| "有效期至": moment(targetSolutionExpirationDate || expireDate).format("YYYY-MM-DD HH:mm"), | |||
| "配置者": lang === "zh_CN" ? nickName : name, | |||
| //type==="subPackage"从分装打印过来的, | |||
| //type==="row" 从列表上点过来的 | |||
| "编号": type === "subPackage" ? printCode : (row.targetSolutionCode + row.subTargetSolutionCode), | |||
| } | |||
| console.log(printConfig, "printConfig") | |||
| EventBus.$emit('showTagPrintDialog', { printConfig }) | |||
| }, | |||
| //开始配置 | |||
| startConfig(val) { | |||
| const { rowData } = val; | |||
| let postData = { | |||
| bh: rowData.targetSolutionCode + rowData.subTargetSolutionCode, | |||
| studySubjectId: this.formData.studySubjectId, | |||
| studyId: this.formData.studyId, | |||
| studyFormId: this.formData.id, | |||
| } | |||
| this.startConfigRequest(postData); | |||
| }, | |||
| //配置完成 | |||
| configComplete(val) { | |||
| const { rowData, headerSelectFields } = val; | |||
| //计算实际目标溶液体积(实际起始溶液体积+实际稀释液体积) | |||
| const { total, unit } = addTj([rowData.actStartSolutionVolume, rowData.actDiluentVolume], [headerSelectFields.actStartSolutionVolumeUnit, headerSelectFields.actDiluentVolumeUnit]) | |||
| debugger | |||
| let postData = { | |||
| mc: null, | |||
| bh: rowData.targetSolutionCode + rowData.subTargetSolutionCode, | |||
| nd: rowData.actSolutionConcentration,//实际目标溶液浓度 | |||
| nddw: headerSelectFields.actSolutionConcentrationUnit, | |||
| studySubjectId: this.formData.studySubjectId, | |||
| studyId: this.formData.studyId, | |||
| studyFormId: this.formData.id, | |||
| kc: total, | |||
| kcdw: unit, | |||
| } | |||
| this.configCompleteRequest(postData); | |||
| }, | |||
| //分装 | |||
| subPackageSubmit(data) { | |||
| const { fzsj, rowData, headerSelectFields } = data; | |||
| const { fzList = [], dw = "", mybh } = fzsj; | |||
| if (fzList && fzList.length > 0) { | |||
| const list = fzList.map((item) => { | |||
| return { | |||
| bh: mybh + item.preCode + item.subCode, | |||
| kc: item.num, | |||
| kcdw: dw, | |||
| } | |||
| }) | |||
| let postData = { | |||
| studyId: this.formData.studyId, | |||
| studyFormId: this.formData.id, | |||
| bh: mybh, | |||
| nd: rowData.actSolutionConcentration || 0, | |||
| nddw: headerSelectFields.actSolutionConcentrationUnit, | |||
| studySubjectId: this.formData.studySubjectId, | |||
| studyId: this.formData.studyId, | |||
| studyFormId: this.formData.id, | |||
| list: list | |||
| } | |||
| this.subPackageRequest(postData); | |||
| } | |||
| }, | |||
| // 删除表格行 | |||
| deleteRow(rowIndex) { | |||
| this.$refs.tableRef.deleteRow(rowIndex); | |||
| }, | |||
| } | |||
| } | |||
| </script> | |||
| <style lang="scss" scoped></style> | |||