feat:列表页新增搜索功能 (#46)

This commit is contained in:
dayou 2024-01-16 14:49:33 +08:00 committed by GitHub
parent a5334a6632
commit 0b7be22d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 118 additions and 4 deletions

View File

@ -1,10 +1,11 @@
import axios from './base'; import axios from './base';
export const getSurveyList = (curPage) => { export const getSurveyList = (curPage, filter) => {
return axios.get('/surveyManage/list', { return axios.get('/surveyManage/list', {
params: { params: {
pageSize: 10, pageSize: 10,
curPage, curPage,
filter,
}, },
}); });
}; };

View File

@ -1,5 +1,13 @@
<template> <template>
<div class="tableview-root"> <div class="tableview-root">
<div class="filter-wrap">
<div class="search">
<text-search
placeholder="请输入问卷标题"
:value="searchVal"
@search="onSearchText" />
</div>
</div>
<el-table <el-table
v-if="total" v-if="total"
ref="multipleListTable" ref="multipleListTable"
@ -59,7 +67,7 @@
</div> </div>
<div v-else> <div v-else>
<empty :data="noListDataConfig" /> <empty :data="!searchVal? noListDataConfig : noSearchDataConfig" />
</div> </div>
<modify-dialog <modify-dialog
@ -83,7 +91,8 @@ import ModifyDialog from './modify';
import Tag from './tag'; import Tag from './tag';
import State from './state'; import State from './state';
import ToolBar from './toolBar'; import ToolBar from './toolBar';
import { fieldConfig, thead, noListDataConfig } from '../config'; import TextSearch from './textSearch'
import { fieldConfig, thead, noListDataConfig, noSearchDataConfig } from '../config';
import { CODE_MAP } from '@/management/api/base'; import { CODE_MAP } from '@/management/api/base';
import { QOP_MAP } from '@/management/utils/constant'; import { QOP_MAP } from '@/management/utils/constant';
import { getSurveyList, deleteSurvey } from '@/management/api/survey'; import { getSurveyList, deleteSurvey } from '@/management/api/survey';
@ -98,10 +107,12 @@ export default {
loading: false, loading: false,
theadDict: thead, theadDict: thead,
noListDataConfig, noListDataConfig,
noSearchDataConfig,
questionInfo: {}, questionInfo: {},
total: 0, total: 0,
data: [], data: [],
currentPage: 1, currentPage: 1,
searchVal: ''
}; };
}, },
computed: { computed: {
@ -111,6 +122,18 @@ export default {
}); });
return fieldInfo; return fieldInfo;
}, },
filter() {
return [
{
comparator:"",
condition:[{
"field":"title",
"value":this.searchVal,
"comparator":"$regex"
}]
}
]
}
}, },
created() { created() {
this.init(); this.init();
@ -119,7 +142,8 @@ export default {
async init() { async init() {
this.loading = true; this.loading = true;
try { try {
const res = await getSurveyList(this.currentPage); const filter = JSON.stringify(this.filter)
const res = await getSurveyList(this.currentPage, filter);
this.loading = false; this.loading = false;
if (res.code === CODE_MAP.SUCCESS) { if (res.code === CODE_MAP.SUCCESS) {
this.total = res.data.count; this.total = res.data.count;
@ -219,12 +243,18 @@ export default {
}, },
}); });
}, },
onSearchText(e) {
this.searchVal = e
this.currentPage = 1
this.init()
}
}, },
components: { components: {
empty, empty,
ModifyDialog, ModifyDialog,
Tag, Tag,
ToolBar, ToolBar,
TextSearch,
State, State,
}, },
}; };
@ -232,6 +262,14 @@ export default {
<style lang="scss" rel="stylesheet/scss" scoped> <style lang="scss" rel="stylesheet/scss" scoped>
.tableview-root { .tableview-root {
.filter-wrap{
display: flex;
justify-content: right;
.search{
padding-bottom: 20px;
}
}
.list-table { .list-table {
min-height: 620px; min-height: 620px;
padding: 10px 20px; padding: 10px 20px;

View File

@ -0,0 +1,68 @@
<template>
<div class="filter-input">
<input
:class="['text-search_root']"
v-model="curValue"
@keyup.enter="onSearch"
autocomplete="off"
:placeholder="placeholder"
type="text"
rows="1"
class="el-input__inner"
/>
<i class="el-icon-search el-input__icon" @click="onSearch"></i>
</div>
</template>
<script>
export default {
name: 'TextSearch',
props: {
value: String,
placeholder: String
},
data() {
return {
curValue: this.value,
}
},
watch: {
value(val) {
this.curValue = val
},
},
methods: {
onSearch() {
this.$emit('search', this.curValue)
},
},
}
</script>
<style lang="scss" rel="stylesheet/scss">
// @import '@didi/question-common/assets/css/variable';
.filter-input {
position: relative;
width: 200px;
.el-input__inner {
height: 32px;
line-height: 32px;
padding: 0 25px;
font-size: 12px;
background: #FFFFFF;
border: 1px solid $border-color;
border-radius: 18px;
&:focus {
border-color: $primary-color;
}
}
.el-icon-search {
position: absolute;
line-height: 32px;
right: 10px;
color: #7E7F8A;
cursor: pointer;
&:hover {
color:$primary-color;
}
}
}
</style>

View File

@ -59,6 +59,12 @@ export const noListDataConfig = {
img: '/imgs/icons/list-empty.png', img: '/imgs/icons/list-empty.png',
}; };
export const noSearchDataConfig = {
title: '没有满足该查询条件的问卷哦',
desc: '可以更换条件查询试试',
img: '/imgs/icons/list-empty.png',
};
export const statusMaps = { export const statusMaps = {
new: '未发布', new: '未发布',
editing: '修改中', editing: '修改中',

View File

@ -79,6 +79,7 @@ export default {
} }
.list-content { .list-content {
height: calc(100% - 56px);
padding: 20px; padding: 20px;
.top { .top {