|
|
@ -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%'‖or‖QZH = '111'‖)‖or‖GDRQ >= 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{ |
|
|
|