Subsearch now work, backend still needs to be perfected, paginate doesn't work properly with the logic I tried to implement

This commit is contained in:
Phoenix 2019-09-16 12:10:04 +01:00
parent 310c9f4784
commit 32cf6f0d11
2 changed files with 18 additions and 14 deletions

View File

@ -42,6 +42,9 @@ export function logout() {
}) })
} }
export function fetchSubstringList(substring, query) {
return axios.get(`${apiUrl}/user/search/${substring}/`, { params: query })
}
export function fetchList(query) { export function fetchList(query) {
query.platform = store.state.platform query.platform = store.state.platform
return axios.get(`${apiUrl}/user/search`, { params: query }) return axios.get(`${apiUrl}/user/search`, { params: query })

View File

@ -2,9 +2,7 @@
<div class="app-container"> <div class="app-container">
<div class="filter-container"> <div class="filter-container">
<el-select v-model="listQuery.accountId" :remote-method="getRemoteAccountList" filterable default-first-option remote placeholder="Search Accounts" loading-text="Loading..."> <input v-model="substring" placeholder="Search Accounts" class="filter-item">
<el-option v-for="(item,index) in accountListOptions" :key="item+index" :label="item.name" :value="item.id" />
</el-select>
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter"> <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
Search Search
</el-button> </el-button>
@ -42,7 +40,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="$store.state.settings.platform === 'OLFDE'" align="center" label=Type width="200"> <el-table-column v-if="$store.state.settings.platform === 'OLFDE'" align="center" label="Type" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.type_id }}</span> <span>{{ scope.row.type_id }}</span>
</template> </template>
@ -75,7 +73,7 @@
</template> </template>
<script> <script>
const fetchAccountList = require('@/api/account').fetchList const fetchSubstringList = require('@/api/user').fetchSubstringList
import { fetchList, sendPasswordReset } from '@/api/user' import { fetchList, sendPasswordReset } from '@/api/user'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
@ -98,6 +96,7 @@ export default {
total: 0, total: 0,
listLoading: true, listLoading: true,
accountListOptions: [], accountListOptions: [],
substring: '',
listQuery: { listQuery: {
page: 1, page: 1,
limit: 20, limit: 20,
@ -121,18 +120,20 @@ export default {
this.listLoading = false this.listLoading = false
}) })
}, },
getRemoteAccountList(query) { getSubstring() {
query = {} fetchSubstringList(this.substring, this.listQuery).then(response => {
query.platform = this.$store.state.settings.platform console.log(response)
query.limit = 100 this.list = response.data.docs
fetchAccountList(query).then(response => { this.total = response.data.total
if (!response.data.docs) return
this.accountListOptions = response.data.docs.map(v => { return { name: v.name, id: v._id } })
}) })
}, },
handleFilter(query) { handleFilter() {
this.listQuery.page = 1 this.listQuery.page = 1
this.getList() if (this.substring === '') {
this.getList
} else {
this.getSubstring()
}
}, },
sendPasswordResetConfirm(email) { sendPasswordResetConfirm(email) {
this.$confirm(`This will send an email to <b>${email}</b>, prompting them to reset their password with the provided link. Are you sure you want to do this?`, 'Warning', { this.$confirm(`This will send an email to <b>${email}</b>, prompting them to reset their password with the provided link. Are you sure you want to do this?`, 'Warning', {