1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<template>
    <el-dialog 
        title="高级查询"
        append-to-body
        width="55vw"
        style="height: 115vh; overflow: hidden"
        :visible.sync="isShowDialog"
        @close="recoverPage"
        destroy-on-close>
        <div class="search-total">
            <el-row>
                <div class="grid-content"> 
                    <el-button 
                        type="primary"  
                        size="small"
                        icon="el-icon-search"
                        @click="searchSubmit">
                        查询
                    </el-button>
                    <el-button 
                        type="warning"
                        size="small"
                        icon="el-icon-refresh"
                        @click="resetInput">
                        重置
                    </el-button>
                </div>
            </el-row>
            <el-row  
                v-for="(item,index) in initOptions.column"
                :key="item.value" 
                class="search-content"
                :span="24">
                <el-col :span="4">
                    <div class="grid-content">
                        <el-select placeholder="请选择">
                            <el-option
                                v-for="feildName in item.searchfeildName"
                                :key="feildName.value"
                                :label="feildName.label"
                                :value="feildName.value">
                                </el-option>
                        </el-select>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content">
                        <el-select placeholder="请选择">
                            <el-option
                            v-for="condition in item.searchCondition"
                            :key="condition.value"
                            :label="condition.label"
                            :value="condition.value">
                            </el-option>
                        </el-select>
                    </div>
                </el-col>
                <el-col :span="13">
                    <div class="grid-content">
                        <div class="el-input">
                            <input type="text" placeholder="请输入" autocomplete="off" class="el-input__inner" :value="value">
                        </div>
                    </div>
                </el-col>
                <el-col :span="2">
                    <div class="grid-content">
                        <i class="el-icon-close" @click="removeInput(index)"></i>
                    </div>
                </el-col>
            </el-row>
        </div>
    </el-dialog>
</template>
 
<script>
export default {
    name: "advancedQuery",
    props: {
        // 对话框显示隐藏控制
        visible: {
            type: "Boolean",
            default: false,
        },
        // 页面显示配置
        options: {
            type: "Object",
            default: {},
        },
        // 页面数据渲染配置
        searchForm: {
            type: "Object",
            default: {},
        },
        value:{
            type: "String",
        }
    },
    data() {
        return {
            // 对话框显示控制
            isShowDialog: this.visible,
            initOptions: {},
            searchForm: {},
        }
    },
    watch: {
        // 监听父组件传的窗口显示隐藏的值
        visible (){
            this.isShowDialog = this.visible;
        }
    },
    created () {
        // 将options配置赋值到data中的option中,避免深浅拷贝的问题所以需要转json之后再赋值
        const data = JSON.stringify(this.options);
        this.initOptions = JSON.parse(data);
        console.log(this.searchForm);
    },
    methods: {
        // 移除搜索框
        removeInput(index){
            //console.log(this.options.column);
            this.$delete(this.initOptions.column,index);
        },
        // 重置当前界面的输入框
        resetInput(){
            const data = JSON.stringify(this.options);
            this.initOptions = JSON.parse(data);
        },
        // 恢复页面
        recoverPage(){
            this.resetInput();
            this.$emit('update:visible', false);
        },
        // 提交当前页面的输入
        searchSubmit(){
            console.log(11);
        },
    }
}
</script>
 
<style lang="scss">
 
    .search-total {
        border-radius: 4px;
        min-height: 36px;
        // margin-left: 35px;
        margin-top: -20px;
    }
    .search-total > .el-row{
        margin-bottom: 10px;
        &:last-child {
            margin-bottom: 0;
        }
    }
    .search-total > .el-col {
        border-radius: 4px;
    }
    .search-total > .el-col > .grid-content {
        border-radius: 4px;
        min-height: 36px;
    }
    .search-content > .el-col {
        margin-right: 6px;
        &:last-child {
            margin-right: 0;
        }
    }
    .grid-content > .el-icon-close {
        font-size: 35px;
        cursor: pointer;
        color: rgb(222, 130, 105);
    }
    .grid-content > .el-icon-close:hover{
        font-size: 38px;
        color: rgb(219, 52, 6);
    }
 
 
</style>