Browse Source

收集库目录下载api/档案检索高级搜索完善

master
xuhuajiao 1 year ago
parent
commit
ae7cf6a539
  1. 165
      src/views/archiveUtilize/archiveSearch/index.vue
  2. 2
      src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue

165
src/views/archiveUtilize/archiveSearch/index.vue

@ -59,24 +59,30 @@
</el-select>
</el-form-item>
<el-form-item label="检索值" prop="keyWord" :rules="getKeywordRules">
<el-input v-model="form.keyWord" />
<el-input v-model="form.keyWord" :type="inputType" />
</el-form-item>
</el-form>
<div class="advanced-btn">
<el-button size="mini" @click="addConditionData"><i class="iconfont icon-xinzeng" />新增</el-button>
<el-button class="filter-refresh" size="mini" icon="el-icon-refresh-left">重置</el-button>
<el-button class="filter-refresh" size="mini" icon="el-icon-refresh-left" @click="resetQuery">重置</el-button>
</div>
<div class="search-condition">
<h4> 检索条件</h4>
<div class="condition-main">
<div class="condition-left">
<el-button size="mini" :disabled="currentIndex===null"><i class="iconfont icon-shanchu" />删除</el-button>
<el-button size="mini" :disabled="currentIndex===null" @click="deltCurrent(currentIndex)"><i class="iconfont icon-shanchu" />删除</el-button>
<el-button size="mini" icon="el-icon-top" :disabled="currentIndex === 0" @click="moveUp(currentIndex)">上移</el-button>
<el-button size="mini" icon="el-icon-bottom" :disabled="currentIndex === conditionData.length - 1" @click="moveDown(currentIndex)">下移</el-button>
</div>
<ul class="condition-content">
<li v-for="(item, index) in conditionData" :key="index" :class="currentIndex===index ? 'active': ''" @click="selectCurrent(index)">
{{ item }}
<ul id="condition-container" class="condition-content">
<li v-for="(item, index) in conditionData" :id="'element-id-' + index" :key="index" :class="currentIndex===index ? 'active': ''" @click="selectCurrent(index)">
<span style="color:#0348F3">{{ item.field }}</span>
<span style="color:#ED4A41; margin:0 4px">{{ item.symbol }}</span>
<span v-if="item.symbol && (item.symbol === '包含'|| item.symbol === '不包含')" class="keyword-style"><i>'%</i>{{ item.keyWord }}<i>%'</i></span>
<span v-else-if="item.keyWord && isNaN(parseInt(item.keyWord))" class="keyword-style"><i>'</i>{{ item.keyWord }}<i>'</i></span>
<span v-else class="keyword-style">{{ item.keyWord }}</span>
<span>{{ item.connector }}</span>
<span>{{ item.bracket }}</span>
</li>
</ul>
<div class="condition-right">
@ -167,31 +173,50 @@ export default {
},
computed: {
getKeywordRules() {
console.log(this.form.symbol)
if ((this.form.symbol && this.form.symbol.label === '为空') || (this.form.symbol && this.form.symbol.label === '不为空')) {
console.log('2222')
return []
} else {
return [{ required: true, message: '请输入检索值', trigger: 'blur' }]
}
},
inputType() {
if (
this.form.symbol &&
(this.form.symbol.label === '大于' ||
this.form.symbol.label === '大于等于' ||
this.form.symbol.label === '小于' ||
this.form.symbol.label === '小于等于')
) {
return 'number'
} else {
return 'text'
}
}
},
mounted() {
this.getFieldCommon()
},
methods: {
resetQuery() {
this.$refs.form.resetFields()
},
addConditionData() {
this.$refs.form.validate((valid) => {
if (valid) {
let str = ''
if ((this.form.symbol && this.form.symbol.label === '包含') || (this.form.symbol && this.form.symbol.label === '不包含')) {
str = `<span style="color:blue">${this.form.field.label}</span> <span style="color:green">${this.form.symbol.label}</span> "%" + <span style="color:red">${this.form.keyWord}</span> + "%"`
// str = this.form.field.label + ' ' + this.form.symbol.label + " '%" + this.form.keyWord + "%'"
} else {
str = `<span style="color:blue">${this.form.field.label}</span> <span style="color:green">${this.form.symbol.label}</span> <span style="color:red">${this.form.keyWord}</span>`
// str = this.form.field.label + ' ' + this.form.symbol.label + ' ' + this.form.keyWord
}
this.conditionData.push(str)
const newConditionData = {}
newConditionData.field = this.form.field.label
newConditionData.fieldName = this.form.field.value
newConditionData.symbol = this.form.symbol.label
newConditionData.symbolCode = this.form.symbol.value
newConditionData.keyWord = this.form.keyWord
this.conditionData.push(newConditionData)
// DOM
this.$nextTick(() => {
//
const container = document.getElementById('condition-container')
//
container.scrollTop = container.scrollHeight
})
}
})
},
@ -203,6 +228,9 @@ export default {
this.conditionData[index - 1] = temp
this.currentIndex = index - 1
}
//
const targetElement = document.getElementById('element-id-' + this.currentIndex)
targetElement.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
},
moveDown(index) {
if (index < this.conditionData.length - 1) {
@ -212,6 +240,12 @@ export default {
this.conditionData[index + 1] = temp
this.currentIndex = index + 1
}
const targetElement = document.getElementById('element-id-' + this.currentIndex)
targetElement.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
},
deltCurrent(index) {
this.conditionData.splice(index, 1)
this.currentIndex = null
},
selectCurrent(index) {
if (this.currentIndex === index) {
@ -221,7 +255,18 @@ export default {
}
},
addConnector(item) {
this.conditionData.push(item)
const newConditionData = {}
if (item === '并且' || item === '或者') {
newConditionData.connector = item
} else {
newConditionData.bracket = item
}
this.conditionData.push(newConditionData)
this.$nextTick(() => {
const container = document.getElementById('condition-container')
container.scrollTop = container.scrollHeight
})
},
getFieldCommon() {
FetchFindGroupType({ isType: 2 }).then((res) => {
@ -237,7 +282,81 @@ export default {
})
},
handleAdvancedSearch() {
this.checkConditions(this.conditionData)
},
checkConditions(conditionData) {
let brackets = 0
let fields = 0
let connectors = 0
let previousTokenType = null
let hasValidConditionBetweenBrackets = false
for (var i = 0; i < conditionData.length; i++) {
const condition = conditionData[i]
let currentTokenType = ''
if (condition.hasOwnProperty('bracket')) {
currentTokenType = 'bracket'
brackets++
} else if (condition.hasOwnProperty('field')) {
currentTokenType = 'field'
fields++
if (brackets > 0) {
hasValidConditionBetweenBrackets = true
}
} else if (condition.hasOwnProperty('connector')) {
currentTokenType = 'connector'
connectors++
}
if (previousTokenType && currentTokenType) {
if ((previousTokenType === 'field' && currentTokenType === 'field') ||
(previousTokenType === 'connector' && currentTokenType === 'connector')) {
this.$message.error('条件之间缺少或且连接符')
return
}
}
previousTokenType = currentTokenType
}
if (brackets > 0 && !hasValidConditionBetweenBrackets) {
this.$message.error('请输入有效条件')
return false
} else if (brackets > 0 && brackets % 2 !== 0) {
this.$message.error('括号不对称')
return false
} else if (fields === 0) {
this.$message.error('请输入有效条件')
return false
} else if (fields === 1 || connectors === fields - 1) {
// this.$message.error('')
// GDR like '%1%' or TITLE < '1' and AJH = '2222'
// wheresql: ( GDR like '%1%' or QZH = '111' ) or GDRQ >= cast('2023-12-07' as datetime)
// arrarshow: ( '%1%' '111') cast('2023-12-07' as datetime)
// arrarsql: (GDR like '%1%'orQZH = '111')orGDRQ >= cast('2023-12-07' as datetime)
// const wheresql = ''
const wheresql = this.conditionData.map(obj => {
if (obj.field) {
if (obj.symbol === '包含' || obj.symbol === '不包含') {
return obj.fieldName + ' ' + obj.symbolCode + " '%" + obj.keyWord + "%'"
} else if (obj.keyWord && isNaN(parseInt(obj.keyWord))) {
return obj.fieldName + ' ' + obj.symbolCode + " '" + obj.keyWord + "'"
} else {
return obj.fieldName + ' ' + obj.symbolCode + ' ' + obj.keyWord
}
} else if (obj.connector === '并且') {
return 'and'
} else if (obj.connector === '或者') {
return 'or'
} else {
return obj.bracket
}
}).join(' ')
console.log('wheresql', wheresql)
} else {
this.$message.error('条件之间缺少或且连接符')
return false
}
},
dimSearch() {
},
@ -464,6 +583,9 @@ export default {
overflow: hidden;
overflow-y: scroll;
li{
display: flex;
justify-content: center;
flex-wrap: nowrap;
height: 32px;
line-height: 32px;
font-size: 14px;
@ -476,6 +598,13 @@ export default {
&.active{
background-color: #E8F2FF;
}
.keyword-style{
color:#2ECAAC;
i{
font-style: normal;
color: #545B65;
}
}
}
}
.condition-right{

2
src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue

@ -100,7 +100,7 @@
<el-menu-item v-if="!(isTitleType === 3 && (selectedCategory.arrangeType === 3 || selectedCategory.arrangeType === 2) && activeIndex === 1) && (isTitleType !== 2 && isTitleType !== 6)" index="3-3" @click="handleFourTest">四性检测</el-menu-item>
<el-menu-item v-if="isTitleType === 6" index="3-4" @click="handleOriginalDownload">下载</el-menu-item>
</el-menu-item-group>
<el-menu-item-group v-if="!(isTitleType === 3 && (selectedCategory.arrangeType === 3 || selectedCategory.arrangeType === 2) && activeIndex === 1) && (isTitleType !== 2 && isTitleType !== 6)" class="collect-submenu-group submenu-tree">
<el-menu-item-group v-if="!(isTitleType === 3 && (selectedCategory.arrangeType === 3 || selectedCategory.arrangeType === 2) && activeIndex === 1) && (isTitleType !== 2 && isTitleType !== 4 && isTitleType !== 6)" class="collect-submenu-group submenu-tree">
<template slot="title">电子文件目录</template>
<el-menu-item index="3-5" @click="handleCatalogDownload">目录下载</el-menu-item>
<el-menu-item index="3-6" @click="fileUpload(2)">目录上传</el-menu-item>

Loading…
Cancel
Save