| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- <template>
- <div>
- <div>
- <!-- <ul
- class="nav nav-tabs m-row"
- role="tablist"
- >
- <li
- role="presentation"
- :class="{'active': isSimple === true}"
- >
- <a @click="changeSearch(true)">{{ $t('lang.QueryCondition.simpleQuery') }}</a>
- </li>
- <li
- role="presentation"
- :class="{'active': isSimple === false}"
- >
- <a @click="changeSearch(false)">{{ $t('lang.QueryCondition.advancedQuery') }}</a>
- </li>
- <slot name="header" :is-simple="isSimple" />
- </ul> -->
- <div>
- <div>
- <QueryConditionSimple
- ref="queryConditionSimple"
- :info-buttons="infoButtons"
- :is-search-widget="isSearchWidget"
- :show-button="showButton"
- @simple-search="simpleSearch"
- @refresh-search="refreshSearch"
- @execute-process="executeProcess($event)"
- @execute-export="executeExport"
- />
- </div>
- <div
- v-show="isComplex"
- >
- <a-drawer
- v-model:open="searchVisible"
- title="高级查询"
- width="440px"
- style="z-index: 1050;"
- placement="right"
- @close="closeSearch"
- >
- <QueryConditionComplex
- ref="queryConditionComplex"
- :info-window-no="infoWindowNo"
- :filter-fields="filterFields"
- :info-buttons="infoButtons"
- :is-search-widget="isSearchWidget"
- :show-button="showButton"
- @complex-search="complexSearch"
- @execute-process="executeProcess($event)"
- @execute-export="executeExport"
- />
- </a-drawer>
- </div>
- <slot name="body" />
- </div>
- </div>
- </div>
- </template>
- <script>
- import InfoWindowUtil from './InfoWindowUtil.js';
- import QueryConditionSimple from './QueryConditionSimple.vue';
- import QueryConditionComplex from './QueryConditionComplex.vue';
- export default {
- name: 'QueryCondition',
- components: {
- QueryConditionSimple, QueryConditionComplex,
- },
- props: {
- 'infoWindowNo':{
- type: String,
- default: null,
- },
- 'infoFilterFields': {
- type: Array,
- default: null,
- },
- 'infoButtons': {
- type: Array,
- default: null,
- },
- 'isSearchWidget':{
- type: Boolean,
- default: null,
- },
- 'showButton':{
- type: Boolean,
- default: null,
- },
- 'isComplex':{
- type: Boolean,
- default: false,
- },
- },
-
- emits: ['simpleSearch', 'complexSearch','openComplex', 'refreshSearch', 'executeProcess', 'executeExport', 'changeSearch'],
- data: function () {
- return {
- simpleConditionValue: '',
- isSimple: true,
- filterFields: [],
- selectedText: [],
- searchVisible:false,
- searchType:'simple',
- };
- },
- watch: {
- $route: function (to, from) {
- var _self = this;
- _self.simpleConditionValue = '';
- _self.filterFields = [];
- },
- infoFilterFields: {
- deep: true,
- handler: function (currentValue, oldValue) {
- var _self = this;
- _self.filterFields.splice(0, _self.filterFields.length);
- if (currentValue == undefined) {
- return;
- }
- var cloneInfoFilterFields = InfoWindowUtil.cloneInfoFilterFields(currentValue);
- for (var i = 0, len = cloneInfoFilterFields.length; i < len; i++) {
- _self.filterFields.push(cloneInfoFilterFields[i]);
- }
- },
- },
-
- isComplex(newVal){
- this.searchVisible = newVal;
- },
-
-
- },
- methods: {
- /**
- * 是否是简单查询
- * @return {Object} 查询条件
- */
- isSimpleQuery: function () {
- return this.isSimple === true;
- },
- closeSearch(){
- this.searchVisible = false;
- this.$emit('openComplex',false);
- },
- /**
- * 获取查询条件供外部调用
- * @return {Object} 查询条件
- */
- getQueryCondition: function () {
- var _self = this;
- var values = [];
- if (_self.searchType === 'simple') {
- values = this.$refs.queryConditionSimple.getQueryCondition();
- } else if (_self.searchType === 'complex') {
- values = this.$refs.queryConditionComplex.getQueryCondition();
- }
- return values;
- },
- /**
- * 触发简单查询
- * @return {void}
- */
- simpleSearch: function (value) {
- this.isSimple = true;
- this.searchType = value;
- this.$emit('simpleSearch','simple');
- },
- /**
- * 获取简单查询条件供外部调用
- * @return {Array} 查询条件
- */
- getSimpleQueryCondition: function () {
- var _self = this;
- var values = [];
- return values;
- },
- /**
- * 回车键查询
- * @return {void}
- */
- complexSearch: function (value) {
- this.isSimple = false;
- this.searchType = value;
- this.$emit('complexSearch','complex');
- },
- /**
- * 刷新搜索
- */
- refreshSearch: function () {
- this.$emit('refreshSearch');
- },
- /**
- * 执行流程
- *
- */
- executeProcess: function (infoButton) {
- this.$emit('executeProcess', infoButton);
- },
- /**
- * 执行导出
- * @return {void}
- */
- executeExport: function () {
- this.$emit('executeExport');
- },
- /**
- * 切换简单查询和高级查询
- * @param {Boolean} val 是否是简单查询
- * @return {void}
- */
- changeSearch: function (val) {
- var _self = this;
- if (val === false) {
- this.simpleConditionValue = '';
- _self.isSimple = false;
- }else if(val === true){
- _self.isSimple = true;
- }else{
- _self.isSimple = val;
- }
-
- _self.$emit('changeSearch', val);
- // 当前查询是简单查询,切换到高级查询的时候,清空查询条件
- if (this.isSimple === true && val === false) {
- if (_self.filterFields != undefined) {
- _self.filterFields.forEach(function (item) {
- item.value.value1 = '';
- item.value.value2 = '';
- });
- }
- }
- },
- },
- };
- </script>
- <style scoped>
- .m-row {
- margin-bottom: 5px;
- }
- .nav > li > a {
- padding: 8px 10px;
- }
- </style>
|