WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2022-01-21 eb514affa9174c7f931b3e71435e7ee819e2d4d0
数值步长输入组件,修复空值时显示异常的问题
2 files modified
28 ■■■■ changed files
forms/numberStep/CNumberStep.vue 21 ●●●● patch | view | raw | blame | history
forms/numberStep/cNumberStep.scss 7 ●●●●● patch | view | raw | blame | history
forms/numberStep/CNumberStep.vue
@@ -15,7 +15,7 @@
        />
        <view
            class="c-number-step-step"
            :class="unit?'on-unit':''"
            :class="[unit?'on-unit':'', isEmpty?'on-empty':'']"
            ref="number"
        >
            <AtInputNumber
@@ -72,13 +72,26 @@
    data() {
        return {};
    },
    computed: {},
    computed: {
        // 空值判断,弥补空值时显示最小值的问题
        isEmpty() {
            const curVal = this.itemRes.formData[this.itemRes.name];
            if (typeof curVal === 'undefined') {
                return true;
            } else if (!curVal && curVal !== 0) {
                return true;
            } else {
                return false;
            }
        },
    },
    methods: {
        handleChange(val) {
            // 奇偶修正模式
            if (this.correct) {
                const lastValue =
                    this.itemRes.formData[this.itemRes.name] || this.range[0];
                const lastValue = this.isEmpty
                    ? this.range[0]
                    : this.itemRes.formData[this.itemRes.name];
                let nextValue = val;
                if (
                    (this.correct === 'odd' && nextValue % 2 === 0) ||
forms/numberStep/cNumberStep.scss
@@ -48,5 +48,12 @@
                color: #999;
            }
        }
        &.on-empty {
            .at-input-number {
                input {
                    color: transparent;
                }
            }
        }
    }
}