Browse Source

feat:[模板管理][update]

luojie
luojie 1 week ago
parent
commit
f3641cd242
11 changed files with 101 additions and 51 deletions
  1. +28
    -23
      src/components/Template/DecimalInput.vue
  2. +10
    -6
      src/components/Template/HandleFormItem.vue
  3. +8
    -1
      src/components/Template/StepComponents/ry/bdzl.vue
  4. +1
    -1
      src/components/Template/StepComponents/ry/fr.vue
  5. +1
    -1
      src/components/Template/StepComponents/ry/fy.vue
  6. +10
    -1
      src/components/Template/StepComponents/ry/tjphcz.vue
  7. +7
    -1
      src/components/Template/StepComponents/ry/tpjydd.vue
  8. +6
    -6
      src/components/Template/mixins/formPackageMixins.js
  9. +30
    -9
      src/components/Template/mixins/stepMixins.js
  10. +0
    -1
      src/utils/tpph.js
  11. +0
    -1
      src/views/business/comps/template/mixins/templateMixin.js

+ 28
- 23
src/components/Template/DecimalInput.vue View File

@ -5,6 +5,9 @@
<template slot="prepend" v-if="prepend">
{{ prepend }}
</template>
<template slot="append" v-if="append">
{{ append }}
</template>
</el-input>
</template>
@ -32,6 +35,10 @@ export default {
type: String,
default: ''
},
append: {
type: String,
default: ''
},
},
data() {
return {
@ -108,7 +115,7 @@ export default {
this.isNA = false;
}
}
// NAFRACTION
// NA
if (/^NA$/i.test(upperVal)) {
@ -123,7 +130,7 @@ export default {
// FRACTION
matchedRule = this.getMatchingRule(val);
}
if (matchedRule) {
if (matchedRule.name === 'FRACTION') {
cleaned = val.replace(/[^\d/]/g, '');
@ -141,10 +148,10 @@ export default {
} else {
//
// decimalDigits 0
const allowedPattern = this.decimalDigits === 0 ? /[^\d-]/g : /[^\d.-]/g;
//
const allowedPattern = this.decimalDigits === 0 ? /[^\d]/g : /[^\d.]/g;
cleaned = val
.replace(allowedPattern, '')
.replace(/^(-)\1+/, '$1');
.replace(allowedPattern, '');
//
const firstDotIndex = cleaned.indexOf('.');
@ -166,28 +173,26 @@ export default {
//
if (this.decimalDigits > 0) {
if (cleaned === '.') cleaned = '0.';
else if (cleaned === '-.') cleaned = '-0.';
else if (cleaned.startsWith('.')) cleaned = '0' + cleaned;
else if (cleaned.startsWith('-.')) cleaned = '-0.' + cleaned.slice(2);
}
//
if (cleaned.includes('.')) {
const [int, dec] = cleaned.split('.');
let newInt = int;
if (/^-?0+\d/.test(int)) {
newInt = int.replace(/^-?0+(\d)/, '$1');
} else if (int === '' || int === '-') {
newInt = int + '0';
} else if (int === '00' || /^-00+$/.test(int)) {
newInt = int.startsWith('-') ? '-0' : '0';
if (/^0+\d/.test(int)) {
newInt = int.replace(/^0+(\d)/, '$1');
} else if (int === '') {
newInt = '0';
} else if (int === '00' || /^00+$/.test(int)) {
newInt = '0';
}
cleaned = newInt + '.' + dec;
} else {
if (/^-?0+\d/.test(cleaned)) {
cleaned = cleaned.replace(/^-?0+(\d)/, '$1');
} else if (cleaned === '00' || /^-00+$/.test(cleaned)) {
cleaned = cleaned.startsWith('-') ? '-0' : '0';
if (/^0+\d/.test(cleaned)) {
cleaned = cleaned.replace(/^0+(\d)/, '$1');
} else if (cleaned === '00' || /^00+$/.test(cleaned)) {
cleaned = '0';
}
}
}
@ -218,7 +223,7 @@ export default {
const actVal = val || this.internalValue;
let finalValue = actVal.trim();
if (finalValue === '' || finalValue === '-') {
if (finalValue === '') {
return '';
}
@ -242,7 +247,7 @@ export default {
handleBlur() {
const val = this.internalValue.trim();
if (val === '') {
this.oldValue = null;
this.oldPattern = null;
@ -253,7 +258,7 @@ export default {
}
const upperVal = val.toUpperCase();
//
for (const rule of this.patternRules) {
if (rule.pattern.test(upperVal)) {
@ -271,7 +276,7 @@ export default {
if (val.includes('/')) {
const parts = val.split('/');
const validParts = parts.filter(part => part !== '');
if (validParts.length === 0) {
if (this.oldValue) {
this.internalValue = this.oldValue;
@ -284,7 +289,7 @@ export default {
}
return;
}
if (validParts.length === 1) {
const result = validParts[0];
this.oldValue = result;
@ -294,7 +299,7 @@ export default {
this.$emit('blur', result);
return;
}
const formattedValue = validParts.join('/');
this.oldValue = formattedValue;
this.oldPattern = this.patternRules.find(r => r.name === 'FRACTION');

+ 10
- 6
src/components/Template/HandleFormItem.vue View File

@ -13,7 +13,7 @@
@input="onInputChange" @change="onInputChange" />
<DecimalInput v-else-if="type === 'inputNumber'" @blur="onCommonHandleSaveRecord"
:maxlength="item.maxlength || 10" class="flex1" :disabled="getDisabled()"
:controls="item.controls || false" :min="item.min || 0" :prepend="item.prepend"
:controls="item.controls || false" :min="item.min || 0" :prepend="item.prepend" :append="item.append"
:decimalDigits="getDecimalDigits()" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')"
:placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" />
<el-select v-else-if="type === 'select'" class="flex1" :multiple="item.multiple"
@ -1245,10 +1245,7 @@ export default {
return
}
let finallyKey = this.fieldKey;
if (recordData) {
this.oldValue = recordData.oldValue;
this.inputValue = recordData.inputValue;
}
let recordOldVlaue = this.oldValue, recordValue = this.inputValue, isModify = !!this.oldValue,oldUrl = "",url="";
if (this.type === "checkboxTag") {
// checkboxTagtagIndex
@ -1291,7 +1288,10 @@ export default {
oldUrl = oldAttList.map(item => item.url).join("|");
url = attList.map(item => item.url).join("|");
}
if (recordData) {
recordOldVlaue = recordData.oldValue;
recordValue = recordData.inputValue;
}
const record = {
...baseInfo,
oldValue: recordOldVlaue,
@ -1617,6 +1617,7 @@ export default {
.orange-border {
.el-input-group__prepend,
.el-input-group__append,
input,
textarea {
border-color: #f9c588;
@ -1696,6 +1697,7 @@ export default {
.green-border {
.el-input-group__prepend,
.el-input-group__append,
input,
textarea {
border-color: green;
@ -1718,6 +1720,7 @@ export default {
.blue-border {
.el-input-group__prepend,
.el-input-group__append,
input,
.el-checkbox__inner,
textarea {
@ -1741,6 +1744,7 @@ export default {
.error-border {
.el-input-group__prepend,
.el-input-group__append,
.el-input__inner,
textarea,
.el-select,

+ 8
- 1
src/components/Template/StepComponents/ry/bdzl.vue View File

@ -14,7 +14,6 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
},
computed: {
formConfig() {
console.log(this.stepIndex,"stepIndex")
return [{
config:{
text1:{
@ -50,11 +49,19 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
compareTo:"rm",
disabled:true,
},
sjbdtjdw:{
type:"inputNumber",
fillType:"actFill",
compareTo:"bdtjdw",
disabled:true,
},
button1:{
type:"button",
dataSource:"tp",//
yqCode:"yq",//
fillField:"sjbdtj",//
fillDwField:"sjbdtjdw",//
dwField:"bdtjdw",//
buttonName:"获取值",
},

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

@ -49,7 +49,7 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
dwCode: "sjtjdw",
},
text3:{
label:"溶液,各预计加入休积为",
label:"溶液,预计加入体积为",
type:"text",
},
yjtj:{

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

@ -55,7 +55,7 @@ export default {
copyFrom:"yjtj",
},
text4: {
label: ",进行孵育",
label: ",对上表进行孵育",
type: "text",
},
fysr: {

+ 10
- 1
src/components/Template/StepComponents/ry/tjphcz.vue View File

@ -1,6 +1,11 @@
<!-- 调节PH(传值) -->
<template>
<StepFormPackage :fieldItemLabel = "fieldItemLabel" ref="stepFormPackageRef" :prefixKey="stepIndex+'_'+'ry_tjphcz'" @resetRecord = "resetRecord" :form-config="formConfig" :formData="formData" />
<StepFormPackage
:fieldItemLabel = "fieldItemLabel"
ref="stepFormPackageRef"
@beforeSaveRecord="onBeforeSaveRecord"
@clickButton="onHandleClickButton"
:prefixKey="stepIndex+'_'+'ry_tjphcz'" @resetRecord = "resetRecord" :form-config="formConfig" :formData="formData" />
</template>
<script>
@ -97,9 +102,13 @@ export default {
type: "inputNumber",
fillType: "actFill",
compareTo: "rm",
disabled: true,
},
button1: {
type: "button",
dataSource:"ph",//
yqCode:"yq",//
fillField:"ph",//
buttonName: "获取值",
},
text8: {

+ 7
- 1
src/components/Template/StepComponents/ry/tpjydd.vue View File

@ -2,8 +2,9 @@
<template>
<StepFormPackage :fieldItemLabel = "fieldItemLabel"
ref = "stepFormPackageRef" :prefixKey="stepIndex+'_'+'ry_tpjydd'" @resetRecord = "resetRecord"
@clickButton="handleClickButton"
@clickButton="onHandleClickButton"
@beforeSaveRecord="onBeforeSaveRecord"
@blur = "onBlur"
:form-config="formConfig" :formData = "formData" />
</template>
@ -124,6 +125,11 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
}]
}
},
methods: {
onBlur(key) {
console.log(key,"key blur")
}
}
}
</script>

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

@ -139,7 +139,7 @@ export default {
},
//更新表单数据
updateFormData(key, value, data) {
const { isUpdateRecord, signData } = data || {}
const { isUpdateRecord, signData,record } = data || {}
// 深拷贝当前表单数据,避免直接修改原数据
const cloneFormFields = JSON.parse(JSON.stringify(this.formFields))
@ -149,13 +149,13 @@ export default {
if (this.errors[key]) {
this.$set(this.errors, key, false)
}
if (isUpdateRecord) {
setTimeout(() => {
this.$refs[key][0].handleUpdateRecord(signData, {
const re = record||{
oldValue: this.oldFormFields[key],
inputValue: value
})
}
if (isUpdateRecord) {
setTimeout(() => {
this.$refs[key][0].handleUpdateRecord(signData, re)
}, 10)
}
},

+ 30
- 9
src/components/Template/mixins/stepMixins.js View File

@ -1,7 +1,7 @@
import { getuuid, justUpdateFilledFormData } from '@/utils/index.js'
import { EventBus } from '@/utils/eventBus'
import { getLatestSn, getLatestSnArr } from '@/api/template'
import { getBalance } from '@/utils/tpph.js';
import { getBalance, getPh } from '@/utils/tpph.js';
export default {
inject: {
templateFillType: { default: 'preFill' },
@ -157,11 +157,15 @@ export default {
const { buttonName } = item;
if (buttonName === '获取值') {
const { dataSource, yqCode } = item;
if (dataSource === "tp") {//电子天平
const stepFormData = this.getFilledFormData()
const stepFormData = this.getFilledFormData()
if (dataSource === "tp" || dataSource === "ph") {//电子天平或PH测量仪
const yq = stepFormData[yqCode] || "";
const obj = {
tp:"请选择电子天平",
ph:"请选择PH测量仪"
}
if (!yq) {
callback.prevent("请选择电子天平")
callback.prevent(obj[dataSource])
}
}
}
@ -218,20 +222,37 @@ export default {
uuid: this.uuid,
})
} else if (buttonName === '获取值') {
const { dataSource, dwField = "", fillField, yqCode } = e;
const { dataSource, dwField = "", fillField,fillDwField = "", yqCode } = e;
const stepFormData = this.getFilledFormData()
const yqInfo = stepFormData[`yqInfo_${yqCode}`] || {};
if (dataSource === "tp") {//电子天平
const stepFormData = this.getFilledFormData()
const yqInfo = stepFormData[`yqInfo_${yqCode}`] || {};
const dw = stepFormData[dwField] || "";
const oldValue = stepFormData[fillDwField] || "";
const result = await getBalance({ yq: yqInfo, dw });
if (result.success) {
const value = dw?result.value:`${result.value}${result.unit}`
this.$refs.stepFormPackageRef.updateFormData(fillField, value,{isUpdateRecord:true,signData})
if(fillDwField){//需要回填的单位字段
this.$refs.stepFormPackageRef.updateFormData(fillField, value)
this.$refs.stepFormPackageRef.updateFormData(fillDwField, result.unit,{isUpdateRecord:true,signData,record:{
oldValue,
inputValue:result.value+result.unit
}})
}else{
this.$refs.stepFormPackageRef.updateFormData(fillField, value,{isUpdateRecord:true,signData})
}
} else {
this.$message.error(result.message || "获取值失败");
}
}else if(dataSource === "ph"){
const result = await getPh({ yq: yqInfo });
if (result.success) {
this.$refs.stepFormPackageRef.updateFormData(fillField, result.value,{isUpdateRecord:true,signData})
} else {
this.$message.error(result.message || "获取值失败");
}
}
}
},

+ 0
- 1
src/utils/tpph.js View File

@ -6,7 +6,6 @@ import { Message } from 'element-ui'
export async function getBalance(obj) {
// alert('入参:' + JSON.stringify(obj))
debugger
return {
success: true,
originalValue: '1000',

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

@ -192,7 +192,6 @@ export default {
this.formData = { ...this.formData, expireDate: end }
}
console.log(this.formData, 'formData from templateData')
this.setTemplateData(v)
}
}

Loading…
Cancel
Save