Browse Source

feat:[模板管理][update]

lkf
luojie 2 months ago
parent
commit
29aabf4dd7
7 changed files with 178 additions and 116 deletions
  1. +13
    -5
      src/components/Template/CustomTable.vue
  2. +1
    -1
      src/components/Template/HandleFormItem.vue
  3. +4
    -84
      src/components/Template/Step.vue
  4. +99
    -2
      src/utils/index.js
  5. +6
    -3
      src/views/business/comps/template/comps/sp/SP003.vue
  6. +46
    -19
      src/views/business/comps/template/comps/sp/SP00456.vue
  7. +9
    -2
      src/views/business/comps/template/mixins/templateMixin.js

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

@ -280,7 +280,11 @@ export default {
columns.forEach((col, colIndex) => { columns.forEach((col, colIndex) => {
const oldValue = oldRow[col.prop]; const oldValue = oldRow[col.prop];
const newValue = row[col.prop]; const newValue = row[col.prop];
//
if(this.isValueEmpty(newValue) && this.isValueEmpty(oldValue)){
return
}
if (!isEqual(oldValue, newValue)) { if (!isEqual(oldValue, newValue)) {
const fieldLabelCn = this.$i18n.t(col.label, "zh_CN"); const fieldLabelCn = this.$i18n.t(col.label, "zh_CN");
const fieldLabelEn = this.$i18n.t(col.label, "en_US"); const fieldLabelEn = this.$i18n.t(col.label, "en_US");
@ -303,7 +307,9 @@ export default {
if (col.bodySubKey) { if (col.bodySubKey) {
const oldSubValue = oldRow[col.bodySubKey]; const oldSubValue = oldRow[col.bodySubKey];
const newSubValue = row[col.bodySubKey]; const newSubValue = row[col.bodySubKey];
if(this.isValueEmpty(newSubValue) && this.isValueEmpty(oldSubValue)){
return
}
if (!isEqual(oldSubValue, newSubValue)) { if (!isEqual(oldSubValue, newSubValue)) {
const fieldLabelCn = this.$i18n.t(col.label, "zh_CN"); const fieldLabelCn = this.$i18n.t(col.label, "zh_CN");
const fieldLabelEn = this.$i18n.t(col.label, "en_US"); const fieldLabelEn = this.$i18n.t(col.label, "en_US");
@ -417,10 +423,10 @@ export default {
onCopy(rowIndex, col) { onCopy(rowIndex, col) {
if (col.copyFrom) { if (col.copyFrom) {
if (!this.localDataSource[rowIndex][col.copyFrom]) {//
if (this.isValueEmpty(this.localDataSource[rowIndex][col.copyFrom])) {//
return return
} }
this.$set(this.localDataSource[rowIndex], col.prop, this.localDataSource[rowIndex][col.copyFrom])
this.updateDataSourceByRowIndex(rowIndex,{[col.prop]:this.localDataSource[rowIndex][col.copyFrom]},"clickable")
this.onBlur(rowIndex, col.prop, this.localDataSource[rowIndex][col.prop]); this.onBlur(rowIndex, col.prop, this.localDataSource[rowIndex][col.prop]);
} }
}, },
@ -724,6 +730,7 @@ export default {
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource));
// //
this.localDataSource = JSON.parse(JSON.stringify(dataSource || [])); this.localDataSource = JSON.parse(JSON.stringify(dataSource || []));
this.checkCompareToOnDataLoad();
}, },
// autoUpdateRecord // autoUpdateRecord
updateDataSourceByRowIndex(rowIndex, data, type) { updateDataSourceByRowIndex(rowIndex, data, type) {
@ -735,6 +742,7 @@ export default {
} }
this.localDataSource[rowIndex] = { ...this.localDataSource[rowIndex], ...data }; this.localDataSource[rowIndex] = { ...this.localDataSource[rowIndex], ...data };
this.localDataSource = [...this.localDataSource]; this.localDataSource = [...this.localDataSource];
this.checkCompareToOnDataLoad();
}, },
showEditSignDialog: _.debounce(function (rowIndex, data) { showEditSignDialog: _.debounce(function (rowIndex, data) {
const oldData = this.oldLocalDataSource[rowIndex]; const oldData = this.oldLocalDataSource[rowIndex];
@ -742,7 +750,7 @@ export default {
const isSame = this.compareOldAndCurrentFormFields(data, oldData); const isSame = this.compareOldAndCurrentFormFields(data, oldData);
// dataoldDatadatakeyoldData // dataoldDatadatakeyoldData
for (const key in data) { for (const key in data) {
if (!oldData[key] && oldData[key] != 0) {
if (this.isValueEmpty(oldData[key])) {
isFirst = true; isFirst = true;
break; break;
} }

+ 1
- 1
src/components/Template/HandleFormItem.vue View File

@ -430,7 +430,7 @@ export default {
if(isSame){ if(isSame){
return; return;
} }
if (this.oldValue && !isSame && this.templateFillType === "actFill") {
if (!this.isValueEmpty(this.oldValue) && !isSame && this.templateFillType === "actFill") {
// EventBus // EventBus
EventBus.$emit('showEditSignDialog', { uuid: this.uuid }); EventBus.$emit('showEditSignDialog', { uuid: this.uuid });
}else{// }else{//

+ 4
- 84
src/components/Template/Step.vue View File

@ -31,6 +31,7 @@
</template> </template>
<script> <script>
import { duplicateResource } from '@/utils/index.js';
import HandleFormItem from './HandleFormItem.vue'; import HandleFormItem from './HandleFormItem.vue';
import Czdd from './StepComponents/ry/czdd.vue';//- import Czdd from './StepComponents/ry/czdd.vue';//-
import Czhj from './StepComponents/ry/czhj.vue';//- import Czhj from './StepComponents/ry/czhj.vue';//-
@ -343,7 +344,7 @@ export default {
getStepResource(){ getStepResource(){
const sj = []; const sj = [];
let yq = []; let yq = [];
const stepData = this.steps.map((step, index) => {
this.steps.map((step, index) => {
const stepComponentRef = this.$refs[`stepCompRef_${index}`]; const stepComponentRef = this.$refs[`stepCompRef_${index}`];
if(stepComponentRef && stepComponentRef.length > 0){ if(stepComponentRef && stepComponentRef.length > 0){
const {sjResource,yqResource} = this.$refs[`stepCompRef_${index}`][0]?.getSjResource(); const {sjResource,yqResource} = this.$refs[`stepCompRef_${index}`][0]?.getSjResource();
@ -355,89 +356,8 @@ export default {
} }
} }
}) })
// sjtypevalueyl
const uniqueSj = [];
const sjMap = new Map();
// L
const volumeUnits = {
'pL': 1e-12,
'nL': 1e-9,
'uL': 1e-6,
'mL': 1e-3,
'L': 1
};
// g
const massUnits = {
'pg': 1e-12,
'ng': 1e-9,
'ug': 1e-6,
'mg': 1e-3,
'g': 1,
'kg': 1e3
};
for(const item of sj) {
const key = `${item.type}_${item.value}`;
console.log(item,"item")
if(sjMap.has(key)) {
// typevalueyl
const existingItem = sjMap.get(key);
console.log(existingItem,"existingItem")
//
let currentItemYlInBaseUnit, existingItemYlInBaseUnit;
if(item.type === '1') {
//
const currentItemYl = isNaN(parseFloat(item.yl)) ? 0 : parseFloat(item.yl);
const existingItemYl = isNaN(parseFloat(existingItem.yl)) ? 0 : parseFloat(existingItem.yl);
currentItemYlInBaseUnit = currentItemYl * volumeUnits[item.dw] || 0;
existingItemYlInBaseUnit = existingItemYl * volumeUnits[existingItem.dw] || 0;
} else if(item.type === '7') {
//
const currentItemYl = isNaN(parseFloat(item.yl)) ? 0 : parseFloat(item.yl);
const existingItemYl = isNaN(parseFloat(existingItem.yl)) ? 0 : parseFloat(existingItem.yl);
currentItemYlInBaseUnit = currentItemYl * massUnits[item.dw] || 0;
existingItemYlInBaseUnit = existingItemYl * massUnits[existingItem.dw] || 0;
} else {
//
const currentItemYl = isNaN(parseFloat(item.yl)) ? 0 : parseFloat(item.yl);
const existingItemYl = isNaN(parseFloat(existingItem.yl)) ? 0 : parseFloat(existingItem.yl);
currentItemYlInBaseUnit = currentItemYl || 0;
existingItemYlInBaseUnit = existingItemYl || 0;
}
//
const totalYlInBaseUnit = currentItemYlInBaseUnit + existingItemYlInBaseUnit;
// existingItemyl使
if(item.type === '1') {
existingItem.yl = (totalYlInBaseUnit / volumeUnits[existingItem.dw]).toString();
} else if(item.type === '7') {
existingItem.yl = (totalYlInBaseUnit / massUnits[existingItem.dw]).toString();
} else {
existingItem.yl = totalYlInBaseUnit.toString();
}
} else {
//
sjMap.set(key, {...item});
}
}
// Map
sj.length = 0; //
for(const value of sjMap.values()) {
sj.push(value);
}
// yqvalue
yq = yq.filter((item, index, self) =>
self.findIndex(obj => obj.value === item.value) === index
);
console.log(sj,yq,"stepsResource")
return { sjResource: sj, yqResource: yq };
const resource = duplicateResource(sj, yq);
return { sjResource: resource.sj, yqResource: resource.yq };
}, },
// //

+ 99
- 2
src/utils/index.js View File

@ -420,7 +420,104 @@ export const getExpireDate = (startDate, effectivePeriod, effectivePeriodUnit) =
} }
export function getuuid() { export function getuuid() {
return Math.random().toString(36).substring(2) +
Date.now().toString(36);
return Math.random().toString(36).substring(2) +
Date.now().toString(36);
} }
// 判断值是否为空
export function 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;
}
//去重步骤里面的试剂(需要计算总和)和仪器;
export function duplicateResource(sj, yq) {
// 对sj数组根据type和value值去重,并将yl按单位换算后累加
const sjMap = new Map();
// 体积单位转换为基本单位L的倍数
const volumeUnits = {
'pL': 1e-12,
'nL': 1e-9,
'uL': 1e-6,
'mL': 1e-3,
'L': 1
};
// 质量单位转换为基本单位g的倍数
const massUnits = {
'pg': 1e-12,
'ng': 1e-9,
'ug': 1e-6,
'mg': 1e-3,
'g': 1,
'kg': 1e3
};
for (const item of sj) {
const key = `${item.type}_${item.value}`;
console.log(item, "item")
if (sjMap.has(key)) {
// 如果已存在相同type和value的项,累加yl值
const existingItem = sjMap.get(key);
console.log(existingItem, "existingItem")
// 根据类型选择合适的单位转换
let currentItemYlInBaseUnit, existingItemYlInBaseUnit;
if (item.type === '1') {
// 体积单位转换
const currentItemYl = isNaN(parseFloat(item.yl)) ? 0 : parseFloat(item.yl);
const existingItemYl = isNaN(parseFloat(existingItem.yl)) ? 0 : parseFloat(existingItem.yl);
currentItemYlInBaseUnit = currentItemYl * volumeUnits[item.dw] || 0;
existingItemYlInBaseUnit = existingItemYl * volumeUnits[existingItem.dw] || 0;
} else if (item.type === '7') {
// 质量单位转换
const currentItemYl = isNaN(parseFloat(item.yl)) ? 0 : parseFloat(item.yl);
const existingItemYl = isNaN(parseFloat(existingItem.yl)) ? 0 : parseFloat(existingItem.yl);
currentItemYlInBaseUnit = currentItemYl * massUnits[item.dw] || 0;
existingItemYlInBaseUnit = existingItemYl * massUnits[existingItem.dw] || 0;
} else {
// 其他类型暂不处理单位转换,直接相加
const currentItemYl = isNaN(parseFloat(item.yl)) ? 0 : parseFloat(item.yl);
const existingItemYl = isNaN(parseFloat(existingItem.yl)) ? 0 : parseFloat(existingItem.yl);
currentItemYlInBaseUnit = currentItemYl || 0;
existingItemYlInBaseUnit = existingItemYl || 0;
}
// 计算总和
const totalYlInBaseUnit = currentItemYlInBaseUnit + existingItemYlInBaseUnit;
// 更新existingItem的yl值,保持使用第一个项目的单位作为基准单位
if (item.type === '1') {
existingItem.yl = (totalYlInBaseUnit / volumeUnits[existingItem.dw]).toString();
} else if (item.type === '7') {
existingItem.yl = (totalYlInBaseUnit / massUnits[existingItem.dw]).toString();
} else {
existingItem.yl = totalYlInBaseUnit.toString();
}
} else {
// 如果不存在,添加新项
sjMap.set(key, { ...item });
}
}
// 将Map中的值转换回数组
sj.length = 0; // 清空原数组
for (const value of sjMap.values()) {
sj.push(value);
}
// 对yq数组根据value去重
yq = yq.filter((item, index, self) =>
self.findIndex(obj => obj.value === item.value) === index
);
return {sj,yq}
}

+ 6
- 3
src/views/business/comps/template/comps/sp/SP003.vue View File

@ -554,9 +554,12 @@ export default {
// targetSolutionCode // targetSolutionCode
newStepTableData[i].startSolutionCode = newStepTableData[i - 1].targetSolutionCode; newStepTableData[i].startSolutionCode = newStepTableData[i - 1].targetSolutionCode;
} }
const { actVol, actNd } = this.updateSjmbrynd(item, row.nd);
item.actSolutionVolume = actVol;
item.actSolutionConcentration = actNd;
const volResult = this.updateSjmbrynd(item, row.nd);
if(!volResult){
continue
}
item.actSolutionVolume = volResult.actVol;
item.actSolutionConcentration = volResult.actNd;
item.actSolutionExpire = row.sxr; item.actSolutionExpire = row.sxr;
} }
this.$refs.stepTableRef.updateDataSource(newStepTableData); this.$refs.stepTableRef.updateDataSource(newStepTableData);

+ 46
- 19
src/views/business/comps/template/comps/sp/SP00456.vue View File

@ -110,7 +110,7 @@ import templateMixin from "../../mixins/templateMixin.js";
import CustomTable from '@/components/Template/CustomTable.vue'; import CustomTable from '@/components/Template/CustomTable.vue';
import SelectReagentDialog from '../../dialog/SelectReagentDialog.vue'; import SelectReagentDialog from '../../dialog/SelectReagentDialog.vue';
import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue"; import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue";
import { getExpireDate } from "@/utils/index.js";
import { getExpireDate,duplicateResource } from "@/utils/index.js";
import moment from "moment"; import moment from "moment";
import { addTj,uniqeResource } from "@/utils/calUnitTools"; import { addTj,uniqeResource } from "@/utils/calUnitTools";
import { getLadderColumnsConfig, getParallelColumnsConfig, getLadderFormConfig, getBaseInfoFormConfig, getRemarkFormConfig, getStorageConditionFormConfig, getParalleStepFormConfig } from "../../formConfig/paralleAndLadderConfig.js"; import { getLadderColumnsConfig, getParallelColumnsConfig, getLadderFormConfig, getBaseInfoFormConfig, getRemarkFormConfig, getStorageConditionFormConfig, getParalleStepFormConfig } from "../../formConfig/paralleAndLadderConfig.js";
@ -401,20 +401,25 @@ export default {
if (type === "ladder") { if (type === "ladder") {
const targetAcSolution = this.$refs[`ladderStepFormPackageRef_${configIndex}`][0]?.getFormDataByKey("targetAcSolution") || 0;// const targetAcSolution = this.$refs[`ladderStepFormPackageRef_${configIndex}`][0]?.getFormDataByKey("targetAcSolution") || 0;//
if (targetAcSolution) { if (targetAcSolution) {
const { actVol, actNd } = this.updateSjmbrynd(item, targetAcSolution);
const volResult = this.updateSjmbrynd(item, targetAcSolution);
if(!volResult){
return
}
this.$refs[`ladderStepTableRef_${configIndex}`][0]?.updateDataSourceByRowIndex(rowIndex, { this.$refs[`ladderStepTableRef_${configIndex}`][0]?.updateDataSourceByRowIndex(rowIndex, {
actSolutionVolume: actVol,
actSolutionConcentration: actNd,
actSolutionVolume: volResult.actVol,
actSolutionConcentration: volResult.actNd,
},"blur"); },"blur");
} }
} else if (type === "paralle") { } else if (type === "paralle") {
const targetAcSolution = item.targetAcSolution || 0;// const targetAcSolution = item.targetAcSolution || 0;//
if (targetAcSolution) { if (targetAcSolution) {
this.updateSjmbrynd(item, targetAcSolution);
const { actVol, actNd } = this.updateSjmbrynd(item, targetAcSolution);
const volResult = this.updateSjmbrynd(item, targetAcSolution);
if(!volResult){
return
}
this.$refs[`paralleStepTableRef_${configIndex}`][0]?.updateDataSourceByRowIndex(rowIndex, { this.$refs[`paralleStepTableRef_${configIndex}`][0]?.updateDataSourceByRowIndex(rowIndex, {
actSolutionVolume: actVol,
actSolutionConcentration: actNd,
actSolutionVolume: volResult.actVol,
actSolutionConcentration: volResult.actNd,
},"blur"); },"blur");
} }
} }
@ -462,12 +467,15 @@ export default {
} else if (currentTableKey === "actStartSolutionCode") {// } else if (currentTableKey === "actStartSolutionCode") {//
const tableRef = this.$refs[`paralleStepTableRef_${currentRowIndex}`][0]; const tableRef = this.$refs[`paralleStepTableRef_${currentRowIndex}`][0];
if (tableRef) { if (tableRef) {
const { actVol, actNd } = this.updateSjmbrynd(this.currentRowData, row.nd);
const volResult = this.updateSjmbrynd(this.currentRowData, row.nd);
if(!volResult){
return
}
tableRef.updateDataSourceByRowIndex(currentTableIndex, { tableRef.updateDataSourceByRowIndex(currentTableIndex, {
actStartSolutionCode: code, actStartSolutionCode: code,
targetAcSolution: row.nd, targetAcSolution: row.nd,
actSolutionVolume: actVol,
actSolutionConcentration: actNd,
actSolutionVolume: volResult.actVol,
actSolutionConcentration: volResult.actNd,
},"clickable") },"clickable")
} }
} }
@ -488,14 +496,13 @@ export default {
const newData = JSON.parse(JSON.stringify(stepTableFormData)); const newData = JSON.parse(JSON.stringify(stepTableFormData));
// //
newData.forEach((item, index) => { newData.forEach((item, index) => {
const { actVol, actNd } = this.updateSjmbrynd(item, row.nd);
console.log(actNd, "actNd")
item.actSolutionVolume = actVol;
item.actSolutionConcentration = actNd;
const o = {
actSolutionVolume: actVol,
actSolutionConcentration: actNd,
const volResult = this.updateSjmbrynd(item, row.nd);
if(!volResult){
return
} }
console.log(volResult.actNd, "actNd")
item.actSolutionVolume = volResult.actVol;
item.actSolutionConcentration = volResult.actNd;
// stepTableRef // stepTableRef
}) })
this.$refs[`ladderStepTableRef_${this.currentRowIndex}`][0].updateDataSource(newData); this.$refs[`ladderStepTableRef_${this.currentRowIndex}`][0].updateDataSource(newData);
@ -694,8 +701,28 @@ export default {
this.resourceTmp=tmpResource this.resourceTmp=tmpResource
return content; return content;
}, },
getStepResource(){
const sjResource=[],yqResource= [];
if (this.formData.paralleConfigs && this.formData.paralleConfigs.length > 0) {
for (let i = 0; i < this.formData.paralleConfigs.length; i++) {
const paralleResource = this.$refs[`paralleStepRef_${i}`][0].getStepResource();
sjResource.push(...paralleResource.sjResource);
yqResource.push(...paralleResource.yqResource);
}
}
if (this.formData.ladderConfigs && this.formData.ladderConfigs.length > 0) {
for (let i = 0; i < this.formData.ladderConfigs.length; i++) {
const ladderResource = this.$refs[`ladderStepRef_${i}`][0].getStepResource();
sjResource.push(...ladderResource.sjResource);
yqResource.push(...ladderResource.yqResource);
}
}
//
const {sj,yq} = duplicateResource(sjResource,yqResource)
return {sjResource:sj,yqResource:yq};
},
async onSave() { async onSave() {
const formData = await this.getFormData();
const formData = this.getStepResource();
console.log(formData, "formData") console.log(formData, "formData")
} }
} }

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

@ -1,5 +1,6 @@
import moment from 'moment' import moment from 'moment'
import { getLatestSn,getLatestSnArr } from '@/api/template'; import { getLatestSn,getLatestSnArr } from '@/api/template';
import { isValueEmpty } from '@/utils/index';
import { sj_subpackage, sj_startConfiguration, sj_configurationCompleted } from '@/api/business/sj/sj'; import { sj_subpackage, sj_startConfiguration, sj_configurationCompleted } from '@/api/business/sj/sj';
export default { export default {
dicts: [ dicts: [
@ -360,8 +361,11 @@ export default {
this.$refs.stepFormPackageRef?.getFormDataByKey('targetAcSolution') || this.$refs.stepFormPackageRef?.getFormDataByKey('targetAcSolution') ||
0 //获取实际起始溶液浓度 0 //获取实际起始溶液浓度
if (targetAcSolution) { if (targetAcSolution) {
const { actVol, actNd } = this.updateSjmbrynd(item, targetAcSolution);
this.$refs.stepTableRef?.updateDataSourceByRowIndex(rowIndex, { actSolutionVolume: actVol,actSolutionConcentration: actNd},"blur")
const volResult = this.updateSjmbrynd(item, targetAcSolution);
if(!volResult){
return
}
this.$refs.stepTableRef?.updateDataSourceByRowIndex(rowIndex, { actSolutionVolume: volResult.actVol,actSolutionConcentration: volResult.actNd},"blur")
} }
} }
}, },
@ -381,6 +385,9 @@ export default {
//实际目标溶液体积 //实际目标溶液体积
// item.actSolutionVolume = actVol // item.actSolutionVolume = actVol
//实际目标溶液浓度 //实际目标溶液浓度
if(!isValueEmpty(actDiluentVolume) && !isValueEmpty(actStartSolutionVolume)){
return false
}
const actNd = ( const actNd = (
targetAcSolution / targetAcSolution /
actStartSolutionVolume / actStartSolutionVolume /

Loading…
Cancel
Save