b07454626daa07a782d208a55bf242df2f19b4ec.svn-base 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div>
  3. <div class="table-page-search-wrapper" v-if="isShow">
  4. <a-form layout="inline" @keyup.enter.native="searchQuery">
  5. <a-row :gutter="24">
  6. <template v-for="(item,i) in searchData">
  7. <a-col :xl="6" :lg="7" :md="8" :sm="24" :key="i" v-if="i<3 || !isCollapse">
  8. <a-form-item :label="item.fieldTxt" v-if="item.searchMode === 'single'" style="padding:4px 0px;">
  9. <a-input type="text" v-if="item.fieldType === 'String'" v-model="item.value" :placeholder="'请输入'+item.fieldTxt"/>
  10. <a-input type="number" v-else-if="item.fieldType === 'Integer' || item.fieldType === 'Long'" v-model="item.value" :placeholder="'请输入'+item.fieldTxt"/>
  11. <a-date-picker v-else-if="item.fieldType === 'Date'" format="YYYY-MM-DD" v-model="item.value" :placeholder="'请输入'+item.fieldTxt"/>
  12. </a-form-item>
  13. <a-form-item :label="item.fieldTxt" v-else style="margin-bottom:0;padding:4px 0px;">
  14. <a-form-item :style="{ display: 'inline-block', width: 'calc(50% - 20px)','margin-right': '0px'}">
  15. <a-input type="text" v-if="item.fieldType === 'String'" v-model="item.value[0]" :placeholder="'请输入'+item.fieldTxt"/>
  16. <a-input type="number" v-else-if="item.fieldType === 'Integer' || item.fieldType === 'Long'" v-model="item.value[0]" :placeholder="'请输入'+item.fieldTxt"/>
  17. <a-date-picker v-else-if="item.fieldType === 'Date' " format="YYYY-MM-DD" v-model="item.value[0]" :placeholder="'请输入'+item.fieldTxt"/>
  18. </a-form-item>
  19. <span style="padding: 0px 8px;">~</span>
  20. <a-form-item :style="{ display: 'inline-block', width: 'calc(50% - 20px)','margin-right': '0px' }">
  21. <a-input type="text" v-if="item.fieldType === 'String'" v-model="item.value[1]" :placeholder="'请输入'+item.fieldTxt"/>
  22. <a-input type="number" v-else-if="item.fieldType === 'Integer' || item.fieldType === 'Long'" v-model="item.value[1]" :placeholder="'请输入'+item.fieldTxt"/>
  23. <a-date-picker v-else-if="item.fieldType === 'Date'" format="YYYY-MM-DD" v-model="item.value[1]" :placeholder="'请输入'+item.fieldTxt"/>
  24. </a-form-item>
  25. </a-form-item>
  26. </a-col>
  27. </template>
  28. <a-col :xl="6" :lg="7" :md="8" :sm="24" style="padding:4px 0px;">
  29. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  30. <a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
  31. <a-button type="primary" icon="reload" style="margin-left: 8px" @click="searchReset">重置</a-button>
  32. <a href="javascript:;" v-if="searchData.length>3" @click="handlerCollapse">
  33. {{isCollapse? '展开':'收回'}}
  34. <a-icon :type="isCollapse? 'down':'up'"/>
  35. </a>
  36. </span>
  37. </a-col>
  38. </a-row>
  39. </a-form>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. export default {
  45. name: 'GroupSearch',
  46. props: {
  47. items: {
  48. type: Array,
  49. default: []
  50. }
  51. },
  52. data() {
  53. return {
  54. searchData: [], // 查询数据
  55. isShow: false, // 控制组件是否显示
  56. isCollapse: true,
  57. isRestSearchData: true// 控制是否重新渲染查询组件
  58. }
  59. },
  60. watch: {
  61. items: {
  62. handler(newValue, oldValue) {
  63. this.getSearchData()
  64. },
  65. deep: true
  66. }
  67. },
  68. mounted() {
  69. this.getSearchData()
  70. },
  71. methods: {
  72. handlerCollapse() {
  73. this.isCollapse = !this.isCollapse
  74. },
  75. searchReset() {
  76. this.searchData.forEach(item => {
  77. if (item.searchMode === 'single') {
  78. item.value = null
  79. } else {
  80. item.value = [null, null]
  81. }
  82. })
  83. this.$emit('chartLoad', this.searchData)
  84. },
  85. searchQuery() {
  86. this.isRestSearchData = false
  87. this.$emit('chartLoad', this.searchData)
  88. },
  89. getSearchData() {
  90. if (!this.isRestSearchData) {
  91. return false
  92. }
  93. this.isRestSearchData = true
  94. this.searchData = []
  95. const itemsCopy = JSON.parse(JSON.stringify(this.items))
  96. itemsCopy.forEach((item, i) => {
  97. if (item.searchFlag === 1) {
  98. if (item.searchMode === 'single' || !item.searchMode) {
  99. this.searchData.push({
  100. value: null,
  101. fieldTxt: item.fieldTxt,
  102. fieldType: item.fieldType,
  103. fieldName: item.fieldName,
  104. searchMode: 'single'
  105. })
  106. } else if (item.searchMode === 'group') {
  107. this.searchData.push({
  108. value: [null, null],
  109. fieldTxt: item.fieldTxt,
  110. fieldType: item.fieldType,
  111. fieldName: item.fieldName,
  112. searchMode: 'group'
  113. })
  114. }
  115. }
  116. })
  117. if (this.searchData.length > 0) {
  118. this.isShow = true
  119. }
  120. }
  121. }
  122. }
  123. </script>
  124. <style scoped>
  125. .table-page-search-wrapper{
  126. padding: 10px 20px;
  127. margin-bottom: 20px;
  128. background-color: #fff;
  129. }
  130. .table-page-search-wrapper .ant-form-inline .ant-form-item,.table-page-search-submitButtons{
  131. margin-right: 16px;
  132. margin-bottom: 0;
  133. }
  134. .table-page-search-wrapper .ant-calendar-picker{
  135. width: 100%;
  136. }
  137. </style>