where: { //添加筛选条件 taskStatus: 2 //只显示taskStatus等于1的数据 }设置一下,大于1小于8的数据
时间: 2023-11-28 11:48:49 浏览: 28
你需要将筛选条件修改为:
```
where: {
taskStatus: {
gt: 1,
lt: 8
}
}
```
这样就可以只显示`taskStatus`大于1且小于8的数据了。
相关问题
这是实体类: @Data @TableName("bis_task") public class BisTask extends PageReqVO implements Serializable { private static final long serialVersionUID = 1L; @TableId(value="id" , type = IdType.AUTO) private Integer id; @TableField("task_status") private Integer taskStatus; } 这是前端部分代码: , url: '/bisTask/taskListPage' //数据接口 , method: 'POST' , where: { //添加筛选条件 taskStatus: [4,5,6] } 给我改一下private Integer taskStatus;字段,让前端能显示taskStatus等于4和5和6的数据
可以将 `private Integer taskStatus;` 改成 `@TableField("task_status") private String taskStatus;`,然后在前端的 `where` 中改成:
```
where: {
taskStatus: ['4','5','6']
}
```
这样前端就能显示 taskStatus 等于 4、5、6 的数据了。注意,这里的 `taskStatus` 需要改成字符串类型,而不是整数类型。
tableIns1 = table.render({ elem: '#showTable' , contentType: 'application/json' , headers: {"authorization": token} , page: true //开启分页 , url: '/bisTask/taskListPage' //数据接口 , method: 'POST' , parseData: function (res) {//将原始数据解析成 table 组件所规定的数据 return { "code": res.code, //解析接口状态 "msg": res.msg, //解析提示文本 "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度 "data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表 } } , cols: [ [ {field: 'taskStatus', title: '任务状态', sort: true} ] ] , toolbar: '#toolbar' }); 只查询taskStatus等于4和5的数据
可以在 `parseData` 函数中进行数据过滤,只保留 `taskStatus` 等于 4 或 5 的数据,如下所示:
```
parseData: function (res) {
var filteredData = res.data.records.filter(function(item) {
return item.taskStatus === 4 || item.taskStatus === 5;
});
return {
"code": res.code,
"msg": res.msg,
"count": CoreUtil.isEmpty(filteredData) ? 0 : filteredData.length,
"data": filteredData
}
}
```
这段代码会将原始数据中 `taskStatus` 等于 4 或 5 的数据筛选出来,并返回给表格组件。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)