Elements-SY

modify

......@@ -37,33 +37,30 @@ export const inputBlurValidate = {
}
// 最小重量有值的情况下
if (target.value && Number(target.value) >= 0) {
if (
/^(0|[1-9]\d*)(.\d{1,5})?$/.test(Number(this.queryForm.maxWeight))
) {
this.validateForm = true;
this.$refs.minWeight.innerHTML = "";
} else {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
// this.msgError("请输入有效重量,小数保留5位");
}
if (/^(0|[1-9]\d*)(.\d{1,5})?$/.test(Number(target.value))) {
this.validateForm = true;
this.$refs.minWeight.innerHTML = "";
if (this.queryForm.maxWeight) {
if (
Number(this.queryForm.maxWeight) <
Number(this.queryForm.minWeight)
) {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "最小重量不得大于最大重量";
} else if (
/^(0|[1-9]\d*)(.\d{1,5})?$/.test(Number(this.queryForm.maxWeight))
) {
this.validateForm = true;
this.$refs.minWeight.innerHTML = "";
} else {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
}
} else {
this.validateForm = true;
this.$refs.minWeight.innerHTML = "";
}
} else {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
// this.msgError("请输入有效重量,小数保留5位");
}
}
// 重量最小值和最大值都不为空的情况下
if (this.queryForm.minWeight && this.queryForm.maxWeight) {
if (
Number(this.queryForm.maxWeight) < Number(this.queryForm.minWeight)
) {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "最小重量不得大于最大重量";
// this.msgError("最小重量不得大于最大重量");
}
}
},
......@@ -87,35 +84,31 @@ export const inputBlurValidate = {
// this.msgError("请输入有效重量,小数保留5位");
}
}
// 最大重量有值的情况下
if (target.value && Number(target.value) >= 0) {
if (
/^(0|[1-9]\d*)(.\d{1,5})?$/.test(Number(this.queryForm.minWeight))
) {
this.validateForm = true;
this.$refs.minWeight.innerHTML = "";
} else {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
// this.msgError("请输入有效重量,小数保留5位");
}
if (/^(0|[1-9]\d*)(.\d{1,5})?$/.test(Number(target.value))) {
this.validateForm = true;
this.$refs.minWeight.innerHTML = "";
if (this.queryForm.minWeight) {
if (
Number(this.queryForm.maxWeight) <
Number(this.queryForm.minWeight)
) {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "最小重量不得大于最大重量";
} else if (
/^(0|[1-9]\d*)(.\d{1,5})?$/.test(Number(this.queryForm.minWeight))
) {
this.validateForm = true;
this.$refs.minWeight.innerHTML = "";
} else {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
}
} else {
this.validateForm = true;
this.$refs.minWeight.innerHTML = "";
}
} else {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "请输入有效重量,小数保留5位";
// this.msgError("请输入有效重量,小数保留5位");
}
}
// 重量最小值和最大值都不为空的情况下
if (this.queryForm.minWeight && this.queryForm.maxWeight) {
if (
Number(this.queryForm.maxWeight) < Number(this.queryForm.minWeight)
) {
this.validateForm = false;
this.$refs.minWeight.innerHTML = "最小重量不得大于最大重量";
// this.msgError("最小重量不得大于最大重量");
}
}
},
......
......@@ -48,8 +48,6 @@
<script>
import ElInput from 'element-ui/packages/input';
import Focus from 'element-ui/src/mixins/focus';
import RepeatClick from 'element-ui/src/directives/repeat-click';
export default {
name: 'YlElInputNumber',
mixins: [Focus('input')],
......@@ -61,9 +59,6 @@
default: ''
}
},
directives: {
repeatClick: RepeatClick
},
components: {
ElInput
},
......@@ -120,13 +115,11 @@
if (isNaN(newVal)) {
return;
}
if (this.stepStrictly) {
const stepPrecision = this.getPrecision(this.step);
const precisionFactor = Math.pow(10, stepPrecision);
newVal = Math.round(newVal / this.step) * precisionFactor * this.step / precisionFactor;
}
if (this.precision !== undefined) {
newVal = this.toPrecision(newVal, this.precision);
}
......@@ -174,9 +167,7 @@
if (this.userInput !== null) {
return this.userInput;
}
let currentValue = this.currentValue;
if (typeof currentValue === 'number') {
if (this.stepStrictly) {
const stepPrecision = this.getPrecision(this.step);
......@@ -188,7 +179,6 @@
currentValue = currentValue.toFixed(this.precision);
}
}
return currentValue;
}
},
......@@ -209,16 +199,12 @@
},
_increase(val, step) {
if (typeof val !== 'number' && val !== undefined) return this.currentValue;
const precisionFactor = Math.pow(10, this.numPrecision);
// Solve the accuracy problem of JS decimal calculation by converting the value to integer.
return this.toPrecision((precisionFactor * val + precisionFactor * step) / precisionFactor);
},
_decrease(val, step) {
if (typeof val !== 'number' && val !== undefined) return this.currentValue;
const precisionFactor = Math.pow(10, this.numPrecision);
return this.toPrecision((precisionFactor * val - precisionFactor * step) / precisionFactor);
},
increase() {
......