如何在使用 || 时包含多个表$cont||在我的 URL 查询参数中使用'&or'条件?



html:

<v-col cols="2">
<v-text-field label="Staff" :disabled="disabled" v-model="search" />
</v-col>
<v-col cols="2" class="d-flex justify-end footer-btn-container">
<v-btn
:disabled="disabled"
color="success"
@click="fetchManagers()">
Search
</v-btn>
</v-col>

javascript:

async fetchManagers () {
let param = `filter=staffId2||$cont||${this.search}&or=firstName||$cont||${this.search}`
await this.fetchEmployee({ pageNumber: 1, pageSize: 1000000, param: param })
}
const actions = {
async fetchEmployee ({ commit }, { pageNumber, pageSize, param }) {
try {
const response = await getAllEmployee(pageNumber, pageSize, param)
commit('setEmployee', response.data)
} catch (error) {
// handle the error here
}
}

import httpClient from './httpClient'
const END_POINT = '/staff'
const getAllEmployee = (pageNumber, pageSize, param) => httpClient.get(`${END_POINT}?${param}`, { params: { 'page': pageNumber, 'limit': pageSize } })

上面的方法有效,但当我尝试多个字段时,它没有给出正确的结果

let param = `filter=staffId2||$cont||${this.search}&or=firstName||$cont||${this.search}&or=lastName||$cont||${this.search}&or=middleName||$cont||${this.search}&or=branch||$cont||${this.search}`
await this.fetchEmployee({ pageNumber: 1, pageSize: 1000000, param: param })

这行不通。

最终解决了这个问题。我所要做的就是删除filter并放入where

从这个

filter=staffId2||$cont||${this.search}&or=firstName||$cont||${this.search}
&or=lastName||$cont||${this.search}&or=middleName||$cont||${this.search}
&or=branch||$cont||${this.search}

到此

where&or=staffId2||$cont||${this.search}&or=branch.name||$cont||${this.search}
&or=surname||$cont||${this.search}&or=firstName||$cont||${this.search}"

最新更新