QueryCondition.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div>
  3. <div>
  4. <!-- <ul
  5. class="nav nav-tabs m-row"
  6. role="tablist"
  7. >
  8. <li
  9. role="presentation"
  10. :class="{'active': isSimple === true}"
  11. >
  12. <a @click="changeSearch(true)">{{ $t('lang.QueryCondition.simpleQuery') }}</a>
  13. </li>
  14. <li
  15. role="presentation"
  16. :class="{'active': isSimple === false}"
  17. >
  18. <a @click="changeSearch(false)">{{ $t('lang.QueryCondition.advancedQuery') }}</a>
  19. </li>
  20. <slot name="header" :is-simple="isSimple" />
  21. </ul> -->
  22. <div>
  23. <div>
  24. <QueryConditionSimple
  25. ref="queryConditionSimple"
  26. :info-buttons="infoButtons"
  27. :is-search-widget="isSearchWidget"
  28. :show-button="showButton"
  29. @simple-search="simpleSearch"
  30. @refresh-search="refreshSearch"
  31. @execute-process="executeProcess($event)"
  32. @execute-export="executeExport"
  33. />
  34. </div>
  35. <div
  36. v-show="isComplex"
  37. >
  38. <a-drawer
  39. v-model:visible="searchVisible"
  40. title="高级查询"
  41. width="440px"
  42. style="z-index: 1050;"
  43. placement="right"
  44. @close="closeSearch"
  45. >
  46. <QueryConditionComplex
  47. ref="queryConditionComplex"
  48. :info-window-no="infoWindowNo"
  49. :filter-fields="filterFields"
  50. :info-buttons="infoButtons"
  51. :is-search-widget="isSearchWidget"
  52. :show-button="showButton"
  53. @complex-search="complexSearch"
  54. @execute-process="executeProcess($event)"
  55. @execute-export="executeExport"
  56. />
  57. </a-drawer>
  58. </div>
  59. <slot name="body" />
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import InfoWindowUtil from './InfoWindowUtil.js';
  66. import QueryConditionSimple from './QueryConditionSimple.vue';
  67. import QueryConditionComplex from './QueryConditionComplex.vue';
  68. export default {
  69. name: 'QueryCondition',
  70. components: {
  71. QueryConditionSimple, QueryConditionComplex,
  72. },
  73. props: {
  74. 'infoWindowNo':{
  75. type: String,
  76. default: null,
  77. },
  78. 'infoFilterFields': {
  79. type: Array,
  80. default: null,
  81. },
  82. 'infoButtons': {
  83. type: Array,
  84. default: null,
  85. },
  86. 'isSearchWidget':{
  87. type: Boolean,
  88. default: null,
  89. },
  90. 'showButton':{
  91. type: Boolean,
  92. default: null,
  93. },
  94. 'isComplex':{
  95. type: Boolean,
  96. default: false,
  97. },
  98. },
  99. emits: ['simpleSearch', 'complexSearch','openComplex', 'refreshSearch', 'executeProcess', 'executeExport', 'changeSearch'],
  100. data: function () {
  101. return {
  102. simpleConditionValue: '',
  103. isSimple: true,
  104. filterFields: [],
  105. selectedText: [],
  106. searchVisible:false,
  107. searchType:'simple',
  108. };
  109. },
  110. watch: {
  111. $route: function (to, from) {
  112. var _self = this;
  113. _self.simpleConditionValue = '';
  114. _self.filterFields = [];
  115. },
  116. infoFilterFields: {
  117. deep: true,
  118. handler: function (currentValue, oldValue) {
  119. var _self = this;
  120. _self.filterFields.splice(0, _self.filterFields.length);
  121. if (currentValue == undefined) {
  122. return;
  123. }
  124. var cloneInfoFilterFields = InfoWindowUtil.cloneInfoFilterFields(currentValue);
  125. for (var i = 0, len = cloneInfoFilterFields.length; i < len; i++) {
  126. _self.filterFields.push(cloneInfoFilterFields[i]);
  127. }
  128. },
  129. },
  130. isComplex(newVal){
  131. this.searchVisible = newVal;
  132. },
  133. },
  134. methods: {
  135. /**
  136. * 是否是简单查询
  137. * @return {Object} 查询条件
  138. */
  139. isSimpleQuery: function () {
  140. return this.isSimple === true;
  141. },
  142. closeSearch(){
  143. this.searchVisible = false;
  144. this.$emit('openComplex',false);
  145. },
  146. /**
  147. * 获取查询条件供外部调用
  148. * @return {Object} 查询条件
  149. */
  150. getQueryCondition: function () {
  151. var _self = this;
  152. var values = [];
  153. if (_self.searchType === 'simple') {
  154. values = this.$refs.queryConditionSimple.getQueryCondition();
  155. } else if (_self.searchType === 'complex') {
  156. values = this.$refs.queryConditionComplex.getQueryCondition();
  157. }
  158. return values;
  159. },
  160. /**
  161. * 触发简单查询
  162. * @return {void}
  163. */
  164. simpleSearch: function (value) {
  165. this.isSimple = true;
  166. this.searchType = value;
  167. this.$emit('simpleSearch','simple');
  168. },
  169. /**
  170. * 获取简单查询条件供外部调用
  171. * @return {Array} 查询条件
  172. */
  173. getSimpleQueryCondition: function () {
  174. var _self = this;
  175. var values = [];
  176. return values;
  177. },
  178. /**
  179. * 回车键查询
  180. * @return {void}
  181. */
  182. complexSearch: function (value) {
  183. this.isSimple = false;
  184. this.searchType = value;
  185. this.$emit('complexSearch','complex');
  186. },
  187. /**
  188. * 刷新搜索
  189. */
  190. refreshSearch: function () {
  191. this.$emit('refreshSearch');
  192. },
  193. /**
  194. * 执行流程
  195. *
  196. */
  197. executeProcess: function (infoButton) {
  198. this.$emit('executeProcess', infoButton);
  199. },
  200. /**
  201. * 执行导出
  202. * @return {void}
  203. */
  204. executeExport: function () {
  205. this.$emit('executeExport');
  206. },
  207. /**
  208. * 切换简单查询和高级查询
  209. * @param {Boolean} val 是否是简单查询
  210. * @return {void}
  211. */
  212. changeSearch: function (val) {
  213. var _self = this;
  214. if (val === false) {
  215. this.simpleConditionValue = '';
  216. _self.isSimple = false;
  217. }else if(val === true){
  218. _self.isSimple = true;
  219. }else{
  220. _self.isSimple = val;
  221. }
  222. _self.$emit('changeSearch', val);
  223. // 当前查询是简单查询,切换到高级查询的时候,清空查询条件
  224. if (this.isSimple === true && val === false) {
  225. if (_self.filterFields != undefined) {
  226. _self.filterFields.forEach(function (item) {
  227. item.value.value1 = '';
  228. item.value.value2 = '';
  229. });
  230. }
  231. }
  232. },
  233. },
  234. };
  235. </script>
  236. <style scoped>
  237. .m-row {
  238. margin-bottom: 5px;
  239. }
  240. .nav > li > a {
  241. padding: 8px 10px;
  242. }
  243. </style>