高级查询优化

szh-new
lijingjia 2 months ago
parent 980d6f7011
commit 0f1b76a260

@ -82,6 +82,8 @@
v-if="row.component == 'RangePicker'"
placeholder="请选择"
style="width: 150px"
format="YYYY-MM-DD"
valueFormat="YYYY-MM-DD"
v-model:value="row.value"
/>
<a-input
@ -130,15 +132,11 @@
</template>
<script lang="ts" setup name="AdvancedSearch">
import {
defineComponent,
PropType,
ref,
watchEffect,
defineProps,
defineEmits,
defineExpose,
unref,
watch,
reactive,
} from 'vue'
// idname
@ -148,7 +146,6 @@
UpdateUserQuerySet,
} from '/@/views/operation/seaexport/api/BookingLedger.js'
import { Modal } from 'ant-design-vue'
import { get, omit } from 'lodash-es'
//
import { useI18n } from '/@/hooks/web/useI18n'
const props = defineProps({
@ -238,6 +235,14 @@
})
// options
const operatorOptions = [
{
label: '包含',
value: 1,
},
{
label: '不包含',
value: 13,
},
{
value: 0,
label: '等于',
@ -261,15 +266,7 @@
{
value: 5,
label: '小于等于',
},
{
label: '包含',
value: 1,
},
{
label: '不包含',
value: 13,
},
}
]
//
const sourceData = {
@ -288,6 +285,7 @@
loading.value = false
const { data } = res
const content = JSON.parse(data?.content || '{}')
console.log(content)
const source = JSON.parse(JSON.stringify(queryOldData))
if (content && content?.conditions?.length) {
// sourceData.logicalOperator = JSON.stringify(JSON.parse(content.logicalOperator))

@ -306,21 +306,29 @@ export function useDataSource(
}
}
// 配置高级查询参数固定格式
console.log(opt.advanced)
opt.advanced?.conditions.forEach(item => {
let obj = {
Key: '',
Value: null
Value: {
ConditionalList: []
}
}
obj['Key'] = item.logicalOperator
if (item?.conditions) {
item.conditions.forEach(row => {
// 只有当查询条件字段和筛选符都有值的时候才行(不然后台报错)
if (row.field && row.value) {
obj.Value = {
FieldName: row.field,
FieldValue: row.value,
ConditionalType: row.operator
}
// 将id替换成Name支持输入框模糊查询(看后期要不要改成外键下拉形式)
const field = replaceEndChar(row.field, 'Id', 'Name')
obj.Value.ConditionalList.push({
Key: 0,
Value: {
FieldName: field,
FieldValue: row.value,
ConditionalType: row.operator
}
})
}
})
}
@ -328,6 +336,7 @@ export function useDataSource(
ap.Value.ConditionalList.push(obj)
}
})
console.log(ap)
if (ap.Value.ConditionalList.length) {
params['advancedSearchParams'] = { ConditionalList: [ap] }
} else {
@ -394,7 +403,11 @@ export function useDataSource(
setLoading(false)
}
}
// 创建正则表达式匹配目标字符在末尾的情况
function replaceEndChar(str, target, replacement) {
const pattern = new RegExp(target + '$')
return str.replace(pattern, replacement)
}
function setTableData<T = Recordable>(values: T[]) {
dataSourceRef.value = values
}

@ -89,6 +89,7 @@ export const searchFormSchema: FormSchema[] = [
label: '委托单位',
labelSlot: 'customerName',
field: 'customerId',
fieldName: 'customerName',
component: 'ApiSelect',
required: false,
dynamicDisabled: false,

Loading…
Cancel
Save