diff --git a/src/views/archiveUtilize/archiveSearch/index.vue b/src/views/archiveUtilize/archiveSearch/index.vue index e21f3be..b8876e3 100644 --- a/src/views/archiveUtilize/archiveSearch/index.vue +++ b/src/views/archiveUtilize/archiveSearch/index.vue @@ -59,24 +59,30 @@ - +
新增 - 重置 + 重置

检索条件

- 删除 + 删除 上移 下移
-
    -
  • - {{ item }} +
      +
    • + {{ item.field }} + {{ item.symbol }} + '%{{ item.keyWord }}%' + '{{ item.keyWord }}' + {{ item.keyWord }} + {{ item.connector }} + {{ item.bracket }}
    @@ -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 = `${this.form.field.label} ${this.form.symbol.label} "%" + ${this.form.keyWord} + "%"` - // str = this.form.field.label + ' ' + this.form.symbol.label + " '%" + this.form.keyWord + "%'" - } else { - str = `${this.form.field.label} ${this.form.symbol.label} ${this.form.keyWord}` - // 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{ diff --git a/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue b/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue index 2d94ffa..8c0f99d 100644 --- a/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue +++ b/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue @@ -100,7 +100,7 @@ 四性检测 下载 - + 目录下载 目录上传