New file |
| | |
| | | /** |
| | | * 校验数据 |
| | | * |
| | | * @param {[Number,String]} val [val description] |
| | | * @param {[Object]} option [option description] |
| | | * |
| | | * @return {[Object]} [return description] |
| | | */ |
| | | function testVal(rules, val, callback, option) { |
| | | let result = { |
| | | code: 1, |
| | | msg: option.msg |
| | | }; |
| | | |
| | | // 根据正则验证数据 |
| | | result.code = option.pattern.test(val)?1:0; |
| | | if(result.code == 1 && option.regVal) { |
| | | let min = option.min; |
| | | let max =option.max; |
| | | if(min > val || max < val) { |
| | | result.code = 0; |
| | | } |
| | | } |
| | | |
| | | if(result.code == 0) { |
| | | callback(new Error(option.msg)); |
| | | }else { |
| | | callback() |
| | | } |
| | | } |
| | | |
| | | export default testVal; |
New file |
| | |
| | | export default { |
| | | Rules: { |
| | | batteryNumber: { |
| | | // 电芯串数 |
| | | pattern: /^[0-9]{1,3}$/, |
| | | regVal: true, |
| | | min: 1, |
| | | max: 100, |
| | | msg: "取值范围1~100(整数)", |
| | | }, |
| | | }, |
| | | }; |
| | |
| | | <template v-if="1 == devType"> |
| | | <el-button |
| | | size="small" |
| | | :disabled="!currentDev.devOnline" |
| | | :disabled="!!currentDev.devOnline" |
| | | class="btn-start" |
| | | v-if="!currentDev.state?.isTesting" |
| | | @click="test(false)" |
| | |
| | | startA200ParamPl, |
| | | } from "./api"; |
| | | import useElement from "@/hooks/useElement.js"; |
| | | import testVal from "@/assets/js/testVal.js"; |
| | | import const_params from "./const_params.js"; |
| | | |
| | | const { $alert, $loading, $message, $confirm } = useElement(); |
| | | |
| | | const $emit = defineEmits(["update:model-value"]); |
| | |
| | | message: "不能为空", |
| | | trigger: "blur", |
| | | }, |
| | | { |
| | | validator(rule, value, callback) { |
| | | testVal(rule, value, callback, const_params.Rules.batteryNumber); |
| | | }, |
| | | trigger: ['blur', 'change'], |
| | | }, |
| | | ], |
| | | diffBatteryVoltage: [ |
| | | { |