高级查询优化

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

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

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

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

Loading…
Cancel
Save