1.0.4 • Published 6 months ago

range-controler v1.0.4

Weekly downloads
-
License
-
Repository
github
Last release
6 months ago

range-controler

Description

This is a Vue2 based component and is used to represent what users want to do in different ranges. For example, this component can be used to control customers to receive different recharge rewards as the recharge amount changes in a recharge activity.

Installation

You need node.js and npm

npm i range-controler

in xxx.vue

import inputRangeConfiger from 'range-controler'

components: {
    inputRangeConfiger
},

For example, When used with the el-dialog component:

<el-dialog title="" :visible.sync="dialogVisible" width="60%">
    <el-form>
    <inputRangeConfiger 
        :configArr.sync="arr" 
        label="Recharge amount" 
        :purpose="true" 
        :step="1" 
        :aimAttri="aimAttri"
        :add-step="1000"
        :infinite="false"
    >
        <template v-slot:purpose="scope">
        <el-form :inline="true">
            <el-form-item label="Additional gift ratio:">
            <el-input-number v-model="arr[scope.row.index].discount" :min="1" :max="100" ></el-input-number>%
            </el-form-item>
            <el-form-item label="Gifts:">
            <el-input v-model="arr[scope.row.index].gift" type="text"></el-input>
            </el-form-item>
        </el-form>
        </template>
    </inputRangeConfiger>
    </el-form>
    <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">cancel</el-button>
    <el-button type="primary" @click="dialogVisible = false">confirm</el-button>
    </span>
</el-dialog>

data(){
    return {
        arr:[
            {
                from:0,
                to:1000,
            },
            {
                from:1001,
                to:2001
            }
        ],
        aimAttri: {
            discount: 0,
            gift: ''
        },
    }
}

after I set the values of discount and gift:

image

and its corresponding results:

 [{ from: 0, to: 1000, discount: 1, gift: 'Random S-level skin' }, { from: 1001, to: 2001, discount: 2, gift: 'Custom spraying' }]

Of course, you can modify the field name through different attributes in the following document.

Reminder Information: The ranges of the interval here will not overlap, and when any one range is modified, the values of other ranges will also change, with the manually modified range having the highest priority.

and here you can add a attribute slideble to change the range by sliding image

Attributes

AttributeDescriptionTypeDefault
configArrbinding valueArray{ from : 0, to: 5 }
stepincremental step and mutatioin stepNumber1
labellabel textStringRange
purposeWhether to use slots for specific purposesBooleanfalse
aimAttrispecific purposes object. It only takes effect when purpose is trueObject{ aimrow: 0 }
readonlysame as readonly in native input, but pay attention to the form elements in "templete v-slot:purpose", you can add readonly attribute manuallyBooleanfalse
minNumminimum number of intervalsNumber1
addStepThe range size of the newly added itemNumber1000
infiniteCan it end with 0 and represent infinityBooleantrue
fromCustom fields represent the starting point of the rangeStringfrom
toCustom fields represent the endpoint of the rangeStringto
numLabelrange amount labelStringrange amount
slidablechange the value by slidingBooleanfalse
1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago