Browse Source

feat:[模板管理][阶梯/平行配置组件抽离,未完]

ouqian
luojie 1 month ago
parent
commit
9aedae322e
5 changed files with 366 additions and 24 deletions
  1. +4
    -13
      src/components/Template/CustomTable.vue
  2. +2
    -0
      src/components/Template/Step.vue
  3. +22
    -9
      src/views/business/comps/template/comps/sp/SP00456.vue
  4. +338
    -0
      src/views/business/comps/template/comps/sp/comps/LadderConfig.vue
  5. +0
    -2
      src/views/business/comps/template/mixins/templateMixin.js

+ 4
- 13
src/components/Template/CustomTable.vue View File

@ -732,19 +732,7 @@ export default {
errors: errors errors: errors
}; };
}, },
//
isValueEmpty(value) {
if (value === null || value === undefined || value === '') {
return true;
}
if (typeof value === 'string' && value.trim() === '') {
return true;
}
if (Array.isArray(value) && value.length === 0) {
return true;
}
return false;
},
// //
onHeaderSelectChange(col, value) { onHeaderSelectChange(col, value) {
if (col.headerSelectTo) { if (col.headerSelectTo) {
@ -943,6 +931,9 @@ export default {
this.isIndeterminate = false; this.isIndeterminate = false;
this.$emit('selectionChange', this.selectedRows); this.$emit('selectionChange', this.selectedRows);
}, },
updateHeaderSelectFields(fields) {
this.headerSelectFields = {...this.headerSelectFields, ...fields};
},
// formData // formData
updateDataSource(dataSource = []) { updateDataSource(dataSource = []) {
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource));

+ 2
- 0
src/components/Template/Step.vue View File

@ -436,6 +436,7 @@ export default {
type: '', type: '',
formData: {} formData: {}
}) })
justUpdateFilledFormData();
this.$emit('step-added', this.steps.length) this.$emit('step-added', this.steps.length)
} catch (error) { } catch (error) {
console.error('添加步骤失败:', error) console.error('添加步骤失败:', error)
@ -447,6 +448,7 @@ export default {
if (this.steps.length > 1) { if (this.steps.length > 1) {
const removedStep = this.steps.splice(index, 1)[0] const removedStep = this.steps.splice(index, 1)[0]
justUpdateFilledFormData();
this.$emit('step-removed', { index, step: removedStep, remaining: this.steps.length }) this.$emit('step-removed', { index, step: removedStep, remaining: this.steps.length })
} else { } else {
this.$message.warning('至少需要保留一个步骤') this.$message.warning('至少需要保留一个步骤')

+ 22
- 9
src/views/business/comps/template/comps/sp/SP00456.vue View File

@ -40,8 +40,18 @@
<!-- 阶梯配制区域 --> <!-- 阶梯配制区域 -->
<div v-for="(ladderConfig, ladderIndex) in formData.ladderConfigs" <div v-for="(ladderConfig, ladderIndex) in formData.ladderConfigs"
:key="'ladder_' + ladderConfig.id"> :key="'ladder_' + ladderConfig.id">
<LadderConfig
:currentFormConfig="ladderStepFormConfig"
:currentFormData = "ladderConfig"
:showOperation="fillType === 'actFill' || fillType === 'preFill'"
:tableColumns = "ladderStepColumns"
:prefixKey="'ladder_'+ladderIndex"
:ref="`ladderRef_${ladderIndex}`"
:fieldItemLabel="$t('template.common.jtpz')"
:fillType="fillType"
<div class="template-form-item">
/>
<!-- <div class="template-form-item">
<div class="config-header"> <div class="config-header">
<div>{{ $t('template.common.jtpz') }}</div> <div>{{ $t('template.common.jtpz') }}</div>
<el-button v-if="fillType === 'preFill'" type="text" icon="el-icon-delete" <el-button v-if="fillType === 'preFill'" type="text" icon="el-icon-delete"
@ -77,7 +87,7 @@
<Step class="mt-0 s-container" :ref="`ladderStepRef_${ladderIndex}`" <Step class="mt-0 s-container" :ref="`ladderStepRef_${ladderIndex}`"
:formData="ladderConfig.ladderStepData" :fieldItemLabel="$t('template.common.jtpz')" :formData="ladderConfig.ladderStepData" :fieldItemLabel="$t('template.common.jtpz')"
:prefixKey="'ladder_' + ladderIndex"></Step> :prefixKey="'ladder_' + ladderIndex"></Step>
</div>
</div> -->
</div> </div>
<!-- 平行配制区域 --> <!-- 平行配制区域 -->
@ -152,9 +162,10 @@ import {
getLadderColumnsConfig, getParallelColumnsConfig, getLadderFormConfig, getLadderColumnsConfig, getParallelColumnsConfig, getLadderFormConfig,
getBaseInfoFormConfig, getRemarkFormConfig, getStorageConditionFormConfig, getParalleStepFormConfig ,getJcbColumnsConfig getBaseInfoFormConfig, getRemarkFormConfig, getStorageConditionFormConfig, getParalleStepFormConfig ,getJcbColumnsConfig
} from "../../formConfig/paralleAndLadderConfig.js"; } from "../../formConfig/paralleAndLadderConfig.js";
import LadderConfig from "@/views/business/comps/template/comps/sp/comps/LadderConfig.vue";
export default { export default {
name: "SP00456", name: "SP00456",
components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion, TableOpertaionDelete },
components: { LadderConfig,BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion, TableOpertaionDelete, LadderConfig },
mixins: [templateMixin], mixins: [templateMixin],
props: { props: {
fillType: { fillType: {
@ -684,14 +695,16 @@ export default {
if (this.formData.ladderConfigs && this.formData.ladderConfigs.length > 0) { if (this.formData.ladderConfigs && this.formData.ladderConfigs.length > 0) {
for (let i = 0; i < this.formData.ladderConfigs.length; i++) { for (let i = 0; i < this.formData.ladderConfigs.length; i++) {
const id = this.formData.ladderConfigs[i].id; const id = this.formData.ladderConfigs[i].id;
const ladderFormData = this.$refs[`ladderStepFormPackageRef_${i}`][0].getFilledFormData();
const ladderTableFormData = this.$refs[`ladderStepTableRef_${i}`][0].getFilledFormData();
const ladderStepData = this.$refs[`ladderStepRef_${i}`][0].getFilledFormData();
const {
baseFormData,
tableData,
stepData,
} = this.$refs[`ladderRef_${i}`][0].getFilledFormData();
ladderConfigsData.push({ ladderConfigsData.push({
...ladderFormData,
...ladderTableFormData,
ladderStepData: ladderStepData.stepData,
...baseFormData,
...tableData,
ladderStepData: stepData,
showLadderConfig: true, showLadderConfig: true,
id id
}); });

+ 338
- 0
src/views/business/comps/template/comps/sp/comps/LadderConfig.vue View File

@ -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>

+ 0
- 2
src/views/business/comps/template/mixins/templateMixin.js View File

@ -372,10 +372,8 @@ export default {
}, },
//统一校验form表单是否填写 //统一校验form表单是否填写
async validFormFields(refArr = []) { async validFormFields(refArr = []) {
console.log(refArr,2121)
let result = {} let result = {}
const refs = refArr.map((ref) => { const refs = refArr.map((ref) => {
console.log(ref,312312321)
let refData = {} let refData = {}
if (this.$refs[ref][0]) { if (this.$refs[ref][0]) {
refData = this.$refs[ref][0]?.getFormData() || {} refData = this.$refs[ref][0]?.getFormData() || {}

Loading…
Cancel
Save