diff --git a/src/components/Template/BaseInfoFormPackage.vue b/src/components/Template/BaseInfoFormPackage.vue index 5d965cf..27520d0 100644 --- a/src/components/Template/BaseInfoFormPackage.vue +++ b/src/components/Template/BaseInfoFormPackage.vue @@ -81,7 +81,7 @@ @update:error="errors[key] = false" :orange-bg="orangeBgFields[key]" />
- @@ -128,7 +128,7 @@ :orange-bg="orangeBgFields[sItem.subKey]" />
{{ formFields[sItem.subKey] }}
@@ -158,14 +158,14 @@ :orange-bg="orangeBgFields[sItem.subKey]" />
{{ formFields[sItem.subKey] }}
diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index ea8040c..e111598 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -165,7 +165,7 @@ import { getuuid } from "@/utils/index.js"; import moment from "moment"; import _ from "lodash"; export default { - inject: ['templateFillType', 'getZdxgjl'], + inject: ['templateFillType', 'getZdxgjl', 'updateZdxgjl'], name: 'CustomTable', components: { HandleFormItem @@ -246,15 +246,15 @@ export default { } } }, - mounted() { - EventBus.$on('onEditSignCallback', this.handleEditSignCallback); - EventBus.$on('onFormEditSignCancel', this.handleEditSignCancel); - }, - unmounted() { + mounted() { + EventBus.$on('onEditSignCallback', this.handleEditSignCallback); + EventBus.$on('onFormEditSignCancel', this.handleEditSignCancel); + }, + unmounted() { this.oldLocalDataSource = []; - EventBus.$off('onEditSignCallback', this.handleEditSignCallback); - EventBus.$off('onFormEditSignCancel', this.handleEditSignCancel); - }, + EventBus.$off('onEditSignCallback', this.handleEditSignCallback); + EventBus.$off('onFormEditSignCancel', this.handleEditSignCancel); + }, methods: { handleEditSignCancel(data) { if (data.uuid === this.uuid) { @@ -263,7 +263,7 @@ export default { }, handleEditSignCallback(data) { if (data.uuid === this.uuid) { - this.updateRecord(); + this.updateRecords(); } }, getRecords() { @@ -295,8 +295,9 @@ export default { title: oldValue ? "修改" : "提交", time: moment().format("YYYY-MM-DD HH:mm:ss"), }; - this.getZdxgjl().unshift(record); + this.updateZdxgjl(record); records.push(record); + } if (col.bodySubKey) { @@ -317,7 +318,7 @@ export default { title: oldSubValue ? "修改" : "提交", time: moment().format("YYYY-MM-DD HH:mm:ss"), }; - this.getZdxgjl().unshift(record); + this.updateZdxgjl(record); records.push(record); } } @@ -342,7 +343,7 @@ export default { title: oldOtherValue ? "修改" : "提交", time: moment().format("YYYY-MM-DD HH:mm:ss"), }; - this.getZdxgjl().unshift(record); + this.updateZdxgjl(record); records.push(record); } } @@ -351,21 +352,27 @@ export default { return records; }, - updateRecord() { - const records = this.getRecords(); - const params = { - type: "fieldChanged", - newRecord: records, - resourceList: this.getZdxgjl(), - } - setTimeout(() => { + updateRecords() { + this.$nextTick(() => { + const records = this.getRecords(); + const params = { + type: "fieldChanged", + newRecord: records, + resourceList: this.getZdxgjl(), + source: "customTable", + } + if (records.length == 0) { + return; + } + console.log(records, "records") EventBus.$emit('onModifyRecord', params); - }, 0); - this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); + this.oldLocalDataSource = []; + + }) }, //取消按钮 重置记录 resetRecord(rowIndex, colIndex,) { - if(this.localDataSource.length){ + if (this.localDataSource.length) { this.localDataSource = [...this.oldLocalDataSource]; this.oldLocalDataSource = []; } @@ -561,7 +568,7 @@ export default { }, // 表头选择器变化 onHeaderSelectChange(col, value) { - if(col.headerSelectTo){ + if (col.headerSelectTo) { this.headerSelectFields[col.headerSelectTo] = value; } this.headerSelectFields[col.headerSelectKey] = value; @@ -719,50 +726,54 @@ export default { this.localDataSource = JSON.parse(JSON.stringify(dataSource || [])); }, // 根据行索引更新数据 autoUpdateRecord 是否自动更新记录 - updateDataSourceByRowIndex(rowIndex, data,autoUpdateRecord = true) { + updateDataSourceByRowIndex(rowIndex, data, type) { this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource)); - if(autoUpdateRecord){//如果formpackage联动table的情况,不需要自动更新,不然会出现多个弹窗的问题。 - this.showEditSignDialog(rowIndex,data); - } + if (type === "clickable") {//如果是custom内部的clickable需要判断是否弹窗 + this.showEditSignDialog(rowIndex,data); + }else if(type === "blur"){ + this.updateRecords(); + } this.localDataSource[rowIndex] = { ...this.localDataSource[rowIndex], ...data }; this.localDataSource = [...this.localDataSource]; }, - showEditSignDialog: _.debounce(function(rowIndex,data){ + showEditSignDialog: _.debounce(function (rowIndex, data) { const oldData = this.oldLocalDataSource[rowIndex]; let isFirst = false;//是否是第一次添加,是否和旧数据相同 - const isSame = this.compareOldAndCurrentFormFields(data,oldData); + const isSame = this.compareOldAndCurrentFormFields(data, oldData); // 遍历data对象,和oldData比较,判断data的key值在对应oldData里面是否有值 - for(const key in data) { - if(!oldData[key]&&oldData[key]!=0){ + for (const key in data) { + if (!oldData[key] && oldData[key] != 0) { isFirst = true; break; } } - if(!isFirst &&!isSame && this.templateFillType === "actFill"){ + if (!isFirst && !isSame && this.templateFillType === "actFill") { console.log("showww") setTimeout(() => { EventBus.$emit('showEditSignDialog', { uuid: this.uuid }); }, 100); - }else{ - this.updateRecord(rowIndex,data); + + } else { + console.log("not show") + this.updateRecords(); } - + }, 100), - // 比较newData和oldData的值是否相等,只要有一对不相等就返回false - compareOldAndCurrentFormFields(newData,oldData) { - for (const key in newData) { + // 比较newData和oldData的值是否相等,只要有一对不相等就返回false + compareOldAndCurrentFormFields(newData, oldData) { + for (const key in newData) { const oldValue = newData[key]; const currentValue = oldData[key]; if (JSON.stringify(oldValue) !== JSON.stringify(currentValue)) { return false; } else { - return false; + return false; } - } + } - return true; - }, + return true; + }, onAddRow() { this.addRow({ actSolutionVolumePrecision: 3,//小数点精度默认为3 @@ -778,7 +789,7 @@ export default { getDataSource() { return this.localDataSource; }, - + // 判断表单项是否有错误 hasError(rowIndex, colIndex, field) { return this.formErrors.some(error => diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index 8133601..210adb5 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -443,7 +443,7 @@ export default { // 用户点击取消,还原数据 this.inputValue = this.oldValue; this.$emit('input', this.inputValue); // 触发 v-model 更新 - this.$emit("blur", this.oldValue); + // this.$emit("blur", this.oldValue); this.$emit("change", this.oldValue,"cancel"); if(this.item.type === "clickable"){ this.$emit("resetRecord"); @@ -475,6 +475,9 @@ export default { this.$emit("blur", this.inputValue); this.$emit('input', this.inputValue); this.$emit("change", this.inputValue,data?"save":""); + if(this.item.type === "clickable"){//clickable的丢给父级去处理 + return; + } if(this.templateFillType === "actFill"){//只有实际填报的时候才记录修改记录 this.updateZdxgjl(record); } diff --git a/src/components/Template/Step.vue b/src/components/Template/Step.vue index ffbda5e..f92ad1d 100644 --- a/src/components/Template/Step.vue +++ b/src/components/Template/Step.vue @@ -389,13 +389,13 @@ export default { console.log(existingItem,"existingItem") // 根据类型选择合适的单位转换 let currentItemYlInBaseUnit, existingItemYlInBaseUnit; - if(item.type === 'sj') { + 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 === 'gsp') { + } 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); @@ -413,9 +413,9 @@ export default { const totalYlInBaseUnit = currentItemYlInBaseUnit + existingItemYlInBaseUnit; // 更新existingItem的yl值,保持使用第一个项目的单位作为基准单位 - if(item.type === 'sj') { + if(item.type === '1') { existingItem.yl = (totalYlInBaseUnit / volumeUnits[existingItem.dw]).toString(); - } else if(item.type === 'gsp') { + } else if(item.type === '7') { existingItem.yl = (totalYlInBaseUnit / massUnits[existingItem.dw]).toString(); } else { existingItem.yl = totalYlInBaseUnit.toString(); diff --git a/src/components/Template/mixins/formPackageMixins.js b/src/components/Template/mixins/formPackageMixins.js index 009b128..6e59d61 100644 --- a/src/components/Template/mixins/formPackageMixins.js +++ b/src/components/Template/mixins/formPackageMixins.js @@ -35,6 +35,7 @@ export default { return { uuid: getuuid(), oldFormFields: {}, + clickableKey: "", } }, mounted() { @@ -120,7 +121,7 @@ export default { }, //更新表单数据 - updateFormData(key, value,autoUpdateRecord = true) { + updateFormData(key, value) { // 深拷贝当前表单数据,避免直接修改原数据 const cloneFormFields = JSON.parse(JSON.stringify(this.formFields)); @@ -139,6 +140,11 @@ export default { newRecord: records, resourceList: this.getZdxgjl(), } + //只要有更新就触发更新记录 + if(this.templateFillType === "actFill" && this.clickableKey){ + this.$emit("onSureModifyRecord", this.clickableKey) + this.clickableKey = ""; + } setTimeout(() => { EventBus.$emit('onModifyRecord', params,) }, 0); @@ -189,10 +195,11 @@ export default { return true; }, - handleClickable(sItem, event) { + handleClickable(sItem, key) { if (this.templateFillType !== 'actFill') { return } + this.clickableKey = key; this.$emit("clickable", sItem) }, //根据span判断一行显示几列 diff --git a/src/views/business/comps/template/TemplateTable.vue b/src/views/business/comps/template/TemplateTable.vue index e4f1713..d00ff5f 100644 --- a/src/views/business/comps/template/TemplateTable.vue +++ b/src/views/business/comps/template/TemplateTable.vue @@ -1,19 +1,20 @@ diff --git a/src/views/business/comps/template/comps/sp/SP003.vue b/src/views/business/comps/template/comps/sp/SP003.vue index fc922e8..a3f367a 100644 --- a/src/views/business/comps/template/comps/sp/SP003.vue +++ b/src/views/business/comps/template/comps/sp/SP003.vue @@ -16,7 +16,9 @@
({prex:item.targetSolutionCode,type:1})); + const snList = await this.getLatestSnArr(codes); stepTableFormData.forEach((item, index) => { this.$refs.stepTableRef.updateDataSourceByRowIndex(index, { subTargetSolutionCode: snList[index] }); }) @@ -543,14 +553,11 @@ export default { newStepTableData[i].startSolutionCode = newStepTableData[i - 1].targetSolutionCode; } const { actVol, actNd } = this.updateSjmbrynd(item, row.nd); - var o = { - actSolutionVolume: actVol, - actSolutionConcentration: actNd, - actSolutionExpire: row.sxr, - } - this.$refs.stepTableRef.updateDataSourceByRowIndex(i, o); + item.actSolutionVolume = actVol; + item.actSolutionConcentration = actNd; + item.actSolutionExpire = row.sxr; } - + this.$refs.stepTableRef.updateDataSource(newStepTableData); // 更新stepTableRef组件的数据 }, async getFormData() { diff --git a/src/views/business/comps/template/comps/sp/SP00456.vue b/src/views/business/comps/template/comps/sp/SP00456.vue index e5037d5..173ea9f 100644 --- a/src/views/business/comps/template/comps/sp/SP00456.vue +++ b/src/views/business/comps/template/comps/sp/SP00456.vue @@ -30,6 +30,7 @@
@@ -187,6 +188,9 @@ export default { mounted() { }, methods: { + onSureModifyRecord(type, index, e) { + this.$refs[`ladderStepTableRef_${index}`][0].updateRecords(); + }, resetRecord(type, index, e) { this.$refs[`ladderStepTableRef_${index}`][0].resetRecord(); }, @@ -286,8 +290,8 @@ export default { row.subTargetSolutionCode && row.subTargetSolutionCode.trim() !== ''); // 如果没有任何一行有值,则为所有行分配编号 if (!hasAnyWithValue) { - const length = tableDataArray.length; - const snList = await this.getLatestSn(length); + const codes = stepTableFormData.map((item) => ({prex:item.targetSolutionCode,type:1})); + const snList = await this.getLatestSnArr(codes); tableDataArray.forEach((row, idx) => { let expDate = {}; if (config === "paralleConfigs" && !row.targetSolutionExpirationDate) { @@ -401,7 +405,7 @@ export default { this.$refs[`ladderStepTableRef_${configIndex}`][0]?.updateDataSourceByRowIndex(rowIndex, { actSolutionVolume: actVol, actSolutionConcentration: actNd, - }); + },"blur"); } } else if (type === "paralle") { const targetAcSolution = item.targetAcSolution || 0;//获取实际起始溶液浓度 @@ -411,7 +415,7 @@ export default { this.$refs[`paralleStepTableRef_${configIndex}`][0]?.updateDataSourceByRowIndex(rowIndex, { actSolutionVolume: actVol, actSolutionConcentration: actNd, - }); + },"blur"); } } @@ -464,8 +468,7 @@ export default { targetAcSolution: row.nd, actSolutionVolume: actVol, actSolutionConcentration: actNd, - }) - + },"clickable") } } this.$refs.selectReagentDialogRef.onCancel(); @@ -494,8 +497,9 @@ export default { actSolutionConcentration: actNd, } // 更新stepTableRef组件的数据 - this.$refs[`ladderStepTableRef_${this.currentRowIndex}`][0].updateDataSourceByRowIndex(index, o); }) + this.$refs[`ladderStepTableRef_${this.currentRowIndex}`][0].updateDataSource(newData); + }, //只做校验 async validFields() { diff --git a/src/views/business/comps/template/dialog/SelectMixReagentDialog.vue b/src/views/business/comps/template/dialog/SelectMixReagentDialog.vue index 53fb0fb..9069abe 100644 --- a/src/views/business/comps/template/dialog/SelectMixReagentDialog.vue +++ b/src/views/business/comps/template/dialog/SelectMixReagentDialog.vue @@ -146,7 +146,8 @@ export default { nd: row.nd, ly: row.ly, nddw: row.nddw, - sxrq: row.sxrq, + sxrq: row.sxr, + ndz: (row.nd||"")+(row.nddw||""), type: Number(this.selectType), } this.$emit('submit', selectedValue, row); diff --git a/src/views/business/comps/template/dialog/SubPackageDialog.vue b/src/views/business/comps/template/dialog/SubPackageDialog.vue index 544a8ff..fd0c25f 100644 --- a/src/views/business/comps/template/dialog/SubPackageDialog.vue +++ b/src/views/business/comps/template/dialog/SubPackageDialog.vue @@ -221,8 +221,9 @@ export default { this.fzList = []; this.fzListErrors = []; const result = await getLatestSn({ - my: this.formData.mybh, + pre: this.formData.mybh, count: e, + type: 2, }) if(result.code === 200){ const codes = result.data; diff --git a/src/views/business/comps/template/formConfig/paralleAndLadderConfig.js b/src/views/business/comps/template/formConfig/paralleAndLadderConfig.js index b2b0463..93520fb 100644 --- a/src/views/business/comps/template/formConfig/paralleAndLadderConfig.js +++ b/src/views/business/comps/template/formConfig/paralleAndLadderConfig.js @@ -81,7 +81,7 @@ export const getLadderColumnsConfig = ($this) => { bodyType: 'inputNumber', bodyFillType: 'actFill', bodyMaxlength: 10, - copyFrom: 'targetDiluentVolume', //复制哪个字段 + // copyFrom: 'targetDiluentVolume', //复制哪个字段 compareTo: 'targetDiluentVolume', //比较哪个字段 }, { @@ -351,6 +351,7 @@ export const getParallelColumnsConfig = ($this) => { bodyType: 'inputNumber', bodyFillType: 'actFill', bodyMaxlength: 10, + copyFrom:"targetDiluentVolume", compareTo: 'targetDiluentVolume' //比较哪个字段 } ] diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js index f12e620..418a1ee 100644 --- a/src/views/business/comps/template/mixins/templateMixin.js +++ b/src/views/business/comps/template/mixins/templateMixin.js @@ -1,5 +1,5 @@ import moment from 'moment' -import { getLatestSn } from '@/api/template'; +import { getLatestSn,getLatestSnArr } from '@/api/template'; import { sj_subpackage, sj_startConfiguration, sj_configurationCompleted } from '@/api/business/sj/sj'; export default { dicts: [ @@ -209,7 +209,15 @@ export default { if (res.code === 200) { return res.data } - return null + return [] + }, + //获取最新的多个编号 + async getLatestSnArr(params) { + const res = await getLatestSnArr(params) + if (res.code === 200) { + return res.data + } + return [] }, getResource() { return this.resourceTmp @@ -353,8 +361,7 @@ export default { 0 //获取实际起始溶液浓度 if (targetAcSolution) { const { actVol, actNd } = this.updateSjmbrynd(item, targetAcSolution); - this.$refs.stepTableRef?.updateDataSourceByRowIndex(rowIndex, { actSolutionVolume: actVol }) - this.$refs.stepTableRef?.updateDataSourceByRowIndex(rowIndex, { actSolutionConcentration: actNd }) + this.$refs.stepTableRef?.updateDataSourceByRowIndex(rowIndex, { actSolutionVolume: actVol,actSolutionConcentration: actNd},"blur") } } }, @@ -379,11 +386,11 @@ export default { actStartSolutionVolume / actVol ).toFixed(precision) - const nd = actNd === 'Infinity' ? 0 : actNd + const nd = actNd === 'Infinity' ? 0 : Number(actNd) console.log(actNd, targetAcSolution, actStartSolutionVolume, actVol, "actNd") // item.actSolutionConcentration = actNd === 'Infinity' ? 0 : actNd - return { actVol, actNd: nd } + return { actVol:Number(actVol), actNd: nd } }, //更新起始溶液体积时,计算目标溶液预计浓度 updateTargetStartSolutionVolume(item, volume) { @@ -391,16 +398,16 @@ export default { const concentration = item.targetSolutionConcentration || 0 const targetVolume = item.targetSolutionVolume || 0 //目标溶液预计浓度:(目标溶液预计体积 乘以 起始溶液浓度)除以 起始溶液体积 - const result = ((concentration * targetVolume) / volume).toFixed( + const result = Number(((concentration * targetVolume) / volume).toFixed( precision - ) + )) item.targetStartSolutionVolume = result // this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetStartSolutionVolume: result }); if (targetVolume) { //预设稀释液体积:目标溶液预计体积 减去 源溶液预计体积; const precision1 = item.targetDiluentVolumePrecision || 0 const result1 = (targetVolume - result).toFixed(precision1) - item.targetDiluentVolume = result1 + item.targetDiluentVolume = Number(result1) // this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetDiluentVolume: result1 }); } }