• ivew 修改排序号的逻辑


    排序号修改的逻辑

    1.构建修改排序号传递的参数

    formInline2:{ recommendType:4, //产品类型 merchantCodes:[], //产品code discountRecommendSort:0 //设置品牌特惠专区排序 },

    2.给参数赋值

        //获得品牌商ID
        this.formInline2.merchantCodes=[];
          this.formInline2.merchantCodes.push(params.row.merchantCode);

    给要修改的排序号赋值

    .获得要修改的排序号recommendSort的值,并且将它赋值给我们输入的值 this.formInline2.discountRecommendSort=e.target.value;

     

    3.调修改排序号的接口,将参数传递进去

    areasort(this.formInline2).then(res=>{ //4.当调接口成功返回200,就调list 接口刷新页面 //console.log(res.status) } console.log(params.row.discountFlag); }).catch(error=>{

          });

    4.刷新页面

    if(params.row.discountRecommendSort==0) { this.data1=res.data.data ? res.data.data :[] } if(params.row.discountRecommendSort==1) { this.data2=res.data.data ? res.data.data :[]

    }

     

    5.table 中要修改的排序号添加方法

    { title: '特惠排序号', key: 'discountSort', align: 'center', sortable: true, //排序 sortType: 'asc', render: (h, params) => { return h('div', [ h('Input', { props: { type: 'text', size: 'small', value:params.row.discountSort }, style: { marginRight: '5px' }, on: { //失去焦点触发事件 'on-blur': (e) => { //console.log(params.row.productCode) this.sort(e,params); //修改排序的方法 } } }, )]) } },

     

    完整代码:

    js

        //修改排序号
             sort(e,params) {
              //1.获得品牌商ID
              this.formInline2.merchantCodes=[];
               this.formInline2.merchantCodes.push(params.row.merchantCode);
               //2.获得要修改的排序号recommendSort的值,并且将它赋值给我们输入的值
               this.formInline2.discountRecommendSort=e.target.value;
               //3.调修改排序号的接口
               areasort(this.formInline2).then(res=>{
                    //4.当调接口成功返回200,就调list 接口刷新页面
                      //console.log(res.status)
                            if(res.status==200) {
                              //console.log(params.row.discountFlag);
                                    referentialproduct(params.row.discountRecommendSort)
                                    .then(res=>{
                                        console.log(params.row.discountRecommendSort);
                                        if(params.row.discountRecommendSort==0) {
                                             this.data1=res.data.data ? res.data.data :[]
                                        }
                                        if(params.row.discountRecommendSort==1) {
                                              this.data2=res.data.data ? res.data.data :[]
                                        }
                                        this.$Message.success(res.data.msg);
                                        this.loading= false;
                                    } )
                                    .catch(error=>{} );
                                    console.log(params.row.discountFlag)
                            }
                            console.log(params.row.discountFlag);
              }).catch(error=>{
    
              });
             },

    table

      {
                            title: '特惠排序号',
                            key: 'discountSort',
                            align: 'center',
                            sortable: true,  //排序
                            sortType: 'asc',
                            render: (h, params) => {
                                 return h('div', [
                                   h('Input', {
                                     props: {
                                       type: 'text',
                                       size: 'small',
                                       value:params.row.discountSort
                                     },
                                     style: {
                                       marginRight: '5px'
                                     },
                                     on: {
                                       //失去焦点触发事件
                                       'on-blur': (e) => {
                                                 //console.log(params.row.productCode)
                                              this.sort(e,params);  //修改排序的方法
                                        }
                                    }
                           }, )])
                         }
                        },

     

  • 相关阅读:
    穷举 百鸡百钱
    for嵌套for ★
    纸张的厚度循环
    MySQL架构由小变大的演变过程
    MySQL数据库主从复制实践
    想要写出高性能sql语句,你得记住这些……
    Mongodb常用的性能监控命令
    Mongodb的mongostat命令
    Windows下MongoDB常用命令
    Windows下Mysql常用操作命令
  • 原文地址:https://www.cnblogs.com/guangzhou11/p/10516769.html
Copyright © 2020-2023  润新知