自定义表单数值类型输入框添加校验允许输入NE
continuous-integration/drone/push Build is running
Details
continuous-integration/drone/push Build is running
Details
parent
99dd28a713
commit
615cf94189
|
@ -69,6 +69,10 @@
|
|||
:rules="[
|
||||
{ required: (question.IsRequired === 0 || (question.IsRequired ===1 && question.RelevanceId && (question.RelevanceValueList.includes(isNaN(parseFloat(questionForm[question.RelevanceId])) ? questionForm[question.RelevanceId] : questionForm[question.RelevanceId].toString())))) && question.Type!=='group' && question.Type!=='summary',
|
||||
message: $t('common:ruleMessage:specify'), trigger: ['blur', 'change']},
|
||||
{
|
||||
validator: question.Type === 'number' && !question.TypeValue ? validatorNumberInput :(rule,value,callback )=>{callback()},
|
||||
trigger: ['blur', 'change']
|
||||
}
|
||||
]"
|
||||
:class="[question.Type==='group'?'mb':question.Type==='upload'?'uploadWrapper':'']"
|
||||
>
|
||||
|
@ -228,9 +232,10 @@
|
|||
/>
|
||||
</el-select>
|
||||
<el-input
|
||||
type="number"
|
||||
type="text"
|
||||
v-if="question.Type === 'number' && !question.TypeValue && question.DataSource !== 1"
|
||||
@change="(val) => { formItemNumberChange(val, question) }"
|
||||
@input="numberInput(question.Id)"
|
||||
@blur="handleBlur(questionForm[question.Id], questionForm, question.Id)"
|
||||
v-model="questionForm[question.Id]"
|
||||
:disabled="readingTaskState === 2"
|
||||
|
@ -240,7 +245,8 @@
|
|||
<template slot="append" v-else-if="question.ValueType === 2">%</template>
|
||||
</el-input>
|
||||
<el-input
|
||||
type="number"
|
||||
type="text"
|
||||
@input="numberInput(question.Id)"
|
||||
v-if="question.Type === 'number' && !question.TypeValue && question.DataSource === 1"
|
||||
@blur="handleBlur(questionForm[question.Id], questionForm, question.Id)"
|
||||
:disabled="question.DataSource === 1 || readingTaskState === 2"
|
||||
|
@ -502,6 +508,21 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
numberInput(id) {
|
||||
this.questionForm[id] = this.questionForm[id].toUpperCase();
|
||||
},
|
||||
validatorNumberInput(rule, value, callback) {
|
||||
let reg = new RegExp(/^(?:-?(?:(?:0|[1-9]\d*)(?:\.\d+)?|\.\d+)|NE)$/, 'g')
|
||||
if (value === '') {
|
||||
callback(new Error(this.$t('common:ruleMessage:specify')));
|
||||
} else {
|
||||
if (!reg.test(value)) {
|
||||
callback(new Error(this.$t('trials:reading:ruleMessage:validatorNumberInput')));
|
||||
}else{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
},
|
||||
limitInput(value, a, b) {
|
||||
if (value.indexOf('.') > -1) {
|
||||
if (value.split('.')[1].length >= this.digitPlaces) {
|
||||
|
@ -510,7 +531,10 @@ export default {
|
|||
}
|
||||
},
|
||||
handleBlur(value, a, b) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
let reg = new RegExp(/[a-zA-Z]/, 'ig')
|
||||
if(!reg.test(value)) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
}
|
||||
},
|
||||
deleteTableCol(row, index) {
|
||||
this.$confirm(this.$t('trials:uploadNonDicoms:message:msg1')).then(() => {
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
:rules="[
|
||||
{ required: (question.IsRequired === 0 || (question.IsRequired ===1 && question.RelevanceId && !!~question.RelevanceValueList.indexOf(questionForm[question.RelevanceId]))) && question.Type!=='group' && question.Type!=='summary',
|
||||
message: $t('common:ruleMessage:select'), trigger: ['blur', 'change']},
|
||||
{
|
||||
validator: question.Type === 'number' && !question.TypeValue ? validatorNumberInput :(rule,value,callback )=>{callback()},
|
||||
trigger: ['blur', 'change']
|
||||
}
|
||||
]"
|
||||
:class="[question.Type==='group'?'mb':question.Type==='upload'?'uploadWrapper':'']"
|
||||
>
|
||||
|
@ -144,19 +148,21 @@
|
|||
<!-- 数值 -->
|
||||
<!-- :precision="2" :step="0.1" :max="10" -->
|
||||
<el-input
|
||||
type="number"
|
||||
type="text"
|
||||
v-if="question.Type === 'number' && question.DataSource !== 1"
|
||||
:disabled="question.TableQuestionType === 2 || (question.IsCopy && type === 'edit' && !IsBaseline && questionForm.IsCurrentTaskAdd === 'False')"
|
||||
@change="((val)=>{formItemNumberChange(val, question)})"
|
||||
@input="numberInput(question.Id)"
|
||||
@blur="handleBlur(questionForm[question.Id], questionForm, question.Id)"
|
||||
v-model="questionForm[question.Id]"
|
||||
>
|
||||
<template slot="append" v-if="question.Unit !== 0">{{question.Unit !== 4 ? $fd('ValueUnit', question.Unit) : question.CustomUnit}}</template>
|
||||
</el-input>
|
||||
<el-input
|
||||
type="number"
|
||||
type="text"
|
||||
v-if="question.Type === 'number' && question.DataSource === 1"
|
||||
:disabled="question.DataSource === 1"
|
||||
@input="numberInput(question.Id, true )"
|
||||
@blur="handleCalculationBlur(calculationValue)"
|
||||
v-model="calculationValue"
|
||||
>
|
||||
|
@ -342,6 +348,25 @@ export default {
|
|||
// }
|
||||
},
|
||||
methods: {
|
||||
numberInput(id,notId = false) {
|
||||
if(notId ) {
|
||||
this.calculationValue = this.calculationValue.toUpperCase();
|
||||
}else {
|
||||
this.questionForm[id] = this.questionForm[id].toUpperCase();
|
||||
}
|
||||
},
|
||||
validatorNumberInput(rule, value, callback) {
|
||||
let reg = new RegExp(/^(?:-?(?:(?:0|[1-9]\d*)(?:\.\d+)?|\.\d+)|NE)$/, 'g')
|
||||
if (value === '') {
|
||||
callback(new Error(this.$t('common:ruleMessage:specify')));
|
||||
} else {
|
||||
if (!reg.test(value)) {
|
||||
callback(new Error(this.$t('trials:reading:ruleMessage:validatorNumberInput')));
|
||||
}else{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
},
|
||||
save() {
|
||||
},
|
||||
openAddTableCol(row) {
|
||||
|
@ -382,7 +407,11 @@ export default {
|
|||
}
|
||||
},
|
||||
handleBlur(value, a, b) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
let reg = new RegExp(/[a-zA-Z]/, 'ig')
|
||||
if(!reg.test(value)) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
}
|
||||
// this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
},
|
||||
handleCalculationBlur(v) {
|
||||
this.calculationValue = parseFloat(v).toFixed(this.digitPlaces)
|
||||
|
|
|
@ -121,6 +121,10 @@
|
|||
:rules="[
|
||||
{ required: (question.IsRequired === 0 || (question.IsRequired ===1 && question.RelevanceId && (question.RelevanceValueList.includes(isNaN(parseFloat(questionForm[question.RelevanceId])) ? questionForm[question.RelevanceId] : questionForm[question.RelevanceId].toString())))) && question.Type!=='group' && question.Type!=='summary',
|
||||
message: $t('common:ruleMessage:specify'), trigger: ['blur', 'change']},
|
||||
{
|
||||
validator: question.Type === 'number' && !question.TypeValue ? validatorNumberInput :(rule,value,callback )=>{callback()},
|
||||
trigger: ['blur', 'change']
|
||||
}
|
||||
]"
|
||||
:class="[question.Type==='group'?'mb':question.Type==='upload'?'uploadWrapper':'']"
|
||||
>
|
||||
|
@ -354,9 +358,10 @@
|
|||
</template>
|
||||
<template v-else-if="question.Type === 'number'">
|
||||
<el-input
|
||||
type="number"
|
||||
type="text"
|
||||
v-if="question.Type === 'number' && !question.TypeValue && question.DataSource !== 1"
|
||||
@change="(val) => { formItemNumberChange(val, question) }"
|
||||
@input="numberInput(question.Id)"
|
||||
@blur="handleBlur(questionForm[question.Id], questionForm, question.Id)"
|
||||
v-model="questionForm[question.Id]"
|
||||
:disabled="readingTaskState === 2"
|
||||
|
@ -367,7 +372,8 @@
|
|||
|
||||
</el-input>
|
||||
<el-input
|
||||
type="number"
|
||||
type="text"
|
||||
@input="numberInput(question.Id)"
|
||||
v-if="question.Type === 'number' && !question.TypeValue && question.DataSource === 1"
|
||||
@blur="handleBlur(questionForm[question.Id], questionForm, question.Id)"
|
||||
:disabled="question.DataSource === 1 || readingTaskState === 2"
|
||||
|
@ -648,6 +654,21 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
numberInput(id) {
|
||||
this.questionForm[id] = this.questionForm[id].toUpperCase();
|
||||
},
|
||||
validatorNumberInput(rule, value, callback) {
|
||||
let reg = new RegExp(/^(?:-?(?:(?:0|[1-9]\d*)(?:\.\d+)?|\.\d+)|NE)$/, 'g')
|
||||
if (value === '') {
|
||||
callback(new Error(this.$t('common:ruleMessage:specify')));
|
||||
} else {
|
||||
if (!reg.test(value)) {
|
||||
callback(new Error(this.$t('trials:reading:ruleMessage:validatorNumberInput')));
|
||||
}else{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
},
|
||||
limitInput(value, a, b) {
|
||||
if (value.indexOf('.') > -1) {
|
||||
if (value.split('.')[1].length >= this.digitPlaces) {
|
||||
|
@ -656,7 +677,11 @@ export default {
|
|||
}
|
||||
},
|
||||
handleBlur(value, a, b) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
let reg = new RegExp(/[a-zA-Z]/, 'ig')
|
||||
if(!reg.test(value)) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
}
|
||||
// this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
},
|
||||
handleMarkedQsBlur(value, a, b, question) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
:rules="[
|
||||
{ required: (question.IsRequired === 0 || (question.IsRequired ===1 && question.RelevanceId && !!~question.RelevanceValueList.indexOf(questionForm[question.RelevanceId]))) && question.Type!=='group' && question.Type!=='summary',
|
||||
message: $t('common:ruleMessage:select'), trigger: ['blur', 'change']},
|
||||
{
|
||||
validator: question.Type === 'number' && !question.TypeValue ? validatorNumberInput :(rule,value,callback )=>{callback()},
|
||||
trigger: ['blur', 'change']
|
||||
}
|
||||
]"
|
||||
:class="[question.Type==='group'?'mb':question.Type==='upload'?'uploadWrapper':'']"
|
||||
>
|
||||
|
@ -217,19 +221,21 @@
|
|||
</template>
|
||||
<template v-else-if="question.Type === 'number'">
|
||||
<el-input
|
||||
type="number"
|
||||
type="text"
|
||||
v-if="question.Type === 'number' && question.DataSource !== 1"
|
||||
:disabled="question.TableQuestionType === 2 || (question.IsCopy && type === 'edit' && !isBaseline && questionForm.IsCurrentTaskAdd === 'False')"
|
||||
@change="((val)=>{formItemNumberChange(val, question)})"
|
||||
@input="numberInput(question.Id)"
|
||||
@blur="handleBlur(questionForm[question.Id], questionForm, question.Id)"
|
||||
v-model="questionForm[question.Id]"
|
||||
>
|
||||
<template slot="append" v-if="question.Unit !== 0">{{question.Unit !== 4 ? $fd('ValueUnit', question.Unit) : question.CustomUnit}}</template>
|
||||
</el-input>
|
||||
<el-input
|
||||
type="number"
|
||||
type="text"
|
||||
v-if="question.Type === 'number' && question.DataSource === 1"
|
||||
:disabled="question.DataSource === 1"
|
||||
@input="numberInput(question.Id, true )"
|
||||
@blur="handleCalculationBlur(calculationValue)"
|
||||
v-model="calculationValue"
|
||||
>
|
||||
|
@ -420,6 +426,25 @@ export default {
|
|||
if (this.type === 'edit') return
|
||||
},
|
||||
methods: {
|
||||
numberInput(id,notId = false) {
|
||||
if(notId ) {
|
||||
this.calculationValue = this.calculationValue.toUpperCase();
|
||||
}else {
|
||||
this.questionForm[id] = this.questionForm[id].toUpperCase();
|
||||
}
|
||||
},
|
||||
validatorNumberInput(rule, value, callback) {
|
||||
let reg = new RegExp(/^(?:-?(?:(?:0|[1-9]\d*)(?:\.\d+)?|\.\d+)|NE)$/, 'g')
|
||||
if (value === '') {
|
||||
callback(new Error(this.$t('common:ruleMessage:specify')));
|
||||
} else {
|
||||
if (!reg.test(value)) {
|
||||
callback(new Error(this.$t('trials:reading:ruleMessage:validatorNumberInput')));
|
||||
}else{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
},
|
||||
save() {
|
||||
},
|
||||
openAddTableCol(row) {
|
||||
|
@ -449,7 +474,11 @@ export default {
|
|||
}
|
||||
},
|
||||
handleBlur(value, a, b) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
let reg = new RegExp(/[a-zA-Z]/, 'ig')
|
||||
if(!reg.test(value)) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
}
|
||||
// this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
},
|
||||
handleMarkedQsBlur(value, a, b, question) {
|
||||
this.$set(a, b, parseFloat(value).toFixed(this.digitPlaces))
|
||||
|
|
Loading…
Reference in New Issue