vuedraggabletuo拖拽插件

vue.draggable一款基于vue的拖拽插件 - itxst.com

   <p slot="title">商品参数</p>
                              <draggable v-model="parameterlist" chosenClass="chosen" forceFallback="true" group="people" animation="1000"
                                    @start="onParameterlist" @end="onParameterlistEnd">
                            <Row type="flex" justify="start" class="margin-top-10"  v-for="(item, index) in product.parameterlist" :key="item.id">
                                <Col span="4">
                                <FormItem 
                                    :prop="'parameterlist.' + index + '.productAttrName'"
                                    :rules="{ required: true, message: '参数名不能为空', trigger: 'blur' }" :label-width="10">
                                    <Input v-model="item.productAttrName" placeholder="参数名"></Input>
                                </FormItem>
                                </Col>
                                <Col span="8" offset="2">
                                <FormItem 
                                    :prop="'parameterlist.' + index + '.productAttrValue'"
                                    :rules="{ required: true, message: '参数值不能为空', trigger: 'blur' }" :label-width="10">
                                    <Input v-model="item.productAttrValue" placeholder="参数值"></Input>
                                </FormItem>
                                </Col>
                                <Col span="2" offset="1">
                                <FormItem 
                                    :label-width="0">
                                    <Button icon="md-close" @click.native="delParam(index)"></Button>
                                </FormItem>
                                </Col>
                            </Row>
                             </draggable>
  onParameterlist (e) {
            this.drag = true;
        },
        onParameterlistEnd (e) {
            console.log(e, '此时的数据');
            this.drag = false;
            const item = { ...this.product.parameterlist[e.oldIndex] };
            this.product.parameterlist.splice(e.oldIndex, 1);
            this.product.parameterlist.splice(e.newIndex, 0, item);
        },

拖拽改变表单列的顺序顺便改变数据的排序。记录一下。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值