elementUI中table中sort排序字符串bug处理

思路:在后端返回的数据遍历,需要排序的字段*1,将字符串转化成数字

代码: 

<el-table ref="multipleTable"
                  :data="tableData"
                  tooltip-effect="dark"
                  @sort-change='tableSort'>
          <el-table-column prop="code"
                           label="商品编号"
                           min-width="100"></el-table-column>
          <el-table-column prop="name"
                           label="商品标题"
                           :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="exchangeCount"
                           label="累计销量"
                           min-width="100"
                           sortable
                           :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column prop="inventory"
                           label="当前库存"
                           min-width="100"
                           sortable
                           :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="marketPrice"
                           label="市价(RMB)"
                           min-width="100"
                           sortable
                           :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="integral"
                           label="积分"
                           min-width="100"
                           sortable
                           :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="rmb"
                           label="RMB"
                           sortable
                           :show-overflow-tooltip="true"
                           min-width="100">
          </el-table-column>
          <el-table-column prop="type"
                           label="商品分类"
                           min-width="100"
                           :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <span>{{scope.row.type|formProductType}}</span>
            </template>
          </el-table-column>
          <el-table-column label="上架情况"
                           :show-overflow-tooltip="true"
                           min-width="200">
            <template slot-scope="scope">
              <el-checkbox label="APP"
                           v-model="scope.row.appChannels"
                           true-label="1"
                           false-label="0"
                           @change="transFormChannels('1', scope.row)"></el-checkbox>
              <el-checkbox label="小程序"
                           v-model="scope.row.miniChannels"
                           true-label="1"
                           false-label="0"
                           @change="transFormChannels('2', scope.row)"></el-checkbox>
            </template>
          </el-table-column>
          <el-table-column fixed="right"
                           label="操作"
                           width="150">
            <template slot-scope="scope">
              <button @click="lookGoodsInfo(scope.row)"
                      class="btn disable">预览</button>
              <button @click="updateGoods(scope.row.id)"
                      class="btn disable">编辑</button>
            </template>
          </el-table-column>
        </el-table>
<script>
methods: {
    selectGoodsList () {
      let parames = {
        "functionName": "productbiz.service.puhui.integralMall.IntegralMallService",                //类型:String  必有字段  备注:无
        "methodName": "selectGoodsByPage",                //类型:String  必有字段  备注:无
        "pageNo": this.pageNo,                //类型:String  必有字段  备注:无
        "pageSize": "10",                //类型:String  必有字段  备注:无
        "data": {                //类型:Object  必有字段  备注:无
          "name": this.searchObj.name,                //类型:String  必有字段  备注:标题
          "type": this.searchObj.type,                //类型:String  必有字段  备注:商品分类(1.实物,2.虚拟)
          "putState": this.searchObj.channels                //类型:String  必有字段  备注:上架情况(1:APP,2:小程序,3:不限)
        }
      };
      console.log('商品列表参数', parames);
      this.http(JSON.stringify(parames))
        .then(res => {
          console.log('商品列表结果', res);
          this.tableData = res.data.goodsList;
          for(let i = 0;i<this.tableData.length;i++){
            this.tableData[i].rmb=this.tableData[i].rmb*1;
            this.tableData[i].marketPrice=this.tableData[i].marketPrice*1;
            this.tableData[i].integral=this.tableData[i].integral*1;
            this.tableData[i].inventory=this.tableData[i].inventory*1;
            this.tableData[i].exchangeCount=this.tableData[i].exchangeCount*1;
          }
          this.sumCount = res.sumCount;
        })
        .catch(res => { });

    },
}
</script>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值