[update] 按后端格式修改一般检索

This commit is contained in:
lideqin
2023-11-14 17:32:14 +08:00
parent e4e5593254
commit 7b835d9e41
11 changed files with 263 additions and 173 deletions
+17 -2
View File
@@ -2,9 +2,19 @@ import { getAction, postAction } from './manage'
// 获取检索历史数据
const getSearchHistoryData = (params) => getAction('/home/lawsHomeNormalSearchHistory/page', params)
// 一般检索(标题)——资源类型改变获取下面筛选项统计数据
const getSearchParamNum = (params) => postAction('/home/lawsHomeNormalSearchData/getNormalSearchTitleCount', params)
const getSearchParamNum = (params) => getAction('/home/lawsHomeSearch/getNormalSearchTitleCount', params)
// 一般检索(标题)—— 查询
const generalSearchTitleSearch = (params) => getAction('/home/lawsHomeSearch/getNormalSearchTitlePage', params)
// 一般检索(全文)——资源类型改变获取下面筛选项统计数据
const getSearchParamNumFullText = (params) => postAction('/home/lawsHomeSearch/getNormalSearchAllCount', params)
const getSearchParamNumFullText = (params) => getAction('/home/lawsHomeSearch/getNormalSearchAllCount', params)
// 一般检索(全文)—— 查询
const generalSearchFullTextSearch = (params) => getAction('/home/lawsHomeSearch/getNormalSearchAllPage', params)
// 一般检索-国内标准获取展示字段
const getDomesticStandardField = (params) => getAction('/laws/standard/domestic/getFormModel', params)
// 一般检索-国外标准获取展示字段
const getOverseasStandardField = (params) => getAction('/laws/standard/overseas/getFormModel', params)
// 一般检索-企标获取展示字段
const getEnterpriseStandardField = (params) => getAction('/laws/standard/enterprise/getFormModel', params)
// 国内标准的高级搜索,查询搜索条件
const getDomesticStandardQuery = (params) => getAction('/laws/standard/domestic/getQueryCondition', params)
@@ -23,7 +33,12 @@ const getEnterStandardList = (params) => getAction('/laws/standard/enterprise/ge
export {
getSearchHistoryData,
getSearchParamNum,
generalSearchTitleSearch,
getSearchParamNumFullText,
generalSearchFullTextSearch,
getDomesticStandardField,
getOverseasStandardField,
getEnterpriseStandardField,
getDomesticStandardQuery,
getOverseasStandardQuery,
getEnterStandardQuery,
+7 -3
View File
@@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 4236293 */
src: url('iconfont.woff2?t=1698992919545') format('woff2'),
url('iconfont.woff?t=1698992919545') format('woff'),
url('iconfont.ttf?t=1698992919545') format('truetype');
src: url('iconfont.woff2?t=1699953801277') format('woff2'),
url('iconfont.woff?t=1699953801277') format('woff'),
url('iconfont.ttf?t=1699953801277') format('truetype');
}
.iconfont {
@@ -13,6 +13,10 @@
-moz-osx-font-smoothing: grayscale;
}
.icon-Searchbar_Search_icon:before {
content: "\e64a";
}
.icon-nav_apartment:before {
content: "\e714";
}
File diff suppressed because one or more lines are too long
+7
View File
@@ -5,6 +5,13 @@
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
{
"icon_id": "12150232",
"name": "Search bar_Search_icon",
"font_class": "Searchbar_Search_icon",
"unicode": "e64a",
"unicode_decimal": 58954
},
{
"icon_id": "16880564",
"name": "nav_apartment",
Binary file not shown.
Binary file not shown.
Binary file not shown.
+11 -1
View File
@@ -7,6 +7,16 @@ module.exports = {
searchHistory: '检索历史',
queryCondition: 'Query Condition',
retrievalMode: 'Retrieval Mode',
resourceType: 'Resource Type'
resourceType: 'Resource Type',
standardClass: 'Standard Class',
dynamicType: 'Dynamic Type',
applicableVehicleType: 'Applicable Vehicle Type',
standardType: 'Standard Type',
state: 'State',
enterpriseStandardCode: 'Enterprise Standard Code',
standardState: 'Standard State',
standardGradeClassification: 'Standard Grade Classification',
all: 'All',
releaseDate: 'Release Date'
}
}
+11 -1
View File
@@ -7,6 +7,16 @@ module.exports = {
searchHistory: '检索历史',
queryCondition: '查询条件',
retrievalMode: '检索方式',
resourceType: '资源类型'
resourceType: '资源类型',
standardClass: '标准类别',
dynamicType: '动力类型',
applicableVehicleType: '适用车辆类型',
standardType: '标准类型',
state: '状态',
enterpriseStandardCode: '企业标准代号',
standardState: '标准状态',
standardGradeClassification: '标准等级分类',
all: '全部',
releaseDate: '发布日期'
}
}
+208 -164
View File
@@ -1,9 +1,16 @@
<template>
<a-card :bordered="false">
<a-card :bordered="false" :loading="loading">
<!-- 搜索框部分 -->
<div class="top-search-div">
<div class="top-search-div-content">
<a-input-search class="input-search" :placeholder="$t('pleaseEnter')+$t('dashboard.generalSearch.queryCondition')" v-model="searchValue" enter-button @search="onSearch" />
<a-input-search class="input-search"
:placeholder="$t('pleaseEnter')+$t('dashboard.generalSearch.queryCondition')"
v-model="searchValue"
@search="onSearch">
<a-button type="primary" slot="enterButton">
<i class="iconfont icon-Searchbar_Search_icon"></i>
</a-button>
</a-input-search>
<a class="search-link" @click="clickAdvancedSearch">{{ $t('dashboard.generalSearch.advancedSearch') }}</a>
<a class="search-link">{{ $t('dashboard.generalSearch.homePage') }}</a>
<a class="search-link" @click="clickSearchHistory">{{ $t('dashboard.generalSearch.searchHistory') }}</a>
@@ -33,10 +40,10 @@
<template v-if="toggleSearchStatus">
<template v-for="(value, key) in selectOptions">
<div :key="key" :gutter="24" class="filter-row">
<div class="label-col"><span class="search_label">{{ lang === 'zh-cn' ? value.label : value.labelEn }}</span></div>
<div class="label-col"><span class="search_label">{{ value.label }}</span></div>
<div class="option-col">
<div v-for="item in value.options" :key="item.value" class="option-div" :class="value.current === item.value ? 'option-curr' : ''" @click="selectOptionsChange(key, item.value)">
{{ item.title }}
<div v-for="item in value.options" :key="item.itemValue" class="option-div" :class="value.current === item.itemValue ? 'option-curr' : ''" @click="selectOptionsChange(key, item.itemValue)">
<span>{{ item.itemText }}<span v-if="item.statisticsCount || item.statisticsCount === 0">(<span class="option-span-num">{{ item.statisticsCount }}</span>)</span></span>
</div>
</div>
</div>
@@ -52,9 +59,18 @@
<div class="result-wrapper">
<div class="result-div" v-for="item in dataSource" :key="item.standardNumber">
<div class="result-title-wrapper">
<p class="result-title">{{ item.standard_number + ' ' + item.standard_name }}</p>
<!-- 正在搜索标题根据搜索内容高亮显示 -->
<p v-if="isSearch" class="result-title">
<span v-if="(item.standard_number + ' ' + item.standard_name).indexOf(searchValue) > -1">
{{ (item.standard_number + ' ' + item.standard_name).substr(0, (item.standard_number + ' ' + item.standard_name).indexOf(searchValue)) }}
<span class="title-high-light">{{ searchValue }}</span>
{{ (item.standard_number + ' ' + item.standard_name).substr((item.standard_number + ' ' + item.standard_name).indexOf(searchValue) + searchValue.length) }}
</span>
<span v-else>{{ item.standard_number + ' ' + item.standard_name }}</span>
</p>
<p v-else class="result-title">{{ item.standard_number + ' ' + item.standard_name }}</p>
<p class="result-source">{{ item.source }}</p>
<p class="result-date">{{ item.publishDate }}</p>
<p class="result-date">{{ $t('dashboard.generalSearch.releaseDate') }} {{ item.publishDate }}</p>
</div>
<div class="result-content-wrapper">
<span class="result-field-span" v-for="field in formInLine" :key="field.dbFieldName">{{field.dbFieldTxt}}: {{ item[field.dbFieldName] || '--' }}</span>
@@ -73,131 +89,46 @@
:showTotal="ipagination.showTotal"
/>
</template>
<a-empty v-else />
<a-empty class="empty-content" v-else />
<search-history-modal ref="searchHistoryModal"></search-history-modal>
</a-card>
</template>
<script>
import { ajaxGetDictItems, getCarTypeProjectList } from '@/api/api'
import SearchHistoryModal from './modules/SearchHistoryModal'
import { getSearchParamNum, getSearchParamNumFullText } from '@/api/dashboard'
// 国内的其他检索条件
const domesticOtherOptions = {
standardCategory: { // 标准类别
label: '标准类别',
labelEn: 'Standard Class',
code: 'standard_type',
current: 'all',
options: []
},
dynamicType: { // 动力类型
label: '动力类型',
labelEn: 'Dynamic Type',
current: 'all',
code: 'POWER_TYPE_DOMESTIC',
options: []
},
applicableVehicleType: { // 适用车辆类型
label: '适用车辆类型',
labelEn: 'Applicable Vehicle Type',
current: 'all',
href: getCarTypeProjectList,
options: []
},
standardType: { // 标准性质
label: '标准性质',
labelEn: 'Standard Property',
current: 'all',
code: 'standard_property',
options: []
},
status: { // 状态
label: '状态',
labelEn: 'Status',
current: 'all',
code: 'standard_state',
options: []
}
}
// 海外的其他检索条件
const overseasOtherOptions = {
standardCategory: { // 标准类别
label: '标准类别',
code: 'standard_type',
current: 'all',
options: []
},
dynamicType: { // 动力类型
label: '动力类型',
labelEn: 'Dynamic Type',
current: 'all',
code: 'POWER_TYPE_DOMESTIC',
options: []
},
applicableVehicleType: { // 适用车辆类型
label: '适用车辆类型',
labelEn: 'Applicable Vehicle Type',
current: 'all',
href: getCarTypeProjectList,
options: []
},
status: { // 状态
label: '状态',
labelEn: 'Status',
current: 'all',
code: 'standard_state',
options: []
}
}
// 企标的其他检索条件
const enterpriseOtherOptions = {
standardCode: { // 企业标准代号
label: '企业标准代号',
labelEn: 'Enterprise Standard Code',
code: 'enterprise_standard_code',
current: 'all',
options: []
},
standardStatus: { // 标准状态
label: '标准状态',
labelEn: 'Standard State',
code: 'standard_state',
current: 'all',
options: []
},
standardLevel: { // 标准等级分类
label: '标准等级分类',
labelEn: 'Standard Grade Classification',
code: 'standard_grade_classify',
current: 'all',
options: []
}
}
import {
getSearchParamNum,
getSearchParamNumFullText,
generalSearchTitleSearch,
generalSearchFullTextSearch,
getDomesticStandardField,
getOverseasStandardField,
getEnterpriseStandardField
} from '@/api/dashboard'
export default {
name: 'GeneralSearch',
components: { SearchHistoryModal },
data () {
return {
loading: false,
searchValue: '', // 搜索框内容
toggleSearchStatus: false, // 检索条件收缩还是展开, false收缩状态
// 检索方式可选择项
retrievalModeOptions: [
{ key: '1', label: '全文检索' },
{ key: '2', label: '标题检索' }
], // 检索方式可选择项
],
retrievalModeCurrent: '1', // 检索方式当前选中项
// 资源类型可选择项
resourceTypeOptions: [
{ key: 'all', label: '全部' },
{ key: '1', label: '国内标准法规' },
{ key: '2', label: '海外标准法规' },
{ key: '3', label: '企业标准' },
{ key: '4', label: '动态消息' }
], // 资源类型可选择项
],
resourceTypeCurrent: 'all', // 资源类型当前选中项
selectOptions: {}, // 其他筛选条件
dataSource: [
@@ -207,18 +138,9 @@ export default {
// { standard_number: 'GB 7258-12', standard_name: '机动车安全', source: '国内标准法规', publishDate: '2023-08-25' },
// { standard_number: 'GB 7258-12', standard_name: '机动车安全', source: '国内标准法规', publishDate: '2023-08-25' }
],
formInLine: [
{
dbFieldName: 'standard_number',
dbFieldNameOld: 'standard_number',
dbFieldTxt: '企标编号'
},
{
dbFieldName: 'standard_name',
dbFieldNameOld: 'standard_name',
dbFieldTxt: '企标名称'
}
],
domesticFormInLine: [], // 国内标准字段值
overseasFormInLine: [], // 海外标准字段值
enterpriseFormInline: [], // 企标字段值
ipagination: {
current: 1,
pageSize: 10,
@@ -229,44 +151,22 @@ export default {
total: 0,
showQuickJumper: true,
showSizeChanger: true
}
},
isSearch: false // 是否正在展示又搜索内容的搜索结果,是的话,标题搜索内容高亮显示
}
},
computed: {
lang () {
return localStorage.language
}
mounted () {
this.initFilterData()
// 获取要展示的字段,看后端返回的查询结果决定查不查
this.initFormInline()
},
methods: {
// 更新selectOptions中的options
initSelectOptionsData () {
// for (const item in this.selectOptions) {
// if (this.selectOptions[item].code) {
// ajaxGetDictItems(this.selectOptions[item].code).then(res => {
// if (res.success) {
// this.selectOptions[item].options = res.result
// this.selectOptions[item].options.unshift({ text: '全部', title: '全部', value: 'all' })
// } else {
// this.selectOptions[item].options = []
// }
// })
// } else if (this.selectOptions[item].href) {
// this.selectOptions[item].href().then(res => {
// if (res.success) {
// this.selectOptions[item].options = res.result
// this.selectOptions[item].options.unshift({ text: '全部', title: '全部', value: 'all' })
// } else {
// this.selectOptions[item].options = []
// }
// })
// }
// }
},
// 获取要显示数量的筛选条件的数据
initFilterData () {
const param = {}
// 资源类型
param.resourceType = this.resourceTypeCurrent === 'all' ? null : this.resourceTypeCurrent
param.searchContent = this.searchValue
// 检索方式
param.searchMode = this.retrievalModeCurrent
let func
if (this.retrievalModeCurrent === '1') {
@@ -276,38 +176,170 @@ export default {
}
func(param).then(res => {
if (res.success) {
this.selectOptions = res.result
// res.result = {
// applications: [
// { itemText: 'N1', itemValue: 1, statisticsCount: 7 },
// { itemText: '汽油', itemValue: 2, statisticsCount: 0 },
// { itemText: '汽油', itemValue: 3, statisticsCount: 0 },
// { itemText: '汽油', itemValue: 4, statisticsCount: 0 },
// { itemText: '汽油', itemValue: 5, statisticsCount: 0 },
// { itemText: '汽油', itemValue: 6, statisticsCount: 0 }
// ],
// enterpriseStandardCode: [],
// enterpriseStandardState: [],
// powerTypeDomestic: [],
// standardGradeClassify: [],
// standardProperty: [],
// standardState: [],
// standardType: []
// }
// 设置对象key为搜索时需要穿给后端的字段名,以及设置选项和字段label
for (const item in res.result) {
res.result[item].unshift({ itemText: this.$t('dashboard.generalSearch.all'), itemValue: 'all' })
// 适用车辆类型
if (item === 'applications' && res.result[item] && res.result[item].length > 0) {
this.selectOptions.applicableVehicle = {
options: res.result[item],
label: this.$t('dashboard.generalSearch.applicableVehicleType'),
current: 'all'
}
}
// 企业标准代号
if (item === 'enterpriseStandardCode' && res.result[item] && res.result[item].length > 0) {
this.selectOptions.standardCode = {
options: res.result[item],
label: this.$t('dashboard.generalSearch.enterpriseStandardCode'),
current: 'all'
}
}
// 标准状态
if (item === 'enterpriseStandardState' && res.result[item] && res.result[item].length > 0) {
this.selectOptions.enterpriseStandardState = {
options: res.result[item],
label: this.$t('dashboard.generalSearch.standardState'),
current: 'all'
}
}
// 动力类型
if (item === 'powerTypeDomestic' && res.result[item] && res.result[item].length > 0) {
this.selectOptions.dynamicType = {
options: res.result[item],
label: this.$t('dashboard.generalSearch.dynamicType'),
current: 'all'
}
}
// 标准等级分类
if (item === 'standardGradeClassify' && res.result[item] && res.result[item].length > 0) {
this.selectOptions.gradeClassification = {
options: res.result[item],
label: this.$t('dashboard.generalSearch.standardGradeClassification'),
current: 'all'
}
}
// 标准类型
if (item === 'standardProperty' && res.result[item] && res.result[item].length > 0) {
this.selectOptions.standardProperty = {
options: res.result[item],
label: this.$t('dashboard.generalSearch.standardType'),
current: 'all'
}
}
// 状态
if (item === 'standardState' && res.result[item] && res.result[item].length > 0) {
this.selectOptions.standardState = {
options: res.result[item],
label: this.$t('dashboard.generalSearch.state'),
current: 'all'
}
}
// 标准类别
if (item === 'standardType' && res.result[item] && res.result[item].length > 0) {
this.selectOptions.standardClass = {
options: res.result[item],
label: this.$t('dashboard.generalSearch.standardClass'),
current: 'all'
}
}
}
}
})
},
// 获取查询结果中要展示的字段值
initFormInline () {
const param = { type: 1 }
getDomesticStandardField(param).then(res => {
if (res.success) {
this.domesticFormInLine = res.result
}
})
getOverseasStandardField(param).then(res => {
if (res.success) {
this.overseasFormInLine = res.result
}
})
getEnterpriseStandardField(param).then(res => {
if (res.success) {
this.enterpriseFormInline = res.result
}
})
},
// 查询时获取参数
getSearchParam () {
const param = {}
// 资源类型
param.resourceType = this.resourceTypeCurrent === 'all' ? null : this.resourceTypeCurrent
// 检索内容
param.searchContent = this.searchValue
// 其他筛选条件
for (const item in this.selectOptions) {
param[item] = this.selectOptions[item].current
}
return param
},
// 查询
onSearch () {},
onSearch () {
const param = this.getSearchParam()
let func
if (this.retrievalModeCurrent === '1') {
// 是全文检索
func = generalSearchFullTextSearch
} else {
// 是标题检索
func = generalSearchTitleSearch
}
this.loading = true
func(param).then(res => {
if (res.success) {
this.dataSource = res.result
if (this.searchValue) {
// 设置正在搜索,标题设置搜索字高亮
this.isSearch = true
} else {
this.isSearch = false
}
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
// 检索方式改变
retrievalModeChange (key) {
this.retrievalModeCurrent = key
// 更新其他筛选项的数据
this.initFilterData()
},
// 资源类型改变
resourceTypeChange (key) {
this.resourceTypeCurrent = key
if (key === 2) {
// 是国内标准法规
this.selectOptions = JSON.parse(JSON.stringify(domesticOtherOptions))
} else if (key === 3) {
// 是海外标准法规
this.selectOptions = JSON.parse(JSON.stringify(overseasOtherOptions))
} else if (key === 4) {
// 是企标
this.selectOptions = JSON.parse(JSON.stringify(enterpriseOtherOptions))
} else {
this.selectOptions = {}
}
// 更新其他筛选项的数据
// this.initSelectOptionsData()
this.initFilterData()
},
// 其他检索条件改变
selectOptionsChange (changeKey, value) {
this.selectOptions[changeKey].current = value
this.$forceUpdate()
},
// 收齐展开点击
handleToggleChange () {
@@ -398,6 +430,9 @@ export default {
overflow: hidden;
white-space: nowrap;
}
.option-span-num {
color: @primary-color;
}
}
}
// 选中项样式
@@ -422,6 +457,11 @@ export default {
padding: 24px;
}
// 标题高亮样式
.title-high-light {
background: @primary-color;
}
// 单个查询结果
.result-div {
width: 100%;
@@ -475,6 +515,10 @@ export default {
}
}
.empty-content {
margin-top: 20px;
}
// 分页
.page-content {
height: 32px;
@@ -55,7 +55,7 @@ export default {
param.pageSize = this.page.pageSize
getSearchHistoryData(param).then(res => {
if (res.success) {
this.model = res.result
this.model = res.result.records
console.log(res.result)
}
})