WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2022-01-21 eb514affa9174c7f931b3e71435e7ee819e2d4d0
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
@@ -51,7 +51,7 @@
        // 取值范围
        range: {
            type: Array,
            default: [0, 100],
            default: () => [0, 100],
        },
        // 步长
        step: {
@@ -72,19 +72,33 @@
    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];
                const lastValue = this.isEmpty
                    ? this.range[0]
                    : this.itemRes.formData[this.itemRes.name];
                let nextValue = val;
                if (
                    (this.correct === 'odd' && nextValue % 2 === 0) ||
                    (this.correct === 'even' && nextValue % 2 === 1)
                ) {
                    // 增加
                    if (lastValue < nextValue) {
                    if (lastValue <= nextValue) {
                        nextValue++;
                    }
                    // 减小
@@ -106,7 +120,7 @@
    mounted() {
        if (process.env.TARO_ENV === 'h5') {
            $(this.$refs.input.$el)
                .find('.at-input__input')
                .find('.at-input__container')
                .prepend(this.$refs.number.$el);
        } else if (process.env.TARO_ENV === 'weapp') {
            $(this.$refs.input.$el)