思路:在后端返回的数据遍历,需要排序的字段*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>