Browse Source

feat:[步骤][update]

lkf
luojie 2 months ago
parent
commit
99fcc5cfd2
17 changed files with 223 additions and 23 deletions
  1. +139
    -12
      src/components/Template/CustomTable.vue
  2. +10
    -0
      src/components/Template/Step.vue
  3. +2
    -0
      src/components/Template/StepComponents/ry/clcz.vue
  4. +2
    -0
      src/components/Template/StepComponents/ry/clfcz.vue
  5. +2
    -0
      src/components/Template/StepComponents/ry/fr.vue
  6. +2
    -0
      src/components/Template/StepComponents/ry/frdrq.vue
  7. +2
    -0
      src/components/Template/StepComponents/ry/jrry.vue
  8. +2
    -0
      src/components/Template/StepComponents/ry/qcyy.vue
  9. +2
    -0
      src/components/Template/StepComponents/ry/rs.vue
  10. +4
    -0
      src/components/Template/StepComponents/ry/tjphcz.vue
  11. +4
    -0
      src/components/Template/StepComponents/ry/tjphfcz.vue
  12. +3
    -1
      src/components/Template/StepComponents/ry/ym.vue
  13. +27
    -0
      src/components/Template/StepFormPackage.vue
  14. +14
    -9
      src/components/Template/mixins/formPackageMixins.js
  15. +3
    -0
      src/components/Template/mixins/stepMixins.js
  16. +4
    -0
      src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue
  17. +1
    -1
      src/views/business/comps/template/dialog/SelectMixReagentDialog.vue

+ 139
- 12
src/components/Template/CustomTable.vue View File

@ -160,8 +160,12 @@
import HandleFormItem from "./HandleFormItem.vue";
import { isEqual } from "@/utils/index.js";
import { isShowOther } from "@/utils/formPackageCommon.js";
import { EventBus } from "@/utils/eventBus";
import { getuuid } from "@/utils/index.js";
import moment from "moment";
import _ from "lodash";
export default {
inject: ['templateFillType'],
inject: ['templateFillType', 'getZdxgjl'],
name: 'CustomTable',
components: {
HandleFormItem
@ -217,6 +221,7 @@ export default {
orangeBgCells: {}, // {rowIndex-colIndex: true/false}
isShowOther,
oldLocalDataSource: [],
uuid: getuuid(),
}
},
watch: {
@ -226,7 +231,6 @@ export default {
const { stepTableFormData = [], headerSelectFields = {} } = newData;
this.updateDataSource(stepTableFormData);
this.headerSelectFields = JSON.parse(JSON.stringify(headerSelectFields));
console.log(stepTableFormData,"stepTableFormData")
// compareTo
this.checkCompareToOnDataLoad();
}
@ -242,10 +246,123 @@ export default {
}
}
},
mounted() {
// this.initHeaderSelectValues();
},
mounted() {
EventBus.$on('onEditSignCallback', this.handleEditSignCallback);
EventBus.$on('onFormEditSignCancel', this.handleEditSignCancel);
},
unmounted() {
this.oldLocalDataSource = [];
EventBus.$off('onEditSignCallback', this.handleEditSignCallback);
EventBus.$off('onFormEditSignCancel', this.handleEditSignCancel);
},
methods: {
handleEditSignCancel(data) {
if (data.uuid === this.uuid) {
this.resetRecord();
}
},
handleEditSignCallback(data) {
if (data.uuid === this.uuid) {
this.updateRecord();
}
},
getRecords() {
const records = [];
const { nickName, name } = this.$store.getters;
const { oldLocalDataSource, localDataSource, columns, prefixKey, fieldItemLabel } = this;
localDataSource.forEach((row, rowIndex) => {
const oldRow = oldLocalDataSource[rowIndex];
if (!oldRow) {
return;
}
columns.forEach((col, colIndex) => {
const oldValue = oldRow[col.prop];
const newValue = row[col.prop];
if (!isEqual(oldValue, newValue)) {
const fieldLabelCn = this.$i18n.t(col.label, "zh_CN");
const fieldLabelEn = this.$i18n.t(col.label, "en_US");
const record = {
userNameCn: nickName,
userNameEn: name,
key: prefixKey + '_' + col.prop + '_' + rowIndex,
fieldCn: `${this.$i18n.t(fieldItemLabel, "zh_CN")}-${fieldLabelCn}`,
fieldEn: `${this.$i18n.t(fieldItemLabel, "en_US")}-${fieldLabelEn}`,
oldValue: oldValue,
value: newValue,
title: oldValue ? "修改" : "提交",
time: moment().format("YYYY-MM-DD HH:mm:ss"),
};
this.getZdxgjl().unshift(record);
records.push(record);
}
if (col.bodySubKey) {
const oldSubValue = oldRow[col.bodySubKey];
const newSubValue = row[col.bodySubKey];
if (!isEqual(oldSubValue, newSubValue)) {
const fieldLabelCn = this.$i18n.t(col.label, "zh_CN");
const fieldLabelEn = this.$i18n.t(col.label, "en_US");
const record = {
userNameCn: nickName,
userNameEn: name,
key: prefixKey + '_' + col.bodySubKey + '_' + rowIndex,
fieldCn: `${this.$i18n.t(fieldItemLabel, "zh_CN")}-${fieldLabelCn}单位`,
fieldEn: `${this.$i18n.t(fieldItemLabel, "en_US")}-${fieldLabelEn}单位`,
oldValue: oldSubValue,
value: newSubValue,
title: oldSubValue ? "修改" : "提交",
time: moment().format("YYYY-MM-DD HH:mm:ss"),
};
this.getZdxgjl().unshift(record);
records.push(record);
}
}
if (col.otherCode) {
const oldOtherValue = oldRow[col.otherCode];
const newOtherValue = row[col.otherCode];
if (!isEqual(oldOtherValue, newOtherValue)) {
const fieldLabelCn = this.$i18n.t(col.label, "zh_CN");
const fieldLabelEn = this.$i18n.t(col.label, "en_US");
const otherLabelCn = col.otherLabel ? this.$i18n.t(col.otherLabel, "zh_CN") : this.$i18n.t("template.common.other", "zh_CN");
const otherLabelEn = col.otherLabel ? this.$i18n.t(col.otherLabel, "en_US") : this.$i18n.t("template.common.other", "en_US");
const record = {
userNameCn: nickName,
userNameEn: name,
key: prefixKey + '_' + col.otherCode + '_' + rowIndex,
fieldCn: `${this.$i18n.t(fieldItemLabel, "zh_CN")}-${fieldLabelCn}${otherLabelCn}`,
fieldEn: `${this.$i18n.t(fieldItemLabel, "en_US")}-${fieldLabelEn}${otherLabelEn}`,
oldValue: oldOtherValue,
value: newOtherValue,
title: oldOtherValue ? "修改" : "提交",
time: moment().format("YYYY-MM-DD HH:mm:ss"),
};
this.getZdxgjl().unshift(record);
records.push(record);
}
}
});
});
return records;
},
updateRecord() {
const records = this.getRecords();
const params = {
type: "fieldChanged",
newRecord: records,
resourceList: this.getZdxgjl(),
}
setTimeout(() => {
EventBus.$emit('onModifyRecord', params);
}, 0);
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource));
},
//
resetRecord(rowIndex, colIndex,) {
if(this.localDataSource.length){
@ -596,12 +713,27 @@ export default {
this.$emit('row-delete', rowIndex);
},
// formData
updateDataSource(dataSource = []) {
updateDataSource(dataSource = [],autoUpdateRecord = true) {
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource));
if(autoUpdateRecord){
this.showEditSignDialog();
}
console.log(this.oldLocalDataSource, "oldLocalDataSource")
//
this.localDataSource = JSON.parse(JSON.stringify(dataSource || []));
},
// autoUpdateRecord
updateDataSourceByRowIndex(rowIndex, data,autoUpdateRecord = true) {
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource));
if(autoUpdateRecord){
this.showEditSignDialog();
}
this.localDataSource[rowIndex] = { ...this.localDataSource[rowIndex], ...data };
this.localDataSource = [...this.localDataSource];
},
showEditSignDialog: _.debounce(()=>{
}, 100),
onAddRow() {
this.addRow({
actSolutionVolumePrecision: 3,//3
@ -617,12 +749,7 @@ export default {
getDataSource() {
return this.localDataSource;
},
//
updateDataSourceByRowIndex(rowIndex, data) {
this.oldLocalDataSource = JSON.parse(JSON.stringify(this.localDataSource));
this.localDataSource[rowIndex] = { ...this.localDataSource[rowIndex], ...data };
this.localDataSource = [...this.localDataSource];
},
//
hasError(rowIndex, colIndex, field) {
return this.formErrors.some(error =>

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

@ -341,6 +341,16 @@ export default {
}
})
},
getSjResource(){
const stepData = this.steps.map((step, index) => {
const stepComponentRef = this.$refs[`stepCompRef_${index}`];
if(stepComponentRef && stepComponentRef.length > 0){
const {sjResource,yqResource} = this.$refs[`stepCompRef_${index}`][0]?.getSjResource();
return { type: step.type, sjResource, yqResource }
}
})
console.log(stepData,"steps")
},
//
getFilledFormData() {

+ 2
- 0
src/components/Template/StepComponents/ry/clcz.vue View File

@ -32,6 +32,8 @@ export default {
wzmc: {
type: "mix",
fillType: "actFill",
ylCode: "sjcz",
dwCode: "wzsuldw",
},
text3: {
label: "物质,称取预计质量为",

+ 2
- 0
src/components/Template/StepComponents/ry/clfcz.vue View File

@ -32,6 +32,8 @@ export default {
wzmc: {
type: "mix",
fillType: "actFill",
ylCode: "sjcz",
dwCode: "wzsuldw1",
},
text3: {
label: "物质,称取预计质量为",

+ 2
- 0
src/components/Template/StepComponents/ry/fr.vue View File

@ -39,6 +39,8 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
sj:{
type:"regent",
fillType:"actFill",
ylCode: "sjtj",
dwCode: "sjtjdw",
},
text3:{
label:"溶液,各预计加入休积为",

+ 2
- 0
src/components/Template/StepComponents/ry/frdrq.vue View File

@ -39,6 +39,8 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
sj:{
type:"regent",
fillType:"actFill",
ylCode: "sjtj",
dwCode: "sjtjdw",
},
text3:{
label:"溶液,分别各预计加入休积为",

+ 2
- 0
src/components/Template/StepComponents/ry/jrry.vue View File

@ -39,6 +39,8 @@ export default {
sjrq:{
fillType: "actFill",
type: "regent",
ylCode: "sjsr2",
dwCode: "sjsrdw2",
},
text3:{
label: "溶液,加入预计体积为",

+ 2
- 0
src/components/Template/StepComponents/ry/qcyy.vue View File

@ -27,6 +27,8 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
yq:{
type:"mix",
fillType:"actFill",
ylCode: "sjqc",
dwCode: "sjqcdw",
},
text2:{
label:"预计取出",

+ 2
- 0
src/components/Template/StepComponents/ry/rs.vue View File

@ -80,6 +80,8 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
yjsj:{
type:"regent",
fillType:"actFill",
ylCode: "sjtj2",
dwCode: "sjtjdw1",
},
text6:{
label:"溶液,加入预计体积为",

+ 4
- 0
src/components/Template/StepComponents/ry/tjphcz.vue View File

@ -43,6 +43,8 @@ export default {
sj1: {
type: "regent",
fillType: "actFill",
ylCode: "sjjrl",
dwCode: "sjjrldw",
},
text4: {
label: "进行调节,实际加入量为",
@ -70,6 +72,8 @@ export default {
sj2: {
type: "regent",
fillType: "actFill",
ylCode: "sjjrl1",
dwCode: "sjjrldw1",
},
text6: {
label: "进行调节,实际加入量为",

+ 4
- 0
src/components/Template/StepComponents/ry/tjphfcz.vue View File

@ -43,6 +43,8 @@ export default {
sj1: {
type: "regent",
fillType: "actFill",
ylCode: "sjjrl",
dwCode: "sjjrldw",
},
text4: {
label: "进行调节,实际加入量为",
@ -70,6 +72,8 @@ export default {
sj2: {
type: "regent",
fillType: "actFill",
ylCode: "sjjrl1",
dwCode: "sjjrldw1",
},
text6: {
label: "进行调节,实际加入量为",

+ 3
- 1
src/components/Template/StepComponents/ry/ym.vue View File

@ -47,6 +47,8 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
sj:{
type:"regent",
fillType:"actFill",
ylCode: "ry3",
dwCode: "sjrytjdw",
},
text4:{
label:"溶媒,加入预计体积为",
@ -75,7 +77,7 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
sjrytjdw:{
type:"select",
options: this.getDictOptions("business_tjdw"),
fillType: "preFill",
fillType: "actFill",
},
text6:{
label:"至研钵中,研磨至",

+ 27
- 0
src/components/Template/StepFormPackage.vue View File

@ -115,6 +115,30 @@ export default {
}
},
methods: {
getSjResource(){
const {allFieldsConfig,formFields} = this;
const sjResource = [],yqResource = [];
for(const key in allFieldsConfig){
const item = allFieldsConfig[key];
if(item.type === "xb" || item.type === "regent" || item.type === "gsp" || item.type === "mix"){
sjResource.push({
type:item.selectType,
value:formFields[key],
yl:formFields[item.ylCode],//
dw:formFields[item.dwCode],//
});
}else if(item.type === "instrument"){
yqResource.push({
type:item.type,
value:formFields[key],
});
}
}
return {
sjResource,
yqResource,
}
},
//
handleClickButton(e,item){
const {buttonName = ""} = e;
@ -137,6 +161,9 @@ export default {
onMixReagentSubmit(data){
if(data.uuid !== this.uuid) return;
this.formFields[this.currentClickKey] = data.selectedId;
if(data.selectType){
this.allFieldsConfig[this.currentClickKey].sjSelectType = data.selectType;
}
this.$emit("onDialogSubmit",data)
},
//

+ 14
- 9
src/components/Template/mixins/formPackageMixins.js View File

@ -144,16 +144,21 @@ export default {
//更新记录
showEditSignDialog: _.debounce(function () {
//如果oldFormFields中存在空值,说明是第一次填写,直接更新记录
const flag = Object.values(this.oldFormFields).some(item => !item);
if (flag) {
this.updateRecord();
const flag = Object.values(this.oldFormFields).every((val)=>{
// 0 算有值
if (val === 0) return true;
if (val === "0") return true;
// 其他情况:非 null、非 undefined、非空字符串
return val != null && val != undefined && val != "";
});
const diff = this.compareOldAndCurrentFormFields();
if (!diff && this.templateFillType === "actFill" && flag) {
setTimeout(() => {//延迟200ms打开弹窗,避免弹窗打开时,会有闪烁
EventBus.$emit('showEditSignDialog', { uuid: this.uuid });
}, 200);
}else{
const diff = this.compareOldAndCurrentFormFields();
if (!diff) {
setTimeout(() => {//延迟200ms打开弹窗,避免弹窗打开时,会有闪烁
EventBus.$emit('showEditSignDialog', { uuid: this.uuid });
}, 200);
}
this.updateRecord();
}
}, 100),

+ 3
- 0
src/components/Template/mixins/stepMixins.js View File

@ -17,6 +17,9 @@ export default {
getFilledFormData() {
return this.$refs.stepFormPackageRef?.getFilledFormData();
},
getSjResource() {
return this.$refs.stepFormPackageRef?.getSjResource();
},
//试验配制条件options
getDictOptions(dictType) {
return this.dict.type[dictType] || []

+ 4
- 0
src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue View File

@ -25,6 +25,7 @@
ref="remarkRef" :formConfig="remarkConig" :formData="formData" />
</div>
</div>
<button @click="onSave">提交</button>
</div>
</div>
</template>
@ -308,6 +309,9 @@ export default {
this.resourceTmp = tmpResource
return content;
},
onSave(){
this.$refs.stepRef.getSjResource()
}
}
};
</script>

+ 1
- 1
src/views/business/comps/template/dialog/SelectMixReagentDialog.vue View File

@ -142,7 +142,7 @@ export default {
const selectedValue = this.otherChecked ? this.otherReagent : this.selectedId;
this.$emit('submit', selectedValue, row);
// eventBus
EventBus.$emit("onMixReagentSubmit", { uuid: this.uuid, selectedId: selectedValue, row });
EventBus.$emit("onMixReagentSubmit", { uuid: this.uuid, selectedId: selectedValue, row,selectType:this.selectType });
this.visible = false;
},
//

Loading…
Cancel
Save