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"> <template slot="prepend" v-if="prepend">
{{ prepend }} {{ prepend }}
</template> </template>
<template slot="append" v-if="append">
{{ append }}
</template>
</el-input> </el-input>
</template> </template>
@ -32,6 +35,10 @@ export default {
type: String, type: String,
default: '' default: ''
}, },
append: {
type: String,
default: ''
},
}, },
data() { data() {
return { return {
@ -108,7 +115,7 @@ export default {
this.isNA = false; this.isNA = false;
} }
} }
// NAFRACTION // NAFRACTION
// NA // NA
if (/^NA$/i.test(upperVal)) { if (/^NA$/i.test(upperVal)) {
@ -123,7 +130,7 @@ export default {
// FRACTION // FRACTION
matchedRule = this.getMatchingRule(val); matchedRule = this.getMatchingRule(val);
} }
if (matchedRule) { if (matchedRule) {
if (matchedRule.name === 'FRACTION') { if (matchedRule.name === 'FRACTION') {
cleaned = val.replace(/[^\d/]/g, ''); cleaned = val.replace(/[^\d/]/g, '');
@ -141,10 +148,10 @@ export default {
} else { } else {
// //
// decimalDigits 0 // decimalDigits 0
const allowedPattern = this.decimalDigits === 0 ? /[^\d-]/g : /[^\d.-]/g;
//
const allowedPattern = this.decimalDigits === 0 ? /[^\d]/g : /[^\d.]/g;
cleaned = val cleaned = val
.replace(allowedPattern, '')
.replace(/^(-)\1+/, '$1');
.replace(allowedPattern, '');
// //
const firstDotIndex = cleaned.indexOf('.'); const firstDotIndex = cleaned.indexOf('.');
@ -166,28 +173,26 @@ export default {
// //
if (this.decimalDigits > 0) { if (this.decimalDigits > 0) {
if (cleaned === '.') cleaned = '0.'; if (cleaned === '.') cleaned = '0.';
else if (cleaned === '-.') cleaned = '-0.';
else if (cleaned.startsWith('.')) cleaned = '0' + cleaned; else if (cleaned.startsWith('.')) cleaned = '0' + cleaned;
else if (cleaned.startsWith('-.')) cleaned = '-0.' + cleaned.slice(2);
} }
// //
if (cleaned.includes('.')) { if (cleaned.includes('.')) {
const [int, dec] = cleaned.split('.'); const [int, dec] = cleaned.split('.');
let newInt = int; 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; cleaned = newInt + '.' + dec;
} else { } 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; const actVal = val || this.internalValue;
let finalValue = actVal.trim(); let finalValue = actVal.trim();
if (finalValue === '' || finalValue === '-') {
if (finalValue === '') {
return ''; return '';
} }
@ -242,7 +247,7 @@ export default {
handleBlur() { handleBlur() {
const val = this.internalValue.trim(); const val = this.internalValue.trim();
if (val === '') { if (val === '') {
this.oldValue = null; this.oldValue = null;
this.oldPattern = null; this.oldPattern = null;
@ -253,7 +258,7 @@ export default {
} }
const upperVal = val.toUpperCase(); const upperVal = val.toUpperCase();
// //
for (const rule of this.patternRules) { for (const rule of this.patternRules) {
if (rule.pattern.test(upperVal)) { if (rule.pattern.test(upperVal)) {
@ -271,7 +276,7 @@ export default {
if (val.includes('/')) { if (val.includes('/')) {
const parts = val.split('/'); const parts = val.split('/');
const validParts = parts.filter(part => part !== ''); const validParts = parts.filter(part => part !== '');
if (validParts.length === 0) { if (validParts.length === 0) {
if (this.oldValue) { if (this.oldValue) {
this.internalValue = this.oldValue; this.internalValue = this.oldValue;
@ -284,7 +289,7 @@ export default {
} }
return; return;
} }
if (validParts.length === 1) { if (validParts.length === 1) {
const result = validParts[0]; const result = validParts[0];
this.oldValue = result; this.oldValue = result;
@ -294,7 +299,7 @@ export default {
this.$emit('blur', result); this.$emit('blur', result);
return; return;
} }
const formattedValue = validParts.join('/'); const formattedValue = validParts.join('/');
this.oldValue = formattedValue; this.oldValue = formattedValue;
this.oldPattern = this.patternRules.find(r => r.name === 'FRACTION'); 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" /> @input="onInputChange" @change="onInputChange" />
<DecimalInput v-else-if="type === 'inputNumber'" @blur="onCommonHandleSaveRecord" <DecimalInput v-else-if="type === 'inputNumber'" @blur="onCommonHandleSaveRecord"
:maxlength="item.maxlength || 10" class="flex1" :disabled="getDisabled()" :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' : '')" :decimalDigits="getDecimalDigits()" :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')"
:placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" /> :placeholder="getPlaceholder()" v-model="inputValue" @input="onInputChange" @change="onInputChange" />
<el-select v-else-if="type === 'select'" class="flex1" :multiple="item.multiple" <el-select v-else-if="type === 'select'" class="flex1" :multiple="item.multiple"
@ -1245,10 +1245,7 @@ export default {
return return
} }
let finallyKey = this.fieldKey; 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=""; let recordOldVlaue = this.oldValue, recordValue = this.inputValue, isModify = !!this.oldValue,oldUrl = "",url="";
if (this.type === "checkboxTag") { if (this.type === "checkboxTag") {
// checkboxTagtagIndex // checkboxTagtagIndex
@ -1291,7 +1288,10 @@ export default {
oldUrl = oldAttList.map(item => item.url).join("|"); oldUrl = oldAttList.map(item => item.url).join("|");
url = attList.map(item => item.url).join("|"); url = attList.map(item => item.url).join("|");
} }
if (recordData) {
recordOldVlaue = recordData.oldValue;
recordValue = recordData.inputValue;
}
const record = { const record = {
...baseInfo, ...baseInfo,
oldValue: recordOldVlaue, oldValue: recordOldVlaue,
@ -1617,6 +1617,7 @@ export default {
.orange-border { .orange-border {
.el-input-group__prepend, .el-input-group__prepend,
.el-input-group__append,
input, input,
textarea { textarea {
border-color: #f9c588; border-color: #f9c588;
@ -1696,6 +1697,7 @@ export default {
.green-border { .green-border {
.el-input-group__prepend, .el-input-group__prepend,
.el-input-group__append,
input, input,
textarea { textarea {
border-color: green; border-color: green;
@ -1718,6 +1720,7 @@ export default {
.blue-border { .blue-border {
.el-input-group__prepend, .el-input-group__prepend,
.el-input-group__append,
input, input,
.el-checkbox__inner, .el-checkbox__inner,
textarea { textarea {
@ -1741,6 +1744,7 @@ export default {
.error-border { .error-border {
.el-input-group__prepend, .el-input-group__prepend,
.el-input-group__append,
.el-input__inner, .el-input__inner,
textarea, textarea,
.el-select, .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: { computed: {
formConfig() { formConfig() {
console.log(this.stepIndex,"stepIndex")
return [{ return [{
config:{ config:{
text1:{ text1:{
@ -50,11 +49,19 @@ import stepMixins from '@/components/Template/mixins/stepMixins.js';
compareTo:"rm", compareTo:"rm",
disabled:true, disabled:true,
}, },
sjbdtjdw:{
type:"inputNumber",
fillType:"actFill",
compareTo:"bdtjdw",
disabled:true,
},
button1:{ button1:{
type:"button", type:"button",
dataSource:"tp",// dataSource:"tp",//
yqCode:"yq",// yqCode:"yq",//
fillField:"sjbdtj",// fillField:"sjbdtj",//
fillDwField:"sjbdtjdw",//
dwField:"bdtjdw",// dwField:"bdtjdw",//
buttonName:"获取值", 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", dwCode: "sjtjdw",
}, },
text3:{ text3:{
label:"溶液,各预计加入休积为",
label:"溶液,预计加入体积为",
type:"text", type:"text",
}, },
yjtj:{ yjtj:{

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

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

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

@ -1,6 +1,11 @@
<!-- 调节PH(传值) --> <!-- 调节PH(传值) -->
<template> <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> </template>
<script> <script>
@ -97,9 +102,13 @@ export default {
type: "inputNumber", type: "inputNumber",
fillType: "actFill", fillType: "actFill",
compareTo: "rm", compareTo: "rm",
disabled: true,
}, },
button1: { button1: {
type: "button", type: "button",
dataSource:"ph",//
yqCode:"yq",//
fillField:"ph",//
buttonName: "获取值", buttonName: "获取值",
}, },
text8: { text8: {

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

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

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

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

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

@ -1,7 +1,7 @@
import { getuuid, justUpdateFilledFormData } from '@/utils/index.js' import { getuuid, justUpdateFilledFormData } from '@/utils/index.js'
import { EventBus } from '@/utils/eventBus' import { EventBus } from '@/utils/eventBus'
import { getLatestSn, getLatestSnArr } from '@/api/template' import { getLatestSn, getLatestSnArr } from '@/api/template'
import { getBalance } from '@/utils/tpph.js';
import { getBalance, getPh } from '@/utils/tpph.js';
export default { export default {
inject: { inject: {
templateFillType: { default: 'preFill' }, templateFillType: { default: 'preFill' },
@ -157,11 +157,15 @@ export default {
const { buttonName } = item; const { buttonName } = item;
if (buttonName === '获取值') { if (buttonName === '获取值') {
const { dataSource, yqCode } = item; 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 yq = stepFormData[yqCode] || "";
const obj = {
tp:"请选择电子天平",
ph:"请选择PH测量仪"
}
if (!yq) { if (!yq) {
callback.prevent("请选择电子天平")
callback.prevent(obj[dataSource])
} }
} }
} }
@ -218,20 +222,37 @@ export default {
uuid: this.uuid, uuid: this.uuid,
}) })
} else if (buttonName === '获取值') { } 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") {//电子天平 if (dataSource === "tp") {//电子天平
const stepFormData = this.getFilledFormData()
const yqInfo = stepFormData[`yqInfo_${yqCode}`] || {};
const dw = stepFormData[dwField] || ""; const dw = stepFormData[dwField] || "";
const oldValue = stepFormData[fillDwField] || "";
const result = await getBalance({ yq: yqInfo, dw }); const result = await getBalance({ yq: yqInfo, dw });
if (result.success) { if (result.success) {
const value = dw?result.value:`${result.value}${result.unit}` 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 { } else {
this.$message.error(result.message || "获取值失败"); 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) { export async function getBalance(obj) {
// alert('入参:' + JSON.stringify(obj)) // alert('入参:' + JSON.stringify(obj))
debugger
return { return {
success: true, success: true,
originalValue: '1000', 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 } this.formData = { ...this.formData, expireDate: end }
} }
console.log(this.formData, 'formData from templateData')
this.setTemplateData(v) this.setTemplateData(v)
} }
} }

Loading…
Cancel
Save