|
|
|
@ -0,0 +1,444 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="columnViewBox">
|
|
|
|
|
<a-spin :spinning="loading">
|
|
|
|
|
<div class="flex ant-form-small">
|
|
|
|
|
<a-switch
|
|
|
|
|
v-model:checked="queryData.logicalOperator"
|
|
|
|
|
class="mt10"
|
|
|
|
|
checked-value="1"
|
|
|
|
|
un-checked-value="0"
|
|
|
|
|
checked-children="或"
|
|
|
|
|
un-checked-children="且"
|
|
|
|
|
/>
|
|
|
|
|
<div style="flex: 1">
|
|
|
|
|
<div
|
|
|
|
|
v-for="(item, index) in queryData.conditions"
|
|
|
|
|
class="ds-advanced-search-item flex"
|
|
|
|
|
:key="`f-${index}`"
|
|
|
|
|
>
|
|
|
|
|
<data
|
|
|
|
|
:style="{ left: index == 0 ? '-30px' : '-15px' }"
|
|
|
|
|
class="v-line"
|
|
|
|
|
style="top: 21px"
|
|
|
|
|
></data>
|
|
|
|
|
<data
|
|
|
|
|
v-if="index != queryData.conditions.length - 1"
|
|
|
|
|
class="r-line r-height"
|
|
|
|
|
style="left: -15px; top: 21px"
|
|
|
|
|
></data>
|
|
|
|
|
<a-switch
|
|
|
|
|
v-model:checked="item.logicalOperator"
|
|
|
|
|
checked-value="1"
|
|
|
|
|
class="mt2"
|
|
|
|
|
un-checked-value="0"
|
|
|
|
|
checked-children="或"
|
|
|
|
|
un-checked-children="且"
|
|
|
|
|
/>
|
|
|
|
|
<div style="flex: 1; margin-left: 30px">
|
|
|
|
|
<div
|
|
|
|
|
v-for="(row, key) in item.conditions"
|
|
|
|
|
:key="`c-${key}`"
|
|
|
|
|
style="margin-bottom: 6px; position: relative"
|
|
|
|
|
>
|
|
|
|
|
<div v-if="key != item.conditions.length - 1" class="r-line"></div>
|
|
|
|
|
<div :style="{ left: key == 0 ? '-29px' : '-16px' }" class="v-line"></div>
|
|
|
|
|
<a-select
|
|
|
|
|
v-model:value="row.field"
|
|
|
|
|
style="width: 150px; margin-right: 6px"
|
|
|
|
|
placeholder="查询字段"
|
|
|
|
|
@change="changeHandle($event, row)"
|
|
|
|
|
>
|
|
|
|
|
<a-select-option v-for="item in schemas" :key="item.field" :value="item.field">
|
|
|
|
|
{{ item.label }}
|
|
|
|
|
</a-select-option>
|
|
|
|
|
</a-select>
|
|
|
|
|
<a-select
|
|
|
|
|
v-model:value="row.operator"
|
|
|
|
|
style="width: 90px; margin-right: 6px"
|
|
|
|
|
placeholder="筛选符"
|
|
|
|
|
>
|
|
|
|
|
<a-select-option
|
|
|
|
|
v-for="item in operatorOptions"
|
|
|
|
|
:key="item.value"
|
|
|
|
|
:value="item.value"
|
|
|
|
|
>
|
|
|
|
|
{{ item.label }}
|
|
|
|
|
</a-select-option>
|
|
|
|
|
</a-select>
|
|
|
|
|
<a-date-picker
|
|
|
|
|
v-if="row.component == 'RangePicker'"
|
|
|
|
|
placeholder="请选择"
|
|
|
|
|
style="width: 150px"
|
|
|
|
|
v-model:value="row.value"
|
|
|
|
|
/>
|
|
|
|
|
<a-input
|
|
|
|
|
v-else
|
|
|
|
|
v-model:value="row.value"
|
|
|
|
|
placeholder="请输入"
|
|
|
|
|
style="width: 150px"
|
|
|
|
|
></a-input>
|
|
|
|
|
<span
|
|
|
|
|
v-if="item.conditions.length != 1"
|
|
|
|
|
@click="deleteItem(index, key)"
|
|
|
|
|
class="iconfont icon-shanchu21"
|
|
|
|
|
></span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="item-btns">
|
|
|
|
|
<a-button type="link" @click="addRow(index)">
|
|
|
|
|
<span class="iconfont icon-new_document"></span>
|
|
|
|
|
添加条件
|
|
|
|
|
</a-button>
|
|
|
|
|
<a-button
|
|
|
|
|
v-if="queryData.conditions.length != 1"
|
|
|
|
|
type="link"
|
|
|
|
|
@click="deleteGroup(index)"
|
|
|
|
|
>
|
|
|
|
|
<span class="iconfont icon-shanchuzu"></span>
|
|
|
|
|
删除整组
|
|
|
|
|
</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</a-spin>
|
|
|
|
|
<a-button class="add-group" type="link" @click="addGroup">
|
|
|
|
|
<span class="iconfont icon-calendar"></span>
|
|
|
|
|
添加条件组
|
|
|
|
|
</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts" setup name="AdvancedSearch">
|
|
|
|
|
import {
|
|
|
|
|
defineComponent,
|
|
|
|
|
PropType,
|
|
|
|
|
ref,
|
|
|
|
|
watchEffect,
|
|
|
|
|
defineProps,
|
|
|
|
|
defineEmits,
|
|
|
|
|
defineExpose,
|
|
|
|
|
unref,
|
|
|
|
|
watch,
|
|
|
|
|
reactive,
|
|
|
|
|
} from 'vue'
|
|
|
|
|
// 引入表格权限信息(包含id和name)
|
|
|
|
|
import { permissionsInfo } from '/@/hooks/web/usePermission'
|
|
|
|
|
import {
|
|
|
|
|
GetUserQuerySet,
|
|
|
|
|
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({
|
|
|
|
|
schemas: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => [],
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '高级查询',
|
|
|
|
|
},
|
|
|
|
|
IsApi: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: true,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
watch(
|
|
|
|
|
() => props.schemas,
|
|
|
|
|
() => {
|
|
|
|
|
console.log(1111111111111111)
|
|
|
|
|
init(null)
|
|
|
|
|
},
|
|
|
|
|
{ deep: true },
|
|
|
|
|
)
|
|
|
|
|
const emit = defineEmits(['toSearch'])
|
|
|
|
|
// 弹窗开关
|
|
|
|
|
const modalFlag = ref(false)
|
|
|
|
|
const queryData = reactive({
|
|
|
|
|
logicalOperator: '0',
|
|
|
|
|
conditions: [],
|
|
|
|
|
})
|
|
|
|
|
// 默认模版数据
|
|
|
|
|
const queryOldData = reactive({
|
|
|
|
|
logicalOperator: '0',
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
logicalOperator: '0',
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: null,
|
|
|
|
|
component: '',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: null,
|
|
|
|
|
component: '',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: null,
|
|
|
|
|
component: '',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: null,
|
|
|
|
|
component: '',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
logicalOperator: '1',
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: null,
|
|
|
|
|
component: '',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: null,
|
|
|
|
|
component: '',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: null,
|
|
|
|
|
component: '',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: null,
|
|
|
|
|
component: '',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
// 筛选符options
|
|
|
|
|
const operatorOptions = [
|
|
|
|
|
{
|
|
|
|
|
value: 0,
|
|
|
|
|
label: '等于',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 10,
|
|
|
|
|
label: '不等于',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 2,
|
|
|
|
|
label: '大于',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 3,
|
|
|
|
|
label: '大于等于',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 4,
|
|
|
|
|
label: '小于',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 5,
|
|
|
|
|
label: '小于等于',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '包含',
|
|
|
|
|
value: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '不包含',
|
|
|
|
|
value: 13,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
// 存储接口返回的查询条件
|
|
|
|
|
const sourceData = {
|
|
|
|
|
logicalOperator: '',
|
|
|
|
|
conditions: '',
|
|
|
|
|
}
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
// 初始化弹窗,请求高级查询数据
|
|
|
|
|
const init = (IsApiData) => {
|
|
|
|
|
modalFlag.value = true
|
|
|
|
|
if (props.IsApi) {
|
|
|
|
|
loading.value = true
|
|
|
|
|
const permissionId = permissionsInfo().permissionId
|
|
|
|
|
GetUserQuerySet({ permissionId })
|
|
|
|
|
.then((res) => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
const { data } = res
|
|
|
|
|
const content = JSON.parse(data?.content || '{}')
|
|
|
|
|
const source = JSON.parse(JSON.stringify(queryOldData))
|
|
|
|
|
if (content && content?.conditions?.length) {
|
|
|
|
|
// sourceData.logicalOperator = JSON.stringify(JSON.parse(content.logicalOperator))
|
|
|
|
|
// sourceData.conditions = JSON.stringify(JSON.parse(content.conditions))
|
|
|
|
|
queryData.logicalOperator = content.logicalOperator
|
|
|
|
|
queryData.conditions = content.conditions
|
|
|
|
|
// queryData.logicalOperator = source.logicalOperator
|
|
|
|
|
// queryData.conditions = source.conditions
|
|
|
|
|
} else {
|
|
|
|
|
queryData.logicalOperator = source.logicalOperator
|
|
|
|
|
queryData.conditions = source.conditions
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
loading.value = false
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
let source = JSON.parse(JSON.stringify(queryOldData))
|
|
|
|
|
if (IsApiData) {
|
|
|
|
|
source = JSON.parse(IsApiData)
|
|
|
|
|
}
|
|
|
|
|
// const source = JSON.parse(JSON.stringify(queryOldData))
|
|
|
|
|
queryData.logicalOperator = source.logicalOperator
|
|
|
|
|
queryData.conditions = source.conditions
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const reset = () => {
|
|
|
|
|
const source = JSON.parse(JSON.stringify(queryOldData))
|
|
|
|
|
queryData.logicalOperator = source.logicalOperator
|
|
|
|
|
queryData.conditions = source.conditions
|
|
|
|
|
}
|
|
|
|
|
// 查询并保存当前条件
|
|
|
|
|
const search = () => {
|
|
|
|
|
// 如果条件有变化则保存新查询条件,否则不调用接口
|
|
|
|
|
// if (JSON.stringify(sourceData) != JSON.stringify(queryData)) {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
modalFlag.value = false
|
|
|
|
|
emit('toSearch', queryData)
|
|
|
|
|
const propsData = {
|
|
|
|
|
permissionId: permissionsInfo().permissionId,
|
|
|
|
|
content: JSON.stringify(queryData),
|
|
|
|
|
}
|
|
|
|
|
if (props.IsApi) {
|
|
|
|
|
UpdateUserQuerySet(propsData).then((res) => {})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const changeHandle = (e, row) => {
|
|
|
|
|
row.value = null
|
|
|
|
|
props.schemas.forEach((item) => {
|
|
|
|
|
if (item.field == e) {
|
|
|
|
|
row.component = item.component
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 删除单组
|
|
|
|
|
const deleteItem = (index, key) => {
|
|
|
|
|
queryData.conditions[index].conditions.splice(key, 1)
|
|
|
|
|
}
|
|
|
|
|
// 添加行
|
|
|
|
|
const addRow = (index) => {
|
|
|
|
|
queryData.conditions[index].conditions.push({
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: '',
|
|
|
|
|
component: '',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 删除组
|
|
|
|
|
const deleteGroup = (index) => {
|
|
|
|
|
queryData.conditions.splice(index, 1)
|
|
|
|
|
}
|
|
|
|
|
// 添加组
|
|
|
|
|
const addGroup = () => {
|
|
|
|
|
queryData.conditions.push({
|
|
|
|
|
logicalOperator: 'and',
|
|
|
|
|
conditions: [
|
|
|
|
|
{
|
|
|
|
|
field: null,
|
|
|
|
|
operator: null,
|
|
|
|
|
value: null,
|
|
|
|
|
component: '',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
defineExpose({
|
|
|
|
|
init,
|
|
|
|
|
queryData,
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.columnViewBox {
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
// .ds-advanced-search-modal {
|
|
|
|
|
.ant-form-small {
|
|
|
|
|
margin-top: 15px;
|
|
|
|
|
min-height: 400px;
|
|
|
|
|
}
|
|
|
|
|
.ds-advanced-search-item {
|
|
|
|
|
position: relative;
|
|
|
|
|
margin-left: 30px;
|
|
|
|
|
padding: 10px 15px;
|
|
|
|
|
border-left: 1px solid #257afa;
|
|
|
|
|
background: #f5f9fc;
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
.icon-shanchu21 {
|
|
|
|
|
margin-left: 6px;
|
|
|
|
|
color: #257afa;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.item-btns {
|
|
|
|
|
text-align: right;
|
|
|
|
|
color: #257afa;
|
|
|
|
|
.iconfont {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
padding-right: 18px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.ds-advanced-search-item:last-child {
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
.add-group {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 16px;
|
|
|
|
|
margin-left: 65px;
|
|
|
|
|
}
|
|
|
|
|
.ant-switch {
|
|
|
|
|
background: #257afa;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
.ant-switch-checked {
|
|
|
|
|
background: #17a6a3;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
.r-line {
|
|
|
|
|
width: 0.8px;
|
|
|
|
|
height: 35px;
|
|
|
|
|
background: #cccccc;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: -16px;
|
|
|
|
|
top: 13px;
|
|
|
|
|
}
|
|
|
|
|
.r-line:last-child {
|
|
|
|
|
height: 10px;
|
|
|
|
|
}
|
|
|
|
|
.r-height {
|
|
|
|
|
height: calc(100% + 20px);
|
|
|
|
|
}
|
|
|
|
|
.v-line {
|
|
|
|
|
width: 30px;
|
|
|
|
|
height: 0.8px;
|
|
|
|
|
background: #cccccc;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: -16px;
|
|
|
|
|
top: 13px;
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
</style>
|