1***@163.com
1***@163.com
  • 发布:2021-12-17 16:22
  • 更新:2024-03-27 17:39
  • 阅读:1956

基于uni-admin的模糊查询和筛选查询(针对用户查询自己商品/产品使用)

分类:uniCloud

说明

1.程序基于uni-admin管理系统(用户)的模糊查询和筛选查询
2.程序由schema2code自动生成,添加几行代码即可
3.如果内容对各位有帮助请关注一下,创作不易

模糊查询

    let newWheres =this.getWhere();  
    let newWhere=newWheres.length>0?'('+newWheres+') && u_id == $cloudEnv_uid':'u_id == $cloudEnv_uid'

筛选查询

    newWhere.u_id=db.getCloudEnv('$cloudEnv_uid')

示例

    const dbOrderBy = 'create_date desc' // 排序字段,asc(升序)、desc(降序)  
    const dbSearchFields = ["title","description","reject_description"] // 模糊搜索字段,支持模糊搜索的字段列表。联表查询格式: 主表字段名.副表字段名,例如用户表关联角色表 role.role_name  
    export default {  
        methods: {  
            // 模糊查询  
            search() {  
                let newWheres =this.getWhere();  
                let newWhere=newWheres.length>0?'('+newWheres+') && u_id == $cloudEnv_uid':'u_id == $cloudEnv_uid'  
                this.where = newWhere  
                this.$nextTick(() => {  
                    this.loadData()  
                })  
            },  
            // 筛选查询  
            filterChange(e, name) {  
                this._filter[name] = {  
                type: e.filterType,  
                    value: e.filter  
                }  
                let newWhere = filterToWhere(this._filter, db.command)   
                newWhere.u_id=db.getCloudEnv('$cloudEnv_uid')  
                if (Object.keys(newWhere).length) {  
                    this.where = newWhere  
                } else {  
                    this.where = ''  
                }  
                this.$nextTick(() => {  
                    this.$refs.udb.loadData()  
                })  
            }  
        }  
    }
1 关注 分享
1***@qq.com

要回复文章请先登录注册

1***@qq.com

1***@qq.com

nb,我也被这个困扰了很久...
2024-03-27 17:39
代木

代木

dbSearchFields的字段类型如果是object,该怎么处理?
2023-08-04 15:59
3***@qq.com

3***@qq.com

感谢真好被这个困扰了很久···
2023-03-30 00:06
hws007

hws007

没看到getWhere()涵数,代码没贴完!没完整的
2022-03-29 04:17
hws007

hws007

模糊查询!不是这样的吧
2022-03-29 04:13
1***@qq.com

1***@qq.com

前端怎么获取uid
2022-03-27 13:23